diff options
author | Fan Li <fanofcode.li@samsung.com> | 2013-10-29 04:21:47 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-10-29 23:17:58 -0400 |
commit | 9a47938b226cc2b8e2afd72b0f1ca1a7e1367cf5 (patch) | |
tree | 8c3ae3af4617422cf4b25f04759584baccc43072 /fs/f2fs/segment.c | |
parent | cc3de6a3acce264f4eb0b5bf552478e5f1380bba (diff) |
f2fs: change the method of calculating the number summary blocks
npages_for_summary_flush uses (SUMMARY_SIZE + 1) as the size of a f2fs_summary
while its actual size is SUMMARY_SIZE. So the result sometimes is bigger than
actual number by one, which causes checkpoint can't be written into disk
contiguously, and sometimes summary blocks can't be compacted like they should.
Besides, when writing summary blocks into pages, if remain space in a page
isn't big enough for one f2fs_summary, it will be left unused, current code
seems not to take it into account.
Signed-off-by: Fan Li <fanofcode.li@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index c7161defff90..3d4d5fc19e6f 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -264,9 +264,8 @@ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type, | |||
264 | */ | 264 | */ |
265 | int npages_for_summary_flush(struct f2fs_sb_info *sbi) | 265 | int npages_for_summary_flush(struct f2fs_sb_info *sbi) |
266 | { | 266 | { |
267 | int total_size_bytes = 0; | ||
268 | int valid_sum_count = 0; | 267 | int valid_sum_count = 0; |
269 | int i, sum_space; | 268 | int i, sum_in_page; |
270 | 269 | ||
271 | for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { | 270 | for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { |
272 | if (sbi->ckpt->alloc_type[i] == SSR) | 271 | if (sbi->ckpt->alloc_type[i] == SSR) |
@@ -275,13 +274,12 @@ int npages_for_summary_flush(struct f2fs_sb_info *sbi) | |||
275 | valid_sum_count += curseg_blkoff(sbi, i); | 274 | valid_sum_count += curseg_blkoff(sbi, i); |
276 | } | 275 | } |
277 | 276 | ||
278 | total_size_bytes = valid_sum_count * (SUMMARY_SIZE + 1) | 277 | sum_in_page = (PAGE_CACHE_SIZE - 2 * SUM_JOURNAL_SIZE - |
279 | + sizeof(struct nat_journal) + 2 | 278 | SUM_FOOTER_SIZE) / SUMMARY_SIZE; |
280 | + sizeof(struct sit_journal) + 2; | 279 | if (valid_sum_count <= sum_in_page) |
281 | sum_space = PAGE_CACHE_SIZE - SUM_FOOTER_SIZE; | ||
282 | if (total_size_bytes < sum_space) | ||
283 | return 1; | 280 | return 1; |
284 | else if (total_size_bytes < 2 * sum_space) | 281 | else if ((valid_sum_count - sum_in_page) <= |
282 | (PAGE_CACHE_SIZE - SUM_FOOTER_SIZE) / SUMMARY_SIZE) | ||
285 | return 2; | 283 | return 2; |
286 | return 3; | 284 | return 3; |
287 | } | 285 | } |