linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: "p.raghav@samsung.com" <p.raghav@samsung.com>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>
Cc: "javier.gonz@samsung.com" <javier.gonz@samsung.com>,
	"mcgrof@kernel.org" <mcgrof@kernel.org>,
	"pankydev8@gmail.com" <pankydev8@gmail.com>
Subject: Re: [f2fs-dev] [PATCH 3/3] libf2fs: don't allow mkfs / fsck on zoned NPO2
Date: Tue, 12 Apr 2022 12:16:53 +0000	[thread overview]
Message-ID: <cf4e409966936c1d5e4486f172b45aaad128ae36.camel@wdc.com> (raw)
In-Reply-To: <20220412112745.44108-4-p.raghav@samsung.com>

On Tue, 2022-04-12 at 13:27 +0200, Pankaj Raghav wrote:
> From: Luis Chamberlain <mcgrof@kernel.org>
> 
> f2fs currently only work with zoned storage devices with a zone
> size which is a power of 2 (PO2). So check if a non-power of 2
> zone is device is found, and if so disallow its use. This prevents
> users from incorrectly using these devices.
> 
> This is a non-issue today give today's kernel does not allow NPO2
> zon devices to exist. But these devices do exist, and so proactively
> put a stop-gap measure in place to prevent the from being assumed
> to be used.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  lib/libf2fs.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 8fad1d7..a13ba32 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -882,6 +882,11 @@ static int open_check_fs(char *path, int flag)
>  	return open(path, O_RDONLY | flag);
>  }
>  
> +static int is_power_of_2(unsigned long n)
> +{
> +	return (n != 0 && ((n & (n - 1)) == 0));
> +}
> +
>  int get_device_info(int i)
>  {
>  	int32_t fd = 0;
> @@ -1043,6 +1048,13 @@ int get_device_info(int i)
>  			return -1;
>  		}
>  
> +		if (!dev->zone_size || !is_power_of_2(dev->zone_size)) {
> +			MSG(0, "\tError: zoned: illegal zone size %lu (not a power of 2)\n",
> +					dev->zone_size);

The message should be different for the !dev->zone_size case since that
would be an error.

> +			free(stat_buf);
> +			return -1;
> +		}
> +
>  		/*
>  		 * Check zone configuration: for the first disk of a
>  		 * multi-device volume, conventional zones are needed.

Of the 3 patches of this series, this one is the only one that makes sense
to me. I fail to see how the first 2 patches improve things.

-- 
Damien Le Moal
Western Digital Research


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2022-04-12 12:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220412112746eucas1p14f52961641ef07fdc7274e75887da9ad@eucas1p1.samsung.com>
2022-04-12 11:27 ` [f2fs-dev] [PATCH 0/3] f2fs-tools: return error for zoned devices with non power-of-2 zone size Pankaj Raghav
     [not found]   ` <CGME20220412112747eucas1p11e2747339407a5c51a93e7b7060ab965@eucas1p1.samsung.com>
2022-04-12 11:27     ` [f2fs-dev] [PATCH 1/3] libf2fs_zoned: factor out helper to get chunk sectors Pankaj Raghav
2022-04-12 12:17       ` Damien Le Moal via Linux-f2fs-devel
     [not found]   ` <CGME20220412112748eucas1p19a9e013fa04d5a82abd5364604a8ad31@eucas1p1.samsung.com>
2022-04-12 11:27     ` [f2fs-dev] [PATCH 2/3] libf2fs: add support to report zone size Pankaj Raghav
2022-04-12 12:14       ` Damien Le Moal via Linux-f2fs-devel
2022-04-12 16:23         ` Luis Chamberlain
2022-04-13  1:03           ` Damien Le Moal via Linux-f2fs-devel
     [not found]   ` <CGME20220412112749eucas1p28b82e6b3b563f2e25c78f479c1192451@eucas1p2.samsung.com>
2022-04-12 11:27     ` [f2fs-dev] [PATCH 3/3] libf2fs: don't allow mkfs / fsck on zoned NPO2 Pankaj Raghav
2022-04-12 12:16       ` Damien Le Moal via Linux-f2fs-devel [this message]
2022-04-12 15:30         ` Pankaj Raghav
2022-04-12 16:33   ` [f2fs-dev] [PATCH 0/3] f2fs-tools: return error for zoned devices with non power-of-2 zone size Jaegeuk Kim
2022-04-13 11:14     ` Pankaj Raghav
2022-04-13 16:22       ` Jaegeuk Kim
2022-04-13 17:53         ` Pankaj Raghav

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=cf4e409966936c1d5e4486f172b45aaad128ae36.camel@wdc.com \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=Damien.LeMoal@wdc.com \
    --cc=javier.gonz@samsung.com \
    --cc=mcgrof@kernel.org \
    --cc=p.raghav@samsung.com \
    --cc=pankydev8@gmail.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;
as well as URLs for NNTP newsgroup(s).