]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: don't count metadata directory files to quota
authorDarrick J. Wong <djwong@kernel.org>
Mon, 4 Nov 2024 04:18:55 +0000 (20:18 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 5 Nov 2024 21:38:32 +0000 (13:38 -0800)
Files in the metadata directory tree are internal to the filesystem.
Don't count the inodes or the blocks they use in the root dquot because
users do not need to know about their resource usage.  This will also
quiet down complaints about dquot usage not matching du output.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_dquot.c
fs/xfs/xfs_qm.c
fs/xfs/xfs_quota.h
fs/xfs/xfs_trans_dquot.c

index c1b211c260a9d5d5f3dd87fc22565eaf43772712..3bf47458c517afd3ddf0778af489ae80555124b3 100644 (file)
@@ -983,6 +983,7 @@ xfs_qm_dqget_inode(
 
        xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
        ASSERT(xfs_inode_dquot(ip, type) == NULL);
+       ASSERT(!xfs_is_metadir_inode(ip));
 
        id = xfs_qm_id_for_quotatype(ip, type);
 
index d0674d84af3ec5670174e8a2479dcde9cbee3981..ec983cca9adaed6f2f00c502701af4a33dee0a58 100644 (file)
@@ -304,6 +304,8 @@ xfs_qm_need_dqattach(
                return false;
        if (xfs_is_quota_inode(&mp->m_sb, ip->i_ino))
                return false;
+       if (xfs_is_metadir_inode(ip))
+               return false;
        return true;
 }
 
@@ -326,6 +328,7 @@ xfs_qm_dqattach_locked(
                return 0;
 
        xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
+       ASSERT(!xfs_is_metadir_inode(ip));
 
        if (XFS_IS_UQUOTA_ON(mp) && !ip->i_udquot) {
                error = xfs_qm_dqattach_one(ip, XFS_DQTYPE_USER,
@@ -1204,6 +1207,10 @@ xfs_qm_dqusage_adjust(
                }
        }
 
+       /* Metadata directory files are not accounted to user-visible quotas. */
+       if (xfs_is_metadir_inode(ip))
+               goto error0;
+
        ASSERT(ip->i_delayed_blks == 0);
 
        if (XFS_IS_REALTIME_INODE(ip)) {
@@ -1754,6 +1761,8 @@ xfs_qm_vop_dqalloc(
        if (!XFS_IS_QUOTA_ON(mp))
                return 0;
 
+       ASSERT(!xfs_is_metadir_inode(ip));
+
        lockflags = XFS_ILOCK_EXCL;
        xfs_ilock(ip, lockflags);
 
@@ -1883,6 +1892,7 @@ xfs_qm_vop_chown(
 
        xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
        ASSERT(XFS_IS_QUOTA_ON(ip->i_mount));
+       ASSERT(!xfs_is_metadir_inode(ip));
 
        /* old dquot */
        prevdq = *IO_olddq;
@@ -1970,6 +1980,7 @@ xfs_qm_vop_create_dqattach(
                return;
 
        xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
+       ASSERT(!xfs_is_metadir_inode(ip));
 
        if (udqp && XFS_IS_UQUOTA_ON(mp)) {
                ASSERT(ip->i_udquot == NULL);
index 23d71a55bbc0062f2fbf6472f67618b60d1e2196..645761997bf2d9548bf841c84efacd83d23b8703 100644 (file)
@@ -29,6 +29,11 @@ struct xfs_buf;
         (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \
         (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL))
 
+#define XFS_IS_DQDETACHED(ip) \
+       ((ip)->i_udquot == NULL && \
+        (ip)->i_gdquot == NULL && \
+        (ip)->i_pdquot == NULL)
+
 #define XFS_QM_NEED_QUOTACHECK(mp) \
        ((XFS_IS_UQUOTA_ON(mp) && \
                (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
index b368e13424c4f474962c9551a2f5dc561b9cd5e1..ca7df018290e0edff19be69bdd9257eef02d69da 100644 (file)
@@ -156,6 +156,8 @@ xfs_trans_mod_ino_dquot(
        unsigned int                    field,
        int64_t                         delta)
 {
+       ASSERT(!xfs_is_metadir_inode(ip) || XFS_IS_DQDETACHED(ip));
+
        xfs_trans_mod_dquot(tp, dqp, field, delta);
 
        if (xfs_hooks_switched_on(&xfs_dqtrx_hooks_switch)) {
@@ -247,6 +249,8 @@ xfs_trans_mod_dquot_byino(
            xfs_is_quota_inode(&mp->m_sb, ip->i_ino))
                return;
 
+       ASSERT(!xfs_is_metadir_inode(ip) || XFS_IS_DQDETACHED(ip));
+
        if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot)
                xfs_trans_mod_ino_dquot(tp, ip, ip->i_udquot, field, delta);
        if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot)
@@ -962,6 +966,8 @@ xfs_trans_reserve_quota_nblks(
 
        if (!XFS_IS_QUOTA_ON(mp))
                return 0;
+       if (xfs_is_metadir_inode(ip))
+               return 0;
 
        ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino));
        xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);