diff options
author | Dave Chinner <dchinner@redhat.com> | 2015-02-23 05:19:53 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-02-23 05:19:53 -0500 |
commit | e88b64ea1f3da64dbb52636377be295c90367377 (patch) | |
tree | 0031d3ed6f296981fdcd2b9f4cf3cebc8b557ab8 /fs/xfs/xfs_super.c | |
parent | 501ab32387533924b211cacff36d19296414ec0b (diff) |
xfs: use generic percpu counters for free inode counter
XFS has hand-rolled per-cpu counters for the superblock since before
there was any generic implementation. The free inode counter is not
used for any limit enforcement - the per-AG free inode counters are
used during allocation to determine if there are inode available for
allocation.
Hence we don't need any of the complexity of the hand-rolled
counters and we can simply replace them with generic per-cpu
counters similar to the inode counter.
This version introduces a xfs_mod_ifree() helper function from
Christoph Hellwig.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_super.c')
-rw-r--r-- | fs/xfs/xfs_super.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 0aa4428bfa31..049147776ee1 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -1086,6 +1086,7 @@ xfs_fs_statfs( | |||
1086 | struct xfs_inode *ip = XFS_I(dentry->d_inode); | 1086 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
1087 | __uint64_t fakeinos, id; | 1087 | __uint64_t fakeinos, id; |
1088 | __uint64_t icount; | 1088 | __uint64_t icount; |
1089 | __uint64_t ifree; | ||
1089 | xfs_extlen_t lsize; | 1090 | xfs_extlen_t lsize; |
1090 | __int64_t ffree; | 1091 | __int64_t ffree; |
1091 | 1092 | ||
@@ -1098,6 +1099,7 @@ xfs_fs_statfs( | |||
1098 | 1099 | ||
1099 | xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT); | 1100 | xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT); |
1100 | icount = percpu_counter_sum(&mp->m_icount); | 1101 | icount = percpu_counter_sum(&mp->m_icount); |
1102 | ifree = percpu_counter_sum(&mp->m_ifree); | ||
1101 | 1103 | ||
1102 | spin_lock(&mp->m_sb_lock); | 1104 | spin_lock(&mp->m_sb_lock); |
1103 | statp->f_bsize = sbp->sb_blocksize; | 1105 | statp->f_bsize = sbp->sb_blocksize; |
@@ -1118,7 +1120,7 @@ xfs_fs_statfs( | |||
1118 | sbp->sb_icount); | 1120 | sbp->sb_icount); |
1119 | 1121 | ||
1120 | /* make sure statp->f_ffree does not underflow */ | 1122 | /* make sure statp->f_ffree does not underflow */ |
1121 | ffree = statp->f_files - (icount - sbp->sb_ifree); | 1123 | ffree = statp->f_files - (icount - ifree); |
1122 | statp->f_ffree = max_t(__int64_t, ffree, 0); | 1124 | statp->f_ffree = max_t(__int64_t, ffree, 0); |
1123 | 1125 | ||
1124 | spin_unlock(&mp->m_sb_lock); | 1126 | spin_unlock(&mp->m_sb_lock); |