diff options
author | George Wang <xuw2015@gmail.com> | 2015-05-28 17:39:34 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-05-28 17:39:34 -0400 |
commit | 74f9ce1cf2830b94e189f4e99678dbf19aa3bc90 (patch) | |
tree | fda31de04c0e47f9ddfe5b9ef4d0a17106233491 /fs | |
parent | 5ebe6afaf0057ac3eaeb98defd5456894b446d22 (diff) |
xfs: use percpu_counter_read_positive for mp->m_icount
Function percpu_counter_read just return the current counter, which can be
negative. This will cause the checking of "allocated inode
counts <= m_maxicount" false positive. Use percpu_counter_read_positive can
solve this problem, and be consistent with the purpose to introduce percpu
mechanism to xfs.
Signed-off-by: George Wang <xuw2015@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/libxfs/xfs_ialloc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 07349a183a11..1c9e75521250 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c | |||
@@ -376,7 +376,7 @@ 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 | percpu_counter_read(&args.mp->m_icount) + newlen > | 379 | percpu_counter_read_positive(&args.mp->m_icount) + newlen > |
380 | args.mp->m_maxicount) | 380 | args.mp->m_maxicount) |
381 | return -ENOSPC; | 381 | return -ENOSPC; |
382 | args.minlen = args.maxlen = args.mp->m_ialloc_blks; | 382 | args.minlen = args.maxlen = args.mp->m_ialloc_blks; |
@@ -1339,10 +1339,13 @@ xfs_dialloc( | |||
1339 | * If we have already hit the ceiling of inode blocks then clear | 1339 | * If we have already hit the ceiling of inode blocks then clear |
1340 | * okalloc so we scan all available agi structures for a free | 1340 | * okalloc so we scan all available agi structures for a free |
1341 | * inode. | 1341 | * inode. |
1342 | * | ||
1343 | * Read rough value of mp->m_icount by percpu_counter_read_positive, | ||
1344 | * which will sacrifice the preciseness but improve the performance. | ||
1342 | */ | 1345 | */ |
1343 | if (mp->m_maxicount && | 1346 | if (mp->m_maxicount && |
1344 | percpu_counter_read(&mp->m_icount) + mp->m_ialloc_inos > | 1347 | percpu_counter_read_positive(&mp->m_icount) + mp->m_ialloc_inos |
1345 | mp->m_maxicount) { | 1348 | > mp->m_maxicount) { |
1346 | noroom = 1; | 1349 | noroom = 1; |
1347 | okalloc = 0; | 1350 | okalloc = 0; |
1348 | } | 1351 | } |