Skip to content

Commit e78790f

Browse files
Sahitya TummalaJaegeuk Kim
authored andcommitted
f2fs: fix retry logic in f2fs_write_cache_pages()
In case a compressed file is getting overwritten, the current retry logic doesn't include the current page to be retried now as it sets the new start index as 0 and new end index as writeback_index - 1. This causes the corresponding cluster to be uncompressed and written as normal pages without compression. Fix this by allowing writeback to be retried for the current page as well (in case of compressed page getting retried due to index mismatch with cluster index). So that this cluster can be written compressed in case of overwrite. Also, align f2fs_write_cache_pages() according to the change - <64081362e8ff>("mm/page-writeback.c: fix range_cyclic writeback vs writepages deadlock"). Signed-off-by: Sahitya Tummala <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent ca7f76e commit e78790f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

fs/f2fs/data.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,6 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
28612861
pgoff_t index;
28622862
pgoff_t end; /* Inclusive */
28632863
pgoff_t done_index;
2864-
int cycled;
28652864
int range_whole = 0;
28662865
xa_mark_t tag;
28672866
int nwritten = 0;
@@ -2879,17 +2878,12 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
28792878
if (wbc->range_cyclic) {
28802879
writeback_index = mapping->writeback_index; /* prev offset */
28812880
index = writeback_index;
2882-
if (index == 0)
2883-
cycled = 1;
2884-
else
2885-
cycled = 0;
28862881
end = -1;
28872882
} else {
28882883
index = wbc->range_start >> PAGE_SHIFT;
28892884
end = wbc->range_end >> PAGE_SHIFT;
28902885
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
28912886
range_whole = 1;
2892-
cycled = 1; /* ignore range_cyclic tests */
28932887
}
28942888
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
28952889
tag = PAGECACHE_TAG_TOWRITE;
@@ -3054,12 +3048,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
30543048
}
30553049
}
30563050
#endif
3057-
if ((!cycled && !done) || retry) {
3058-
cycled = 1;
3051+
if (retry) {
30593052
index = 0;
3060-
end = writeback_index - 1;
3053+
end = -1;
30613054
goto retry;
30623055
}
3056+
if (wbc->range_cyclic && !done)
3057+
done_index = 0;
30633058
if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
30643059
mapping->writeback_index = done_index;
30653060

0 commit comments

Comments
 (0)