diff options
author | Dave Chinner <david@fromorbit.com> | 2015-02-23 05:22:03 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-02-23 05:22:03 -0500 |
commit | 0d485ada404b3614b045e574bec26aaf5d9b3c5b (patch) | |
tree | b08812daee1eed9e8be59e6c12bf0eeef5b6f7cf /fs/xfs/libxfs/xfs_sb.c | |
parent | e88b64ea1f3da64dbb52636377be295c90367377 (diff) |
xfs: use generic percpu counters for free block counter
XFS has hand-rolled per-cpu counters for the superblock since before
there was any generic implementation. The free block counter is
special in that it is used for ENOSPC detection outside transaction
contexts for for delayed allocation. This means that the counter
needs to be accurate at zero. The current per-cpu counter code jumps
through lots of hoops to ensure we never run past zero, but we don't
need to make all those jumps with the generic counter
implementation.
The generic counter implementation allows us to pass a "batch"
threshold at which the addition/subtraction to the counter value
will be folded back into global value under lock. We can use this
feature to reduce the batch size as we approach 0 in a very similar
manner to the existing counters and their rebalance algorithm. If we
use a batch size of 1 as we approach 0, then every addition and
subtraction will be done against the global value and hence allow
accurate detection of zero threshold crossing.
Hence we can replace the handrolled, accurate-at-zero counters with
generic percpu counters.
Note: this removes just enough of the icsb infrastructure to compile
without warnings. The rest will go in subsequent commits.
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/libxfs/xfs_sb.c')
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index b66aeab99cfb..31a3e972f86f 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c | |||
@@ -773,6 +773,7 @@ xfs_log_sb( | |||
773 | 773 | ||
774 | mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount); | 774 | mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount); |
775 | mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree); | 775 | mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree); |
776 | mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); | ||
776 | 777 | ||
777 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); | 778 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); |
778 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); | 779 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); |