f2fs: clean up with a macro
This patch adds GET_BLKOFF_FROM_SEG0 to clean up some codes. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
924a2ddbd0
commit
491c0854b4
|
@ -218,8 +218,7 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
|
||||||
{
|
{
|
||||||
struct seg_entry *sentry;
|
struct seg_entry *sentry;
|
||||||
unsigned int segno = GET_SEGNO(sbi, blkaddr);
|
unsigned int segno = GET_SEGNO(sbi, blkaddr);
|
||||||
unsigned short blkoff = GET_SEGOFF_FROM_SEG0(sbi, blkaddr) &
|
unsigned short blkoff = GET_BLKOFF_FROM_SEG0(sbi, blkaddr);
|
||||||
(sbi->blocks_per_seg - 1);
|
|
||||||
struct f2fs_summary sum;
|
struct f2fs_summary sum;
|
||||||
nid_t ino, nid;
|
nid_t ino, nid;
|
||||||
void *kaddr;
|
void *kaddr;
|
||||||
|
|
|
@ -405,7 +405,7 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
|
||||||
|
|
||||||
se = get_seg_entry(sbi, segno);
|
se = get_seg_entry(sbi, segno);
|
||||||
new_vblocks = se->valid_blocks + del;
|
new_vblocks = se->valid_blocks + del;
|
||||||
offset = GET_SEGOFF_FROM_SEG0(sbi, blkaddr) & (sbi->blocks_per_seg - 1);
|
offset = GET_BLKOFF_FROM_SEG0(sbi, blkaddr);
|
||||||
|
|
||||||
f2fs_bug_on((new_vblocks >> (sizeof(unsigned short) << 3) ||
|
f2fs_bug_on((new_vblocks >> (sizeof(unsigned short) << 3) ||
|
||||||
(new_vblocks > sbi->blocks_per_seg)));
|
(new_vblocks > sbi->blocks_per_seg)));
|
||||||
|
@ -987,8 +987,7 @@ void recover_data_page(struct f2fs_sb_info *sbi,
|
||||||
change_curseg(sbi, type, true);
|
change_curseg(sbi, type, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
curseg->next_blkoff = GET_SEGOFF_FROM_SEG0(sbi, new_blkaddr) &
|
curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, new_blkaddr);
|
||||||
(sbi->blocks_per_seg - 1);
|
|
||||||
__add_sum_entry(sbi, type, sum);
|
__add_sum_entry(sbi, type, sum);
|
||||||
|
|
||||||
refresh_sit_entry(sbi, old_blkaddr, new_blkaddr);
|
refresh_sit_entry(sbi, old_blkaddr, new_blkaddr);
|
||||||
|
@ -1026,8 +1025,7 @@ void rewrite_node_page(struct f2fs_sb_info *sbi,
|
||||||
curseg->next_segno = segno;
|
curseg->next_segno = segno;
|
||||||
change_curseg(sbi, type, true);
|
change_curseg(sbi, type, true);
|
||||||
}
|
}
|
||||||
curseg->next_blkoff = GET_SEGOFF_FROM_SEG0(sbi, new_blkaddr) &
|
curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, new_blkaddr);
|
||||||
(sbi->blocks_per_seg - 1);
|
|
||||||
__add_sum_entry(sbi, type, sum);
|
__add_sum_entry(sbi, type, sum);
|
||||||
|
|
||||||
/* change the current log to the next block addr in advance */
|
/* change the current log to the next block addr in advance */
|
||||||
|
@ -1035,8 +1033,7 @@ void rewrite_node_page(struct f2fs_sb_info *sbi,
|
||||||
curseg->next_segno = next_segno;
|
curseg->next_segno = next_segno;
|
||||||
change_curseg(sbi, type, true);
|
change_curseg(sbi, type, true);
|
||||||
}
|
}
|
||||||
curseg->next_blkoff = GET_SEGOFF_FROM_SEG0(sbi, next_blkaddr) &
|
curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, next_blkaddr);
|
||||||
(sbi->blocks_per_seg - 1);
|
|
||||||
|
|
||||||
/* rewrite node page */
|
/* rewrite node page */
|
||||||
set_page_writeback(page);
|
set_page_writeback(page);
|
||||||
|
|
|
@ -57,6 +57,9 @@
|
||||||
((blk_addr) - SM_I(sbi)->seg0_blkaddr)
|
((blk_addr) - SM_I(sbi)->seg0_blkaddr)
|
||||||
#define GET_SEGNO_FROM_SEG0(sbi, blk_addr) \
|
#define GET_SEGNO_FROM_SEG0(sbi, blk_addr) \
|
||||||
(GET_SEGOFF_FROM_SEG0(sbi, blk_addr) >> sbi->log_blocks_per_seg)
|
(GET_SEGOFF_FROM_SEG0(sbi, blk_addr) >> sbi->log_blocks_per_seg)
|
||||||
|
#define GET_BLKOFF_FROM_SEG0(sbi, blk_addr) \
|
||||||
|
(GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & (sbi->blocks_per_seg - 1))
|
||||||
|
|
||||||
#define GET_SEGNO(sbi, blk_addr) \
|
#define GET_SEGNO(sbi, blk_addr) \
|
||||||
(((blk_addr == NULL_ADDR) || (blk_addr == NEW_ADDR)) ? \
|
(((blk_addr == NULL_ADDR) || (blk_addr == NEW_ADDR)) ? \
|
||||||
NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \
|
NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \
|
||||||
|
|
Loading…
Reference in New Issue