7878 ((((blk_addr) == NULL_ADDR) || ((blk_addr) == NEW_ADDR)) ? \
7979 NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \
8080 GET_SEGNO_FROM_SEG0(sbi, blk_addr)))
81- #define GET_SECNO (sbi , segno ) \
81+ #define BLKS_PER_SEC (sbi ) \
82+ ((sbi)->segs_per_sec * (sbi)->blocks_per_seg)
83+ #define GET_SEC_FROM_SEG (sbi , segno ) \
8284 ((segno) / (sbi)->segs_per_sec)
83- #define GET_SEGNO_FROM_SECNO (sbi , secno ) \
85+ #define GET_SEG_FROM_SEC (sbi , secno ) \
8486 ((secno) * (sbi)->segs_per_sec)
85- #define GET_ZONENO_FROM_SEGNO (sbi , segno ) \
86- (((segno) / (sbi)->segs_per_sec) / (sbi)->secs_per_zone)
87+ #define GET_ZONE_FROM_SEC (sbi , secno ) \
88+ ((secno) / (sbi)->secs_per_zone)
89+ #define GET_ZONE_FROM_SEG (sbi , segno ) \
90+ GET_ZONE_FROM_SEC(sbi, GET_SEC_FROM_SEG(sbi, segno))
8791
8892#define GET_SUM_BLOCK (sbi , segno ) \
8993 ((sbi)->sm_info->ssa_blkaddr + (segno))
@@ -305,7 +309,7 @@ static inline struct sec_entry *get_sec_entry(struct f2fs_sb_info *sbi,
305309 unsigned int segno )
306310{
307311 struct sit_info * sit_i = SIT_I (sbi );
308- return & sit_i -> sec_entries [GET_SECNO (sbi , segno )];
312+ return & sit_i -> sec_entries [GET_SEC_FROM_SEG (sbi , segno )];
309313}
310314
311315static inline unsigned int get_valid_blocks (struct f2fs_sb_info * sbi ,
@@ -360,8 +364,8 @@ static inline unsigned int find_next_inuse(struct free_segmap_info *free_i,
360364static inline void __set_free (struct f2fs_sb_info * sbi , unsigned int segno )
361365{
362366 struct free_segmap_info * free_i = FREE_I (sbi );
363- unsigned int secno = segno / sbi -> segs_per_sec ;
364- unsigned int start_segno = secno * sbi -> segs_per_sec ;
367+ unsigned int secno = GET_SEC_FROM_SEG ( sbi , segno ) ;
368+ unsigned int start_segno = GET_SEG_FROM_SEC ( sbi , secno ) ;
365369 unsigned int next ;
366370
367371 spin_lock (& free_i -> segmap_lock );
@@ -381,7 +385,8 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi,
381385 unsigned int segno )
382386{
383387 struct free_segmap_info * free_i = FREE_I (sbi );
384- unsigned int secno = segno / sbi -> segs_per_sec ;
388+ unsigned int secno = GET_SEC_FROM_SEG (sbi , segno );
389+
385390 set_bit (segno , free_i -> free_segmap );
386391 free_i -> free_segments -- ;
387392 if (!test_and_set_bit (secno , free_i -> free_secmap ))
@@ -392,8 +397,8 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi,
392397 unsigned int segno )
393398{
394399 struct free_segmap_info * free_i = FREE_I (sbi );
395- unsigned int secno = segno / sbi -> segs_per_sec ;
396- unsigned int start_segno = secno * sbi -> segs_per_sec ;
400+ unsigned int secno = GET_SEC_FROM_SEG ( sbi , segno ) ;
401+ unsigned int start_segno = GET_SEG_FROM_SEC ( sbi , secno ) ;
397402 unsigned int next ;
398403
399404 spin_lock (& free_i -> segmap_lock );
@@ -414,7 +419,8 @@ static inline void __set_test_and_inuse(struct f2fs_sb_info *sbi,
414419 unsigned int segno )
415420{
416421 struct free_segmap_info * free_i = FREE_I (sbi );
417- unsigned int secno = segno / sbi -> segs_per_sec ;
422+ unsigned int secno = GET_SEC_FROM_SEG (sbi , segno );
423+
418424 spin_lock (& free_i -> segmap_lock );
419425 if (!test_and_set_bit (segno , free_i -> free_segmap )) {
420426 free_i -> free_segments -- ;
@@ -479,12 +485,12 @@ static inline int overprovision_segments(struct f2fs_sb_info *sbi)
479485
480486static inline int overprovision_sections (struct f2fs_sb_info * sbi )
481487{
482- return ( (unsigned int ) overprovision_segments (sbi )) / sbi -> segs_per_sec ;
488+ return GET_SEC_FROM_SEG ( sbi , (unsigned int )overprovision_segments (sbi ));
483489}
484490
485491static inline int reserved_sections (struct f2fs_sb_info * sbi )
486492{
487- return ( (unsigned int ) reserved_segments (sbi )) / sbi -> segs_per_sec ;
493+ return GET_SEC_FROM_SEG ( sbi , (unsigned int )reserved_segments (sbi ));
488494}
489495
490496static inline bool need_SSR (struct f2fs_sb_info * sbi )
@@ -722,7 +728,7 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
722728static inline bool no_fggc_candidate (struct f2fs_sb_info * sbi ,
723729 unsigned int secno )
724730{
725- if (get_valid_blocks (sbi , GET_SEGNO_FROM_SECNO (sbi , secno ), true) >=
731+ if (get_valid_blocks (sbi , GET_SEG_FROM_SEC (sbi , secno ), true) >=
726732 sbi -> fggc_threshold )
727733 return true;
728734 return false;
0 commit comments