Skip to content

Commit

Permalink
f2fs: remove __add_sum_entry
Browse files Browse the repository at this point in the history
This function just assigns a summary entry.  This can be done entirely
typesafe with an open code struct assignment that relies on array
indexing.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Christoph Hellwig authored and asuka-mio committed Mar 3, 2023
1 parent 7c76345 commit 72cc033
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -2337,19 +2337,6 @@ bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr)
return is_cp;
}

/*
* This function should be resided under the curseg_mutex lock
*/
static void __add_sum_entry(struct f2fs_sb_info *sbi, int type,
struct f2fs_summary *sum)
{
struct curseg_info *curseg = CURSEG_I(sbi, type);
void *addr = curseg->sum_blk;

addr += curseg->next_blkoff * sizeof(struct f2fs_summary);
memcpy(addr, sum, sizeof(struct f2fs_summary));
}

/*
* Calculate the number of current summary pages for writing
*/
Expand Down Expand Up @@ -3276,13 +3263,7 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,

f2fs_wait_discard_bio(sbi, *new_blkaddr);

/*
* __add_sum_entry should be resided under the curseg_mutex
* because, this function updates a summary entry in the
* current summary block.
*/
__add_sum_entry(sbi, type, sum);

curseg->sum_blk->entries[curseg->next_blkoff] = *sum;
__refresh_next_blkoff(sbi, curseg);

stat_inc_block_count(sbi, curseg);
Expand Down Expand Up @@ -3584,7 +3565,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
}

curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, new_blkaddr);
__add_sum_entry(sbi, type, sum);
curseg->sum_blk->entries[curseg->next_blkoff] = *sum;

if (!recover_curseg || recover_newaddr) {
if (!from_gc)
Expand Down

0 comments on commit 72cc033

Please sign in to comment.