Thomas Gleixner | 7336d0e | 2019-05-31 01:09:56 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Bob Peterson | cf45b75 | 2008-01-31 10:31:39 -0600 | [diff] [blame] | 4 | * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 7 | #include <linux/spinlock.h> |
| 8 | #include <linux/completion.h> |
| 9 | #include <linux/buffer_head.h> |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 10 | #include <linux/gfs2_ondisk.h> |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 11 | #include <linux/bio.h> |
Steven Whitehouse | c65f7fb | 2009-10-02 11:54:39 +0100 | [diff] [blame] | 12 | #include <linux/posix_acl.h> |
Andreas Gruenbacher | f39814f6 | 2015-12-24 11:09:40 -0500 | [diff] [blame] | 13 | #include <linux/security.h> |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 14 | |
| 15 | #include "gfs2.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 16 | #include "incore.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 17 | #include "bmap.h" |
| 18 | #include "glock.h" |
| 19 | #include "glops.h" |
| 20 | #include "inode.h" |
| 21 | #include "log.h" |
| 22 | #include "meta_io.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 23 | #include "recovery.h" |
| 24 | #include "rgrp.h" |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 25 | #include "util.h" |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 26 | #include "trans.h" |
Steven Whitehouse | 17d539f | 2011-06-15 10:29:37 +0100 | [diff] [blame] | 27 | #include "dir.h" |
Abhi Das | f4686c2 | 2019-05-02 14:17:40 -0500 | [diff] [blame] | 28 | #include "lops.h" |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 29 | |
Benjamin Marzinski | 2e60d76 | 2014-11-13 20:42:04 -0600 | [diff] [blame] | 30 | struct workqueue_struct *gfs2_freeze_wq; |
| 31 | |
Bob Peterson | 601ef0d | 2020-01-28 20:23:45 +0100 | [diff] [blame] | 32 | extern struct workqueue_struct *gfs2_control_wq; |
| 33 | |
Steven Whitehouse | 7554918 | 2011-08-02 13:09:36 +0100 | [diff] [blame] | 34 | static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh) |
| 35 | { |
Bob Peterson | 69a6114 | 2021-05-24 11:51:26 -0500 | [diff] [blame] | 36 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
| 37 | |
| 38 | fs_err(sdp, |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 39 | "AIL buffer %p: blocknr %llu state 0x%08lx mapping %p page " |
| 40 | "state 0x%lx\n", |
Steven Whitehouse | 7554918 | 2011-08-02 13:09:36 +0100 | [diff] [blame] | 41 | bh, (unsigned long long)bh->b_blocknr, bh->b_state, |
| 42 | bh->b_page->mapping, bh->b_page->flags); |
Bob Peterson | 69a6114 | 2021-05-24 11:51:26 -0500 | [diff] [blame] | 43 | fs_err(sdp, "AIL glock %u:%llu mapping %p\n", |
Steven Whitehouse | 7554918 | 2011-08-02 13:09:36 +0100 | [diff] [blame] | 44 | gl->gl_name.ln_type, gl->gl_name.ln_number, |
| 45 | gfs2_glock2aspace(gl)); |
Bob Peterson | 69a6114 | 2021-05-24 11:51:26 -0500 | [diff] [blame] | 46 | gfs2_lm(sdp, "AIL error\n"); |
Bob Peterson | fffe9be | 2021-07-30 13:23:49 -0500 | [diff] [blame] | 47 | gfs2_withdraw_delayed(sdp); |
Steven Whitehouse | 7554918 | 2011-08-02 13:09:36 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 50 | /** |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 51 | * __gfs2_ail_flush - remove all buffers for a given lock from the AIL |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 52 | * @gl: the glock |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 53 | * @fsync: set when called from fsync (not all buffers will be clean) |
Lee Jones | c551f66 | 2021-03-30 17:44:29 +0100 | [diff] [blame] | 54 | * @nr_revokes: Number of buffers to revoke |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 55 | * |
| 56 | * None of the buffers should be dirty, locked, or pinned. |
| 57 | */ |
| 58 | |
Benjamin Marzinski | 1bc333f | 2013-07-26 17:09:33 -0500 | [diff] [blame] | 59 | static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync, |
| 60 | unsigned int nr_revokes) |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 61 | { |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 62 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 63 | struct list_head *head = &gl->gl_ail_list; |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 64 | struct gfs2_bufdata *bd, *tmp; |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 65 | struct buffer_head *bh; |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 66 | const unsigned long b_state = (1UL << BH_Dirty)|(1UL << BH_Pinned)|(1UL << BH_Lock); |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 67 | |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 68 | gfs2_log_lock(sdp); |
Dave Chinner | d6a079e | 2011-03-11 11:52:25 +0000 | [diff] [blame] | 69 | spin_lock(&sdp->sd_ail_lock); |
Benjamin Marzinski | 1bc333f | 2013-07-26 17:09:33 -0500 | [diff] [blame] | 70 | list_for_each_entry_safe_reverse(bd, tmp, head, bd_ail_gl_list) { |
| 71 | if (nr_revokes == 0) |
| 72 | break; |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 73 | bh = bd->bd_bh; |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 74 | if (bh->b_state & b_state) { |
| 75 | if (fsync) |
| 76 | continue; |
Steven Whitehouse | 7554918 | 2011-08-02 13:09:36 +0100 | [diff] [blame] | 77 | gfs2_ail_error(gl, bh); |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 78 | } |
Steven Whitehouse | 1ad38c4 | 2007-09-03 11:01:33 +0100 | [diff] [blame] | 79 | gfs2_trans_add_revoke(sdp, bd); |
Benjamin Marzinski | 1bc333f | 2013-07-26 17:09:33 -0500 | [diff] [blame] | 80 | nr_revokes--; |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 81 | } |
Steven Whitehouse | 8eae1ca0 | 2012-10-15 10:57:02 +0100 | [diff] [blame] | 82 | GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count)); |
Dave Chinner | d6a079e | 2011-03-11 11:52:25 +0000 | [diff] [blame] | 83 | spin_unlock(&sdp->sd_ail_lock); |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 84 | gfs2_log_unlock(sdp); |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 85 | } |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 86 | |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 87 | |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 88 | static int gfs2_ail_empty_gl(struct gfs2_glock *gl) |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 89 | { |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 90 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 91 | struct gfs2_trans tr; |
Andreas Gruenbacher | c968f57 | 2021-01-29 16:45:33 +0100 | [diff] [blame] | 92 | unsigned int revokes; |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 93 | int ret; |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 94 | |
Andreas Gruenbacher | c968f57 | 2021-01-29 16:45:33 +0100 | [diff] [blame] | 95 | revokes = atomic_read(&gl->gl_ail_count); |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 96 | |
Andreas Gruenbacher | c968f57 | 2021-01-29 16:45:33 +0100 | [diff] [blame] | 97 | if (!revokes) { |
Bob Peterson | 9ff7828 | 2019-11-13 13:47:02 -0600 | [diff] [blame] | 98 | bool have_revokes; |
| 99 | bool log_in_flight; |
| 100 | |
| 101 | /* |
| 102 | * We have nothing on the ail, but there could be revokes on |
| 103 | * the sdp revoke queue, in which case, we still want to flush |
| 104 | * the log and wait for it to finish. |
| 105 | * |
| 106 | * If the sdp revoke list is empty too, we might still have an |
| 107 | * io outstanding for writing revokes, so we should wait for |
| 108 | * it before returning. |
| 109 | * |
| 110 | * If none of these conditions are true, our revokes are all |
| 111 | * flushed and we can return. |
| 112 | */ |
| 113 | gfs2_log_lock(sdp); |
| 114 | have_revokes = !list_empty(&sdp->sd_log_revokes); |
| 115 | log_in_flight = atomic_read(&sdp->sd_log_in_flight); |
| 116 | gfs2_log_unlock(sdp); |
| 117 | if (have_revokes) |
| 118 | goto flush; |
| 119 | if (log_in_flight) |
| 120 | log_flush_wait(sdp); |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 121 | return 0; |
Bob Peterson | 9ff7828 | 2019-11-13 13:47:02 -0600 | [diff] [blame] | 122 | } |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 123 | |
Andreas Gruenbacher | c968f57 | 2021-01-29 16:45:33 +0100 | [diff] [blame] | 124 | memset(&tr, 0, sizeof(tr)); |
| 125 | set_bit(TR_ONSTACK, &tr.tr_flags); |
| 126 | ret = __gfs2_trans_begin(&tr, sdp, 0, revokes, _RET_IP_); |
| 127 | if (ret) |
| 128 | goto flush; |
| 129 | __gfs2_ail_flush(gl, 0, revokes); |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 130 | gfs2_trans_end(sdp); |
Andreas Gruenbacher | c968f57 | 2021-01-29 16:45:33 +0100 | [diff] [blame] | 131 | |
Bob Peterson | 9ff7828 | 2019-11-13 13:47:02 -0600 | [diff] [blame] | 132 | flush: |
Bob Peterson | 805c0907 | 2018-01-08 10:34:17 -0500 | [diff] [blame] | 133 | gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL | |
| 134 | GFS2_LFC_AIL_EMPTY_GL); |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 135 | return 0; |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 136 | } |
| 137 | |
Steven Whitehouse | b5b24d7 | 2011-09-07 10:33:25 +0100 | [diff] [blame] | 138 | void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync) |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 139 | { |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 140 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 141 | unsigned int revokes = atomic_read(&gl->gl_ail_count); |
| 142 | int ret; |
| 143 | |
| 144 | if (!revokes) |
| 145 | return; |
| 146 | |
Andreas Gruenbacher | 2129b42 | 2020-12-17 16:14:30 +0100 | [diff] [blame] | 147 | ret = gfs2_trans_begin(sdp, 0, revokes); |
Steven Whitehouse | dba898b | 2011-04-14 09:54:02 +0100 | [diff] [blame] | 148 | if (ret) |
| 149 | return; |
Andreas Gruenbacher | 2129b42 | 2020-12-17 16:14:30 +0100 | [diff] [blame] | 150 | __gfs2_ail_flush(gl, fsync, revokes); |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 151 | gfs2_trans_end(sdp); |
Bob Peterson | 805c0907 | 2018-01-08 10:34:17 -0500 | [diff] [blame] | 152 | gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL | |
| 153 | GFS2_LFC_AIL_FLUSH); |
Steven Whitehouse | ddacfaf | 2006-10-03 11:10:41 -0400 | [diff] [blame] | 154 | } |
Steven Whitehouse | ba7f729 | 2006-07-26 11:27:10 -0400 | [diff] [blame] | 155 | |
| 156 | /** |
Bob Peterson | 4a55752 | 2020-10-27 12:29:37 -0500 | [diff] [blame] | 157 | * gfs2_rgrp_metasync - sync out the metadata of a resource group |
| 158 | * @gl: the glock protecting the resource group |
| 159 | * |
| 160 | */ |
| 161 | |
| 162 | static int gfs2_rgrp_metasync(struct gfs2_glock *gl) |
| 163 | { |
| 164 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
| 165 | struct address_space *metamapping = &sdp->sd_aspace; |
| 166 | struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl); |
| 167 | const unsigned bsize = sdp->sd_sb.sb_bsize; |
| 168 | loff_t start = (rgd->rd_addr * bsize) & PAGE_MASK; |
| 169 | loff_t end = PAGE_ALIGN((rgd->rd_addr + rgd->rd_length) * bsize) - 1; |
| 170 | int error; |
| 171 | |
| 172 | filemap_fdatawrite_range(metamapping, start, end); |
| 173 | error = filemap_fdatawait_range(metamapping, start, end); |
| 174 | WARN_ON_ONCE(error && !gfs2_withdrawn(sdp)); |
| 175 | mapping_set_error(metamapping, error); |
| 176 | if (error) |
| 177 | gfs2_io_error(sdp); |
| 178 | return error; |
| 179 | } |
| 180 | |
| 181 | /** |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 182 | * rgrp_go_sync - sync out the metadata for this glock |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 183 | * @gl: the glock |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 184 | * |
| 185 | * Called when demoting or unlocking an EX glock. We must flush |
| 186 | * to disk all dirty buffers/pages relating to this glock, and must not |
Andreas Gruenbacher | 6f6597ba | 2017-06-30 07:55:08 -0500 | [diff] [blame] | 187 | * return to caller to demote/unlock the glock until I/O is complete. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 188 | */ |
| 189 | |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 190 | static int rgrp_go_sync(struct gfs2_glock *gl) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 191 | { |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 192 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Bob Peterson | b3422ca | 2019-11-13 11:50:30 -0600 | [diff] [blame] | 193 | struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl); |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 194 | int error; |
Steven Whitehouse | b5d32be | 2007-01-22 12:15:34 -0500 | [diff] [blame] | 195 | |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 196 | if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 197 | return 0; |
Steven Whitehouse | 8eae1ca0 | 2012-10-15 10:57:02 +0100 | [diff] [blame] | 198 | GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE); |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 199 | |
Bob Peterson | 805c0907 | 2018-01-08 10:34:17 -0500 | [diff] [blame] | 200 | gfs2_log_flush(sdp, gl, GFS2_LOG_HEAD_FLUSH_NORMAL | |
| 201 | GFS2_LFC_RGRP_GO_SYNC); |
Bob Peterson | 4a55752 | 2020-10-27 12:29:37 -0500 | [diff] [blame] | 202 | error = gfs2_rgrp_metasync(gl); |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 203 | if (!error) |
| 204 | error = gfs2_ail_empty_gl(gl); |
Bob Peterson | 23cfb0c | 2020-10-15 11:07:26 -0500 | [diff] [blame] | 205 | gfs2_free_clones(rgd); |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 206 | return error; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 210 | * rgrp_go_inval - invalidate the metadata for this glock |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 211 | * @gl: the glock |
| 212 | * @flags: |
| 213 | * |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 214 | * We never used LM_ST_DEFERRED with resource groups, so that we |
| 215 | * should always see the metadata flag set here. |
| 216 | * |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 217 | */ |
| 218 | |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 219 | static void rgrp_go_inval(struct gfs2_glock *gl, int flags) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 220 | { |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 221 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | 70d4ee9 | 2013-12-06 16:19:54 +0000 | [diff] [blame] | 222 | struct address_space *mapping = &sdp->sd_aspace; |
Andreas Gruenbacher | 6f6597ba | 2017-06-30 07:55:08 -0500 | [diff] [blame] | 223 | struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl); |
Bob Peterson | 23cfb0c | 2020-10-15 11:07:26 -0500 | [diff] [blame] | 224 | const unsigned bsize = sdp->sd_sb.sb_bsize; |
| 225 | loff_t start = (rgd->rd_addr * bsize) & PAGE_MASK; |
| 226 | loff_t end = PAGE_ALIGN((rgd->rd_addr + rgd->rd_length) * bsize) - 1; |
Bob Peterson | 39b0f1e | 2015-06-05 08:38:57 -0500 | [diff] [blame] | 227 | |
Bob Peterson | 23cfb0c | 2020-10-15 11:07:26 -0500 | [diff] [blame] | 228 | gfs2_rgrp_brelse(rgd); |
Steven Whitehouse | 8eae1ca0 | 2012-10-15 10:57:02 +0100 | [diff] [blame] | 229 | WARN_ON_ONCE(!(flags & DIO_METADATA)); |
Bob Peterson | 23cfb0c | 2020-10-15 11:07:26 -0500 | [diff] [blame] | 230 | truncate_inode_pages_range(mapping, start, end); |
Bob Peterson | 4b3113a | 2021-10-05 09:28:17 -0500 | [diff] [blame] | 231 | set_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 232 | } |
| 233 | |
Andrew Price | 0e539ca | 2020-10-07 12:30:58 +0100 | [diff] [blame] | 234 | static void gfs2_rgrp_go_dump(struct seq_file *seq, struct gfs2_glock *gl, |
| 235 | const char *fs_id_buf) |
| 236 | { |
Alexander Aring | 16e6281 | 2020-11-22 18:10:24 -0500 | [diff] [blame] | 237 | struct gfs2_rgrpd *rgd = gl->gl_object; |
Andrew Price | 0e539ca | 2020-10-07 12:30:58 +0100 | [diff] [blame] | 238 | |
| 239 | if (rgd) |
| 240 | gfs2_rgrp_dump(seq, rgd, fs_id_buf); |
| 241 | } |
| 242 | |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 243 | static struct gfs2_inode *gfs2_glock2inode(struct gfs2_glock *gl) |
| 244 | { |
| 245 | struct gfs2_inode *ip; |
| 246 | |
| 247 | spin_lock(&gl->gl_lockref.lock); |
| 248 | ip = gl->gl_object; |
| 249 | if (ip) |
| 250 | set_bit(GIF_GLOP_PENDING, &ip->i_flags); |
| 251 | spin_unlock(&gl->gl_lockref.lock); |
| 252 | return ip; |
| 253 | } |
| 254 | |
Andreas Gruenbacher | 6f6597ba | 2017-06-30 07:55:08 -0500 | [diff] [blame] | 255 | struct gfs2_rgrpd *gfs2_glock2rgrp(struct gfs2_glock *gl) |
| 256 | { |
| 257 | struct gfs2_rgrpd *rgd; |
| 258 | |
| 259 | spin_lock(&gl->gl_lockref.lock); |
| 260 | rgd = gl->gl_object; |
| 261 | spin_unlock(&gl->gl_lockref.lock); |
| 262 | |
| 263 | return rgd; |
| 264 | } |
| 265 | |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 266 | static void gfs2_clear_glop_pending(struct gfs2_inode *ip) |
| 267 | { |
| 268 | if (!ip) |
| 269 | return; |
| 270 | |
| 271 | clear_bit_unlock(GIF_GLOP_PENDING, &ip->i_flags); |
| 272 | wake_up_bit(&ip->i_flags, GIF_GLOP_PENDING); |
| 273 | } |
| 274 | |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 275 | /** |
Bob Peterson | 4a55752 | 2020-10-27 12:29:37 -0500 | [diff] [blame] | 276 | * gfs2_inode_metasync - sync out the metadata of an inode |
| 277 | * @gl: the glock protecting the inode |
| 278 | * |
| 279 | */ |
| 280 | int gfs2_inode_metasync(struct gfs2_glock *gl) |
| 281 | { |
| 282 | struct address_space *metamapping = gfs2_glock2aspace(gl); |
| 283 | int error; |
| 284 | |
| 285 | filemap_fdatawrite(metamapping); |
| 286 | error = filemap_fdatawait(metamapping); |
| 287 | if (error) |
| 288 | gfs2_io_error(gl->gl_name.ln_sbd); |
| 289 | return error; |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * inode_go_sync - Sync the dirty metadata of an inode |
Steven Whitehouse | b5d32be | 2007-01-22 12:15:34 -0500 | [diff] [blame] | 294 | * @gl: the glock protecting the inode |
| 295 | * |
| 296 | */ |
| 297 | |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 298 | static int inode_go_sync(struct gfs2_glock *gl) |
Steven Whitehouse | b5d32be | 2007-01-22 12:15:34 -0500 | [diff] [blame] | 299 | { |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 300 | struct gfs2_inode *ip = gfs2_glock2inode(gl); |
| 301 | int isreg = ip && S_ISREG(ip->i_inode.i_mode); |
Steven Whitehouse | 009d851 | 2009-12-08 12:12:13 +0000 | [diff] [blame] | 302 | struct address_space *metamapping = gfs2_glock2aspace(gl); |
Bob Peterson | bbae10f | 2020-05-08 09:18:03 -0500 | [diff] [blame] | 303 | int error = 0, ret; |
Steven Whitehouse | 3042a2cc | 2007-11-02 08:39:34 +0000 | [diff] [blame] | 304 | |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 305 | if (isreg) { |
Steven Whitehouse | 582d2f7 | 2013-12-19 11:04:14 +0000 | [diff] [blame] | 306 | if (test_and_clear_bit(GIF_SW_PAGED, &ip->i_flags)) |
| 307 | unmap_shared_mapping_range(ip->i_inode.i_mapping, 0, 0); |
| 308 | inode_dio_wait(&ip->i_inode); |
| 309 | } |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 310 | if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 311 | goto out; |
Steven Whitehouse | b5d32be | 2007-01-22 12:15:34 -0500 | [diff] [blame] | 312 | |
Steven Whitehouse | 8eae1ca0 | 2012-10-15 10:57:02 +0100 | [diff] [blame] | 313 | GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE); |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 314 | |
Bob Peterson | 805c0907 | 2018-01-08 10:34:17 -0500 | [diff] [blame] | 315 | gfs2_log_flush(gl->gl_name.ln_sbd, gl, GFS2_LOG_HEAD_FLUSH_NORMAL | |
| 316 | GFS2_LFC_INODE_GO_SYNC); |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 317 | filemap_fdatawrite(metamapping); |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 318 | if (isreg) { |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 319 | struct address_space *mapping = ip->i_inode.i_mapping; |
| 320 | filemap_fdatawrite(mapping); |
| 321 | error = filemap_fdatawait(mapping); |
| 322 | mapping_set_error(mapping, error); |
Steven Whitehouse | b5d32be | 2007-01-22 12:15:34 -0500 | [diff] [blame] | 323 | } |
Bob Peterson | 4a55752 | 2020-10-27 12:29:37 -0500 | [diff] [blame] | 324 | ret = gfs2_inode_metasync(gl); |
Bob Peterson | bbae10f | 2020-05-08 09:18:03 -0500 | [diff] [blame] | 325 | if (!error) |
| 326 | error = ret; |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 327 | gfs2_ail_empty_gl(gl); |
Steven Whitehouse | 52fcd11 | 2009-04-20 08:58:45 +0100 | [diff] [blame] | 328 | /* |
| 329 | * Writeback of the data mapping may cause the dirty flag to be set |
| 330 | * so we have to clear it again here. |
| 331 | */ |
Peter Zijlstra | 4e857c5 | 2014-03-17 18:06:10 +0100 | [diff] [blame] | 332 | smp_mb__before_atomic(); |
Steven Whitehouse | 52fcd11 | 2009-04-20 08:58:45 +0100 | [diff] [blame] | 333 | clear_bit(GLF_DIRTY, &gl->gl_flags); |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 334 | |
| 335 | out: |
| 336 | gfs2_clear_glop_pending(ip); |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 337 | return error; |
Steven Whitehouse | b5d32be | 2007-01-22 12:15:34 -0500 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | /** |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 341 | * inode_go_inval - prepare a inode glock to be released |
| 342 | * @gl: the glock |
| 343 | * @flags: |
Geert Uytterhoeven | 6b49d1d | 2014-06-29 12:21:39 +0200 | [diff] [blame] | 344 | * |
| 345 | * Normally we invalidate everything, but if we are moving into |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 346 | * LM_ST_DEFERRED from LM_ST_SHARED or LM_ST_EXCLUSIVE then we |
| 347 | * can keep hold of the metadata, since it won't have changed. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 348 | * |
| 349 | */ |
| 350 | |
| 351 | static void inode_go_inval(struct gfs2_glock *gl, int flags) |
| 352 | { |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 353 | struct gfs2_inode *ip = gfs2_glock2inode(gl); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 354 | |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 355 | if (flags & DIO_METADATA) { |
Steven Whitehouse | 009d851 | 2009-12-08 12:12:13 +0000 | [diff] [blame] | 356 | struct address_space *mapping = gfs2_glock2aspace(gl); |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 357 | truncate_inode_pages(mapping, 0); |
Steven Whitehouse | c65f7fb | 2009-10-02 11:54:39 +0100 | [diff] [blame] | 358 | if (ip) { |
Bob Peterson | f2e70d8 | 2021-10-06 09:29:18 -0500 | [diff] [blame] | 359 | set_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags); |
Steven Whitehouse | c65f7fb | 2009-10-02 11:54:39 +0100 | [diff] [blame] | 360 | forget_all_cached_acls(&ip->i_inode); |
Andreas Gruenbacher | f39814f6 | 2015-12-24 11:09:40 -0500 | [diff] [blame] | 361 | security_inode_invalidate_secctx(&ip->i_inode); |
Steven Whitehouse | 17d539f | 2011-06-15 10:29:37 +0100 | [diff] [blame] | 362 | gfs2_dir_hash_inval(ip); |
Steven Whitehouse | c65f7fb | 2009-10-02 11:54:39 +0100 | [diff] [blame] | 363 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 364 | } |
Steven Whitehouse | b004157 | 2006-11-23 10:51:34 -0500 | [diff] [blame] | 365 | |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 366 | if (ip == GFS2_I(gl->gl_name.ln_sbd->sd_rindex)) { |
Bob Peterson | c1696fb | 2018-01-17 00:01:33 +0100 | [diff] [blame] | 367 | gfs2_log_flush(gl->gl_name.ln_sbd, NULL, |
Bob Peterson | 805c0907 | 2018-01-08 10:34:17 -0500 | [diff] [blame] | 368 | GFS2_LOG_HEAD_FLUSH_NORMAL | |
| 369 | GFS2_LFC_INODE_GO_INVAL); |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 370 | gl->gl_name.ln_sbd->sd_rindex_uptodate = 0; |
Benjamin Marzinski | 1ce5336 | 2011-06-13 14:27:40 -0500 | [diff] [blame] | 371 | } |
Steven Whitehouse | 3cc3f71 | 2007-10-15 15:40:33 +0100 | [diff] [blame] | 372 | if (ip && S_ISREG(ip->i_inode.i_mode)) |
Steven Whitehouse | b004157 | 2006-11-23 10:51:34 -0500 | [diff] [blame] | 373 | truncate_inode_pages(ip->i_inode.i_mapping, 0); |
Andreas Gruenbacher | 4fd1a57 | 2017-06-30 07:47:15 -0500 | [diff] [blame] | 374 | |
| 375 | gfs2_clear_glop_pending(ip); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | /** |
| 379 | * inode_go_demote_ok - Check to see if it's ok to unlock an inode glock |
| 380 | * @gl: the glock |
| 381 | * |
| 382 | * Returns: 1 if it's ok |
| 383 | */ |
| 384 | |
Steven Whitehouse | 97cc1025 | 2008-11-20 13:39:47 +0000 | [diff] [blame] | 385 | static int inode_go_demote_ok(const struct gfs2_glock *gl) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 386 | { |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 387 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | bc015cb | 2011-01-19 09:30:01 +0000 | [diff] [blame] | 388 | |
Steven Whitehouse | 97cc1025 | 2008-11-20 13:39:47 +0000 | [diff] [blame] | 389 | if (sdp->sd_jindex == gl->gl_object || sdp->sd_rindex == gl->gl_object) |
| 390 | return 0; |
Steven Whitehouse | bc015cb | 2011-01-19 09:30:01 +0000 | [diff] [blame] | 391 | |
Steven Whitehouse | 97cc1025 | 2008-11-20 13:39:47 +0000 | [diff] [blame] | 392 | return 1; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 393 | } |
| 394 | |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 395 | static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) |
| 396 | { |
| 397 | const struct gfs2_dinode *str = buf; |
Deepa Dinamani | 95582b0 | 2018-05-08 19:36:02 -0700 | [diff] [blame] | 398 | struct timespec64 atime; |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 399 | u16 height, depth; |
Al Viro | 4a378d8 | 2021-02-12 13:22:38 -0500 | [diff] [blame] | 400 | umode_t mode = be32_to_cpu(str->di_mode); |
Bob Peterson | 4194dec | 2021-05-19 14:45:56 -0400 | [diff] [blame] | 401 | bool is_new = ip->i_inode.i_state & I_NEW; |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 402 | |
| 403 | if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr))) |
| 404 | goto corrupt; |
Al Viro | 4a378d8 | 2021-02-12 13:22:38 -0500 | [diff] [blame] | 405 | if (unlikely(!is_new && inode_wrong_type(&ip->i_inode, mode))) |
| 406 | goto corrupt; |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 407 | ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino); |
Al Viro | 4a378d8 | 2021-02-12 13:22:38 -0500 | [diff] [blame] | 408 | ip->i_inode.i_mode = mode; |
| 409 | if (is_new) { |
| 410 | ip->i_inode.i_rdev = 0; |
| 411 | switch (mode & S_IFMT) { |
| 412 | case S_IFBLK: |
| 413 | case S_IFCHR: |
| 414 | ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major), |
| 415 | be32_to_cpu(str->di_minor)); |
| 416 | break; |
| 417 | } |
Aliasgar Surti | 098b9c1 | 2019-10-04 10:55:29 -0500 | [diff] [blame] | 418 | } |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 419 | |
Eric W. Biederman | d054642 | 2013-01-31 22:08:10 -0800 | [diff] [blame] | 420 | i_uid_write(&ip->i_inode, be32_to_cpu(str->di_uid)); |
| 421 | i_gid_write(&ip->i_inode, be32_to_cpu(str->di_gid)); |
Andreas Gruenbacher | eebd2e8 | 2017-08-01 11:33:17 -0500 | [diff] [blame] | 422 | set_nlink(&ip->i_inode, be32_to_cpu(str->di_nlink)); |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 423 | i_size_write(&ip->i_inode, be64_to_cpu(str->di_size)); |
| 424 | gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks)); |
| 425 | atime.tv_sec = be64_to_cpu(str->di_atime); |
| 426 | atime.tv_nsec = be32_to_cpu(str->di_atime_nsec); |
Deepa Dinamani | 95582b0 | 2018-05-08 19:36:02 -0700 | [diff] [blame] | 427 | if (timespec64_compare(&ip->i_inode.i_atime, &atime) < 0) |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 428 | ip->i_inode.i_atime = atime; |
| 429 | ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime); |
| 430 | ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec); |
| 431 | ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime); |
| 432 | ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec); |
| 433 | |
| 434 | ip->i_goal = be64_to_cpu(str->di_goal_meta); |
| 435 | ip->i_generation = be64_to_cpu(str->di_generation); |
| 436 | |
| 437 | ip->i_diskflags = be32_to_cpu(str->di_flags); |
Steven Whitehouse | 9964afb | 2011-06-16 14:06:55 +0100 | [diff] [blame] | 438 | ip->i_eattr = be64_to_cpu(str->di_eattr); |
| 439 | /* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */ |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 440 | gfs2_set_inode_flags(&ip->i_inode); |
| 441 | height = be16_to_cpu(str->di_height); |
| 442 | if (unlikely(height > GFS2_MAX_META_HEIGHT)) |
| 443 | goto corrupt; |
| 444 | ip->i_height = (u8)height; |
| 445 | |
| 446 | depth = be16_to_cpu(str->di_depth); |
| 447 | if (unlikely(depth > GFS2_DIR_MAX_DEPTH)) |
| 448 | goto corrupt; |
| 449 | ip->i_depth = (u8)depth; |
| 450 | ip->i_entries = be32_to_cpu(str->di_entries); |
| 451 | |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 452 | if (S_ISREG(ip->i_inode.i_mode)) |
| 453 | gfs2_set_aops(&ip->i_inode); |
| 454 | |
| 455 | return 0; |
| 456 | corrupt: |
| 457 | gfs2_consist_inode(ip); |
| 458 | return -EIO; |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * gfs2_inode_refresh - Refresh the incore copy of the dinode |
| 463 | * @ip: The GFS2 inode |
| 464 | * |
| 465 | * Returns: errno |
| 466 | */ |
| 467 | |
| 468 | int gfs2_inode_refresh(struct gfs2_inode *ip) |
| 469 | { |
| 470 | struct buffer_head *dibh; |
| 471 | int error; |
| 472 | |
| 473 | error = gfs2_meta_inode_buffer(ip, &dibh); |
| 474 | if (error) |
| 475 | return error; |
| 476 | |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 477 | error = gfs2_dinode_in(ip, dibh->b_data); |
| 478 | brelse(dibh); |
Steven Whitehouse | d4b2cf1 | 2011-05-09 13:49:59 +0100 | [diff] [blame] | 479 | return error; |
| 480 | } |
| 481 | |
| 482 | /** |
Bob Peterson | 3278b97 | 2021-09-29 15:06:21 -0500 | [diff] [blame] | 483 | * inode_go_instantiate - read in an inode if necessary |
Lee Jones | c551f66 | 2021-03-30 17:44:29 +0100 | [diff] [blame] | 484 | * @gh: The glock holder |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 485 | * |
| 486 | * Returns: errno |
| 487 | */ |
| 488 | |
Bob Peterson | 3278b97 | 2021-09-29 15:06:21 -0500 | [diff] [blame] | 489 | static int inode_go_instantiate(struct gfs2_holder *gh) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 490 | { |
| 491 | struct gfs2_glock *gl = gh->gh_gl; |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 492 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 493 | struct gfs2_inode *ip = gl->gl_object; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 494 | int error = 0; |
| 495 | |
Bob Peterson | f2e70d8 | 2021-10-06 09:29:18 -0500 | [diff] [blame] | 496 | if (!ip) /* no inode to populate - read it in later */ |
| 497 | goto out; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 498 | |
Bob Peterson | ec1d398 | 2021-10-05 09:10:51 -0500 | [diff] [blame] | 499 | error = gfs2_inode_refresh(ip); |
| 500 | if (error) |
| 501 | goto out; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 502 | |
Steven Whitehouse | 582d2f7 | 2013-12-19 11:04:14 +0000 | [diff] [blame] | 503 | if (gh->gh_state != LM_ST_DEFERRED) |
| 504 | inode_dio_wait(&ip->i_inode); |
| 505 | |
Steven Whitehouse | 383f01f | 2008-11-04 10:05:22 +0000 | [diff] [blame] | 506 | if ((ip->i_diskflags & GFS2_DIF_TRUNC_IN_PROG) && |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 507 | (gl->gl_state == LM_ST_EXCLUSIVE) && |
Steven Whitehouse | 813e0c4 | 2008-11-18 13:38:48 +0000 | [diff] [blame] | 508 | (gh->gh_state == LM_ST_EXCLUSIVE)) { |
| 509 | spin_lock(&sdp->sd_trunc_lock); |
| 510 | if (list_empty(&ip->i_trunc_list)) |
Wang Xibo | e7cb550 | 2017-07-21 07:40:59 -0500 | [diff] [blame] | 511 | list_add(&ip->i_trunc_list, &sdp->sd_trunc_list); |
Steven Whitehouse | 813e0c4 | 2008-11-18 13:38:48 +0000 | [diff] [blame] | 512 | spin_unlock(&sdp->sd_trunc_lock); |
| 513 | wake_up(&sdp->sd_quota_wait); |
Bob Peterson | f2e70d8 | 2021-10-06 09:29:18 -0500 | [diff] [blame] | 514 | error = 1; |
Steven Whitehouse | 813e0c4 | 2008-11-18 13:38:48 +0000 | [diff] [blame] | 515 | } |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 516 | |
Bob Peterson | f2e70d8 | 2021-10-06 09:29:18 -0500 | [diff] [blame] | 517 | out: |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 518 | return error; |
| 519 | } |
| 520 | |
| 521 | /** |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 522 | * inode_go_dump - print information about an inode |
| 523 | * @seq: The iterator |
Lee Jones | c551f66 | 2021-03-30 17:44:29 +0100 | [diff] [blame] | 524 | * @gl: The glock |
Bob Peterson | 3792ce9 | 2019-05-09 09:21:48 -0500 | [diff] [blame] | 525 | * @fs_id_buf: file system id (may be empty) |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 526 | * |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 527 | */ |
| 528 | |
Bob Peterson | 3792ce9 | 2019-05-09 09:21:48 -0500 | [diff] [blame] | 529 | static void inode_go_dump(struct seq_file *seq, struct gfs2_glock *gl, |
| 530 | const char *fs_id_buf) |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 531 | { |
Bob Peterson | 27a2660f | 2018-04-18 12:05:01 -0700 | [diff] [blame] | 532 | struct gfs2_inode *ip = gl->gl_object; |
| 533 | struct inode *inode = &ip->i_inode; |
| 534 | unsigned long nrpages; |
| 535 | |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 536 | if (ip == NULL) |
Steven Whitehouse | ac3beb6 | 2014-01-16 10:31:13 +0000 | [diff] [blame] | 537 | return; |
Bob Peterson | 27a2660f | 2018-04-18 12:05:01 -0700 | [diff] [blame] | 538 | |
| 539 | xa_lock_irq(&inode->i_data.i_pages); |
| 540 | nrpages = inode->i_data.nrpages; |
| 541 | xa_unlock_irq(&inode->i_data.i_pages); |
| 542 | |
Bob Peterson | 3792ce9 | 2019-05-09 09:21:48 -0500 | [diff] [blame] | 543 | gfs2_print_dbg(seq, "%s I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu " |
| 544 | "p:%lu\n", fs_id_buf, |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 545 | (unsigned long long)ip->i_no_formal_ino, |
| 546 | (unsigned long long)ip->i_no_addr, |
Steven Whitehouse | fa75ced | 2008-11-10 10:10:12 +0000 | [diff] [blame] | 547 | IF2DT(ip->i_inode.i_mode), ip->i_flags, |
| 548 | (unsigned int)ip->i_diskflags, |
Bob Peterson | 27a2660f | 2018-04-18 12:05:01 -0700 | [diff] [blame] | 549 | (unsigned long long)i_size_read(inode), nrpages); |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | /** |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 553 | * freeze_go_sync - promote/demote the freeze glock |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 554 | * @gl: the glock |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 555 | */ |
| 556 | |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 557 | static int freeze_go_sync(struct gfs2_glock *gl) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 558 | { |
Benjamin Marzinski | 2e60d76 | 2014-11-13 20:42:04 -0600 | [diff] [blame] | 559 | int error = 0; |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 560 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 561 | |
Bob Peterson | 20b3291 | 2020-11-18 08:54:31 -0500 | [diff] [blame] | 562 | /* |
| 563 | * We need to check gl_state == LM_ST_SHARED here and not gl_req == |
| 564 | * LM_ST_EXCLUSIVE. That's because when any node does a freeze, |
| 565 | * all the nodes should have the freeze glock in SH mode and they all |
| 566 | * call do_xmote: One for EX and the others for UN. They ALL must |
| 567 | * freeze locally, and they ALL must queue freeze work. The freeze_work |
| 568 | * calls freeze_func, which tries to reacquire the freeze glock in SH, |
| 569 | * effectively waiting for the thaw on the node who holds it in EX. |
| 570 | * Once thawed, the work func acquires the freeze glock in |
| 571 | * SH and everybody goes back to thawed. |
| 572 | */ |
Bob Peterson | f39e7d3 | 2020-11-24 10:41:40 -0600 | [diff] [blame] | 573 | if (gl->gl_state == LM_ST_SHARED && !gfs2_withdrawn(sdp) && |
| 574 | !test_bit(SDF_NORECOVERY, &sdp->sd_flags)) { |
Benjamin Marzinski | 2e60d76 | 2014-11-13 20:42:04 -0600 | [diff] [blame] | 575 | atomic_set(&sdp->sd_freeze_state, SFS_STARTING_FREEZE); |
| 576 | error = freeze_super(sdp->sd_vfs); |
| 577 | if (error) { |
Bob Peterson | f29e62e | 2019-05-13 09:42:18 -0500 | [diff] [blame] | 578 | fs_info(sdp, "GFS2: couldn't freeze filesystem: %d\n", |
| 579 | error); |
Bob Peterson | 601ef0d | 2020-01-28 20:23:45 +0100 | [diff] [blame] | 580 | if (gfs2_withdrawn(sdp)) { |
| 581 | atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN); |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 582 | return 0; |
Bob Peterson | 601ef0d | 2020-01-28 20:23:45 +0100 | [diff] [blame] | 583 | } |
Benjamin Marzinski | 2e60d76 | 2014-11-13 20:42:04 -0600 | [diff] [blame] | 584 | gfs2_assert_withdraw(sdp, 0); |
| 585 | } |
| 586 | queue_work(gfs2_freeze_wq, &sdp->sd_freeze_work); |
Bob Peterson | 541656d | 2020-06-25 13:29:44 -0500 | [diff] [blame] | 587 | if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) |
| 588 | gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_FREEZE | |
| 589 | GFS2_LFC_FREEZE_GO_SYNC); |
| 590 | else /* read-only mounts */ |
| 591 | atomic_set(&sdp->sd_freeze_state, SFS_FROZEN); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 592 | } |
Bob Peterson | 1c634f9 | 2019-11-13 14:09:28 -0600 | [diff] [blame] | 593 | return 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | /** |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 597 | * freeze_go_xmote_bh - After promoting/demoting the freeze glock |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 598 | * @gl: the glock |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 599 | */ |
Bob Peterson | f68effb | 2021-03-19 07:56:44 -0400 | [diff] [blame] | 600 | static int freeze_go_xmote_bh(struct gfs2_glock *gl) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 601 | { |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 602 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | feaa7bb | 2006-06-14 15:32:57 -0400 | [diff] [blame] | 603 | struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode); |
Steven Whitehouse | 5c676f6 | 2006-02-27 17:23:27 -0500 | [diff] [blame] | 604 | struct gfs2_glock *j_gl = ip->i_gl; |
Al Viro | 5516762 | 2006-10-13 21:47:13 -0400 | [diff] [blame] | 605 | struct gfs2_log_header_host head; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 606 | int error; |
| 607 | |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 608 | if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { |
Steven Whitehouse | 1a14d3a | 2006-11-20 10:37:45 -0500 | [diff] [blame] | 609 | j_gl->gl_ops->go_inval(j_gl, DIO_METADATA); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 610 | |
Abhi Das | f4686c2 | 2019-05-02 14:17:40 -0500 | [diff] [blame] | 611 | error = gfs2_find_jhead(sdp->sd_jdesc, &head, false); |
Bob Peterson | 9d9b160 | 2021-06-01 09:41:40 -0500 | [diff] [blame] | 612 | if (gfs2_assert_withdraw_delayed(sdp, !error)) |
| 613 | return error; |
| 614 | if (gfs2_assert_withdraw_delayed(sdp, head.lh_flags & |
| 615 | GFS2_LOG_HEAD_UNMOUNT)) |
| 616 | return -EIO; |
| 617 | sdp->sd_log_sequence = head.lh_sequence + 1; |
| 618 | gfs2_log_pointers_init(sdp, head.lh_blkno); |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 619 | } |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 620 | return 0; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | /** |
Lee Jones | c551f66 | 2021-03-30 17:44:29 +0100 | [diff] [blame] | 624 | * freeze_go_demote_ok |
Steven Whitehouse | 97cc1025 | 2008-11-20 13:39:47 +0000 | [diff] [blame] | 625 | * @gl: the glock |
| 626 | * |
| 627 | * Always returns 0 |
| 628 | */ |
| 629 | |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 630 | static int freeze_go_demote_ok(const struct gfs2_glock *gl) |
Steven Whitehouse | 97cc1025 | 2008-11-20 13:39:47 +0000 | [diff] [blame] | 631 | { |
| 632 | return 0; |
| 633 | } |
| 634 | |
Benjamin Marzinski | b94a170 | 2009-07-23 18:52:34 -0500 | [diff] [blame] | 635 | /** |
| 636 | * iopen_go_callback - schedule the dcache entry for the inode to be deleted |
| 637 | * @gl: the glock |
Lee Jones | c551f66 | 2021-03-30 17:44:29 +0100 | [diff] [blame] | 638 | * @remote: true if this came from a different cluster node |
Benjamin Marzinski | b94a170 | 2009-07-23 18:52:34 -0500 | [diff] [blame] | 639 | * |
Andreas Gruenbacher | f3dd164 | 2015-10-29 10:58:09 -0500 | [diff] [blame] | 640 | * gl_lockref.lock lock is held while calling this |
Benjamin Marzinski | b94a170 | 2009-07-23 18:52:34 -0500 | [diff] [blame] | 641 | */ |
Steven Whitehouse | 81ffbf6 | 2013-04-10 10:26:55 +0100 | [diff] [blame] | 642 | static void iopen_go_callback(struct gfs2_glock *gl, bool remote) |
Benjamin Marzinski | b94a170 | 2009-07-23 18:52:34 -0500 | [diff] [blame] | 643 | { |
Andreas Gruenbacher | 6f6597ba | 2017-06-30 07:55:08 -0500 | [diff] [blame] | 644 | struct gfs2_inode *ip = gl->gl_object; |
Bob Peterson | 15562c4 | 2015-03-16 11:52:05 -0500 | [diff] [blame] | 645 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
Steven Whitehouse | 001e8e8 | 2011-03-30 14:17:51 +0100 | [diff] [blame] | 646 | |
David Howells | bc98a42 | 2017-07-17 08:45:34 +0100 | [diff] [blame] | 647 | if (!remote || sb_rdonly(sdp->sd_vfs)) |
Steven Whitehouse | 001e8e8 | 2011-03-30 14:17:51 +0100 | [diff] [blame] | 648 | return; |
Benjamin Marzinski | b94a170 | 2009-07-23 18:52:34 -0500 | [diff] [blame] | 649 | |
| 650 | if (gl->gl_demote_state == LM_ST_UNLOCKED && |
Steven Whitehouse | 009d851 | 2009-12-08 12:12:13 +0000 | [diff] [blame] | 651 | gl->gl_state == LM_ST_SHARED && ip) { |
Steven Whitehouse | e66cf16 | 2013-10-15 15:18:08 +0100 | [diff] [blame] | 652 | gl->gl_lockref.count++; |
Andreas Gruenbacher | a0e3cc6 | 2020-01-16 20:12:26 +0100 | [diff] [blame] | 653 | if (!queue_delayed_work(gfs2_delete_workqueue, |
| 654 | &gl->gl_delete, 0)) |
Steven Whitehouse | e66cf16 | 2013-10-15 15:18:08 +0100 | [diff] [blame] | 655 | gl->gl_lockref.count--; |
Benjamin Marzinski | b94a170 | 2009-07-23 18:52:34 -0500 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | |
Andreas Gruenbacher | a0e3cc6 | 2020-01-16 20:12:26 +0100 | [diff] [blame] | 659 | static int iopen_go_demote_ok(const struct gfs2_glock *gl) |
| 660 | { |
| 661 | return !gfs2_delete_work_queued(gl); |
| 662 | } |
| 663 | |
Bob Peterson | 601ef0d | 2020-01-28 20:23:45 +0100 | [diff] [blame] | 664 | /** |
| 665 | * inode_go_free - wake up anyone waiting for dlm's unlock ast to free it |
| 666 | * @gl: glock being freed |
| 667 | * |
| 668 | * For now, this is only used for the journal inode glock. In withdraw |
| 669 | * situations, we need to wait for the glock to be freed so that we know |
| 670 | * other nodes may proceed with recovery / journal replay. |
| 671 | */ |
| 672 | static void inode_go_free(struct gfs2_glock *gl) |
| 673 | { |
| 674 | /* Note that we cannot reference gl_object because it's already set |
| 675 | * to NULL by this point in its lifecycle. */ |
| 676 | if (!test_bit(GLF_FREEING, &gl->gl_flags)) |
| 677 | return; |
| 678 | clear_bit_unlock(GLF_FREEING, &gl->gl_flags); |
| 679 | wake_up_bit(&gl->gl_flags, GLF_FREEING); |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * nondisk_go_callback - used to signal when a node did a withdraw |
| 684 | * @gl: the nondisk glock |
| 685 | * @remote: true if this came from a different cluster node |
| 686 | * |
| 687 | */ |
| 688 | static void nondisk_go_callback(struct gfs2_glock *gl, bool remote) |
| 689 | { |
| 690 | struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; |
| 691 | |
| 692 | /* Ignore the callback unless it's from another node, and it's the |
| 693 | live lock. */ |
| 694 | if (!remote || gl->gl_name.ln_number != GFS2_LIVE_LOCK) |
| 695 | return; |
| 696 | |
| 697 | /* First order of business is to cancel the demote request. We don't |
| 698 | * really want to demote a nondisk glock. At best it's just to inform |
| 699 | * us of another node's withdraw. We'll keep it in SH mode. */ |
| 700 | clear_bit(GLF_DEMOTE, &gl->gl_flags); |
| 701 | clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags); |
| 702 | |
| 703 | /* Ignore the unlock if we're withdrawn, unmounting, or in recovery. */ |
| 704 | if (test_bit(SDF_NORECOVERY, &sdp->sd_flags) || |
| 705 | test_bit(SDF_WITHDRAWN, &sdp->sd_flags) || |
| 706 | test_bit(SDF_REMOTE_WITHDRAW, &sdp->sd_flags)) |
| 707 | return; |
| 708 | |
| 709 | /* We only care when a node wants us to unlock, because that means |
| 710 | * they want a journal recovered. */ |
| 711 | if (gl->gl_demote_state != LM_ST_UNLOCKED) |
| 712 | return; |
| 713 | |
| 714 | if (sdp->sd_args.ar_spectator) { |
| 715 | fs_warn(sdp, "Spectator node cannot recover journals.\n"); |
| 716 | return; |
| 717 | } |
| 718 | |
| 719 | fs_warn(sdp, "Some node has withdrawn; checking for recovery.\n"); |
| 720 | set_bit(SDF_REMOTE_WITHDRAW, &sdp->sd_flags); |
| 721 | /* |
| 722 | * We can't call remote_withdraw directly here or gfs2_recover_journal |
| 723 | * because this is called from the glock unlock function and the |
| 724 | * remote_withdraw needs to enqueue and dequeue the same "live" glock |
| 725 | * we were called from. So we queue it to the control work queue in |
| 726 | * lock_dlm. |
| 727 | */ |
| 728 | queue_delayed_work(gfs2_control_wq, &sdp->sd_control_work, 0); |
| 729 | } |
| 730 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 731 | const struct gfs2_glock_operations gfs2_meta_glops = { |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 732 | .go_type = LM_TYPE_META, |
Bob Peterson | a72d240 | 2019-06-13 13:28:45 -0500 | [diff] [blame] | 733 | .go_flags = GLOF_NONDISK, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 734 | }; |
| 735 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 736 | const struct gfs2_glock_operations gfs2_inode_glops = { |
Bob Peterson | 06dfc30 | 2012-10-24 14:41:05 -0400 | [diff] [blame] | 737 | .go_sync = inode_go_sync, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 738 | .go_inval = inode_go_inval, |
| 739 | .go_demote_ok = inode_go_demote_ok, |
Bob Peterson | 3278b97 | 2021-09-29 15:06:21 -0500 | [diff] [blame] | 740 | .go_instantiate = inode_go_instantiate, |
Steven Whitehouse | 6802e34 | 2008-05-21 17:03:22 +0100 | [diff] [blame] | 741 | .go_dump = inode_go_dump, |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 742 | .go_type = LM_TYPE_INODE, |
Andreas Gruenbacher | f286d62 | 2020-01-13 21:21:49 +0100 | [diff] [blame] | 743 | .go_flags = GLOF_ASPACE | GLOF_LRU | GLOF_LVB, |
Bob Peterson | 601ef0d | 2020-01-28 20:23:45 +0100 | [diff] [blame] | 744 | .go_free = inode_go_free, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 745 | }; |
| 746 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 747 | const struct gfs2_glock_operations gfs2_rgrp_glops = { |
Bob Peterson | 06dfc30 | 2012-10-24 14:41:05 -0400 | [diff] [blame] | 748 | .go_sync = rgrp_go_sync, |
Steven Whitehouse | 6bac243 | 2009-03-09 09:03:51 +0000 | [diff] [blame] | 749 | .go_inval = rgrp_go_inval, |
Bob Peterson | 3278b97 | 2021-09-29 15:06:21 -0500 | [diff] [blame] | 750 | .go_instantiate = gfs2_rgrp_go_instantiate, |
Andrew Price | 0e539ca | 2020-10-07 12:30:58 +0100 | [diff] [blame] | 751 | .go_dump = gfs2_rgrp_go_dump, |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 752 | .go_type = LM_TYPE_RGRP, |
Steven Whitehouse | 70d4ee9 | 2013-12-06 16:19:54 +0000 | [diff] [blame] | 753 | .go_flags = GLOF_LVB, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 754 | }; |
| 755 | |
Benjamin Marzinski | 2497255 | 2014-05-01 22:26:55 -0500 | [diff] [blame] | 756 | const struct gfs2_glock_operations gfs2_freeze_glops = { |
| 757 | .go_sync = freeze_go_sync, |
| 758 | .go_xmote_bh = freeze_go_xmote_bh, |
| 759 | .go_demote_ok = freeze_go_demote_ok, |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 760 | .go_type = LM_TYPE_NONDISK, |
Bob Peterson | a72d240 | 2019-06-13 13:28:45 -0500 | [diff] [blame] | 761 | .go_flags = GLOF_NONDISK, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 762 | }; |
| 763 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 764 | const struct gfs2_glock_operations gfs2_iopen_glops = { |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 765 | .go_type = LM_TYPE_IOPEN, |
Benjamin Marzinski | b94a170 | 2009-07-23 18:52:34 -0500 | [diff] [blame] | 766 | .go_callback = iopen_go_callback, |
Andreas Gruenbacher | a0e3cc6 | 2020-01-16 20:12:26 +0100 | [diff] [blame] | 767 | .go_demote_ok = iopen_go_demote_ok, |
Bob Peterson | a72d240 | 2019-06-13 13:28:45 -0500 | [diff] [blame] | 768 | .go_flags = GLOF_LRU | GLOF_NONDISK, |
Alexander Aring | 515b269 | 2020-11-23 10:53:35 -0500 | [diff] [blame] | 769 | .go_subclass = 1, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 770 | }; |
| 771 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 772 | const struct gfs2_glock_operations gfs2_flock_glops = { |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 773 | .go_type = LM_TYPE_FLOCK, |
Bob Peterson | a72d240 | 2019-06-13 13:28:45 -0500 | [diff] [blame] | 774 | .go_flags = GLOF_LRU | GLOF_NONDISK, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 775 | }; |
| 776 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 777 | const struct gfs2_glock_operations gfs2_nondisk_glops = { |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 778 | .go_type = LM_TYPE_NONDISK, |
Bob Peterson | a72d240 | 2019-06-13 13:28:45 -0500 | [diff] [blame] | 779 | .go_flags = GLOF_NONDISK, |
Bob Peterson | 601ef0d | 2020-01-28 20:23:45 +0100 | [diff] [blame] | 780 | .go_callback = nondisk_go_callback, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 781 | }; |
| 782 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 783 | const struct gfs2_glock_operations gfs2_quota_glops = { |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 784 | .go_type = LM_TYPE_QUOTA, |
Bob Peterson | a72d240 | 2019-06-13 13:28:45 -0500 | [diff] [blame] | 785 | .go_flags = GLOF_LVB | GLOF_LRU | GLOF_NONDISK, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 786 | }; |
| 787 | |
Steven Whitehouse | 8fb4b53 | 2006-08-30 09:30:00 -0400 | [diff] [blame] | 788 | const struct gfs2_glock_operations gfs2_journal_glops = { |
Steven Whitehouse | ea67eed | 2006-09-05 10:53:09 -0400 | [diff] [blame] | 789 | .go_type = LM_TYPE_JOURNAL, |
Bob Peterson | a72d240 | 2019-06-13 13:28:45 -0500 | [diff] [blame] | 790 | .go_flags = GLOF_NONDISK, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 791 | }; |
| 792 | |
Steven Whitehouse | 64d576b | 2009-02-12 13:31:58 +0000 | [diff] [blame] | 793 | const struct gfs2_glock_operations *gfs2_glops_list[] = { |
| 794 | [LM_TYPE_META] = &gfs2_meta_glops, |
| 795 | [LM_TYPE_INODE] = &gfs2_inode_glops, |
| 796 | [LM_TYPE_RGRP] = &gfs2_rgrp_glops, |
Steven Whitehouse | 64d576b | 2009-02-12 13:31:58 +0000 | [diff] [blame] | 797 | [LM_TYPE_IOPEN] = &gfs2_iopen_glops, |
| 798 | [LM_TYPE_FLOCK] = &gfs2_flock_glops, |
| 799 | [LM_TYPE_NONDISK] = &gfs2_nondisk_glops, |
| 800 | [LM_TYPE_QUOTA] = &gfs2_quota_glops, |
| 801 | [LM_TYPE_JOURNAL] = &gfs2_journal_glops, |
| 802 | }; |
| 803 | |