From 5bc95fac7d71f2f7a4968cbf484dfda62910176a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 18 Aug 2021 11:29:38 -0700 Subject: [PATCH] Add scoutfs_unmounting() Add a quick helper that can be used to avoid doing work if we know that we're already shutting down. This can be a single coarser indicator than adding functions to each subsystem to track that we're shutting down. Signed-off-by: Zach Brown --- kmod/src/super.c | 7 ++++++- kmod/src/super.h | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/kmod/src/super.c b/kmod/src/super.c index eccc6023..a54e8cf9 100644 --- a/kmod/src/super.c +++ b/kmod/src/super.c @@ -661,7 +661,12 @@ static struct dentry *scoutfs_mount(struct file_system_type *fs_type, int flags, */ static void scoutfs_kill_sb(struct super_block *sb) { - trace_scoutfs_kill_sb(sb); + struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); + + if (sbi) { + sbi->unmounting = true; + smp_wmb(); + } if (SCOUTFS_HAS_SBI(sb)) scoutfs_lock_unmount_begin(sb); diff --git a/kmod/src/super.h b/kmod/src/super.h index e7733856..92106b63 100644 --- a/kmod/src/super.h +++ b/kmod/src/super.h @@ -89,6 +89,7 @@ struct scoutfs_sb_info { struct dentry *debug_root; bool forced_unmount; + bool unmounting; unsigned long corruption_messages_once[SC_NR_LONGS]; }; @@ -117,6 +118,19 @@ static inline bool scoutfs_forcing_unmount(struct super_block *sb) return sbi->forced_unmount; } +/* + * True if we're shutting down the system and can be used as a coarse + * indicator that we can avoid doing some work that no longer makes + * sense. + */ +static inline bool scoutfs_unmounting(struct super_block *sb) +{ + struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); + + smp_rmb(); + return !sbi || sbi->unmounting; +} + /* * A small string embedded in messages that's used to identify a * specific mount. It's the three most significant bytes of the fsid