Skip to content

Commit 974ff36

Browse files
Daniel LeeJaegeuk Kim
authored andcommitted
mkfs.f2fs: Fix zoned alignment check for multi-device setups
Commit 84447ee 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 <chullee@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent d22f243 commit 974ff36

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

mkfs/f2fs_format.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,6 @@ static int f2fs_prepare_super_block(void)
339339
MSG(0, "Info: zone aligned segment0 blkaddr: %u\n",
340340
get_sb(segment0_blkaddr));
341341

342-
if (c.zoned_mode &&
343-
((c.ndevs == 1 &&
344-
(get_sb(segment0_blkaddr) + c.start_sector /
345-
DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) ||
346-
(c.ndevs > 1 &&
347-
c.devices[1].start_blkaddr % c.zone_blocks))) {
348-
MSG(1, "\tError: Unaligned segment0 block address %u\n",
349-
get_sb(segment0_blkaddr));
350-
return -1;
351-
}
352-
353342
for (i = 0; i < c.ndevs; i++) {
354343
if (i == 0) {
355344
c.devices[i].total_segments =
@@ -390,6 +379,33 @@ static int f2fs_prepare_super_block(void)
390379

391380
c.total_segments += c.devices[i].total_segments;
392381
}
382+
383+
if (c.zoned_mode) {
384+
if (c.ndevs == 1 &&
385+
(get_sb(segment0_blkaddr) + c.start_sector /
386+
DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) {
387+
/*
388+
* With a sole zoned LU, segment0 start should be
389+
* aligned at the zone.
390+
*/
391+
MSG(1, "\tError: Unaligned segment0 start (%u) for zoned LU (zone_blocks: %lu)\n",
392+
get_sb(segment0_blkaddr), c.zone_blocks);
393+
return -1;
394+
} else if (c.ndevs > 1 &&
395+
(c.devices[1].start_blkaddr - get_sb(segment0_blkaddr)) % c.zone_blocks) {
396+
/*
397+
* With the first device as a conventional LU and the
398+
* second as a zoned LU, the start address for the zoned
399+
* LU should be aligned to the zone size, starting from
400+
* segment0.
401+
*/
402+
MSG(1, "\tError: Unaligned start (%lu) for zoned LU from segment0 (%u) (zone_blocks: %lu)\n",
403+
c.devices[1].start_blkaddr,
404+
get_sb(segment0_blkaddr), c.zone_blocks);
405+
return -1;
406+
}
407+
}
408+
393409
set_sb(segment_count, c.total_segments);
394410
set_sb(segment_count_ckpt, F2FS_NUMBER_OF_CHECKPOINT_PACK);
395411

0 commit comments

Comments
 (0)