diff options
author | Dave Chinner <david@fromorbit.com> | 2015-02-23 18:27:28 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-02-23 18:27:28 -0500 |
commit | 4225441a1eec45241efe529d23403d8ca3d1d71b (patch) | |
tree | 12ed2dead95f32531cccebf31d95d67280c6e361 /fs/xfs/libxfs | |
parent | 3cabb836d801c3ad791c2dc6be07ec5819ab0a37 (diff) | |
parent | 964aa8d9e4d36e0e54a88683d14c7d5b9d02aed8 (diff) |
Merge branch 'xfs-generic-sb-counters' into for-next
Conflicts:
fs/xfs/xfs_super.c
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 40 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 62 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_ialloc.c | 6 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.c | 12 |
4 files changed, 27 insertions, 93 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 60cfa90163b8..8ae3775a9b63 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
@@ -2215,9 +2215,8 @@ xfs_bmap_add_extent_delay_real( | |||
2215 | diff = (int)(temp + temp2 - startblockval(PREV.br_startblock) - | 2215 | diff = (int)(temp + temp2 - startblockval(PREV.br_startblock) - |
2216 | (bma->cur ? bma->cur->bc_private.b.allocated : 0)); | 2216 | (bma->cur ? bma->cur->bc_private.b.allocated : 0)); |
2217 | if (diff > 0) { | 2217 | if (diff > 0) { |
2218 | error = xfs_icsb_modify_counters(bma->ip->i_mount, | 2218 | error = xfs_mod_fdblocks(bma->ip->i_mount, |
2219 | XFS_SBS_FDBLOCKS, | 2219 | -((int64_t)diff), false); |
2220 | -((int64_t)diff), 0); | ||
2221 | ASSERT(!error); | 2220 | ASSERT(!error); |
2222 | if (error) | 2221 | if (error) |
2223 | goto done; | 2222 | goto done; |
@@ -2268,9 +2267,8 @@ xfs_bmap_add_extent_delay_real( | |||
2268 | temp += bma->cur->bc_private.b.allocated; | 2267 | temp += bma->cur->bc_private.b.allocated; |
2269 | ASSERT(temp <= da_old); | 2268 | ASSERT(temp <= da_old); |
2270 | if (temp < da_old) | 2269 | if (temp < da_old) |
2271 | xfs_icsb_modify_counters(bma->ip->i_mount, | 2270 | xfs_mod_fdblocks(bma->ip->i_mount, |
2272 | XFS_SBS_FDBLOCKS, | 2271 | (int64_t)(da_old - temp), false); |
2273 | (int64_t)(da_old - temp), 0); | ||
2274 | } | 2272 | } |
2275 | 2273 | ||
2276 | /* clear out the allocated field, done with it now in any case. */ | 2274 | /* clear out the allocated field, done with it now in any case. */ |
@@ -2948,8 +2946,8 @@ xfs_bmap_add_extent_hole_delay( | |||
2948 | } | 2946 | } |
2949 | if (oldlen != newlen) { | 2947 | if (oldlen != newlen) { |
2950 | ASSERT(oldlen > newlen); | 2948 | ASSERT(oldlen > newlen); |
2951 | xfs_icsb_modify_counters(ip->i_mount, XFS_SBS_FDBLOCKS, | 2949 | xfs_mod_fdblocks(ip->i_mount, (int64_t)(oldlen - newlen), |
2952 | (int64_t)(oldlen - newlen), 0); | 2950 | false); |
2953 | /* | 2951 | /* |
2954 | * Nothing to do for disk quota accounting here. | 2952 | * Nothing to do for disk quota accounting here. |
2955 | */ | 2953 | */ |
@@ -4166,18 +4164,15 @@ xfs_bmapi_reserve_delalloc( | |||
4166 | ASSERT(indlen > 0); | 4164 | ASSERT(indlen > 0); |
4167 | 4165 | ||
4168 | if (rt) { | 4166 | if (rt) { |
4169 | error = xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS, | 4167 | error = xfs_mod_frextents(mp, -((int64_t)extsz)); |
4170 | -((int64_t)extsz), 0); | ||
4171 | } else { | 4168 | } else { |
4172 | error = xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS, | 4169 | error = xfs_mod_fdblocks(mp, -((int64_t)alen), false); |
4173 | -((int64_t)alen), 0); | ||
4174 | } | 4170 | } |
4175 | 4171 | ||
4176 | if (error) | 4172 | if (error) |
4177 | goto out_unreserve_quota; | 4173 | goto out_unreserve_quota; |
4178 | 4174 | ||
4179 | error = xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS, | 4175 | error = xfs_mod_fdblocks(mp, -((int64_t)indlen), false); |
4180 | -((int64_t)indlen), 0); | ||
4181 | if (error) | 4176 | if (error) |
4182 | goto out_unreserve_blocks; | 4177 | goto out_unreserve_blocks; |
4183 | 4178 | ||
@@ -4204,9 +4199,9 @@ xfs_bmapi_reserve_delalloc( | |||
4204 | 4199 | ||
4205 | out_unreserve_blocks: | 4200 | out_unreserve_blocks: |
4206 | if (rt) | 4201 | if (rt) |
4207 | xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS, extsz, 0); | 4202 | xfs_mod_frextents(mp, extsz); |
4208 | else | 4203 | else |
4209 | xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS, alen, 0); | 4204 | xfs_mod_fdblocks(mp, alen, false); |
4210 | out_unreserve_quota: | 4205 | out_unreserve_quota: |
4211 | if (XFS_IS_QUOTA_ON(mp)) | 4206 | if (XFS_IS_QUOTA_ON(mp)) |
4212 | xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0, rt ? | 4207 | xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0, rt ? |
@@ -5019,10 +5014,8 @@ xfs_bmap_del_extent( | |||
5019 | * Nothing to do for disk quota accounting here. | 5014 | * Nothing to do for disk quota accounting here. |
5020 | */ | 5015 | */ |
5021 | ASSERT(da_old >= da_new); | 5016 | ASSERT(da_old >= da_new); |
5022 | if (da_old > da_new) { | 5017 | if (da_old > da_new) |
5023 | xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS, | 5018 | xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), false); |
5024 | (int64_t)(da_old - da_new), 0); | ||
5025 | } | ||
5026 | done: | 5019 | done: |
5027 | *logflagsp = flags; | 5020 | *logflagsp = flags; |
5028 | return error; | 5021 | return error; |
@@ -5291,14 +5284,13 @@ xfs_bunmapi( | |||
5291 | 5284 | ||
5292 | rtexts = XFS_FSB_TO_B(mp, del.br_blockcount); | 5285 | rtexts = XFS_FSB_TO_B(mp, del.br_blockcount); |
5293 | do_div(rtexts, mp->m_sb.sb_rextsize); | 5286 | do_div(rtexts, mp->m_sb.sb_rextsize); |
5294 | xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS, | 5287 | xfs_mod_frextents(mp, (int64_t)rtexts); |
5295 | (int64_t)rtexts, 0); | ||
5296 | (void)xfs_trans_reserve_quota_nblks(NULL, | 5288 | (void)xfs_trans_reserve_quota_nblks(NULL, |
5297 | ip, -((long)del.br_blockcount), 0, | 5289 | ip, -((long)del.br_blockcount), 0, |
5298 | XFS_QMOPT_RES_RTBLKS); | 5290 | XFS_QMOPT_RES_RTBLKS); |
5299 | } else { | 5291 | } else { |
5300 | xfs_icsb_modify_counters(mp, XFS_SBS_FDBLOCKS, | 5292 | xfs_mod_fdblocks(mp, (int64_t)del.br_blockcount, |
5301 | (int64_t)del.br_blockcount, 0); | 5293 | false); |
5302 | (void)xfs_trans_reserve_quota_nblks(NULL, | 5294 | (void)xfs_trans_reserve_quota_nblks(NULL, |
5303 | ip, -((long)del.br_blockcount), 0, | 5295 | ip, -((long)del.br_blockcount), 0, |
5304 | XFS_QMOPT_RES_REGBLKS); | 5296 | XFS_QMOPT_RES_REGBLKS); |
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 8eb718979383..4daaa662337b 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
@@ -264,68 +264,6 @@ typedef struct xfs_dsb { | |||
264 | /* must be padded to 64 bit alignment */ | 264 | /* must be padded to 64 bit alignment */ |
265 | } xfs_dsb_t; | 265 | } xfs_dsb_t; |
266 | 266 | ||
267 | /* | ||
268 | * Sequence number values for the fields. | ||
269 | */ | ||
270 | typedef enum { | ||
271 | XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS, | ||
272 | XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO, | ||
273 | XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS, | ||
274 | XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS, | ||
275 | XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE, | ||
276 | XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG, | ||
277 | XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG, | ||
278 | XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT, | ||
279 | XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO, | ||
280 | XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, | ||
281 | XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, | ||
282 | XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, | ||
283 | XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT, | ||
284 | XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT, | ||
285 | XFS_SBS_FEATURES_LOG_INCOMPAT, XFS_SBS_CRC, XFS_SBS_PAD, | ||
286 | XFS_SBS_PQUOTINO, XFS_SBS_LSN, | ||
287 | XFS_SBS_FIELDCOUNT | ||
288 | } xfs_sb_field_t; | ||
289 | |||
290 | /* | ||
291 | * Mask values, defined based on the xfs_sb_field_t values. | ||
292 | * Only define the ones we're using. | ||
293 | */ | ||
294 | #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x) | ||
295 | #define XFS_SB_UUID XFS_SB_MVAL(UUID) | ||
296 | #define XFS_SB_FNAME XFS_SB_MVAL(FNAME) | ||
297 | #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO) | ||
298 | #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO) | ||
299 | #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO) | ||
300 | #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM) | ||
301 | #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO) | ||
302 | #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO) | ||
303 | #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS) | ||
304 | #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) | ||
305 | #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) | ||
306 | #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) | ||
307 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) | ||
308 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) | ||
309 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) | ||
310 | #define XFS_SB_FEATURES2 (XFS_SB_MVAL(FEATURES2) | \ | ||
311 | XFS_SB_MVAL(BAD_FEATURES2)) | ||
312 | #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) | ||
313 | #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) | ||
314 | #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) | ||
315 | #define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT) | ||
316 | #define XFS_SB_CRC XFS_SB_MVAL(CRC) | ||
317 | #define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO) | ||
318 | #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) | ||
319 | #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) | ||
320 | #define XFS_SB_MOD_BITS \ | ||
321 | (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ | ||
322 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ | ||
323 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ | ||
324 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ | ||
325 | XFS_SB_FEATURES_COMPAT | XFS_SB_FEATURES_RO_COMPAT | \ | ||
326 | XFS_SB_FEATURES_INCOMPAT | XFS_SB_FEATURES_LOG_INCOMPAT | \ | ||
327 | XFS_SB_PQUOTINO) | ||
328 | |||
329 | 267 | ||
330 | /* | 268 | /* |
331 | * Misc. Flags - warning - these will be cleared by xfs_repair unless | 269 | * Misc. Flags - warning - these will be cleared by xfs_repair unless |
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index db0444893e96..07349a183a11 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c | |||
@@ -376,7 +376,8 @@ xfs_ialloc_ag_alloc( | |||
376 | */ | 376 | */ |
377 | newlen = args.mp->m_ialloc_inos; | 377 | newlen = args.mp->m_ialloc_inos; |
378 | if (args.mp->m_maxicount && | 378 | if (args.mp->m_maxicount && |
379 | args.mp->m_sb.sb_icount + newlen > args.mp->m_maxicount) | 379 | percpu_counter_read(&args.mp->m_icount) + newlen > |
380 | args.mp->m_maxicount) | ||
380 | return -ENOSPC; | 381 | return -ENOSPC; |
381 | args.minlen = args.maxlen = args.mp->m_ialloc_blks; | 382 | args.minlen = args.maxlen = args.mp->m_ialloc_blks; |
382 | /* | 383 | /* |
@@ -1340,7 +1341,8 @@ xfs_dialloc( | |||
1340 | * inode. | 1341 | * inode. |
1341 | */ | 1342 | */ |
1342 | if (mp->m_maxicount && | 1343 | if (mp->m_maxicount && |
1343 | mp->m_sb.sb_icount + mp->m_ialloc_inos > mp->m_maxicount) { | 1344 | percpu_counter_read(&mp->m_icount) + mp->m_ialloc_inos > |
1345 | mp->m_maxicount) { | ||
1344 | noroom = 1; | 1346 | noroom = 1; |
1345 | okalloc = 0; | 1347 | okalloc = 0; |
1346 | } | 1348 | } |
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index f3ea02bf893e..dc4bfc5d88fc 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c | |||
@@ -735,17 +735,15 @@ xfs_initialize_perag_data( | |||
735 | btree += pag->pagf_btreeblks; | 735 | btree += pag->pagf_btreeblks; |
736 | xfs_perag_put(pag); | 736 | xfs_perag_put(pag); |
737 | } | 737 | } |
738 | /* | 738 | |
739 | * Overwrite incore superblock counters with just-read data | 739 | /* Overwrite incore superblock counters with just-read data */ |
740 | */ | ||
741 | spin_lock(&mp->m_sb_lock); | 740 | spin_lock(&mp->m_sb_lock); |
742 | sbp->sb_ifree = ifree; | 741 | sbp->sb_ifree = ifree; |
743 | sbp->sb_icount = ialloc; | 742 | sbp->sb_icount = ialloc; |
744 | sbp->sb_fdblocks = bfree + bfreelst + btree; | 743 | sbp->sb_fdblocks = bfree + bfreelst + btree; |
745 | spin_unlock(&mp->m_sb_lock); | 744 | spin_unlock(&mp->m_sb_lock); |
746 | 745 | ||
747 | /* Fixup the per-cpu counters as well. */ | 746 | xfs_reinit_percpu_counters(mp); |
748 | xfs_icsb_reinit_counters(mp); | ||
749 | 747 | ||
750 | return 0; | 748 | return 0; |
751 | } | 749 | } |
@@ -763,6 +761,10 @@ xfs_log_sb( | |||
763 | struct xfs_mount *mp = tp->t_mountp; | 761 | struct xfs_mount *mp = tp->t_mountp; |
764 | struct xfs_buf *bp = xfs_trans_getsb(tp, mp, 0); | 762 | struct xfs_buf *bp = xfs_trans_getsb(tp, mp, 0); |
765 | 763 | ||
764 | mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount); | ||
765 | mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree); | ||
766 | mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); | ||
767 | |||
766 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); | 768 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); |
767 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); | 769 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); |
768 | xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb)); | 770 | xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb)); |