Commit 6392e9ff authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jaegeuk Kim

f2fs: add a f2fs_curseg_valid_blocks helper

Add a helper to return the valid blocks on log and SSR segments, and
replace the last two uses of curseg_blkoff with it.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 5a4fed7c
...@@ -2339,6 +2339,15 @@ bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr) ...@@ -2339,6 +2339,15 @@ bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr)
return is_cp; return is_cp;
} }
static unsigned short f2fs_curseg_valid_blocks(struct f2fs_sb_info *sbi, int type)
{
struct curseg_info *curseg = CURSEG_I(sbi, type);
if (sbi->ckpt->alloc_type[type] == SSR)
return sbi->blocks_per_seg;
return curseg->next_blkoff;
}
/* /*
* Calculate the number of current summary pages for writing * Calculate the number of current summary pages for writing
*/ */
...@@ -2348,15 +2357,11 @@ int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra) ...@@ -2348,15 +2357,11 @@ int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)
int i, sum_in_page; int i, sum_in_page;
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
if (sbi->ckpt->alloc_type[i] == SSR) if (sbi->ckpt->alloc_type[i] != SSR && for_ra)
valid_sum_count += sbi->blocks_per_seg; valid_sum_count +=
else { le16_to_cpu(F2FS_CKPT(sbi)->cur_data_blkoff[i]);
if (for_ra) else
valid_sum_count += le16_to_cpu( valid_sum_count += f2fs_curseg_valid_blocks(sbi, i);
F2FS_CKPT(sbi)->cur_data_blkoff[i]);
else
valid_sum_count += curseg_blkoff(sbi, i);
}
} }
sum_in_page = (PAGE_SIZE - 2 * SUM_JOURNAL_SIZE - sum_in_page = (PAGE_SIZE - 2 * SUM_JOURNAL_SIZE -
...@@ -3877,15 +3882,8 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr) ...@@ -3877,15 +3882,8 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
/* Step 3: write summary entries */ /* Step 3: write summary entries */
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
unsigned short blkoff;
seg_i = CURSEG_I(sbi, i); seg_i = CURSEG_I(sbi, i);
if (sbi->ckpt->alloc_type[i] == SSR) for (j = 0; j < f2fs_curseg_valid_blocks(sbi, i); j++) {
blkoff = sbi->blocks_per_seg;
else
blkoff = curseg_blkoff(sbi, i);
for (j = 0; j < blkoff; j++) {
if (!page) { if (!page) {
page = f2fs_grab_meta_page(sbi, blkaddr++); page = f2fs_grab_meta_page(sbi, blkaddr++);
kaddr = (unsigned char *)page_address(page); kaddr = (unsigned char *)page_address(page);
......
...@@ -710,12 +710,6 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi, ...@@ -710,12 +710,6 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
return curseg->alloc_type; return curseg->alloc_type;
} }
static inline unsigned short curseg_blkoff(struct f2fs_sb_info *sbi, int type)
{
struct curseg_info *curseg = CURSEG_I(sbi, type);
return curseg->next_blkoff;
}
static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno) 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 > TOTAL_SEGS(sbi) - 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment