diff options
author | Ritesh Harjani <riteshh@linux.ibm.com> | 2020-05-20 12:10:32 +0530 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-06-03 23:16:53 -0400 |
commit | 53f86b170dfa8d50b8b3fb1c5cf17c33b2327db2 (patch) | |
tree | d76dec5a659413307ebc463bdc4922d101071fdf /fs/char_dev.c | |
parent | de8ff14cab998f51a3a289d2b58d6d440782f77e (diff) | |
download | linux-53f86b170dfa8d50b8b3fb1c5cf17c33b2327db2.tar.bz2 |
ext4: mballoc: add blocks to PA list under same spinlock after allocating blocks
ext4_mb_discard_preallocations() only checks for grp->bb_prealloc_list
of every group to discard the group's PA to free up the space if
allocation request fails. Consider below race:-
Process A Process B
1. allocate blocks
1. Fails block allocation from
ext4_mb_regular_allocator()
ext4_lock_group()
allocated blocks
more than ac_o_ex.fe_len
ext4_unlock_group()
2. Scans the
grp->bb_prealloc_list (under
ext4_lock_group()) and
find nothing and thus return
-ENOSPC.
2. Add the additional blocks to PA list
ext4_lock_group()
add blocks to grp->bb_prealloc_list
ext4_unlock_group()
Above race could be avoided if we add those additional blocks to
grp->bb_prealloc_list at the same time with block allocation when
ext4_lock_group() was still held.
With this discard-PA will know if there are actually any blocks which
could be freed from the PA
Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/a2217dd782585b42328981832e6d396abaaccb80.1589955723.git.riteshh@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/char_dev.c')
0 files changed, 0 insertions, 0 deletions