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