Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Naohiro Aota <naohiro.aota@wdc.com>,
	linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH v4 05/10] btrfs-progs: mkfs: align byte_count with sectorsize and zone size
Date: Wed, 29 May 2024 17:15:37 +0930	[thread overview]
Message-ID: <63ce80fe-879e-469a-8d93-49aeb8659191@gmx.com> (raw)
In-Reply-To: <20240529071325.940910-6-naohiro.aota@wdc.com>



在 2024/5/29 16:43, Naohiro Aota 写道:
> While "byte_count" is eventually rounded down to sectorsize at make_btrfs()
> or btrfs_add_to_fs_id(), it would be better round it down first and do the
> size checks not to confuse the things.
>
> Also, on a zoned device, creating a btrfs whose size is not aligned to the
> zone boundary can be confusing. Round it down further to the zone boundary.
>
> The size calculation with a source directory is also tweaked to be aligned.
> device_get_partition_size_fd_stat() must be aligned down not to exceed the
> device size. And, btrfs_mkfs_size_dir() should have return sectorsize aligned
> size. So, add an UASSERT for it.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

To David, since I have the write permission to btrfs-progs and reviewed
the series, can I push it to devel branch now?

Thanks,
Qu
> ---
>   mkfs/main.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/mkfs/main.c b/mkfs/main.c
> index a437ecc40c7f..3446a5b1222f 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -1591,6 +1591,12 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
>   	min_dev_size = btrfs_min_dev_size(nodesize, mixed,
>   					  opt_zoned ? zone_size(file) : 0,
>   					  metadata_profile, data_profile);
> +	if (byte_count) {
> +		byte_count = round_down(byte_count, sectorsize);
> +		if (opt_zoned)
> +			byte_count = round_down(byte_count,  zone_size(file));
> +	}
> +
>   	/*
>   	 * Enlarge the destination file or create a new one, using the size
>   	 * calculated from source dir.
> @@ -1624,9 +1630,11 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
>   		 * Or we will always use source_dir_size calculated for mkfs.
>   		 */
>   		if (!byte_count)
> -			byte_count = device_get_partition_size_fd_stat(fd, &statbuf);
> +			byte_count = round_down(device_get_partition_size_fd_stat(fd, &statbuf),
> +						sectorsize);
>   		source_dir_size = btrfs_mkfs_size_dir(source_dir, sectorsize,
>   				min_dev_size, metadata_profile, data_profile);
> +		UASSERT(IS_ALIGNED(source_dir_size, sectorsize));
>   		if (byte_count < source_dir_size) {
>   			if (S_ISREG(statbuf.st_mode)) {
>   				byte_count = source_dir_size;

  reply	other threads:[~2024-05-29  7:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29  7:13 [PATCH v4 00/10] btrfs-progs: zoned: proper "mkfs.btrfs -b" support Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 01/10] btrfs-progs: rename block_count to byte_count Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 02/10] btrfs-progs: mkfs: remove duplicated device size check Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 03/10] btrfs-progs: mkfs: unify zoned mode minimum size calc into btrfs_min_dev_size() Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 04/10] btrfs-progs: mkfs: fix minimum size calculation for zoned mode Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 05/10] btrfs-progs: mkfs: align byte_count with sectorsize and zone size Naohiro Aota
2024-05-29  7:45   ` Qu Wenruo [this message]
2024-05-30 17:26     ` David Sterba
2024-05-29  7:13 ` [PATCH v4 06/10] btrfs-progs: support byte length for zone resetting Naohiro Aota
2024-06-03 19:26   ` David Sterba
2024-05-29  7:13 ` [PATCH v4 07/10] btrfs-progs: test: add nullb setup functions Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 08/10] btrfs-progs: test: add test for zone resetting Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 09/10] btrfs-progs: test: use nullb helper and smaller zone size Naohiro Aota
2024-05-29  7:13 ` [PATCH v4 10/10] btrfs-progs: test: use nullb helpers in 031-zoned-bgt Naohiro Aota
2024-06-03 19:36 ` [PATCH v4 00/10] btrfs-progs: zoned: proper "mkfs.btrfs -b" support David Sterba

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=63ce80fe-879e-469a-8d93-49aeb8659191@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.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