]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: don't take m_sb_lock in xfs_fs_statfs
authorChristoph Hellwig <hch@lst.de>
Mon, 13 Jan 2025 04:32:58 +0000 (05:32 +0100)
committerCarlos Maiolino <cem@kernel.org>
Mon, 13 Jan 2025 13:56:24 +0000 (14:56 +0100)
The only non-constant value read under m_sb_lock in xfs_fs_statfs is
sb_dblocks, and it could become stale right after dropping the lock
anyway.  Remove the thus pointless lock section.

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_super.c

index 7c3f996cd39e8177938e06ca37e3a3d29b3635c4..20cc00b992a6ef974359bf1b8b630860dadfdb7d 100644 (file)
@@ -850,11 +850,13 @@ xfs_fs_statfs(
        ifree = percpu_counter_sum(&mp->m_ifree);
        fdblocks = percpu_counter_sum(&mp->m_fdblocks);
 
-       spin_lock(&mp->m_sb_lock);
        statp->f_bsize = sbp->sb_blocksize;
        lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
+       /*
+        * sb_dblocks can change during growfs, but nothing cares about reporting
+        * the old or new value during growfs.
+        */
        statp->f_blocks = sbp->sb_dblocks - lsize;
-       spin_unlock(&mp->m_sb_lock);
 
        /* make sure statp->f_bfree does not underflow */
        statp->f_bfree = max_t(int64_t, 0,