Patch "ext4: try all groups in ext4_mb_new_blocks_simple" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ext4: try all groups in ext4_mb_new_blocks_simple

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ext4-try-all-groups-in-ext4_mb_new_blocks_simple.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e428b77fee0556dca674a9d3abef788a7cbdfc07
Author: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
Date:   Sat Jun 3 23:03:15 2023 +0800

    ext4: try all groups in ext4_mb_new_blocks_simple
    
    [ Upstream commit 19a043bb1fd1b5cb2652ca33536c55e6c0a70df0 ]
    
    ext4_mb_new_blocks_simple ignores the group before goal, so it will fail
    if free blocks reside in group before goal. Try all groups to avoid
    unexpected failure.
    Search finishes either if any free block is found or if no available
    blocks are found. Simpliy check "i >= max" to distinguish the above
    cases.
    
    Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
    Suggested-by: Theodore Ts'o <tytso@xxxxxxx>
    Reviewed-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230603150327.3596033-8-shikemeng@xxxxxxxxxxxxxxx
    Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
    Stable-dep-of: 3f4830abd236 ("ext4: fix potential unnitialized variable")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a809a80589857..a7801d2a7d1b4 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -5875,7 +5875,7 @@ static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle,
 	struct buffer_head *bitmap_bh;
 	struct super_block *sb = ar->inode->i_sb;
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
-	ext4_group_t group;
+	ext4_group_t group, nr;
 	ext4_grpblk_t blkoff;
 	ext4_grpblk_t max = EXT4_CLUSTERS_PER_GROUP(sb);
 	ext4_grpblk_t i = 0;
@@ -5889,7 +5889,7 @@ static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle,
 
 	ar->len = 0;
 	ext4_get_group_no_and_offset(sb, goal, &group, &blkoff);
-	for (; group < ext4_get_groups_count(sb); group++) {
+	for (nr = ext4_get_groups_count(sb); nr > 0; nr--) {
 		bitmap_bh = ext4_read_block_bitmap(sb, group);
 		if (IS_ERR(bitmap_bh)) {
 			*errp = PTR_ERR(bitmap_bh);
@@ -5913,10 +5913,13 @@ static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle,
 		if (i < max)
 			break;
 
+		if (++group >= ext4_get_groups_count(sb))
+			group = 0;
+
 		blkoff = 0;
 	}
 
-	if (group >= ext4_get_groups_count(sb) || i >= max) {
+	if (i >= max) {
 		*errp = -ENOSPC;
 		return 0;
 	}




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux