f2fs: fix wrong segment count
Jaegeuk Kim
maintainerPATCH 1/1 f2fs: fix wrong segment count
MAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.
--- fs/f2fs/segment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/segment.h +2 -2
@@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,static inline void check_seg_range (struct f2fs_sb_info *sbi,unsigned int segno) { -f2fs_bug_on (sbi, segno >TOTAL_SEGS (sbi) -1 ); +f2fs_bug_on (sbi, segno >MAIN_SEGS (sbi) -1 ); }static inline void verify_fio_blkaddr (struct f2fs_io_info *fio)
@@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,/* check segment usage, and check boundary of a given segment number */ if (unlikely (GET_SIT_VBLOCKS (raw_sit) > usable_blks_per_seg - || segno >TOTAL_SEGS (sbi) -1 )) { + || segno >MAIN_SEGS (sbi) -1 )) {f2fs_err (sbi,"Wrong valid blocks %d or segno %u" ,GET_SIT_VBLOCKS (raw_sit), segno);set_sbi_flag (sbi,SBI_NEED_FSCK );
Signature · 1 line
2.39.1.581.gbfd45094c4-goog
Chao Yu
maintainerQuoted 1 line · Jaegeuk Kim
MAIN_SEGSis for data area, whileTOTAL_SEGSincludes data and metadata.
Good catch!
Could you please add fixes line?
Thanks,
Quoted 20 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/segment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/f2fs/segment.h +1
-1@@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,static inline void check_seg_range (struct f2fs_sb_info *sbi,unsigned int segno) { -f2fs_bug_on (sbi, segno >TOTAL_SEGS (sbi) -1 ); +f2fs_bug_on (sbi, segno >MAIN_SEGS (sbi) -1 ); }static inline void verify_fio_blkaddr (struct f2fs_io_info *fio)
fs/f2fs/segment.h static inline int check_block_count(struct f2fs_sb_info *sbi, · line 781
Quoted 8 lines
fs/f2fs/segment.h +1
-1@@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,/* check segment usage, and check boundary of a given segment number */ if (unlikely (GET_SIT_VBLOCKS (raw_sit) > usable_blks_per_seg - || segno >TOTAL_SEGS (sbi) -1 )) { + || segno >MAIN_SEGS (sbi) -1 )) {f2fs_err (sbi,"Wrong valid blocks %d or segno %u" ,GET_SIT_VBLOCKS (raw_sit), segno);set_sbi_flag (sbi,SBI_NEED_FSCK );
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 6 lines · Chao Yu
Quoted 1 line · Jaegeuk Kim
MAIN_SEGSis for data area, whileTOTAL_SEGSincludes data and metadata.Good catch!
Could you please add fixes line?
It seems this is not a bug case, and exisits from the first F2FS patch. :)
Quoted 28 lines
Thanks,
Quoted 25 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/segment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/f2fs/segment.h +2
-2@@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,static inline void check_seg_range (struct f2fs_sb_info *sbi,unsigned int segno) { -f2fs_bug_on (sbi, segno >TOTAL_SEGS (sbi) -1 ); +f2fs_bug_on (sbi, segno >MAIN_SEGS (sbi) -1 ); }static inline void verify_fio_blkaddr (struct f2fs_io_info *fio)@@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,/* check segment usage, and check boundary of a given segment number */ if (unlikely (GET_SIT_VBLOCKS (raw_sit) > usable_blks_per_seg - || segno >TOTAL_SEGS (sbi) -1 )) { + || segno >MAIN_SEGS (sbi) -1 )) {f2fs_err (sbi,"Wrong valid blocks %d or segno %u" ,GET_SIT_VBLOCKS (raw_sit), segno);set_sbi_flag (sbi,SBI_NEED_FSCK );
Quoted 9 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 1 line · Jaegeuk Kim
MAIN_SEGSis for data area, whileTOTAL_SEGSincludes data and metadata.Good catch!
Could you please add fixes line?
It seems this is not a bug case, and exisits from the first F2FS patch. :)
Alright, anyway, it looks good to me.
Thanks,
Quoted 29 lines
Quoted 29 lines
Thanks,
Quoted 25 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/segment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/f2fs/segment.h +2
-2@@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,static inline void check_seg_range (struct f2fs_sb_info *sbi,unsigned int segno) { -f2fs_bug_on (sbi, segno >TOTAL_SEGS (sbi) -1 ); +f2fs_bug_on (sbi, segno >MAIN_SEGS (sbi) -1 ); }static inline void verify_fio_blkaddr (struct f2fs_io_info *fio)@@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,/* check segment usage, and check boundary of a given segment number */ if (unlikely (GET_SIT_VBLOCKS (raw_sit) > usable_blks_per_seg - || segno >TOTAL_SEGS (sbi) -1 )) { + || segno >MAIN_SEGS (sbi) -1 )) {f2fs_err (sbi,"Wrong valid blocks %d or segno %u" ,GET_SIT_VBLOCKS (raw_sit), segno);set_sbi_flag (sbi,SBI_NEED_FSCK );
Jaegeuk Kim
maintainerQuoted 7 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 5 lines · Chao Yu
Quoted 1 line · Jaegeuk Kim
MAIN_SEGSis for data area, whileTOTAL_SEGSincludes data and metadata.Good catch!
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Could you please add fixes line?
It seems this is not a bug case, and exisits from the first F2FS patch. :)
Alright, anyway, it looks good to me.
Reviewed-by Chao Yu <[email protected]>
I assumed this for v2. Let me know if you have other concern.
Quoted 32 lines
Thanks,
Quoted 29 lines
Quoted 29 lines
Thanks,
Quoted 25 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/segment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/f2fs/segment.h +2
-2@@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,static inline void check_seg_range (struct f2fs_sb_info *sbi,unsigned int segno) { -f2fs_bug_on (sbi, segno >TOTAL_SEGS (sbi) -1 ); +f2fs_bug_on (sbi, segno >MAIN_SEGS (sbi) -1 ); }static inline void verify_fio_blkaddr (struct f2fs_io_info *fio)@@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,/* check segment usage, and check boundary of a given segment number */ if (unlikely (GET_SIT_VBLOCKS (raw_sit) > usable_blks_per_seg - || segno >TOTAL_SEGS (sbi) -1 )) { + || segno >MAIN_SEGS (sbi) -1 )) {f2fs_err (sbi,"Wrong valid blocks %d or segno %u" ,GET_SIT_VBLOCKS (raw_sit), segno);set_sbi_flag (sbi,SBI_NEED_FSCK );
Jaegeuk Kim
maintainerMAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.
---
Change log from v1:
- replace check_seg_range with valid_main_segno to avoid confusion.
fs/f2fs/segment.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/f2fs/segment.h +5 -4
@@ -719,9 +719,10 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,return curseg->alloc_type; } -static inline void check_seg_range (struct f2fs_sb_info *sbi,unsigned int segno) +static inline bool valid_main_segno (struct f2fs_sb_info *sbi, +unsigned int segno) { -f2fs_bug_on (sbi, segno >TOTAL_SEGS (sbi) -1 ); +return segno <= (MAIN_SEGS (sbi) -1 ); }static inline void verify_fio_blkaddr (struct f2fs_io_info *fio)
@@ -776,7 +777,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,/* check segment usage, and check boundary of a given segment number */ if (unlikely (GET_SIT_VBLOCKS (raw_sit) > usable_blks_per_seg - || segno >TOTAL_SEGS (sbi) -1 )) { + || !valid_main_segno (sbi, segno))) {f2fs_err (sbi,"Wrong valid blocks %d or segno %u" ,GET_SIT_VBLOCKS (raw_sit), segno);set_sbi_flag (sbi,SBI_NEED_FSCK );
@@ -793,7 +794,7 @@ static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,unsigned int offset =SIT_BLOCK_OFFSET (start);block_t blk_addr = sit_i->sit_base_addr + offset; -check_seg_range (sbi, start); +f2fs_bug_on (sbi, !valid_main_segno (sbi, start));#ifdef CONFIG_F2FS_CHECK_FS if (f2fs_test_bit(offset, sit_i->sit_bitmap) !=
Signature · 8 lines
2.39.1.581.gbfd45094c4-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel