mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
UPSTREAM: f2fs: clear writeback when compression failed
Let's stop issuing compressed writes and clear their writeback flags. Bug: 345273844 Reviewed-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Change-Id: I69835bbcf0ac993cc03b11bcd7bdcfa2ff2bbd4a Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> (cherry picked from commit 2174035a7f1148a52f5a3f371f04224168b5b00a)
This commit is contained in:
@@ -1029,6 +1029,31 @@ static void set_cluster_writeback(struct compress_ctx *cc)
|
||||
}
|
||||
}
|
||||
|
||||
static void cancel_cluster_writeback(struct compress_ctx *cc,
|
||||
struct compress_io_ctx *cic, int submitted)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Wait for submitted IOs. */
|
||||
if (submitted > 1) {
|
||||
f2fs_submit_merged_write(F2FS_I_SB(cc->inode), DATA);
|
||||
while (atomic_read(&cic->pending_pages) !=
|
||||
(cc->valid_nr_cpages - submitted + 1))
|
||||
f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT);
|
||||
}
|
||||
|
||||
/* Cancel writeback and stay locked. */
|
||||
for (i = 0; i < cc->cluster_size; i++) {
|
||||
if (i < submitted) {
|
||||
inode_inc_dirty_pages(cc->inode);
|
||||
lock_page(cc->rpages[i]);
|
||||
}
|
||||
clear_page_private_gcing(cc->rpages[i]);
|
||||
if (folio_test_writeback(page_folio(cc->rpages[i])))
|
||||
end_page_writeback(cc->rpages[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void set_cluster_dirty(struct compress_ctx *cc)
|
||||
{
|
||||
int i;
|
||||
@@ -1230,7 +1255,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
|
||||
.page = NULL,
|
||||
.encrypted_page = NULL,
|
||||
.compressed_page = NULL,
|
||||
.submitted = 0,
|
||||
.io_type = io_type,
|
||||
.io_wbc = wbc,
|
||||
.encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ?
|
||||
@@ -1356,7 +1380,16 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
|
||||
fio.compressed_page = cc->cpages[i - 1];
|
||||
|
||||
cc->cpages[i - 1] = NULL;
|
||||
fio.submitted = 0;
|
||||
f2fs_outplace_write_data(&dn, &fio);
|
||||
if (unlikely(!fio.submitted)) {
|
||||
cancel_cluster_writeback(cc, cic, i);
|
||||
|
||||
/* To call fscrypt_finalize_bounce_page */
|
||||
i = cc->valid_nr_cpages;
|
||||
*submitted = 0;
|
||||
goto out_destroy_crypt;
|
||||
}
|
||||
(*submitted)++;
|
||||
unlock_continue:
|
||||
inode_dec_dirty_pages(cc->inode);
|
||||
@@ -1392,8 +1425,11 @@ unlock_continue:
|
||||
out_destroy_crypt:
|
||||
page_array_free(cc->inode, cic->rpages, cc->cluster_size);
|
||||
|
||||
for (--i; i >= 0; i--)
|
||||
for (--i; i >= 0; i--) {
|
||||
if (!cc->cpages[i])
|
||||
continue;
|
||||
fscrypt_finalize_bounce_page(&cc->cpages[i]);
|
||||
}
|
||||
out_put_cic:
|
||||
kmem_cache_free(cic_entry_slab, cic);
|
||||
out_put_dnode:
|
||||
|
||||
Reference in New Issue
Block a user