Skip to contentSkip to conversation

ext4: check if group has free space

PATCH In review Artem Blagodarenko 2 participants 2 messages Mar 7, 2019 – Mar 15, 2019 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: check if group has free space

Regular allocator make four groups processing loops to find good group to allocate blocks. On 4th loop it accept any group, even if there is no free space at all.

This patch adds group free space check to skip full groups.

---
 fs/ext4/mballoc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +2 -1
index e2248083cdca..4e6c36ff1d55 100644
@@ -2087,7 +2087,8 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac,
 			return 1;
 		break;
 	case 3:
-		return 1;
+		/* Skip group without any free space */
+		return free ? 1 : 0;
 	default:
 		BUG();
 	}
Signature · 1 line
2.14.3
maintainer
#1 lore raw
Quoted 7 lines · Artem Blagodarenko

Regular allocator make four groups processing loops to find good group to allocate blocks. On 4th loop it accept any group, even if there is no free space at all.

This patch adds group free space check to skip full groups.

This patch doesn't change anything. Note the check that we have at the very beginning of ext4_mb_good_group():

	free = grp->bb_free;
	if (free == 0)
		return 0;

This is before we even go into the case statement, so your change:

fs/ext4/mballoc.c static int ext4_mb_good_group(struct ext4_allocation_context *ac, · line 2091

Quoted 4 lines
fs/ext4/mballoc.c +2 -1
 	case 3:
-		return 1;
+		/* Skip group without any free space */
+		return free ? 1 : 0;

is a no-op; we will always be returning 1, since if free == 0, we would have bailed out at the top of the function.

Cheers,

- Ted