From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Pankaj Raghav <p.raghav@samsung.com>
Cc: Damien.LeMoal@wdc.com, pankydev8@gmail.com,
linux-f2fs-devel@lists.sourceforge.net, mcgrof@kernel.org,
Adam Manzanares <a.manzanares@samsung.com>,
javier.gonz@samsung.com
Subject: Re: [f2fs-dev] [PATCH v2] libf2fs: don't allow mkfs / fsck on non power-of-2 zoned devices
Date: Tue, 19 Apr 2022 16:07:47 -0700 [thread overview]
Message-ID: <Yl9Aw0vLdxM5Fexg@google.com> (raw)
In-Reply-To: <41ba478d-f32d-cf10-8096-43fb98dd3114@samsung.com>
On 04/19, Pankaj Raghav wrote:
> On 2022-04-13 21:45, Jaegeuk Kim wrote:>> As I explained in the v1
> thread, zoned support for f2fs assumes po2 zone
> >> sizes. For e.g.,
> >> static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> >> struct block_device *bdev, block_t blkstart, block_t blklen)
> >> {
> >> sector_t sector, nr_sects;
> >> block_t lblkstart = blkstart;
> >> int devi = 0;
> >> ...
> >> ...
> >> // Assumes zone sectors to be po2
> s/Assumes zone sectors to be po2/Works correctly only if the base
> alignment is a power of 2 value./
>
> Taken from align.h:
> /* @a is a power of 2 value */
> ...
> #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
>
> >
> > Well, I think this will be aligned to 2MB, if the device gives NPO2? IOWs, this
> Could you elaborate what you mean by `this will be aligned to 2MB`?
> > is just checking the granularity, not PO2.
> Yeah, so whenever we send a discard or a zone reset, the block zoned
> device expects the `sector` to be the start of a device zone. The check
> below essentially checks if the `sector` aligns with the `zone size
> sector` of the device. But to check for alignment using this `sector &
> (bdev_zone_sectors(bdev) - 1)` will only work if
> `bdev_zone_sectors(bdev)` is a power of 2.
>
> Even if the device zone size is a multiple of 2MB, these checks will
> fail for a non power of 2 zone size device. The solution is simple, it
> is to make this alignment check generic but until this is done in the
> kernel, mkfs.f2fs should fail to mount for a non power of 2 device.
> >
> >> if (sector & (bdev_zone_sectors(bdev) - 1) ||
> >> nr_sects != bdev_zone_sectors(bdev)) {
> >> f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted (block %x + %x)",
> >> devi, sbi->s_ndevs ? FDEV(devi).path : "",
> >> blkstart, blklen);
> I tried it locally in QEMU along with my local changes to remove power
> of 2 constraint in the block layer and zns device, and indeed the
> `Unaligned zone reset attempted` error popped up for a zns drive with a
> zone size 96MB.
>
> When I changed the condition from `sector & (bdev_zone_sectors(bdev) -
> 1)` to `sector % bdev_zone_sectors(bdev)`, the error went away because
> the calculation doesn't depend on the alignment base to be a power of 2.
>
>
> TL;DR until we change some calculations in f2fs for zoned device to be
> generic, we need to bail out during mkfs time for non power of 2 zone
> size devices.
Ah, I see. Yeah, that in f2fs is actually PO2. Let me merge this patch to
force it before getting that relax. Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2022-04-19 23:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220413122941eucas1p1ec05e8e8dfe2baf451fcb549d60fda35@eucas1p1.samsung.com>
2022-04-13 12:29 ` [f2fs-dev] [PATCH v2] libf2fs: don't allow mkfs / fsck on non power-of-2 zoned devices Pankaj Raghav
2022-04-13 17:03 ` Jaegeuk Kim
2022-04-13 17:53 ` Pankaj Raghav
2022-04-13 19:45 ` Jaegeuk Kim
2022-04-19 8:02 ` Pankaj Raghav
2022-04-19 23:07 ` Jaegeuk Kim [this message]
2022-04-20 6:48 ` Pankaj Raghav
2022-04-20 8:30 ` Pankaj Raghav
2022-04-20 10:45 ` Chao Yu
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=Yl9Aw0vLdxM5Fexg@google.com \
--to=jaegeuk@kernel.org \
--cc=Damien.LeMoal@wdc.com \
--cc=a.manzanares@samsung.com \
--cc=javier.gonz@samsung.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.