Skip to content

Commit 8c157dd

Browse files
Daeho Jeongopsiff
authored andcommitted
f2fs: fix incomplete block usage in compact SSA summaries
commit 91b76f1 upstream. 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> Cc: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit df337ba02ca53ca9cfcefc1ed7ca38424daa52a0) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 57fa5bc commit 8c157dd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/f2fs/segment.c

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

2692-
sum_in_page = (sbi->sum_blocksize - 2 * sbi->sum_journal_size -
2692+
sum_in_page = (sbi->blocksize - 2 * sbi->sum_journal_size -
26932693
SUM_FOOTER_SIZE) / SUMMARY_SIZE;
26942694
if (valid_sum_count <= sum_in_page)
26952695
return 1;
26962696
else if ((valid_sum_count - sum_in_page) <=
2697-
(sbi->sum_blocksize - SUM_FOOTER_SIZE) / SUMMARY_SIZE)
2697+
(sbi->blocksize - SUM_FOOTER_SIZE) / SUMMARY_SIZE)
26982698
return 2;
26992699
return 3;
27002700
}
@@ -4337,7 +4337,7 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
43374337
s = (struct f2fs_summary *)(kaddr + offset);
43384338
sum_entries(seg_i->sum_blk)[j] = *s;
43394339
offset += SUMMARY_SIZE;
4340-
if (offset + SUMMARY_SIZE <= sbi->sum_blocksize -
4340+
if (offset + SUMMARY_SIZE <= sbi->blocksize -
43414341
SUM_FOOTER_SIZE)
43424342
continue;
43434343

@@ -4510,7 +4510,7 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
45104510
*summary = sum_entries(seg_i->sum_blk)[j];
45114511
written_size += SUMMARY_SIZE;
45124512

4513-
if (written_size + SUMMARY_SIZE <= PAGE_SIZE -
4513+
if (written_size + SUMMARY_SIZE <= sbi->blocksize -
45144514
SUM_FOOTER_SIZE)
45154515
continue;
45164516

0 commit comments

Comments
 (0)