Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Srivathsa Dara <srivathsa.d.dara@oracle.com>,
	linux-btrfs@vger.kernel.org
Cc: rajesh.sivaramasubramaniom@oracle.com, junxiao.bi@oracle.com,
	clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
Subject: Re: [PATCH v2] btrfs-progs: convert: Add 64 bit block numbers support
Date: Fri, 7 Jun 2024 07:58:25 +0930	[thread overview]
Message-ID: <c3060faf-f0e8-4bd2-865b-332e423a8801@gmx.com> (raw)
In-Reply-To: <20240606102215.3695032-1-srivathsa.d.dara@oracle.com>



在 2024/6/6 19:52, Srivathsa Dara 写道:
> In ext4, number of blocks can be greater than 2^32. Therefore, if
> btrfs-convert is used on filesystems greater than 16TiB (Staring from
> 16TiB, number of blocks overflow 32 bits), it fails to convert.
>
> Example:
>
> Here, /dev/sdc1 is 16TiB partition intitialized with an ext4 filesystem.
>
> [root@rasivara-arm2 opc]# btrfs-convert -d -p /dev/sdc1
> btrfs-convert from btrfs-progs v5.15.1
>
> convert/main.c:1164: do_convert: Assertion `cctx.total_bytes != 0` failed, value 0
> btrfs-convert(+0xfd04)[0xaaaaba44fd04]
> btrfs-convert(main+0x258)[0xaaaaba44d278]
> /lib64/libc.so.6(__libc_start_main+0xdc)[0xffffb962777c]
> btrfs-convert(+0xd4fc)[0xaaaaba44d4fc]
> Aborted (core dumped)
>
> Fix it by considering 64 bit block numbers.
>
> Signed-off-by: Srivathsa Dara <srivathsa.d.dara@oracle.com>
> ---
>   convert/source-ext2.c | 6 +++---
>   convert/source-ext2.h | 2 +-
>   2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/convert/source-ext2.c b/convert/source-ext2.c
> index 2186b252..afa48606 100644
> --- a/convert/source-ext2.c
> +++ b/convert/source-ext2.c
> @@ -288,8 +288,8 @@ error:
>   	return -1;
>   }
>
> -static int ext2_block_iterate_proc(ext2_filsys fs, blk_t *blocknr,
> -			        e2_blkcnt_t blockcnt, blk_t ref_block,
> +static int ext2_block_iterate_proc(ext2_filsys fs, blk64_t *blocknr,
> +			        e2_blkcnt_t blockcnt, blk64_t ref_block,
>   			        int ref_offset, void *priv_data)
>   {
>   	int ret;
> @@ -323,7 +323,7 @@ static int ext2_create_file_extents(struct btrfs_trans_handle *trans,
>   	init_blk_iterate_data(&data, trans, root, btrfs_inode, objectid,
>   			convert_flags & CONVERT_FLAG_DATACSUM);
>
> -	err = ext2fs_block_iterate2(ext2_fs, ext2_ino, BLOCK_FLAG_DATA_ONLY,
> +	err = ext2fs_block_iterate3(ext2_fs, ext2_ino, BLOCK_FLAG_DATA_ONLY,
>   				    NULL, ext2_block_iterate_proc, &data);

I'm wondering does ext2 really supports 64bit block number.

For ext* fs with extent support (3 and 4), we're no longer utilizing
ext2fs_block_iterate2(), instead we go with iterate_file_extents()
instead, and that function is already using blk64_t for both file offset
and the block number.

I'm guessing the code base doesn't have the latest c23e068aaf91
("btrfs-progs: convert: rework file extent iteration to handle unwritten
extents") commit yet?


>   	if (err)
>   		goto error;
> diff --git a/convert/source-ext2.h b/convert/source-ext2.h
> index d204aac5..62c9b1fa 100644
> --- a/convert/source-ext2.h
> +++ b/convert/source-ext2.h
> @@ -46,7 +46,7 @@ struct btrfs_trans_handle;
>   #define ext2fs_get_block_bitmap_range2 ext2fs_get_block_bitmap_range
>   #define ext2fs_inode_data_blocks2 ext2fs_inode_data_blocks
>   #define ext2fs_read_ext_attr2 ext2fs_read_ext_attr
> -#define ext2fs_blocks_count(s)		((s)->s_blocks_count)
> +#define ext2fs_blocks_count(s)		(((s)->s_blocks_count_hi << 32) | (s)->s_blocks_count)

This is definitely needed, or it would trigger the ASSERT().

But again, the newer btrfs-progs no longer go with internally defined
ext2fs_blocks_count(), but using the one from e2fsprogs headers, and the
library version is already returning blk64_t.

So I'm afraid you're testing an older version of btrfs-progs.

Thanks,
Qu
>   #define EXT2FS_CLUSTER_RATIO(fs)	(1)
>   #define EXT2_CLUSTERS_PER_GROUP(s)	(EXT2_BLOCKS_PER_GROUP(s))
>   #define EXT2FS_B2C(fs, blk)		(blk)

  reply	other threads:[~2024-06-06 22:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06 10:22 [PATCH v2] btrfs-progs: convert: Add 64 bit block numbers support Srivathsa Dara
2024-06-06 22:28 ` Qu Wenruo [this message]
2024-06-11  6:03   ` Srivathsa Dara
2024-06-12 20:37     ` David Sterba
2024-06-13  0:02       ` David Sterba
2024-06-13  0:10         ` Qu Wenruo
2024-06-13  0:23           ` David Sterba
2024-06-13  0:25             ` Qu Wenruo
2024-06-13  0:52               ` David Sterba
2024-06-13  1:23                 ` David Sterba
2024-06-13 18:27                   ` [External] : " Srivathsa Dara
2024-06-13 18:32       ` Srivathsa Dara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3060faf-f0e8-4bd2-865b-332e423a8801@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=junxiao.bi@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=rajesh.sivaramasubramaniom@oracle.com \
    --cc=srivathsa.d.dara@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox