]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: make qi_dquots a 64-bit value
authorChristoph Hellwig <hch@lst.de>
Mon, 10 Nov 2025 13:22:54 +0000 (14:22 +0100)
committerCarlos Maiolino <cem@kernel.org>
Tue, 11 Nov 2025 10:45:57 +0000 (11:45 +0100)
qi_dquots counts all quotas in the file system, which can be up to
3 * UINT_MAX and overflow a 32-bit counter, but can't be negative.
Make qi_dquots a uint64_t, and saturate the value to UINT_MAX for
userspace reporting.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_qm.h
fs/xfs/xfs_quotaops.c

index 35b64bc3a7a8671e17c2bd89d82e82164e0cbb05..e88ed6ad0e65d446f9054e844729b7d1dd69b3eb 100644 (file)
@@ -57,7 +57,7 @@ struct xfs_quotainfo {
        struct xfs_inode        *qi_pquotaip;   /* project quota inode */
        struct xfs_inode        *qi_dirip;      /* quota metadir */
        struct list_lru         qi_lru;
-       int                     qi_dquots;
+       uint64_t                qi_dquots;
        struct mutex            qi_quotaofflock;/* to serialize quotaoff */
        xfs_filblks_t           qi_dqchunklen;  /* # BBs in a chunk of dqs */
        uint                    qi_dqperchunk;  /* # ondisk dq in above chunk */
index 4c7f7ce4fd2f4238e1ed14012ec5cacc01edcfd1..94fbe3d99ec77645e4a35cd579f209cb7ed49ec2 100644 (file)
@@ -65,7 +65,7 @@ xfs_fs_get_quota_state(
        memset(state, 0, sizeof(*state));
        if (!XFS_IS_QUOTA_ON(mp))
                return 0;
-       state->s_incoredqs = q->qi_dquots;
+       state->s_incoredqs = min_t(uint64_t, q->qi_dquots, UINT_MAX);
        if (XFS_IS_UQUOTA_ON(mp))
                state->s_state[USRQUOTA].flags |= QCI_ACCT_ENABLED;
        if (XFS_IS_UQUOTA_ENFORCED(mp))