Skip to contentSkip to conversation

btrfs-progs: convert: Mention which reserve_space call failed

PATCH In review Marcos Paulo de Souza 3 participants 5 messages Sep 23, 2020 – Sep 24, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: convert: Mention which reserve_space call failed

From: Marcos Paulo de Souza <[email protected]>

btrfs-convert currently can't handle more fragmented block groups when converting ext4 because the minimum size of a data chunk is 32Mb.

When converting an ext4 fs with more fragmented block group and the disk almost full, we can end up hitting a ENOSPC problem [1] since smaller block groups (10Mb for example) end up being extended to 32Mb, leaving the free space tree smaller when converting it to btrfs.

This patch adds error messages telling which needed bytes couldn't be allocated from the free space tree:

create btrfs filesystem:

        blocksize: 4096
        nodesize:  16384
        features:  extref, skinny-metadata (default)
        checksum:  crc32c
free space report:
        total:     1073741824
        free:      39124992 (3.64%)

ERROR: failed to reserve 33554432 bytes from free space for metadata chunk
ERROR: unable to create initial ctree: No space left on device

---
 convert/common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
convert/common.c +9 -3
index 048629df..6392e7f4 100644
@@ -812,8 +812,10 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
 	 */
 	ret = reserve_free_space(free_space, BTRFS_STRIPE_LEN,
 				 &cfg->super_bytenr);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for temporary superblock", BTRFS_STRIPE_LEN);
 		goto out;
+	}
 
 	/*
 	 * Then reserve system chunk space
@@ -823,12 +825,16 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
 	 */
 	ret = reserve_free_space(free_space, BTRFS_MKFS_SYSTEM_GROUP_SIZE,
 				 &sys_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for system chunk", BTRFS_MKFS_SYSTEM_GROUP_SIZE);
 		goto out;
+	}
 	ret = reserve_free_space(free_space, BTRFS_CONVERT_META_GROUP_SIZE,
 				 &meta_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for metadata chunk", BTRFS_CONVERT_META_GROUP_SIZE);
 		goto out;
+	}
 
 	/*
 	 * Allocated meta/sys chunks will be mapped 1:1 with device offset.
Signature · 1 line
2.28.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 68 lines · Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

btrfs-convert currently can't handle more fragmented block groups when converting ext4 because the minimum size of a data chunk is 32Mb.

When converting an ext4 fs with more fragmented block group and the disk almost full, we can end up hitting a ENOSPC problem [1] since smaller block groups (10Mb for example) end up being extended to 32Mb, leaving the free space tree smaller when converting it to btrfs.

This patch adds error messages telling which needed bytes couldn't be allocated from the free space tree:

create btrfs filesystem:

        blocksize: 4096
        nodesize:  16384
        features:  extref, skinny-metadata (default)
        checksum:  crc32c
free space report:
        total:     1073741824
        free:      39124992 (3.64%)

ERROR: failed to reserve 33554432 bytes from free space for metadata chunk
ERROR: unable to create initial ctree: No space left on device

---
 convert/common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
convert/common.c +9 -4
index 048629df..6392e7f4 100644
@@ -812,8 +812,10 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
         */
        ret = reserve_free_space(free_space, BTRFS_STRIPE_LEN,
                                 &cfg->super_bytenr);
-       if (ret < 0)
+       if (ret < 0) {
+               error("failed to reserve %d bytes from free space for temporary superblock", BTRFS_STRIPE_LEN);
                goto out;
+       }
 
        /*
         * Then reserve system chunk space
@@ -823,12 +825,16 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
         */
        ret = reserve_free_space(free_space, BTRFS_MKFS_SYSTEM_GROUP_SIZE,
                                 &sys_chunk_start);
-       if (ret < 0)
+       if (ret < 0) {
+               error("failed to reserve %d bytes from free space for system chunk", BTRFS_MKFS_SYSTEM_GROUP_SIZE);
                goto out;
+       }
        ret = reserve_free_space(free_space, BTRFS_CONVERT_META_GROUP_SIZE,
                                 &meta_chunk_start);
-       if (ret < 0)
+       if (ret < 0) {
+               error("failed to reserve %d bytes from free space for metadata chunk", BTRFS_CONVERT_META_GROUP_SIZE);
                goto out;
+       }
 
        /*
         * Allocated meta/sys chunks will be mapped 1:1 with device offset.
--
Quoted 2 lines

2.28.0

--
真実はいつも一つ!/ Always, there's only one truth!

Reviewed-by on v1 1/1
#2 lore raw
In reply to Marcos Paulo de Souza
Quoted 21 lines · Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

btrfs-convert currently can't handle more fragmented block groups when converting ext4 because the minimum size of a data chunk is 32Mb.

When converting an ext4 fs with more fragmented block group and the disk almost full, we can end up hitting a ENOSPC problem [1] since smaller block groups (10Mb for example) end up being extended to 32Mb, leaving the free space tree smaller when converting it to btrfs.

This patch adds error messages telling which needed bytes couldn't be allocated from the free space tree:

create btrfs filesystem:

        blocksize: 4096
        nodesize:  16384
        features:  extref, skinny-metadata (default)
        checksum:  crc32c
free space report:
        total:     1073741824
        free:      39124992 (3.64%)
Quoted 6 lines

ERROR: failed to reserve 33554432 bytes from free space for metadata chunk
ERROR: unable to create initial ctree: No space left on device

Looks pretty good, but can be enhanced a little, inlined below.

Despite that, feel free to add my tag:

Quoted 9 lines
---
 convert/common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
convert/common.c +0 -0
index 048629df..6392e7f4 100644

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg, · line 816

Quoted 6 lines
convert/common.c +2 -1
@@ -812,8 +812,10 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
 	 */
 	ret = reserve_free_space(free_space, BTRFS_STRIPE_LEN,
 				 &cfg->super_bytenr);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for temporary superblock", BTRFS_STRIPE_LEN);

It would be awesome if we can output the free space.

Just the largest portion is enough to show that we're hitting a real ENOSPC situation.

Thanks,
Qu

Quoted 25 lines
convert/common.c +7 -2
 		goto out;
+	}
 
 	/*
 	 * Then reserve system chunk space
@@ -823,12 +825,16 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
 	 */
 	ret = reserve_free_space(free_space, BTRFS_MKFS_SYSTEM_GROUP_SIZE,
 				 &sys_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for system chunk", BTRFS_MKFS_SYSTEM_GROUP_SIZE);
 		goto out;
+	}
 	ret = reserve_free_space(free_space, BTRFS_CONVERT_META_GROUP_SIZE,
 				 &meta_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for metadata chunk", BTRFS_CONVERT_META_GROUP_SIZE);
 		goto out;
+	}
 
 	/*
 	 * Allocated meta/sys chunks will be mapped 1:1 with device offset.
#3 lore raw
Quoted 59 lines · Qu Wenruo
Quoted 3 lines · Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

btrfs-convert currently can't handle more fragmented block groups

when

Quoted 3 lines

converting ext4 because the minimum size of a data chunk is 32Mb.

When converting an ext4 fs with more fragmented block group and the

disk

Quoted 1 line

almost full, we can end up hitting a ENOSPC problem [1] since

smaller

Quoted 1 line

block groups (10Mb for example) end up being extended to 32Mb,

leaving

Quoted 3 lines

the free space tree smaller when converting it to btrfs.

This patch adds error messages telling which needed bytes couldn't

be

Quoted 11 lines

allocated from the free space tree:

create btrfs filesystem:

        blocksize: 4096
        nodesize:  16384
        features:  extref, skinny-metadata (default)
        checksum:  crc32c
free space report:
        total:     1073741824
        free:      39124992 (3.64%)

ERROR: failed to reserve 33554432 bytes from free space for

metadata chunk

Quoted 5 lines

ERROR: unable to create initial ctree: No space left on device

Looks pretty good, but can be enhanced a little, inlined below.

Despite that, feel free to add my tag:

convert/common.c int make_convert_btrfs(int fd, struct

Quoted 9 lines
---
 convert/common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
convert/common.c +0 -0
index 048629df..6392e7f4 100644
@@ -812,8 +812,10 @@ int make_convert_btrfs(int fd, struct

btrfs_mkfs_config *cfg,

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 6 lines
convert/common.c +2 -1
 	 */
 	ret = reserve_free_space(free_space, BTRFS_STRIPE_LEN,
 				 &cfg->super_bytenr);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for

temporary superblock", BTRFS_STRIPE_LEN);

Quoted 4 lines

It would be awesome if we can output the free space.

Just the largest portion is enough to show that we're hitting a real ENOSPC situation.

Indeed, I'll send a v2 printing the free space tree when ENOSPC happens.

Quoted 35 lines

Thanks,
Qu

convert/common.c int make_convert_btrfs(int fd, struct

Quoted 6 lines
convert/common.c +1 -0
 		goto out;
+	}
 
 	/*
 	 * Then reserve system chunk space
@@ -823,12 +825,16 @@ int make_convert_btrfs(int fd, struct

btrfs_mkfs_config *cfg,

convert/common.c int make_convert_btrfs(int fd, struct · line 826

Quoted 2 lines
convert/common.c +0 -0
 	 */
 	ret = reserve_free_space(free_space,

BTRFS_MKFS_SYSTEM_GROUP_SIZE,

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 4 lines
convert/common.c +2 -1
 				 &sys_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for

system chunk", BTRFS_MKFS_SYSTEM_GROUP_SIZE);

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 3 lines
convert/common.c +1 -0
 		goto out;
+	}
 	ret = reserve_free_space(free_space,

BTRFS_CONVERT_META_GROUP_SIZE,

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 4 lines
convert/common.c +2 -1
 				 &meta_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for

metadata chunk", BTRFS_CONVERT_META_GROUP_SIZE);

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 5 lines
convert/common.c +1 -0
 		goto out;
+	}
 
 	/*
 	 * Allocated meta/sys chunks will be mapped 1:1 with device

offset.

Quoted 1 line
#4 lore raw
Quoted 60 lines · Marcos Paulo de Souza
Quoted 59 lines · Qu Wenruo
Quoted 3 lines · Marcos Paulo de Souza

From: Marcos Paulo de Souza <[email protected]>

btrfs-convert currently can't handle more fragmented block groups

when

Quoted 3 lines

converting ext4 because the minimum size of a data chunk is 32Mb.

When converting an ext4 fs with more fragmented block group and the

disk

Quoted 1 line

almost full, we can end up hitting a ENOSPC problem [1] since

smaller

Quoted 1 line

block groups (10Mb for example) end up being extended to 32Mb,

leaving

Quoted 3 lines

the free space tree smaller when converting it to btrfs.

This patch adds error messages telling which needed bytes couldn't

be

Quoted 11 lines

allocated from the free space tree:

create btrfs filesystem:

        blocksize: 4096
        nodesize:  16384
        features:  extref, skinny-metadata (default)
        checksum:  crc32c
free space report:
        total:     1073741824
        free:      39124992 (3.64%)

ERROR: failed to reserve 33554432 bytes from free space for

metadata chunk

Quoted 5 lines

ERROR: unable to create initial ctree: No space left on device

Looks pretty good, but can be enhanced a little, inlined below.

Despite that, feel free to add my tag:

convert/common.c int make_convert_btrfs(int fd, struct

Quoted 9 lines
---
 convert/common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
convert/common.c +0 -0
index 048629df..6392e7f4 100644
@@ -812,8 +812,10 @@ int make_convert_btrfs(int fd, struct

btrfs_mkfs_config *cfg,

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 6 lines
convert/common.c +2 -1
 	 */
 	ret = reserve_free_space(free_space, BTRFS_STRIPE_LEN,
 				 &cfg->super_bytenr);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for

temporary superblock", BTRFS_STRIPE_LEN);

Quoted 7 lines
Quoted 4 lines

It would be awesome if we can output the free space.

Just the largest portion is enough to show that we're hitting a real ENOSPC situation.

Indeed, I'll send a v2 printing the free space tree when ENOSPC happens.

And it would be even better to mention the fragmentation problem in the man page for btrfs-convert.

The fragmentation problem is a little too complex to explain in the error message nor usage.

Although I guess the man page update could be another patch.

Thanks,
Qu

Quoted 37 lines
Quoted 36 lines

Thanks,
Qu

convert/common.c int make_convert_btrfs(int fd, struct

Quoted 6 lines
convert/common.c +1 -0
 		goto out;
+	}
 
 	/*
 	 * Then reserve system chunk space
@@ -823,12 +825,16 @@ int make_convert_btrfs(int fd, struct

btrfs_mkfs_config *cfg,

convert/common.c int make_convert_btrfs(int fd, struct · line 826

Quoted 2 lines
convert/common.c +0 -0
 	 */
 	ret = reserve_free_space(free_space,

BTRFS_MKFS_SYSTEM_GROUP_SIZE,

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 4 lines
convert/common.c +2 -1
 				 &sys_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for

system chunk", BTRFS_MKFS_SYSTEM_GROUP_SIZE);

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 3 lines
convert/common.c +1 -0
 		goto out;
+	}
 	ret = reserve_free_space(free_space,

BTRFS_CONVERT_META_GROUP_SIZE,

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 4 lines
convert/common.c +2 -1
 				 &meta_chunk_start);
-	if (ret < 0)
+	if (ret < 0) {
+		error("failed to reserve %d bytes from free space for

metadata chunk", BTRFS_CONVERT_META_GROUP_SIZE);

convert/common.c int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,

Quoted 5 lines
convert/common.c +1 -0
 		goto out;
+	}
 
 	/*
 	 * Allocated meta/sys chunks will be mapped 1:1 with device

offset.

Quoted 1 line