Skip to contentSkip to conversation

gfs2: No quotas for meta inodes

PATCH New Andreas Gruenbacher 1 participant 1 message Aug 27 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: No quotas for meta inodes

Inodes on the meta filesystem (mount -o meta) can never have quotas, so skip them entirely in the quota code. This avoids allocating ip->i_qadata unnecessarily.

Without this fix, unlinking meta inodes like "statfs" on the meta filesystem will result in a NULL pointer dereference at unmount time:

gfs2_evict_inode() -> gfs2_dinode_dealloc() -> gfs2_quota_hold()

    -> qdsb_get() -> slot_get() -> find_first_zero_bit(sd_quota_bitmap)

Unlinking inodes on the meta filesystem isn't a useful operation, but it still shouldn't cause the kernel to misbehave.

---
 fs/gfs2/quota.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/gfs2/quota.c +3 -1
index b62431724eea..dbfc21693dd5 100644
@@ -562,6 +562,8 @@ int gfs2_qa_get(struct gfs2_inode *ip)
 
 	if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
 		return 0;
+	if (ip->i_diskflags & GFS2_DIF_SYSTEM)
+		return 0;
 
 	spin_lock(&inode->i_lock);
 	if (ip->i_qadata == NULL) {
@@ -605,7 +607,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
 		return 0;
 
 	error = gfs2_qa_get(ip);
-	if (error)
+	if (error || !ip->i_qadata)
 		return error;
 
 	qd = ip->i_qadata->qa_qd;
Signature · 1 line
2.55.0