Skip to content

Commit 0baa265

Browse files
author
Darrick J. Wong
committed
xfs: always succeed at setting the reserve pool size
Nowadays, xfs_mod_fdblocks will always choose to fill the reserve pool with freed blocks before adding to fdblocks. Therefore, we can change the behavior of xfs_reserve_blocks slightly -- setting the target size of the pool should always succeed, since a deficiency will eventually be made up as blocks get freed. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 15f04fd commit 0baa265

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

fs/xfs/xfs_fsops.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,14 @@ xfs_reserve_blocks(
434434
* The code below estimates how many blocks it can request from
435435
* fdblocks to stash in the reserve pool. This is a classic TOCTOU
436436
* race since fdblocks updates are not always coordinated via
437-
* m_sb_lock.
437+
* m_sb_lock. Set the reserve size even if there's not enough free
438+
* space to fill it because mod_fdblocks will refill an undersized
439+
* reserve when it can.
438440
*/
439441
free = percpu_counter_sum(&mp->m_fdblocks) -
440442
xfs_fdblocks_unavailable(mp);
441443
delta = request - mp->m_resblks;
444+
mp->m_resblks = request;
442445
if (delta > 0 && free > 0) {
443446
/*
444447
* We'll either succeed in getting space from the free block
@@ -455,10 +458,8 @@ xfs_reserve_blocks(
455458
* Update the reserve counters if blocks have been successfully
456459
* allocated.
457460
*/
458-
if (!error) {
459-
mp->m_resblks += fdblks_delta;
461+
if (!error)
460462
mp->m_resblks_avail += fdblks_delta;
461-
}
462463
}
463464
out:
464465
if (outval) {

0 commit comments

Comments
 (0)