summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_mount.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2015-02-23 21:22:54 +1100
committerDave Chinner <david@fromorbit.com>2015-02-23 21:22:54 +1100
commitbab98bbe6e1e38bf2fa5018a195608553095f51b (patch)
tree7d22e47227132f29ad6f9d7e116d1e4eabfca04f /fs/xfs/xfs_mount.c
parent5681ca40064fdb3efe477a604d690ab0425708b3 (diff)
downloadlwn-bab98bbe6e1e38bf2fa5018a195608553095f51b.tar.gz
lwn-bab98bbe6e1e38bf2fa5018a195608553095f51b.zip
xfs: introduce xfs_mod_frextents
Add a new helper to modify the incore counter of free realtime extents. This matches the helpers used for inode and data block counters, and removes a significant users of the xfs_mod_incore_sb() interface. Based on a patch originally 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_mount.c')
-rw-r--r--fs/xfs/xfs_mount.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 05b392e35e35..df4c32fdc706 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1198,6 +1198,24 @@ fdblocks_enospc:
return -ENOSPC;
}
+int
+xfs_mod_frextents(
+ struct xfs_mount *mp,
+ int64_t delta)
+{
+ int64_t lcounter;
+ int ret = 0;
+
+ spin_lock(&mp->m_sb_lock);
+ lcounter = mp->m_sb.sb_frextents + delta;
+ if (lcounter < 0)
+ ret = -ENOSPC;
+ else
+ mp->m_sb.sb_frextents = lcounter;
+ spin_unlock(&mp->m_sb_lock);
+ return ret;
+}
+
/*
* xfs_mod_incore_sb_unlocked() is a utility routine commonly used to apply
* a delta to a specified field in the in-core superblock. Simply
@@ -1227,16 +1245,9 @@ xfs_mod_incore_sb_unlocked(
case XFS_SBS_ICOUNT:
case XFS_SBS_IFREE:
case XFS_SBS_FDBLOCKS:
+ case XFS_SBS_FREXTENTS:
ASSERT(0);
return -EINVAL;
- case XFS_SBS_FREXTENTS:
- lcounter = (long long)mp->m_sb.sb_frextents;
- lcounter += delta;
- if (lcounter < 0) {
- return -ENOSPC;
- }
- mp->m_sb.sb_frextents = lcounter;
- return 0;
case XFS_SBS_DBLOCKS:
lcounter = (long long)mp->m_sb.sb_dblocks;
lcounter += delta;