Skip to contentSkip to conversation

f2fs-tools: allocate logs after conventional area for HM zoned devices

PATCH Superseded Daeho Jeong 3 participants 11 messages Jan 17, 2024 – Jan 31, 2024 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs-tools: allocate logs after conventional area for HM zoned devices

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
 mkfs/f2fs_format.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
 		c.cur_seg[CURSEG_COLD_DATA] = 0;
 		c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
 	} else if (c.zoned_mode) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+			c.devices[0].total_segments : 0;
 		c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
 		c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
 		c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
Signature · 1 line
2.43.0.381.gb435a96ce8-goog
#2 lore raw
In reply to Daeho Jeong

+Cc Yongpeng Yang

Daeho,

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Quoted 24 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
  mkfs/f2fs_format.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
  		c.cur_seg[CURSEG_COLD_DATA] = 0;
  		c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
  	} else if (c.zoned_mode) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+			c.devices[0].total_segments : 0;
  		c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
  		c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
  		c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
#3 lore raw
Quoted 9 lines · Chao Yu

+Cc Yongpeng Yang

Daeho,

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?
In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

Quoted 26 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
  mkfs/f2fs_format.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
              c.cur_seg[CURSEG_COLD_DATA] = 0;
              c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
      } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
              c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
              c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
              c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
#4 lore raw
Quoted 4 lines · Daeho Jeong
Quoted 3 lines · Chao Yu

+Cc Yongpeng Yang

Quoted 8 lines
Quoted 6 lines

Daeho,

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?

Since c.cur_seg[CURSEG_HOT_NODE] is an offset started from main_blkaddr. If c.cur_seg[CURSEG_HOT_NODE] was assigned w/ c.devices[0].total_segments, and c.devices[0].total_segments is larger than segments of mainare, c.cur_seg[CURSEG_HOT_NODE] will exceed the end boundary of mainarea.

	c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
			c.devices[0].total_segments : 0;
Quoted 3 lines

In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

I mean blew case:
device[0]: conventional device size = 10240 MB
device[1]: zone device size = 2 MB

Thanks,

Quoted 27 lines
Quoted 27 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
   mkfs/f2fs_format.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
               c.cur_seg[CURSEG_COLD_DATA] = 0;
               c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
       } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
               c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
               c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
               c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
#5 lore raw
Quoted 8 lines · Chao Yu
Quoted 6 lines · Daeho Jeong
Quoted 5 lines · Chao Yu

+Cc Yongpeng Yang

Daeho,

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?

Since c.cur_seg[CURSEG_HOT_NODE] is an offset started from main_blkaddr.

Oh, Got it.
Then, how about this?

         c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                         (c.devices[1].start_blkaddr -

get_sb(main_blkaddr)) / c.blks_per_seg : 0;

Quoted 44 lines

If c.cur_seg[CURSEG_HOT_NODE] was assigned w/ c.devices[0].total_segments, and c.devices[0].total_segments is larger than segments of mainare, c.cur_seg[CURSEG_HOT_NODE] will exceed the end boundary of mainarea.

        c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                        c.devices[0].total_segments : 0;
Quoted 3 lines

In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

I mean blew case:
device[0]: conventional device size = 10240 MB
device[1]: zone device size = 2 MB

Thanks,

Quoted 27 lines
Quoted 27 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
   mkfs/f2fs_format.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
               c.cur_seg[CURSEG_COLD_DATA] = 0;
               c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
       } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
               c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
               c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
               c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
#6 lore raw
Quoted 16 lines · Daeho Jeong
Quoted 15 lines · Chao Yu
Quoted 12 lines · Daeho Jeong
Quoted 9 lines · Chao Yu

+Cc Yongpeng Yang

Daeho,

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?

Quoted 8 lines
Quoted 1 line

Since c.cur_seg[CURSEG_HOT_NODE] is an offset started from main_blkaddr.

Oh, Got it.
Then, how about this?

          c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                          (c.devices[1].start_blkaddr -

get_sb(main_blkaddr)) / c.blks_per_seg : 0;

Better, but log header should align to start blkaddr of zone?

Thanks,

Quoted 45 lines
Quoted 45 lines

If c.cur_seg[CURSEG_HOT_NODE] was assigned w/ c.devices[0].total_segments, and c.devices[0].total_segments is larger than segments of mainare, c.cur_seg[CURSEG_HOT_NODE] will exceed the end boundary of mainarea.

         c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                         c.devices[0].total_segments : 0;
Quoted 3 lines

In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

I mean blew case:
device[0]: conventional device size = 10240 MB
device[1]: zone device size = 2 MB

Thanks,

Quoted 27 lines
Quoted 27 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
    mkfs/f2fs_format.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
                c.cur_seg[CURSEG_COLD_DATA] = 0;
                c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
        } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
                c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
                c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
                c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
#7 lore raw
Quoted 20 lines · Chao Yu
Quoted 18 lines · Daeho Jeong
Quoted 16 lines · Chao Yu
Quoted 4 lines · Daeho Jeong
Quoted 3 lines · Chao Yu

+Cc Yongpeng Yang

Quoted 8 lines
Quoted 6 lines

Daeho,

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?

Since c.cur_seg[CURSEG_HOT_NODE] is an offset started from main_blkaddr.

Quoted 8 lines
Quoted 6 lines

Oh, Got it.
Then, how about this?

          c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                          (c.devices[1].start_blkaddr -

get_sb(main_blkaddr)) / c.blks_per_seg : 0;

Better, but log header should align to start blkaddr of zone?

It's already aligned here.

        if (c.zoned_mode && c.ndevs > 1)
                zone_align_start_offset +=
                        (c.devices[0].total_sectors * c.sector_size) %

zone_size_bytes;

...

        for (i = 0; i < c.ndevs; i++) {
                if (i == 0) {
                        c.devices[i].total_segments =
                                (c.devices[i].total_sectors *
                                c.sector_size - zone_align_start_offset) /
                                segment_size_bytes;
                        c.devices[i].start_blkaddr = 0;
                        c.devices[i].end_blkaddr = c.devices[i].total_segments *
                                                c.blks_per_seg - 1 +
                                                sb->segment0_blkaddr;
                } else {
                        c.devices[i].total_segments =
                                c.devices[i].total_sectors /
                                (c.sectors_per_blk * c.blks_per_seg);
                        c.devices[i].start_blkaddr =
                                        c.devices[i - 1].end_blkaddr + 1;

...

total_meta_zones = ZONE_ALIGN(total_meta_segments *
c.blks_per_seg);

set_sb(main_blkaddr, get_sb(segment0_blkaddr) + total_meta_zones *
c.segs_per_zone * c.blks_per_seg);

Quoted 48 lines

Thanks,

Quoted 45 lines
Quoted 45 lines

If c.cur_seg[CURSEG_HOT_NODE] was assigned w/ c.devices[0].total_segments, and c.devices[0].total_segments is larger than segments of mainare, c.cur_seg[CURSEG_HOT_NODE] will exceed the end boundary of mainarea.

         c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                         c.devices[0].total_segments : 0;
Quoted 3 lines

In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

I mean blew case:
device[0]: conventional device size = 10240 MB
device[1]: zone device size = 2 MB

Thanks,

Quoted 27 lines
Quoted 27 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
    mkfs/f2fs_format.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
                c.cur_seg[CURSEG_COLD_DATA] = 0;
                c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
        } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
                c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
                c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
                c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
#8 lore raw

cur_seg[CURSEG_COLD_DATA] will exceed end boundary of main area when:
device[1]: zone device size = [2 MB ~ 10MB]

So, if there are not enough seq zones for six cursegs, we should still assign 0 to c.cur_seg[CURSEG_HOT_NODE] or reserve several conv zones for cursegs.

Quoted 112 lines · Daeho Jeong
Quoted 20 lines · Chao Yu
Quoted 18 lines · Daeho Jeong
Quoted 16 lines · Chao Yu
Quoted 4 lines · Daeho Jeong
Quoted 3 lines · Chao Yu

+Cc Yongpeng Yang

Quoted 8 lines
Quoted 6 lines

Daeho,

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?

Since c.cur_seg[CURSEG_HOT_NODE] is an offset started from main_blkaddr.

Quoted 8 lines
Quoted 6 lines

Oh, Got it.
Then, how about this?

           c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                           (c.devices[1].start_blkaddr -

get_sb(main_blkaddr)) / c.blks_per_seg : 0;

Better, but log header should align to start blkaddr of zone?

It's already aligned here.

         if (c.zoned_mode && c.ndevs > 1)
                 zone_align_start_offset +=
                         (c.devices[0].total_sectors * c.sector_size) %

zone_size_bytes;

...

         for (i = 0; i < c.ndevs; i++) {
                 if (i == 0) {
                         c.devices[i].total_segments =
                                 (c.devices[i].total_sectors *
                                 c.sector_size - zone_align_start_offset) /
                                 segment_size_bytes;
                         c.devices[i].start_blkaddr = 0;
                         c.devices[i].end_blkaddr = c.devices[i].total_segments *
                                                 c.blks_per_seg - 1 +
                                                 sb->segment0_blkaddr;
                 } else {
                         c.devices[i].total_segments =
                                 c.devices[i].total_sectors /
                                 (c.sectors_per_blk * c.blks_per_seg);
                         c.devices[i].start_blkaddr =
                                         c.devices[i - 1].end_blkaddr + 1;

...

total_meta_zones = ZONE_ALIGN(total_meta_segments *
c.blks_per_seg);

set_sb(main_blkaddr, get_sb(segment0_blkaddr) + total_meta_zones *
c.segs_per_zone * c.blks_per_seg);

Quoted 48 lines

Thanks,

Quoted 45 lines
Quoted 45 lines

If c.cur_seg[CURSEG_HOT_NODE] was assigned w/ c.devices[0].total_segments, and c.devices[0].total_segments is larger than segments of mainare, c.cur_seg[CURSEG_HOT_NODE] will exceed the end boundary of mainarea.

          c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                          c.devices[0].total_segments : 0;
Quoted 3 lines

In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

I mean blew case:
device[0]: conventional device size = 10240 MB
device[1]: zone device size = 2 MB

Thanks,

Quoted 27 lines
Quoted 27 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
     mkfs/f2fs_format.c | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
                 c.cur_seg[CURSEG_COLD_DATA] = 0;
                 c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
         } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
                 c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
                 c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
                 c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);

A message that is not in the archive (sent off-list or not yet received): CACOAw_zKTPD5epxD2RsvarDJJUxz8LEhFvkWJex19XtY9hxa0w@mail.gmail.com

#10 lore raw
Quoted 11 lines · Daeho Jeong
Quoted 7 lines · Yongpeng Yang

cur_seg[CURSEG_COLD_DATA] will exceed end boundary of main area when:
device[1]: zone device size = [2 MB ~ 10MB]

So, if there are not enough seq zones for six cursegs, we should still assign 0 to c.cur_seg[CURSEG_HOT_NODE] or reserve several conv zones for cursegs.

To tackle that case, how about this?

Quoted 13 lines
         } else if (c.zoned_mode) {
                 c.cur_seg[CURSEG_HOT_NODE] = 0;
                 if (c.zoned_model == F2FS_ZONED_HM) {
                         uint32_t conv_zones =
                                 c.devices[0].total_segments / c.segs_per_zone
                                 - total_meta_zones;

                         if (total_zones - conv_zones >= avail_zones)
                                 c.cur_seg[CURSEG_HOT_NODE] =
                                         (c.devices[1].start_blkaddr -
                                          get_sb(main_blkaddr)) / c.blks_per_seg;
                 }

It seems fine, thanks.

Quoted 114 lines
Quoted 114 lines · Daeho Jeong
Quoted 112 lines · Chao Yu
Quoted 20 lines · Daeho Jeong
Quoted 18 lines · Chao Yu
Quoted 16 lines · Daeho Jeong
Quoted 12 lines · Chao Yu
Quoted 9 lines

+Cc Yongpeng Yang

Daeho,

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?

Since c.cur_seg[CURSEG_HOT_NODE] is an offset started from main_blkaddr.

Quoted 8 lines
Quoted 6 lines

Oh, Got it.
Then, how about this?

            c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                            (c.devices[1].start_blkaddr -

get_sb(main_blkaddr)) / c.blks_per_seg : 0;

Better, but log header should align to start blkaddr of zone?

It's already aligned here.

          if (c.zoned_mode && c.ndevs > 1)
                  zone_align_start_offset +=
                          (c.devices[0].total_sectors * c.sector_size) %

zone_size_bytes;

...

          for (i = 0; i < c.ndevs; i++) {
                  if (i == 0) {
                          c.devices[i].total_segments =
                                  (c.devices[i].total_sectors *
                                  c.sector_size - zone_align_start_offset) /
                                  segment_size_bytes;
                          c.devices[i].start_blkaddr = 0;
                          c.devices[i].end_blkaddr = c.devices[i].total_segments *
                                                  c.blks_per_seg - 1 +
                                                  sb->segment0_blkaddr;
                  } else {
                          c.devices[i].total_segments =
                                  c.devices[i].total_sectors /
                                  (c.sectors_per_blk * c.blks_per_seg);
                          c.devices[i].start_blkaddr =
                                          c.devices[i - 1].end_blkaddr + 1;

...

total_meta_zones = ZONE_ALIGN(total_meta_segments *
c.blks_per_seg);

set_sb(main_blkaddr, get_sb(segment0_blkaddr) + total_meta_zones *
c.segs_per_zone * c.blks_per_seg);

Quoted 48 lines

Thanks,

Quoted 45 lines
Quoted 45 lines

If c.cur_seg[CURSEG_HOT_NODE] was assigned w/ c.devices[0].total_segments, and c.devices[0].total_segments is larger than segments of mainare, c.cur_seg[CURSEG_HOT_NODE] will exceed the end boundary of mainarea.

           c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                           c.devices[0].total_segments : 0;
Quoted 3 lines

In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

I mean blew case:
device[0]: conventional device size = 10240 MB
device[1]: zone device size = 2 MB

Thanks,

Quoted 27 lines
Quoted 27 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
      mkfs/f2fs_format.c | 3 ++-
      1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
                  c.cur_seg[CURSEG_COLD_DATA] = 0;
                  c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
          } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
                  c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
                  c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
                  c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);
#11 lore raw
In reply to Daeho Jeong
Quoted 24 lines · Daeho Jeong
Quoted 23 lines · Chao Yu
Quoted 21 lines · Daeho Jeong
Quoted 8 lines · Chao Yu
Quoted 6 lines · Daeho Jeong
Quoted 5 lines · Chao Yu

+Cc Yongpeng Yang

Daeho,

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Yongpeng reports a potential issue: if c.devices[0].total_segments is larger than segments of mainarea, c.cur_seg[CURSEG_HOT_NODE] will exceed end boundary of mainarea. Could you please check that? though it's a corner case.

Can you elaborate more?

Since c.cur_seg[CURSEG_HOT_NODE] is an offset started from main_blkaddr.

Oh, Got it.
Then, how about this?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
           c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                           (c.devices[1].start_blkaddr -

get_sb(main_blkaddr)) / c.blks_per_seg : 0;

Better, but log header should align to start blkaddr of zone?

It's already aligned here.

Ah, thanks for the explanation. :)

Thanks,

Quoted 81 lines
         if (c.zoned_mode && c.ndevs > 1)
                 zone_align_start_offset +=
                         (c.devices[0].total_sectors * c.sector_size) %

zone_size_bytes;

...

         for (i = 0; i < c.ndevs; i++) {
                 if (i == 0) {
                         c.devices[i].total_segments =
                                 (c.devices[i].total_sectors *
                                 c.sector_size - zone_align_start_offset) /
                                 segment_size_bytes;
                         c.devices[i].start_blkaddr = 0;
                         c.devices[i].end_blkaddr = c.devices[i].total_segments *
                                                 c.blks_per_seg - 1 +
                                                 sb->segment0_blkaddr;
                 } else {
                         c.devices[i].total_segments =
                                 c.devices[i].total_sectors /
                                 (c.sectors_per_blk * c.blks_per_seg);
                         c.devices[i].start_blkaddr =
                                         c.devices[i - 1].end_blkaddr + 1;

...

total_meta_zones = ZONE_ALIGN(total_meta_segments *
c.blks_per_seg);

set_sb(main_blkaddr, get_sb(segment0_blkaddr) + total_meta_zones *
c.segs_per_zone * c.blks_per_seg);

Quoted 48 lines

Thanks,

Quoted 45 lines
Quoted 45 lines

If c.cur_seg[CURSEG_HOT_NODE] was assigned w/ c.devices[0].total_segments, and c.devices[0].total_segments is larger than segments of mainare, c.cur_seg[CURSEG_HOT_NODE] will exceed the end boundary of mainarea.

          c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
                          c.devices[0].total_segments : 0;
Quoted 3 lines

In the case of F2FS_ZONED_HM, we have the devices[1].
Do you mean the case we format the filesystem intentionally smaller than what devices have?

I mean blew case:
device[0]: conventional device size = 10240 MB
device[1]: zone device size = 2 MB

Thanks,

Quoted 27 lines
Quoted 27 lines · Daeho Jeong
Quoted 24 lines

From: Daeho Jeong <[email protected]>

Make to allocate logs after conventional area for HM zoned devices to spare them for file pinning support.

---
     mkfs/f2fs_format.c | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
mkfs/f2fs_format.c +2 -1
index f2840c8..91a7f4b 100644
@@ -557,7 +557,8 @@ static int f2fs_prepare_super_block(void)
                 c.cur_seg[CURSEG_COLD_DATA] = 0;
                 c.cur_seg[CURSEG_WARM_DATA] = next_zone(CURSEG_COLD_DATA);
         } else if (c.zoned_mode) {
-             c.cur_seg[CURSEG_HOT_NODE] = 0;
+             c.cur_seg[CURSEG_HOT_NODE] = c.zoned_model == F2FS_ZONED_HM ?
+                     c.devices[0].total_segments : 0;
                 c.cur_seg[CURSEG_WARM_NODE] = next_zone(CURSEG_HOT_NODE);
                 c.cur_seg[CURSEG_COLD_NODE] = next_zone(CURSEG_WARM_NODE);
                 c.cur_seg[CURSEG_HOT_DATA] = next_zone(CURSEG_COLD_NODE);