On 2025/11/6 17:15, Yongpeng Yang wrote:
From: Yongpeng Yang <[email protected]>

sbi->unusable_blocks_per_sec is used only within CONFIG_BLK_DEV_ZONED
sections, except for CAP_BLKS_PER_SEC and CAP_SEGS_PER_SEC. This patch
renames unusable_blocks_per_sec to unusable_blocks_per_blkz and ensures
that unusable_blocks_per_blkz is properly enclosed within the
CONFIG_BLK_DEV_ZONED.

Signed-off-by: Yongpeng Yang <[email protected]>
---
  fs/f2fs/f2fs.h    | 2 +-
  fs/f2fs/segment.c | 3 +--
  fs/f2fs/segment.h | 9 +++++++--
  fs/f2fs/super.c   | 6 +++---
  fs/f2fs/sysfs.c   | 4 ++--
  5 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 5b4e9548a231..c47a09c7f7e7 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1661,6 +1661,7 @@ struct f2fs_sb_info {
#ifdef CONFIG_BLK_DEV_ZONED
        unsigned int blocks_per_blkz;           /* F2FS blocks per zone */
+       unsigned int unusable_blocks_per_blkz;  /* F2FS unusable blocks per 
zone */
        unsigned int max_open_zones;            /* max open zone resources of 
the zoned device */
        /* For adjust the priority writing position of data in zone UFS */
        unsigned int blkzone_alloc_policy;
@@ -1732,7 +1733,6 @@ struct f2fs_sb_info {
        unsigned int meta_ino_num;              /* meta inode number*/
        unsigned int log_blocks_per_seg;        /* log2 blocks per segment */
        unsigned int blocks_per_seg;            /* blocks per segment */
-       unsigned int unusable_blocks_per_sec;   /* unusable blocks per section 
*/
        unsigned int segs_per_sec;              /* segments per section */
        unsigned int secs_per_zone;             /* sections per zone */
        unsigned int total_sections;            /* total section count */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b45eace879d7..54ad774ee338 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -5567,7 +5567,7 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(
        block_t seg_start, sec_start_blkaddr, sec_cap_blkaddr;
        unsigned int secno;
- if (!sbi->unusable_blocks_per_sec)
+       if (!sbi->unusable_blocks_per_blkz)
                return BLKS_PER_SEG(sbi);
secno = GET_SEC_FROM_SEG(sbi, segno);
@@ -5599,7 +5599,6 @@ static inline unsigned int 
f2fs_usable_zone_blks_in_seg(struct f2fs_sb_info *sbi
  {
        return 0;
  }
-
  #endif
  unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi,
                                        unsigned int segno)
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 1ce2c8abaf48..0a1ca929ce1a 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -69,11 +69,16 @@ static inline void sanity_check_seg_type(struct 
f2fs_sb_info *sbi,
        ((!__is_valid_data_blkaddr(blk_addr)) ?                 \
        NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi),                 \
                GET_SEGNO_FROM_SEG0(sbi, blk_addr)))
+#ifdef CONFIG_BLK_DEV_ZONED
  #define CAP_BLKS_PER_SEC(sbi)                                 \
-       (BLKS_PER_SEC(sbi) - (sbi)->unusable_blocks_per_sec)
+       (BLKS_PER_SEC(sbi) - (sbi)->unusable_blocks_per_blkz)
  #define CAP_SEGS_PER_SEC(sbi)                                 \
        (SEGS_PER_SEC(sbi) -                                    \
-       BLKS_TO_SEGS(sbi, (sbi)->unusable_blocks_per_sec))
+       BLKS_TO_SEGS(sbi, (sbi)->unusable_blocks_per_blkz))
+#else
+#define CAP_BLKS_PER_SEC(sbi) BLKS_PER_SEC(sbi)
+#define CAP_SEGS_PER_SEC(sbi) SEGS_PER_SEC(sbi)
+#endif
  #define GET_START_SEG_FROM_SEC(sbi, segno)                    \
        (rounddown(segno, SEGS_PER_SEC(sbi)))
  #define GET_SEC_FROM_SEG(sbi, segno)                          \
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index db7afb806411..c055032593b7 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4333,11 +4333,11 @@ static int f2fs_report_zone_cb(struct blk_zone *zone, 
unsigned int idx,
                return 0;
set_bit(idx, rz_args->dev->blkz_seq);
-       if (!rz_args->sbi->unusable_blocks_per_sec) {
-               rz_args->sbi->unusable_blocks_per_sec = unusable_blocks;
+       if (!rz_args->sbi->unusable_blocks_per_blkz) {
+               rz_args->sbi->unusable_blocks_per_blkz = unusable_blocks;
                return 0;
        }
-       if (rz_args->sbi->unusable_blocks_per_sec != unusable_blocks) {
+       if (rz_args->sbi->unusable_blocks_per_blkz != unusable_blocks) {
                f2fs_err(rz_args->sbi, "F2FS supports single zone capacity\n");
                return -EINVAL;
        }
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 6d2a4fba68a2..98d2cb60e806 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -1209,7 +1209,7 @@ F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
  /* read extent cache */
  F2FS_SBI_GENERAL_RW_ATTR(max_read_extent_count);
  #ifdef CONFIG_BLK_DEV_ZONED
-F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
+F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_blkz);

Yongpeng,

We need to keep userspace sysfs API stable, can we keep the original name?

Thanks,

  F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
  #endif
  F2FS_SBI_GENERAL_RW_ATTR(carve_out);
@@ -1383,7 +1383,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(avg_vblocks),
  #endif
  #ifdef CONFIG_BLK_DEV_ZONED
-       ATTR_LIST(unusable_blocks_per_sec),
+       ATTR_LIST(unusable_blocks_per_blkz),
        ATTR_LIST(blkzone_alloc_policy),
  #endif
  #ifdef CONFIG_F2FS_FS_COMPRESSION



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to