Commit 84447ee7212e correctly relocated the zone alignment check to its proper location. However, this revealed that the original check's condition was incorrect for multi-device setups.
This patch corrects the logic to check the alignment relative to the start of the segment0 and improves the error messages. Signed-off-by: Daniel Lee <chul...@google.com> --- mkfs/f2fs_format.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 2680bd3..18f6e34 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -339,17 +339,6 @@ static int f2fs_prepare_super_block(void) MSG(0, "Info: zone aligned segment0 blkaddr: %u\n", get_sb(segment0_blkaddr)); - if (c.zoned_mode && - ((c.ndevs == 1 && - (get_sb(segment0_blkaddr) + c.start_sector / - DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) || - (c.ndevs > 1 && - c.devices[1].start_blkaddr % c.zone_blocks))) { - MSG(1, "\tError: Unaligned segment0 block address %u\n", - get_sb(segment0_blkaddr)); - return -1; - } - for (i = 0; i < c.ndevs; i++) { if (i == 0) { c.devices[i].total_segments = @@ -390,6 +379,33 @@ static int f2fs_prepare_super_block(void) c.total_segments += c.devices[i].total_segments; } + + if (c.zoned_mode) { + if (c.ndevs == 1 && + (get_sb(segment0_blkaddr) + c.start_sector / + DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) { + /* + * With a sole zoned LU, segment0 start should be + * aligned at the zone. + */ + MSG(1, "\tError: Unaligned segment0 start (%u) for zoned LU (zone_blocks: %lu)\n", + get_sb(segment0_blkaddr), c.zone_blocks); + return -1; + } else if (c.ndevs > 1 && + (c.devices[1].start_blkaddr - get_sb(segment0_blkaddr)) % c.zone_blocks) { + /* + * With the first device as a conventional LU and the + * second as a zoned LU, the start address for the zoned + * LU should be aligned to the zone size, starting from + * segment0. + */ + MSG(1, "\tError: Unaligned start (%lu) for zoned LU from segment0 (%u) (zone_blocks: %lu)\n", + c.devices[1].start_blkaddr, + get_sb(segment0_blkaddr), c.zone_blocks); + return -1; + } + } + set_sb(segment_count, c.total_segments); set_sb(segment_count_ckpt, F2FS_NUMBER_OF_CHECKPOINT_PACK); -- 2.50.1.552.g942d659e1b-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel