Message ID | 20241211085636.1380516-6-hch@lst.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/43] xfs: constify feature checks | expand |
On Wed, Dec 11, 2024 at 09:54:30AM +0100, Christoph Hellwig wrote: > 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. Is there a stronger reason later for removing the critical section? Do we lose much by leaving the protection in place? --D > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > fs/xfs/xfs_super.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c > index 0fa7b7cc75c1..bfa8cc927009 100644 > --- a/fs/xfs/xfs_super.c > +++ b/fs/xfs/xfs_super.c > @@ -850,11 +850,9 @@ 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; > 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, > -- > 2.45.2 > >
On Thu, Dec 12, 2024 at 01:42:06PM -0800, Darrick J. Wong wrote: > On Wed, Dec 11, 2024 at 09:54:30AM +0100, Christoph Hellwig wrote: > > 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. > > Is there a stronger reason later for removing the critical section? > Do we lose much by leaving the protection in place? It makes a completely mess of xfs_fs_statfs, and as stated in the commit message about it's not actually useful at all. I also don't think taking a global lock from a non-privileged operation is an old that good idea to start with if we can avoid it.
On Fri, Dec 13, 2024 at 06:06:15AM +0100, Christoph Hellwig wrote: > On Thu, Dec 12, 2024 at 01:42:06PM -0800, Darrick J. Wong wrote: > > On Wed, Dec 11, 2024 at 09:54:30AM +0100, Christoph Hellwig wrote: > > > 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. > > > > Is there a stronger reason later for removing the critical section? > > Do we lose much by leaving the protection in place? > > It makes a completely mess of xfs_fs_statfs, and as stated in the > commit message about it's not actually useful at all. I also don't > think taking a global lock from a non-privileged operation is an > old that good idea to start with if we can avoid it. Ok, I'm convinced. But perhaps you could leave a comment that we don't care if the accesses are torn, to try to head off the inevitable kcsan/ dept/whatever patches? Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 0fa7b7cc75c1..bfa8cc927009 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -850,11 +850,9 @@ 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; 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,
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> --- fs/xfs/xfs_super.c | 2 -- 1 file changed, 2 deletions(-)