summaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2022-12-06 17:27:14 +0100
committerAndreas Gruenbacher <agruenba@redhat.com>2023-01-31 22:40:24 +0100
commit6b388abc33998330c6fe55a712d61be888fd7b67 (patch)
tree71d05d2b7c57fd4b3bd8d6a7eb10d35b8f9795e2 /fs/gfs2
parent6c0246a96e08cd1b5036c34c52de99bd9dffbb48 (diff)
downloadlinux-stable-6b388abc33998330c6fe55a712d61be888fd7b67.tar.gz
linux-stable-6b388abc33998330c6fe55a712d61be888fd7b67.tar.bz2
linux-stable-6b388abc33998330c6fe55a712d61be888fd7b67.zip
gfs2: Flush delete work before shrinking inode cache
In gfs2_kill_sb(), flush the delete work queue after setting the SDF_DEACTIVATING flag. This ensures that no new inodes will be instantiated anymore, and the inode cache will be empty after the following kill_block_super() -> generic_shutdown_super() -> evict_inodes() call. With that, function gfs2_make_fs_ro() now calls gfs2_flush_delete_work() after the workqueue has been destroyed. Skip that by checking for the presence of the SDF_DEACTIVATING flag. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/ops_fstype.c9
-rw-r--r--fs/gfs2/super.c6
2 files changed, 12 insertions, 3 deletions
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index c9fef0678320..9db376950014 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1743,7 +1743,16 @@ static void gfs2_kill_sb(struct super_block *sb)
sdp->sd_root_dir = NULL;
sdp->sd_master_dir = NULL;
shrink_dcache_sb(sb);
+
+ /*
+ * Flush and then drain the delete workqueue here (via
+ * destroy_workqueue()) to ensure that any delete work that
+ * may be running will also see the SDF_DEACTIVATING flag.
+ */
set_bit(SDF_DEACTIVATING, &sdp->sd_flags);
+ gfs2_flush_delete_work(sdp);
+ destroy_workqueue(sdp->sd_delete_wq);
+
kill_block_super(sb);
}
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 7b0bfe41b5cc..63512bb9d6f0 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -529,7 +529,9 @@ void gfs2_make_fs_ro(struct gfs2_sbd *sdp)
{
int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
- gfs2_flush_delete_work(sdp);
+ if (!test_bit(SDF_DEACTIVATING, &sdp->sd_flags))
+ gfs2_flush_delete_work(sdp);
+
if (!log_write_allowed && current == sdp->sd_quotad_process)
fs_warn(sdp, "The quotad daemon is withdrawing.\n");
else if (sdp->sd_quotad_process)
@@ -630,8 +632,6 @@ restart:
/* Unmount the locking protocol */
gfs2_lm_unmount(sdp);
- destroy_workqueue(sdp->sd_delete_wq);
-
/* At this point, we're through participating in the lockspace */
gfs2_sys_fs_del(sdp);
free_sbd(sdp);