mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 13:41:30 +00:00
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>
This commit is contained in:
parent
5ebe6afaf0
commit
74f9ce1cf2
1 changed files with 6 additions and 3 deletions
|
@ -376,7 +376,7 @@ xfs_ialloc_ag_alloc(
|
||||||
*/
|
*/
|
||||||
newlen = args.mp->m_ialloc_inos;
|
newlen = args.mp->m_ialloc_inos;
|
||||||
if (args.mp->m_maxicount &&
|
if (args.mp->m_maxicount &&
|
||||||
percpu_counter_read(&args.mp->m_icount) + newlen >
|
percpu_counter_read_positive(&args.mp->m_icount) + newlen >
|
||||||
args.mp->m_maxicount)
|
args.mp->m_maxicount)
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
args.minlen = args.maxlen = args.mp->m_ialloc_blks;
|
args.minlen = args.maxlen = args.mp->m_ialloc_blks;
|
||||||
|
@ -1339,10 +1339,13 @@ xfs_dialloc(
|
||||||
* If we have already hit the ceiling of inode blocks then clear
|
* If we have already hit the ceiling of inode blocks then clear
|
||||||
* okalloc so we scan all available agi structures for a free
|
* okalloc so we scan all available agi structures for a free
|
||||||
* inode.
|
* inode.
|
||||||
|
*
|
||||||
|
* Read rough value of mp->m_icount by percpu_counter_read_positive,
|
||||||
|
* which will sacrifice the preciseness but improve the performance.
|
||||||
*/
|
*/
|
||||||
if (mp->m_maxicount &&
|
if (mp->m_maxicount &&
|
||||||
percpu_counter_read(&mp->m_icount) + mp->m_ialloc_inos >
|
percpu_counter_read_positive(&mp->m_icount) + mp->m_ialloc_inos
|
||||||
mp->m_maxicount) {
|
> mp->m_maxicount) {
|
||||||
noroom = 1;
|
noroom = 1;
|
||||||
okalloc = 0;
|
okalloc = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue