Skip to content

Commit c86df2b

Browse files
Jaegeuk Kimgregkh
authored andcommitted
f2fs: handle unallocated section and zone on pinned/atgc
[ Upstream commit 632faca ] If we have large section/zone, unallocated segment makes them corrupted. E.g., - Pinned file: -1 119304647 119304647 - ATGC data: -1 119304647 119304647 Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cc52ed1 commit c86df2b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎fs/f2fs/segment.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,
101101
#define BLKS_PER_SEC(sbi) \
102102
((sbi)->segs_per_sec * (sbi)->blocks_per_seg)
103103
#define GET_SEC_FROM_SEG(sbi, segno) \
104-
((segno) / (sbi)->segs_per_sec)
104+
(((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)
105105
#define GET_SEG_FROM_SEC(sbi, secno) \
106106
((secno) * (sbi)->segs_per_sec)
107107
#define GET_ZONE_FROM_SEC(sbi, secno) \
108-
((secno) / (sbi)->secs_per_zone)
108+
(((secno) == -1) ? -1: (secno) / (sbi)->secs_per_zone)
109109
#define GET_ZONE_FROM_SEG(sbi, segno) \
110110
GET_ZONE_FROM_SEC(sbi, GET_SEC_FROM_SEG(sbi, segno))
111111

0 commit comments

Comments
 (0)