btrfs-progs: mkfs: Fix a wrong extent buffer size causing wrong superblock csum
diff mbox

Message ID 1448525755-1192-1-git-send-email-quwenruo@cn.fujitsu.com
State New
Headers show

Commit Message

Qu Wenruo Nov. 26, 2015, 8:15 a.m. UTC
For make_btrfs(), it's setting wrong buf size for last super block write
out.
The superblock size is always BTRFS_SUPER_INFO_SIZE, not
cfg->sectorsize.

And this makes mkfs.btrfs -f -s 8K fails.

Fix it to BTRFS_SUPER_INFO_SIZE.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
Thanks goodness, this time it's not my super block checksum patches
causing bugs.
---
 utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba Nov. 26, 2015, 1:51 p.m. UTC | #1
On Thu, Nov 26, 2015 at 04:15:55PM +0800, Qu Wenruo wrote:
> For make_btrfs(), it's setting wrong buf size for last super block write
> out.
> The superblock size is always BTRFS_SUPER_INFO_SIZE, not
> cfg->sectorsize.
> 
> And this makes mkfs.btrfs -f -s 8K fails.
> 
> Fix it to BTRFS_SUPER_INFO_SIZE.
> 
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>

Already fixed in current devel (bf1ac8305ab3f191d9).

> --- a/utils.c
> +++ b/utils.c
> @@ -554,7 +554,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
>  	BUG_ON(sizeof(super) > cfg->sectorsize);
>  	memset(buf->data, 0, cfg->sectorsize);
>  	memcpy(buf->data, &super, sizeof(super));
> -	buf->len = cfg->sectorsize;
> +	buf->len = BTRFS_SUPER_INFO_SIZE;
>  	csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
>  	ret = pwrite(fd, buf->data, cfg->sectorsize, cfg->blocks[0]);

Also, this overwrites more bytes than necessary so my fix uses
BTRFS_SUPER_INFO_SIZE everywhere.

>  	if (ret != cfg->sectorsize) {
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/utils.c b/utils.c
index 60235d8..00355a2 100644
--- a/utils.c
+++ b/utils.c
@@ -554,7 +554,7 @@  int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
 	BUG_ON(sizeof(super) > cfg->sectorsize);
 	memset(buf->data, 0, cfg->sectorsize);
 	memcpy(buf->data, &super, sizeof(super));
-	buf->len = cfg->sectorsize;
+	buf->len = BTRFS_SUPER_INFO_SIZE;
 	csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
 	ret = pwrite(fd, buf->data, cfg->sectorsize, cfg->blocks[0]);
 	if (ret != cfg->sectorsize) {