* [f2fs-dev] [PATCH] mkfs.f2fs: adjust zone alignment check to correct position
@ 2025-07-14 9:51 Zhiguo Niu via Linux-f2fs-devel
2025-07-15 6:52 ` Chao Yu via Linux-f2fs-devel
0 siblings, 1 reply; 3+ messages in thread
From: Zhiguo Niu via Linux-f2fs-devel @ 2025-07-14 9:51 UTC (permalink / raw)
To: jaegeuk, chao
Cc: ke.wang, linux-kernel, linux-f2fs-devel, zhiguo.niu, Hao_hao.Wang
Should check these after c.devices[1].start_blkaddr is assigned
when c.ndevs > 1.
Fixes: 316e128fe3dc ("mkfs.f2fs: adjust zone alignment when using multi-partitions")
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
mkfs/f2fs_format.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 2680bd3..3a899e6 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,18 @@ static int f2fs_prepare_super_block(void)
c.total_segments += c.devices[i].total_segments;
}
+
+ 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;
+ }
+
set_sb(segment_count, c.total_segments);
set_sb(segment_count_ckpt, F2FS_NUMBER_OF_CHECKPOINT_PACK);
--
1.9.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread* [f2fs-dev] [PATCH] mkfs.f2fs: adjust zone alignment check to correct position
@ 2024-11-05 11:25 Zhiguo Niu
0 siblings, 0 replies; 3+ messages in thread
From: Zhiguo Niu @ 2024-11-05 11:25 UTC (permalink / raw)
To: jaegeuk, chao
Cc: ke.wang, linux-kernel, linux-f2fs-devel, zhiguo.niu, Hao_hao.Wang
Should check after c.devices[1].start_blkaddr is assigned
if c.ndevs > 1.
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
mkfs/f2fs_format.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 52a1e18..f7cfa5e 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,18 @@ static int f2fs_prepare_super_block(void)
c.total_segments += c.devices[i].total_segments;
}
+
+ 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;
+ }
+
set_sb(segment_count, c.total_segments);
set_sb(segment_count_ckpt, F2FS_NUMBER_OF_CHECKPOINT_PACK);
--
1.9.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-15 6:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 9:51 [f2fs-dev] [PATCH] mkfs.f2fs: adjust zone alignment check to correct position Zhiguo Niu via Linux-f2fs-devel
2025-07-15 6:52 ` Chao Yu via Linux-f2fs-devel
-- strict thread matches above, loose matches on Subject: below --
2024-11-05 11:25 Zhiguo Niu
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).