[PATCH v3 3/4] gfs2: protect quota sync sysfs callback

From: Jiacheng Xu

Date: Sun Sep 20 2026 - 04:32:34 EST


The quota_sync sysfs callback can run while quota cleanup is releasing
the quota bitmap and internal quota inodes during mount rollback or
unmount.

Hold s_umount for reading while synchronizing quota data and reject
requests before the superblock is active. Use trylock semantics so the
callback cannot deadlock with the write-side teardown path.

Signed-off-by: Jiacheng Xu <stitch@xxxxxxxxxx>
---
fs/gfs2/sys.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index fd6e8e34651d..c5868354073a 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -254,6 +254,7 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
size_t len)
{
+ struct super_block *sb = sdp->sd_vfs;
int error, val;

if (!capable(CAP_SYS_ADMIN))
@@ -266,7 +267,12 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
if (val != 1)
return -EINVAL;

- gfs2_quota_sync(sdp->sd_vfs, 0);
+ if (!super_trylock_shared_active(sb))
+ return -EAGAIN;
+
+ gfs2_quota_sync(sb, 0);
+
+ super_unlock_active(sb);
return len;
}

--
2.51.0