aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_mount.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2015-05-28 17:39:34 -0400
committerDave Chinner <david@fromorbit.com>2015-05-28 17:39:34 -0400
commit8c1903d3081ab7c416f1bbc7905f37a265d5e2e9 (patch)
tree3a496915f91a7b8a671ef0ce64666737f4f9ab56 /fs/xfs/xfs_mount.c
parent80188b0d77d7426b494af739ac129e0e684acb84 (diff)
xfs: inode and free block counters need to use __percpu_counter_compare
Because the counters use a custom batch size, the comparison functions need to be aware of that batch size otherwise the comparison does not work correctly. This leads to ASSERT failures on generic/027 like this: XFS: Assertion failed: 0, file: fs/xfs/xfs_mount.c, line: 1099 ------------[ cut here ]------------ .... Call Trace: [<ffffffff81522a39>] xfs_mod_icount+0x99/0xc0 [<ffffffff815285cb>] xfs_trans_unreserve_and_mod_sb+0x28b/0x5b0 [<ffffffff8152f941>] xfs_log_commit_cil+0x321/0x580 [<ffffffff81528e17>] xfs_trans_commit+0xb7/0x260 [<ffffffff81503d4d>] xfs_bmap_finish+0xcd/0x1b0 [<ffffffff8151da41>] xfs_inactive_ifree+0x1e1/0x250 [<ffffffff8151dbe0>] xfs_inactive+0x130/0x200 [<ffffffff81523a21>] xfs_fs_evict_inode+0x91/0xf0 [<ffffffff811f3958>] evict+0xb8/0x190 [<ffffffff811f433b>] iput+0x18b/0x1f0 [<ffffffff811e8853>] do_unlinkat+0x1f3/0x320 [<ffffffff811d548a>] ? filp_close+0x5a/0x80 [<ffffffff811e999b>] SyS_unlinkat+0x1b/0x40 [<ffffffff81e0892e>] system_call_fastpath+0x12/0x71 This is a regression introduced by commit 501ab32 ("xfs: use generic percpu counters for inode counter"). This patch fixes the same problem for both the inode counter and the free block counter in the superblocks. 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.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 2ce7ee3b4ec1..6f23fbdfb365 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1084,14 +1084,18 @@ xfs_log_sbcount(xfs_mount_t *mp)
1084 return xfs_sync_sb(mp, true); 1084 return xfs_sync_sb(mp, true);
1085} 1085}
1086 1086
1087/*
1088 * Deltas for the inode count are +/-64, hence we use a large batch size
1089 * of 128 so we don't need to take the counter lock on every update.
1090 */
1091#define XFS_ICOUNT_BATCH 128
1087int 1092int
1088xfs_mod_icount( 1093xfs_mod_icount(
1089 struct xfs_mount *mp, 1094 struct xfs_mount *mp,
1090 int64_t delta) 1095 int64_t delta)
1091{ 1096{
1092 /* deltas are +/-64, hence the large batch size of 128. */ 1097 __percpu_counter_add(&mp->m_icount, delta, XFS_ICOUNT_BATCH);
1093 __percpu_counter_add(&mp->m_icount, delta, 128); 1098 if (__percpu_counter_compare(&mp->m_icount, 0, XFS_ICOUNT_BATCH) < 0) {
1094 if (percpu_counter_compare(&mp->m_icount, 0) < 0) {
1095 ASSERT(0); 1099 ASSERT(0);
1096 percpu_counter_add(&mp->m_icount, -delta); 1100 percpu_counter_add(&mp->m_icount, -delta);
1097 return -EINVAL; 1101 return -EINVAL;
@@ -1113,6 +1117,14 @@ xfs_mod_ifree(
1113 return 0; 1117 return 0;
1114} 1118}
1115 1119
1120/*
1121 * Deltas for the block count can vary from 1 to very large, but lock contention
1122 * only occurs on frequent small block count updates such as in the delayed
1123 * allocation path for buffered writes (page a time updates). Hence we set
1124 * a large batch count (1024) to minimise global counter updates except when
1125 * we get near to ENOSPC and we have to be very accurate with our updates.
1126 */
1127#define XFS_FDBLOCKS_BATCH 1024
1116int 1128int
1117xfs_mod_fdblocks( 1129xfs_mod_fdblocks(
1118 struct xfs_mount *mp, 1130 struct xfs_mount *mp,
@@ -1151,25 +1163,19 @@ xfs_mod_fdblocks(
1151 * Taking blocks away, need to be more accurate the closer we 1163 * Taking blocks away, need to be more accurate the closer we
1152 * are to zero. 1164 * are to zero.
1153 * 1165 *
1154 * batch size is set to a maximum of 1024 blocks - if we are
1155 * allocating of freeing extents larger than this then we aren't
1156 * going to be hammering the counter lock so a lock per update
1157 * is not a problem.
1158 *
1159 * If the counter has a value of less than 2 * max batch size, 1166 * If the counter has a value of less than 2 * max batch size,
1160 * then make everything serialise as we are real close to 1167 * then make everything serialise as we are real close to
1161 * ENOSPC. 1168 * ENOSPC.
1162 */ 1169 */
1163#define __BATCH 1024 1170 if (__percpu_counter_compare(&mp->m_fdblocks, 2 * XFS_FDBLOCKS_BATCH,
1164 if (percpu_counter_compare(&mp->m_fdblocks, 2 * __BATCH) < 0) 1171 XFS_FDBLOCKS_BATCH) < 0)
1165 batch = 1; 1172 batch = 1;
1166 else 1173 else
1167 batch = __BATCH; 1174 batch = XFS_FDBLOCKS_BATCH;
1168#undef __BATCH
1169 1175
1170 __percpu_counter_add(&mp->m_fdblocks, delta, batch); 1176 __percpu_counter_add(&mp->m_fdblocks, delta, batch);
1171 if (percpu_counter_compare(&mp->m_fdblocks, 1177 if (__percpu_counter_compare(&mp->m_fdblocks, XFS_ALLOC_SET_ASIDE(mp),
1172 XFS_ALLOC_SET_ASIDE(mp)) >= 0) { 1178 XFS_FDBLOCKS_BATCH) >= 0) {
1173 /* we had space! */ 1179 /* we had space! */
1174 return 0; 1180 return 0;
1175 } 1181 }