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