Skip to content

Commit 91b76f1

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: fix incomplete block usage in compact SSA summaries
In a previous commit, a bug was introduced where compact SSA summaries failed to utilize the entire block space in non-4KB block size configurations, leading to inefficient space management. This patch fixes the calculation logic to ensure that compact SSA summaries can fully occupy the block regardless of the block size. Reported-by: Chris Mason <clm@meta.com> Fixes: e48e16f ("f2fs: support non-4KB block size without packed_ssa feature") Signed-off-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 6bb9010 commit 91b76f1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

fs/f2fs/segment.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,12 +2674,12 @@ int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)
26742674
valid_sum_count += f2fs_curseg_valid_blocks(sbi, i);
26752675
}
26762676

2677-
sum_in_page = (sbi->sum_blocksize - 2 * sbi->sum_journal_size -
2677+
sum_in_page = (sbi->blocksize - 2 * sbi->sum_journal_size -
26782678
SUM_FOOTER_SIZE) / SUMMARY_SIZE;
26792679
if (valid_sum_count <= sum_in_page)
26802680
return 1;
26812681
else if ((valid_sum_count - sum_in_page) <=
2682-
(sbi->sum_blocksize - SUM_FOOTER_SIZE) / SUMMARY_SIZE)
2682+
(sbi->blocksize - SUM_FOOTER_SIZE) / SUMMARY_SIZE)
26832683
return 2;
26842684
return 3;
26852685
}
@@ -4324,7 +4324,7 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
43244324
s = (struct f2fs_summary *)(kaddr + offset);
43254325
sum_entries(seg_i->sum_blk)[j] = *s;
43264326
offset += SUMMARY_SIZE;
4327-
if (offset + SUMMARY_SIZE <= sbi->sum_blocksize -
4327+
if (offset + SUMMARY_SIZE <= sbi->blocksize -
43284328
SUM_FOOTER_SIZE)
43294329
continue;
43304330

@@ -4497,7 +4497,7 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
44974497
*summary = sum_entries(seg_i->sum_blk)[j];
44984498
written_size += SUMMARY_SIZE;
44994499

4500-
if (written_size + SUMMARY_SIZE <= PAGE_SIZE -
4500+
if (written_size + SUMMARY_SIZE <= sbi->blocksize -
45014501
SUM_FOOTER_SIZE)
45024502
continue;
45034503

0 commit comments

Comments
 (0)