aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOjaswin Mujoo <[email protected]>2023-03-25 13:43:34 +0530
committerTheodore Ts'o <[email protected]>2023-04-06 01:13:12 -0400
commite86a718228b61eef747b8deb446f807b2be73148 (patch)
tree5940c92b2f616295c52ec2c8a5a5991bfec4c989
parent19b8b035a776939ceb3de0f45aded4751d7849ef (diff)
ext4: Stop searching if PA doesn't satisfy non-extent file
If we come across a PA that matches the logical offset but is unable to satisfy a non-extent file due to its physical start being higher than that supported by non extent files, then simply stop searching for another PA and break out of loop. This is because, since PAs don't overlap, we won't be able to find another inode PA which can satisfy the original request. Signed-off-by: Ojaswin Mujoo <[email protected]> Reviewed-by: Ritesh Harjani (IBM) <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/42404ca29bd304ae2c962184c3c32a02e8eefcd0.1679731817.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o <[email protected]>
-rw-r--r--fs/ext4/mballoc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 90b061edb57d..2d4dc307941c 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4380,8 +4380,13 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac)
/* non-extent files can't have physical blocks past 2^32 */
if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)) &&
(pa->pa_pstart + EXT4_C2B(sbi, pa->pa_len) >
- EXT4_MAX_BLOCK_FILE_PHYS))
- continue;
+ EXT4_MAX_BLOCK_FILE_PHYS)) {
+ /*
+ * Since PAs don't overlap, we won't find any
+ * other PA to satisfy this.
+ */
+ break;
+ }
/* found preallocated blocks, use them */
spin_lock(&pa->pa_lock);