Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-progs: mkfs: refactor how we handle sectorsize override
Date: Tue, 1 Dec 2020 18:16:28 +0100	[thread overview]
Message-ID: <20201201171628.GN6430@twin.jikos.cz> (raw)
In-Reply-To: <20201013010602.11605-1-wqu@suse.com>

On Tue, Oct 13, 2020 at 09:06:02AM +0800, Qu Wenruo wrote:
> There are several problems for current sectorsize check:
> - No check at all for sectorsize
>   This means you can even specify "-s 62k".
> 
> - No way to specify sectorsize smaller than page size
> 
> Fix all these problems by:
> - Introduce btrfs_check_sectorsize()
>   To do:
>   * power of 2 check for sectorsize
>   * lower and upper boundary check for sectorsize
>   * warn about sectorsize mismatch with page size
> 
> - Remove the max() between page size and sectorsize
>   This allows us to override the sectorsize for 64K page systems.
> 
> - Make nodesize calculation based on sectorsize
>   No need to use page size any more.
>   Users who specify sectorsize manually really know what they are doing,
>   and we have warned them already.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Added to devel, thanks.

> +int btrfs_check_sectorsize(u32 sectorsize)
> +{
> +	u32 page_size = (u32)sysconf(_SC_PAGESIZE);
> +
> +	if (!is_power_of_2(sectorsize)) {
> +		error("illegal sectorsize %u, expect value power of 2",
> +		      sectorsize);
> +		return -EUCLEAN;

This should be EINVAL, updated

> +	}
> +	if (sectorsize < SZ_4K || sectorsize > SZ_64K) {
> +		error("illegal sectorsize %u, expect range [4K, 64K]",
> +		      sectorsize);
> +		return -EUCLEAN;
> +	}
> +	if (page_size != sectorsize)
> +		warning(
> +"the fs may not be mountable, sectorsize %u doesn't match page size %u",
> +			sectorsize, page_size);
> +	return 0;
> +}

      reply	other threads:[~2020-12-01 17:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13  1:06 [PATCH] btrfs-progs: mkfs: refactor how we handle sectorsize override Qu Wenruo
2020-12-01 17:16 ` David Sterba [this message]

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=20201201171628.GN6430@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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