f2fs: rename and refactor sbi->unusable_blocks_per_sec
PATCH 1/2 f2fs: rename and refactor sbi->unusable_blocks_per_sec
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.
--- 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(-)
fs/f2fs/f2fs.h +1 -1
@@ -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 */
fs/f2fs/segment.c +1 -2
@@ -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)
fs/f2fs/segment.h +7 -2
@@ -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) \
fs/f2fs/super.c +3 -3
@@ -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 ; }
fs/f2fs/sysfs.c +2 -2
@@ -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);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
Signature · 8 lines
2.43.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 2/2 f2fs: fix handling of block devices with max_open_zones == 0
From: Yongpeng Yang <[email protected]>
When the block device reports max_open_zones == 0, sbi->max_open_zones is initialized to UINT_MAX. In such cases, F2FS can still be mounted successfully (as tested under qemu).
However, for SSDs, a device reporting max_open_zones == 0 should not be mountable, while for SMR HDDs this is acceptable.
Fix this issue by handling max_open_zones == 0 properly:
- Disallow mounting on SSDs when max_open_zones == 0.
- For SMR HDDs, set max_open_zones to the total number of zones.
- Remove redundant zoned device checks.
- Add a sysfs entry to expose max_open_zones.
--- fs/f2fs/super.c | 36 +++++++++++++++++++++--------------- fs/f2fs/sysfs.c | 2 ++ 2 files changed, 23 insertions(+), 15 deletions(-)
fs/f2fs/super.c +21 -15
@@ -4353,21 +4353,6 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)unsigned int max_open_zones;int ret; -if (!f2fs_sb_has_blkzoned (sbi)) -return 0 ; - -if (bdev_is_zoned (FDEV (devi).bdev)) { - max_open_zones =bdev_max_open_zones (bdev); -if (max_open_zones && (max_open_zones < sbi->max_open_zones)) - sbi->max_open_zones = max_open_zones; -if (sbi->max_open_zones <F2FS_OPTION (sbi).active_logs) { -f2fs_err (sbi, -"zoned: max open zones %u is too small, need at least %u open zones" , - sbi->max_open_zones,F2FS_OPTION (sbi).active_logs); -return -EINVAL ; - } - } - zone_sectors =bdev_zone_sectors (bdev);if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=SECTOR_TO_BLOCK (zone_sectors))
@@ -4378,6 +4363,27 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)if (nr_sectors & (zone_sectors -1 ))FDEV (devi).nr_blkz++; + max_open_zones =bdev_max_open_zones (bdev); +if (!max_open_zones) { +/* +* SSDs require max_open_zones > 0 to be mountable. +* For HDDs, if max_open_zones is reported as 0, it doesn't matter, +* set it to FDEV(devi).nr_blkz. +*/ +if (bdev_nonrot (bdev)) { +f2fs_err (sbi,"zoned: SSD device %s without open zones" ,FDEV (devi).path); +return -EINVAL ; + } + max_open_zones =FDEV (devi).nr_blkz; + } + sbi->max_open_zones = min_t(unsigned int, max_open_zones, sbi->max_open_zones); +if (sbi->max_open_zones <F2FS_OPTION (sbi).active_logs) { +f2fs_err (sbi, +"zoned: max open zones %u is too small, need at least %u open zones" , + sbi->max_open_zones,F2FS_OPTION (sbi).active_logs); +return -EINVAL ; + } + FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi, BITS_TO_LONGS(FDEV(devi).nr_blkz) * sizeof(unsigned long),
fs/f2fs/sysfs.c +2 -0
@@ -1210,6 +1210,7 @@ F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);F2FS_SBI_GENERAL_RW_ATTR (max_read_extent_count);#ifdef CONFIG_BLK_DEV_ZONED F2FS_SBI_GENERAL_RO_ATTR (unusable_blocks_per_blkz); +F2FS_SBI_GENERAL_RO_ATTR (max_open_zones);F2FS_SBI_GENERAL_RW_ATTR (blkzone_alloc_policy);#endif F2FS_SBI_GENERAL_RW_ATTR (carve_out);
@@ -1384,6 +1385,7 @@ static struct attribute *f2fs_attrs[] = {#endif #ifdef CONFIG_BLK_DEV_ZONED ATTR_LIST (unusable_blocks_per_blkz), +ATTR_LIST (max_open_zones),ATTR_LIST (blkzone_alloc_policy), #endif #ifdef CONFIG_F2FS_FS_COMPRESSION
Signature · 8 lines
2.43.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/2] f2fs: fix handling of block devices with max_open_zones == 0
Quoted 25 lines · Yongpeng Yang
From: Yongpeng Yang <[email protected]>
When the block device reports
max_open_zones== 0,sbi->max_open_zonesis initialized toUINT_MAX. In such cases, F2FS can still be mounted successfully (as tested under qemu).
However, for SSDs, a device reportingmax_open_zones== 0 should not be mountable, while for SMR HDDs this is acceptable.
Fix this issue by handlingmax_open_zones== 0 properly:
- Disallow mounting on SSDs whenmax_open_zones== 0.
- For SMR HDDs, setmax_open_zonesto the total number of zones.
- Remove redundant zoned device checks.
- Add a sysfs entry to exposemax_open_zones.Fixes 0f9b12142be1af("f2fs: fix zoned block device information initialization")Signed-off-by Yongpeng Yang <[email protected]>--- fs/f2fs/super.c | 36 +++++++++++++++++++++--------------- fs/f2fs/sysfs.c | 2 ++ 2 files changed, 23 insertions(+), 15 deletions(-)fs/f2fs/super.c +0
-0
fs/f2fs/super.c static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) · line 4357
Quoted 5 lines
fs/f2fs/super.c +0
-2@@ -4353,21 +4353,6 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)unsigned int max_open_zones;int ret; -if (!f2fs_sb_has_blkzoned (sbi)) -return 0 ;
init_blkz_info() should only be called if blkzoned feature is on?
Quoted 17 lines
fs/f2fs/super.c +0
-13- -if (bdev_is_zoned (FDEV (devi).bdev)) { - max_open_zones =bdev_max_open_zones (bdev); -if (max_open_zones && (max_open_zones < sbi->max_open_zones)) - sbi->max_open_zones = max_open_zones; -if (sbi->max_open_zones <F2FS_OPTION (sbi).active_logs) { -f2fs_err (sbi, -"zoned: max open zones %u is too small, need at least %u open zones" , - sbi->max_open_zones,F2FS_OPTION (sbi).active_logs); -return -EINVAL ; - } - } - zone_sectors =bdev_zone_sectors (bdev);if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=SECTOR_TO_BLOCK (zone_sectors))
fs/f2fs/super.c static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) · line 4369
Quoted 7 lines
fs/f2fs/super.c +4
-0@@ -4378,6 +4363,27 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)if (nr_sectors & (zone_sectors -1 ))FDEV (devi).nr_blkz++; + max_open_zones =bdev_max_open_zones (bdev); +if (!max_open_zones) { +/* +* SSDs require max_open_zones > 0 to be mountable.
Do you mean we enabled blkzoned feature on a zoned SSD? Such SSD can report zeroed max_open_zones? If so, can you please add more details in commit message?
Quoted 25 lines
fs/f2fs/super.c +17
-0+* For HDDs, if max_open_zones is reported as 0, it doesn't matter, +* set it to FDEV(devi).nr_blkz. +*/ +if (bdev_nonrot (bdev)) { +f2fs_err (sbi,"zoned: SSD device %s without open zones" ,FDEV (devi).path); +return -EINVAL ; + } + max_open_zones =FDEV (devi).nr_blkz; + } + sbi->max_open_zones = min_t(unsigned int, max_open_zones, sbi->max_open_zones); +if (sbi->max_open_zones <F2FS_OPTION (sbi).active_logs) { +f2fs_err (sbi, +"zoned: max open zones %u is too small, need at least %u open zones" , + sbi->max_open_zones,F2FS_OPTION (sbi).active_logs); +return -EINVAL ; + } + FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi, BITS_TO_LONGS(FDEV(devi).nr_blkz) * sizeof(unsigned long),fs/f2fs/sysfs.c +0
-0
fs/f2fs/sysfs.c F2FS_SBI_GENERAL_RW_ATTR(last_age_weight); · line 1213
Quoted 4 lines
fs/f2fs/sysfs.c +1
-0@@ -1210,6 +1210,7 @@ F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);F2FS_SBI_GENERAL_RW_ATTR (max_read_extent_count);#ifdef CONFIG_BLK_DEV_ZONED F2FS_SBI_GENERAL_RO_ATTR (unusable_blocks_per_blkz); +F2FS_SBI_GENERAL_RO_ATTR (max_open_zones);
Need to update manual page as well, what about adding this new sysfs entry in a separated patch?
Thanks,
fs/f2fs/sysfs.c static struct attribute *f2fs_attrs[] = { · line 1391
Quoted 11 lines
fs/f2fs/sysfs.c +1
-0F2FS_SBI_GENERAL_RW_ATTR (blkzone_alloc_policy);#endif F2FS_SBI_GENERAL_RW_ATTR (carve_out);@@ -1384,6 +1385,7 @@ static struct attribute *f2fs_attrs[] = {#endif #ifdef CONFIG_BLK_DEV_ZONED ATTR_LIST (unusable_blocks_per_blkz), +ATTR_LIST (max_open_zones),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
Re: [f2fs-dev] [PATCH 2/2] f2fs: fix handling of block devices with max_open_zones == 0
Quoted 21 lines · On 11/8/25 10:57, Chao Yu via Linux-f2fs-devel wrote:
Quoted 20 lines · Yongpeng Yang
From: Yongpeng Yang <[email protected]>
When the block device reports
max_open_zones== 0,sbi->max_open_zonesis initialized toUINT_MAX. In such cases, F2FS can still be mounted successfully (as tested under qemu).
However, for SSDs, a device reportingmax_open_zones== 0 should not be mountable, while for SMR HDDs this is acceptable.
Fix this issue by handlingmax_open_zones== 0 properly:
- Disallow mounting on SSDs whenmax_open_zones== 0.
- For SMR HDDs, setmax_open_zonesto the total number of zones.
- Remove redundant zoned device checks.
- Add a sysfs entry to exposemax_open_zones.Fixes 0f9b12142be1af("f2fs: fix zoned block device information initialization")Signed-off-by Yongpeng Yang <[email protected]>---
fs/f2fs/super.c| 36 +++++++++++++++++++++---------------fs/f2fs/sysfs.c| 2 ++2 files changed, 23 insertions(+), 15 deletions(-)
Quoted 13 lines
fs/f2fs/super.c static int init_blkz_info(struct f2fs_sb_info · line 4357
Quoted 10 lines
fs/f2fs/super.c +0
-2@@ -4353,21 +4353,6 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) unsigned int max_open_zones; int ret; - if (!f2fs_sb_has_blkzoned(sbi)) - return 0;
init_blkz_info()should only be called if blkzoned feature is on?
Yes, init_blkz_info() is only called by f2fs_scan_devices(), and the blkzoned feature has already been checked there. So there’s no need to check it again.
Quoted 20 lines
Quoted 20 lines
fs/f2fs/super.c +0
-13- - if (bdev_is_zoned(FDEV(devi).bdev)) { - max_open_zones = bdev_max_open_zones(bdev); - if (max_open_zones && (max_open_zones < sbi->max_open_zones)) - sbi->max_open_zones = max_open_zones; - if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { - f2fs_err(sbi, - "zoned: max open zones %u is too small, need at least %u open zones", - sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); - return -EINVAL; - } - } - zone_sectors = bdev_zone_sectors(bdev);if (
sbi->blocks_per_blkz&&sbi->blocks_per_blkz!=SECTOR_TO_BLOCK(zone_sectors))fs/f2fs/super.c +0
-0@@ -4378,6 +4363,27 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) if (nr_sectors & (zone_sectors - 1))
Quoted 9 lines
fs/f2fs/super.c static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) · line 4369
Quoted 5 lines
fs/f2fs/super.c +4
-0FDEV(devi).nr_blkz++; + max_open_zones = bdev_max_open_zones(bdev); + if (!max_open_zones) { + /* +* SSDs require max_open_zones > 0 to be mountable. Do you mean we enabled blkzoned feature on a zoned SSD? Such SSD can report zeroed
max_open_zones? If so, can you please add more details in commit message?
Yes, I tested with a ZNS SSD emulated on qemu and set zoned.max_open to
0. f2fs with zns ssd and conventional ssd can be mounted normally, and sbi->max_open_zones is UINT_MAX. I will add more explanations in the v2 patch.
Quoted 37 lines
Quoted 29 lines
fs/f2fs/super.c +13
-0+* For HDDs, if max_open_zones is reported as 0, it doesn't matter, +* set it to FDEV(devi).nr_blkz. +*/ + if (bdev_nonrot(bdev)) { + f2fs_err(sbi, "zoned: SSD device %s without open zones",FDEV (devi).path); + return -EINVAL; + } + max_open_zones = FDEV(devi).nr_blkz; + } + sbi->max_open_zones = min_t(unsigned int, max_open_zones, sbi- >max_open_zones); + if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { + f2fs_err(sbi, + "zoned: max open zones %u is too small, need at least %uopen zones",
+sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); + return-EINVAL;
+ }
+
FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi, BITS_TO_LONGS(FDEV(devi).nr_blkz)
* sizeof(unsigned long),fs/f2fs/sysfs.c +0
-0fs/f2fs/sysfs.c F2FS_SBI_GENERAL_RW_ATTR(last_age_weight); · line 1213
Quoted 4 lines
fs/f2fs/sysfs.c +1
-0@@ -1210,6 +1210,7 @@ F2FS_SBI_GENERAL_RW_ATTR(last_age_weight); F2FS_SBI_GENERAL_RW_ATTR(max_read_extent_count); #ifdef CONFIG_BLK_DEV_ZONED F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_blkz); +F2FS_SBI_GENERAL_RO_ATTR (max_open_zones);Need to update manual page as well, what about adding this new sysfs entry in a separated patch?
Quoted 2 lines
Thanks,
I agree, it makes more sense to split them. I’ll separate the patch and update manual page in v2.
Yongpeng,
Quoted 10 lines
Quoted 10 lines
fs/f2fs/sysfs.c +1
-0F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy); #endif F2FS_SBI_GENERAL_RW_ATTR(carve_out);@@ -1384,6 +1385,7 @@ static struct attribute *f2fs_attrs[] = { #endif #ifdef CONFIG_BLK_DEV_ZONED ATTR_LIST(unusable_blocks_per_blkz), + ATTR_LIST(max_open_zones), ATTR_LIST(blkzone_alloc_policy), #endif
Quoted 8 lines
fs/f2fs/sysfs.c static struct attribute *f2fs_attrs[] = { · line 1391
Quoted 1 line
fs/f2fs/sysfs.c +0
-0#ifdef CONFIG_F2FS_FS_COMPRESSION_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 105 lines · Yongpeng Yang
From: Yongpeng Yang <[email protected]>
sbi->unusable_blocks_per_secis used only withinCONFIG_BLK_DEV_ZONEDsections, except forCAP_BLKS_PER_SECandCAP_SEGS_PER_SEC. This patch renamesunusable_blocks_per_sectounusable_blocks_per_blkzand ensures thatunusable_blocks_per_blkzis properly enclosed within theCONFIG_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(-)fs/f2fs/f2fs.h +1
-1@@ -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 */ fs/f2fs/segment.c +1
-2@@ -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)fs/f2fs/segment.h +7
-2@@ -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) \fs/f2fs/super.c +3
-3@@ -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 ; }fs/f2fs/sysfs.c +0
-0
fs/f2fs/sysfs.c F2FS_SBI_GENERAL_RW_ATTR(last_age_weight); · line 1212
Quoted 5 lines
fs/f2fs/sysfs.c +1
-1@@ -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,
fs/f2fs/sysfs.c static struct attribute *f2fs_attrs[] = { · line 1389
Quoted 12 lines
fs/f2fs/sysfs.c +1
-1F2FS_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
Quoted 116 lines · On 11/8/25 10:41, Chao Yu via Linux-f2fs-devel wrote:
Quoted 107 lines · Yongpeng Yang
From: Yongpeng Yang <[email protected]>
sbi->unusable_blocks_per_secis used only withinCONFIG_BLK_DEV_ZONEDsections, except forCAP_BLKS_PER_SECandCAP_SEGS_PER_SEC. This patch renamesunusable_blocks_per_sectounusable_blocks_per_blkzand ensures thatunusable_blocks_per_blkzis properly enclosed within theCONFIG_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(-)fs/f2fs/f2fs.h +0
-0@@ -1661,6 +1661,7 @@ struct f2fs_sb_info { #ifdef CONFIG_BLK_DEV_ZONEDunsigned 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 intblkzone_alloc_policy;fs/f2fs/f2fs.h +0
-0@@ -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 */fs/f2fs/segment.c +0
-0@@ -5567,7 +5567,7 @@ static inline unsigned intf2fs_usable_zone_blks_in_seg(
block_tseg_start,sec_start_blkaddr,sec_cap_blkaddr; unsigned int secno;
- if (!sbi->unusable_blocks_per_sec)
+ if (!sbi->unusable_blocks_per_blkz)
returnBLKS_PER_SEG(sbi);
secno =GET_SEC_FROM_SEG(sbi, segno);fs/f2fs/segment.c +0
-0@@ -5599,7 +5599,6 @@ static inline unsigned intf2fs_usable_zone_blks_in_seg(struct
f2fs_sb_info*sbi {
return 0;
}
-
#endif
unsigned intf2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi, unsigned int segno)fs/f2fs/segment.h +7
-2@@ -69,11 +69,16 @@ static inline void sanity_check_seg_type(structf2fs_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)\fs/f2fs/super.c +3
-3@@ -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; }fs/f2fs/sysfs.c +0
-0fs/f2fs/sysfs.c F2FS_SBI_GENERAL_RW_ATTR(last_age_weight); · line 1212
Quoted 5 lines
fs/f2fs/sysfs.c +1
-1@@ -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,
Quoted 3 lines
We need to keep userspace sysfs API stable, can we keep the original name?
Thanks,
I agree, I didn’t consider the userspace sysfs API previously. I’ll revert the renaming of the unusable_blocks_per_sec in the v2 patch
Yongpeng,
Quoted 12 lines
Quoted 12 lines
fs/f2fs/sysfs.c +1
-1F2FS_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
Quoted 8 lines
fs/f2fs/sysfs.c static struct attribute *f2fs_attrs[] = { · line 1389
Quoted 1 line
fs/f2fs/sysfs.c +0
-0#ifdef CONFIG_F2FS_FS_COMPRESSION_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel