Lines Matching refs:cc

52 	int (*init_compress_ctx)(struct compress_ctx *cc);
53 void (*destroy_compress_ctx)(struct compress_ctx *cc);
54 int (*compress_pages)(struct compress_ctx *cc);
61 static unsigned int offset_in_cluster(struct compress_ctx *cc, pgoff_t index) in offset_in_cluster() argument
63 return index & (cc->cluster_size - 1); in offset_in_cluster()
66 static pgoff_t cluster_idx(struct compress_ctx *cc, pgoff_t index) in cluster_idx() argument
68 return index >> cc->log_cluster_size; in cluster_idx()
71 static pgoff_t start_idx_of_cluster(struct compress_ctx *cc) in start_idx_of_cluster() argument
73 return cc->cluster_idx << cc->log_cluster_size; in start_idx_of_cluster()
102 static void f2fs_drop_rpages(struct compress_ctx *cc, int len, bool unlock) in f2fs_drop_rpages() argument
107 if (!cc->rpages[i]) in f2fs_drop_rpages()
110 unlock_page(cc->rpages[i]); in f2fs_drop_rpages()
112 put_page(cc->rpages[i]); in f2fs_drop_rpages()
116 static void f2fs_put_rpages(struct compress_ctx *cc) in f2fs_put_rpages() argument
118 f2fs_drop_rpages(cc, cc->cluster_size, false); in f2fs_put_rpages()
121 static void f2fs_unlock_rpages(struct compress_ctx *cc, int len) in f2fs_unlock_rpages() argument
123 f2fs_drop_rpages(cc, len, true); in f2fs_unlock_rpages()
126 static void f2fs_put_rpages_wbc(struct compress_ctx *cc, in f2fs_put_rpages_wbc() argument
131 for (i = 0; i < cc->cluster_size; i++) { in f2fs_put_rpages_wbc()
132 if (!cc->rpages[i]) in f2fs_put_rpages_wbc()
135 redirty_page_for_writepage(wbc, cc->rpages[i]); in f2fs_put_rpages_wbc()
136 f2fs_put_page(cc->rpages[i], unlock); in f2fs_put_rpages_wbc()
145 int f2fs_init_compress_ctx(struct compress_ctx *cc) in f2fs_init_compress_ctx() argument
147 if (cc->rpages) in f2fs_init_compress_ctx()
150 cc->rpages = page_array_alloc(cc->inode, cc->cluster_size); in f2fs_init_compress_ctx()
151 return cc->rpages ? 0 : -ENOMEM; in f2fs_init_compress_ctx()
154 void f2fs_destroy_compress_ctx(struct compress_ctx *cc, bool reuse) in f2fs_destroy_compress_ctx() argument
156 page_array_free(cc->inode, cc->rpages, cc->cluster_size); in f2fs_destroy_compress_ctx()
157 cc->rpages = NULL; in f2fs_destroy_compress_ctx()
158 cc->nr_rpages = 0; in f2fs_destroy_compress_ctx()
159 cc->nr_cpages = 0; in f2fs_destroy_compress_ctx()
160 cc->valid_nr_cpages = 0; in f2fs_destroy_compress_ctx()
162 cc->cluster_idx = NULL_CLUSTER; in f2fs_destroy_compress_ctx()
165 void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct folio *folio) in f2fs_compress_ctx_add_page() argument
169 if (!f2fs_cluster_can_merge_page(cc, folio->index)) in f2fs_compress_ctx_add_page()
170 f2fs_bug_on(F2FS_I_SB(cc->inode), 1); in f2fs_compress_ctx_add_page()
172 cluster_ofs = offset_in_cluster(cc, folio->index); in f2fs_compress_ctx_add_page()
173 cc->rpages[cluster_ofs] = folio_page(folio, 0); in f2fs_compress_ctx_add_page()
174 cc->nr_rpages++; in f2fs_compress_ctx_add_page()
175 cc->cluster_idx = cluster_idx(cc, folio->index); in f2fs_compress_ctx_add_page()
179 static int lzo_init_compress_ctx(struct compress_ctx *cc) in lzo_init_compress_ctx() argument
181 cc->private = f2fs_kvmalloc(F2FS_I_SB(cc->inode), in lzo_init_compress_ctx()
183 if (!cc->private) in lzo_init_compress_ctx()
186 cc->clen = lzo1x_worst_compress(PAGE_SIZE << cc->log_cluster_size); in lzo_init_compress_ctx()
190 static void lzo_destroy_compress_ctx(struct compress_ctx *cc) in lzo_destroy_compress_ctx() argument
192 kvfree(cc->private); in lzo_destroy_compress_ctx()
193 cc->private = NULL; in lzo_destroy_compress_ctx()
196 static int lzo_compress_pages(struct compress_ctx *cc) in lzo_compress_pages() argument
200 ret = lzo1x_1_compress(cc->rbuf, cc->rlen, cc->cbuf->cdata, in lzo_compress_pages()
201 &cc->clen, cc->private); in lzo_compress_pages()
203 f2fs_err_ratelimited(F2FS_I_SB(cc->inode), in lzo_compress_pages()
240 static int lz4_init_compress_ctx(struct compress_ctx *cc) in lz4_init_compress_ctx() argument
245 if (F2FS_I(cc->inode)->i_compress_level) in lz4_init_compress_ctx()
249 cc->private = f2fs_kvmalloc(F2FS_I_SB(cc->inode), size, GFP_NOFS); in lz4_init_compress_ctx()
250 if (!cc->private) in lz4_init_compress_ctx()
258 cc->clen = cc->rlen - PAGE_SIZE - COMPRESS_HEADER_SIZE; in lz4_init_compress_ctx()
262 static void lz4_destroy_compress_ctx(struct compress_ctx *cc) in lz4_destroy_compress_ctx() argument
264 kvfree(cc->private); in lz4_destroy_compress_ctx()
265 cc->private = NULL; in lz4_destroy_compress_ctx()
268 static int lz4_compress_pages(struct compress_ctx *cc) in lz4_compress_pages() argument
271 unsigned char level = F2FS_I(cc->inode)->i_compress_level; in lz4_compress_pages()
274 len = LZ4_compress_default(cc->rbuf, cc->cbuf->cdata, cc->rlen, in lz4_compress_pages()
275 cc->clen, cc->private); in lz4_compress_pages()
278 len = LZ4_compress_HC(cc->rbuf, cc->cbuf->cdata, cc->rlen, in lz4_compress_pages()
279 cc->clen, level, cc->private); in lz4_compress_pages()
286 cc->clen = len; in lz4_compress_pages()
330 static int zstd_init_compress_ctx(struct compress_ctx *cc) in zstd_init_compress_ctx() argument
336 unsigned char level = F2FS_I(cc->inode)->i_compress_level; in zstd_init_compress_ctx()
342 params = zstd_get_params(level, cc->rlen); in zstd_init_compress_ctx()
345 workspace = f2fs_kvmalloc(F2FS_I_SB(cc->inode), in zstd_init_compress_ctx()
352 f2fs_err_ratelimited(F2FS_I_SB(cc->inode), in zstd_init_compress_ctx()
358 cc->private = workspace; in zstd_init_compress_ctx()
359 cc->private2 = stream; in zstd_init_compress_ctx()
361 cc->clen = cc->rlen - PAGE_SIZE - COMPRESS_HEADER_SIZE; in zstd_init_compress_ctx()
365 static void zstd_destroy_compress_ctx(struct compress_ctx *cc) in zstd_destroy_compress_ctx() argument
367 kvfree(cc->private); in zstd_destroy_compress_ctx()
368 cc->private = NULL; in zstd_destroy_compress_ctx()
369 cc->private2 = NULL; in zstd_destroy_compress_ctx()
372 static int zstd_compress_pages(struct compress_ctx *cc) in zstd_compress_pages() argument
374 zstd_cstream *stream = cc->private2; in zstd_compress_pages()
377 int src_size = cc->rlen; in zstd_compress_pages()
382 inbuf.src = cc->rbuf; in zstd_compress_pages()
386 outbuf.dst = cc->cbuf->cdata; in zstd_compress_pages()
391 f2fs_err_ratelimited(F2FS_I_SB(cc->inode), in zstd_compress_pages()
399 f2fs_err_ratelimited(F2FS_I_SB(cc->inode), in zstd_compress_pages()
412 cc->clen = outbuf.pos; in zstd_compress_pages()
504 static int lzorle_compress_pages(struct compress_ctx *cc) in lzorle_compress_pages() argument
508 ret = lzorle1x_1_compress(cc->rbuf, cc->rlen, cc->cbuf->cdata, in lzorle_compress_pages()
509 &cc->clen, cc->private); in lzorle_compress_pages()
511 f2fs_err_ratelimited(F2FS_I_SB(cc->inode), in lzorle_compress_pages()
620 static int f2fs_compress_pages(struct compress_ctx *cc) in f2fs_compress_pages() argument
622 struct f2fs_inode_info *fi = F2FS_I(cc->inode); in f2fs_compress_pages()
629 trace_f2fs_compress_pages_start(cc->inode, cc->cluster_idx, in f2fs_compress_pages()
630 cc->cluster_size, fi->i_compress_algorithm); in f2fs_compress_pages()
633 ret = cops->init_compress_ctx(cc); in f2fs_compress_pages()
638 max_len = COMPRESS_HEADER_SIZE + cc->clen; in f2fs_compress_pages()
639 cc->nr_cpages = DIV_ROUND_UP(max_len, PAGE_SIZE); in f2fs_compress_pages()
640 cc->valid_nr_cpages = cc->nr_cpages; in f2fs_compress_pages()
642 cc->cpages = page_array_alloc(cc->inode, cc->nr_cpages); in f2fs_compress_pages()
643 if (!cc->cpages) { in f2fs_compress_pages()
648 for (i = 0; i < cc->nr_cpages; i++) in f2fs_compress_pages()
649 cc->cpages[i] = f2fs_compress_alloc_page(); in f2fs_compress_pages()
651 cc->rbuf = f2fs_vmap(cc->rpages, cc->cluster_size); in f2fs_compress_pages()
652 if (!cc->rbuf) { in f2fs_compress_pages()
657 cc->cbuf = f2fs_vmap(cc->cpages, cc->nr_cpages); in f2fs_compress_pages()
658 if (!cc->cbuf) { in f2fs_compress_pages()
663 ret = cops->compress_pages(cc); in f2fs_compress_pages()
667 max_len = PAGE_SIZE * (cc->cluster_size - 1) - COMPRESS_HEADER_SIZE; in f2fs_compress_pages()
669 if (cc->clen > max_len) { in f2fs_compress_pages()
674 cc->cbuf->clen = cpu_to_le32(cc->clen); in f2fs_compress_pages()
677 chksum = f2fs_crc32(F2FS_I_SB(cc->inode), in f2fs_compress_pages()
678 cc->cbuf->cdata, cc->clen); in f2fs_compress_pages()
679 cc->cbuf->chksum = cpu_to_le32(chksum); in f2fs_compress_pages()
682 cc->cbuf->reserved[i] = cpu_to_le32(0); in f2fs_compress_pages()
684 new_nr_cpages = DIV_ROUND_UP(cc->clen + COMPRESS_HEADER_SIZE, PAGE_SIZE); in f2fs_compress_pages()
687 memset(&cc->cbuf->cdata[cc->clen], 0, in f2fs_compress_pages()
689 (cc->clen + COMPRESS_HEADER_SIZE)); in f2fs_compress_pages()
691 vm_unmap_ram(cc->cbuf, cc->nr_cpages); in f2fs_compress_pages()
692 vm_unmap_ram(cc->rbuf, cc->cluster_size); in f2fs_compress_pages()
694 for (i = new_nr_cpages; i < cc->nr_cpages; i++) { in f2fs_compress_pages()
695 f2fs_compress_free_page(cc->cpages[i]); in f2fs_compress_pages()
696 cc->cpages[i] = NULL; in f2fs_compress_pages()
700 cops->destroy_compress_ctx(cc); in f2fs_compress_pages()
702 cc->valid_nr_cpages = new_nr_cpages; in f2fs_compress_pages()
704 trace_f2fs_compress_pages_end(cc->inode, cc->cluster_idx, in f2fs_compress_pages()
705 cc->clen, ret); in f2fs_compress_pages()
709 vm_unmap_ram(cc->cbuf, cc->nr_cpages); in f2fs_compress_pages()
711 vm_unmap_ram(cc->rbuf, cc->cluster_size); in f2fs_compress_pages()
713 for (i = 0; i < cc->nr_cpages; i++) { in f2fs_compress_pages()
714 if (cc->cpages[i]) in f2fs_compress_pages()
715 f2fs_compress_free_page(cc->cpages[i]); in f2fs_compress_pages()
717 page_array_free(cc->inode, cc->cpages, cc->nr_cpages); in f2fs_compress_pages()
718 cc->cpages = NULL; in f2fs_compress_pages()
721 cops->destroy_compress_ctx(cc); in f2fs_compress_pages()
723 trace_f2fs_compress_pages_end(cc->inode, cc->cluster_idx, in f2fs_compress_pages()
724 cc->clen, ret); in f2fs_compress_pages()
822 static bool is_page_in_cluster(struct compress_ctx *cc, pgoff_t index) in is_page_in_cluster() argument
824 if (cc->cluster_idx == NULL_CLUSTER) in is_page_in_cluster()
826 return cc->cluster_idx == cluster_idx(cc, index); in is_page_in_cluster()
829 bool f2fs_cluster_is_empty(struct compress_ctx *cc) in f2fs_cluster_is_empty() argument
831 return cc->nr_rpages == 0; in f2fs_cluster_is_empty()
834 static bool f2fs_cluster_is_full(struct compress_ctx *cc) in f2fs_cluster_is_full() argument
836 return cc->cluster_size == cc->nr_rpages; in f2fs_cluster_is_full()
839 bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index) in f2fs_cluster_can_merge_page() argument
841 if (f2fs_cluster_is_empty(cc)) in f2fs_cluster_can_merge_page()
843 return is_page_in_cluster(cc, index); in f2fs_cluster_can_merge_page()
846 bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, in f2fs_all_cluster_page_ready() argument
856 if (uptodate && (pgidx % cc->cluster_size)) in f2fs_all_cluster_page_ready()
859 if (nr_pages - index < cc->cluster_size) in f2fs_all_cluster_page_ready()
862 for (; i < cc->cluster_size; i++) { in f2fs_all_cluster_page_ready()
872 static bool cluster_has_invalid_data(struct compress_ctx *cc) in cluster_has_invalid_data() argument
874 loff_t i_size = i_size_read(cc->inode); in cluster_has_invalid_data()
878 for (i = 0; i < cc->cluster_size; i++) { in cluster_has_invalid_data()
879 struct page *page = cc->rpages[i]; in cluster_has_invalid_data()
881 f2fs_bug_on(F2FS_I_SB(cc->inode), !page); in cluster_has_invalid_data()
996 static int f2fs_compressed_blocks(struct compress_ctx *cc) in f2fs_compressed_blocks() argument
998 return __f2fs_cluster_blocks(cc->inode, cc->cluster_idx, in f2fs_compressed_blocks()
1027 static bool cluster_may_compress(struct compress_ctx *cc) in cluster_may_compress() argument
1029 if (!f2fs_need_compress_data(cc->inode)) in cluster_may_compress()
1031 if (f2fs_is_atomic_file(cc->inode)) in cluster_may_compress()
1033 if (!f2fs_cluster_is_full(cc)) in cluster_may_compress()
1035 if (unlikely(f2fs_cp_error(F2FS_I_SB(cc->inode)))) in cluster_may_compress()
1037 return !cluster_has_invalid_data(cc); in cluster_may_compress()
1040 static void set_cluster_writeback(struct compress_ctx *cc) in set_cluster_writeback() argument
1044 for (i = 0; i < cc->cluster_size; i++) { in set_cluster_writeback()
1045 if (cc->rpages[i]) in set_cluster_writeback()
1046 set_page_writeback(cc->rpages[i]); in set_cluster_writeback()
1050 static void cancel_cluster_writeback(struct compress_ctx *cc, in cancel_cluster_writeback() argument
1057 f2fs_submit_merged_write(F2FS_I_SB(cc->inode), DATA); in cancel_cluster_writeback()
1059 (cc->valid_nr_cpages - submitted + 1)) in cancel_cluster_writeback()
1064 for (i = 0; i < cc->cluster_size; i++) { in cancel_cluster_writeback()
1066 inode_inc_dirty_pages(cc->inode); in cancel_cluster_writeback()
1067 lock_page(cc->rpages[i]); in cancel_cluster_writeback()
1069 clear_page_private_gcing(cc->rpages[i]); in cancel_cluster_writeback()
1070 if (folio_test_writeback(page_folio(cc->rpages[i]))) in cancel_cluster_writeback()
1071 end_page_writeback(cc->rpages[i]); in cancel_cluster_writeback()
1075 static void set_cluster_dirty(struct compress_ctx *cc) in set_cluster_dirty() argument
1079 for (i = 0; i < cc->cluster_size; i++) in set_cluster_dirty()
1080 if (cc->rpages[i]) { in set_cluster_dirty()
1081 set_page_dirty(cc->rpages[i]); in set_cluster_dirty()
1082 set_page_private_gcing(cc->rpages[i]); in set_cluster_dirty()
1086 static int prepare_compress_overwrite(struct compress_ctx *cc, in prepare_compress_overwrite() argument
1089 struct f2fs_sb_info *sbi = F2FS_I_SB(cc->inode); in prepare_compress_overwrite()
1090 struct address_space *mapping = cc->inode->i_mapping; in prepare_compress_overwrite()
1094 pgoff_t start_idx = start_idx_of_cluster(cc); in prepare_compress_overwrite()
1098 ret = f2fs_is_compressed_cluster(cc->inode, start_idx); in prepare_compress_overwrite()
1102 ret = f2fs_init_compress_ctx(cc); in prepare_compress_overwrite()
1107 for (i = 0; i < cc->cluster_size; i++) { in prepare_compress_overwrite()
1118 f2fs_compress_ctx_add_page(cc, page_folio(page)); in prepare_compress_overwrite()
1121 if (!f2fs_cluster_is_empty(cc)) { in prepare_compress_overwrite()
1124 ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size, in prepare_compress_overwrite()
1126 f2fs_put_rpages(cc); in prepare_compress_overwrite()
1127 f2fs_destroy_compress_ctx(cc, true); in prepare_compress_overwrite()
1133 ret = f2fs_init_compress_ctx(cc); in prepare_compress_overwrite()
1138 for (i = 0; i < cc->cluster_size; i++) { in prepare_compress_overwrite()
1139 f2fs_bug_on(sbi, cc->rpages[i]); in prepare_compress_overwrite()
1148 f2fs_compress_ctx_add_page(cc, page_folio(page)); in prepare_compress_overwrite()
1152 f2fs_put_rpages(cc); in prepare_compress_overwrite()
1153 f2fs_unlock_rpages(cc, i + 1); in prepare_compress_overwrite()
1154 f2fs_destroy_compress_ctx(cc, true); in prepare_compress_overwrite()
1160 *fsdata = cc->rpages; in prepare_compress_overwrite()
1161 *pagep = cc->rpages[offset_in_cluster(cc, index)]; in prepare_compress_overwrite()
1162 return cc->cluster_size; in prepare_compress_overwrite()
1166 f2fs_put_rpages(cc); in prepare_compress_overwrite()
1167 f2fs_unlock_rpages(cc, i); in prepare_compress_overwrite()
1168 f2fs_destroy_compress_ctx(cc, true); in prepare_compress_overwrite()
1176 struct compress_ctx cc = { in f2fs_prepare_compress_overwrite() local
1185 return prepare_compress_overwrite(&cc, pagep, index, fsdata); in f2fs_prepare_compress_overwrite()
1192 struct compress_ctx cc = { in f2fs_compress_write_end() local
1198 bool first_index = (index == cc.rpages[0]->index); in f2fs_compress_write_end()
1201 set_cluster_dirty(&cc); in f2fs_compress_write_end()
1203 f2fs_put_rpages_wbc(&cc, NULL, false, 1); in f2fs_compress_write_end()
1204 f2fs_destroy_compress_ctx(&cc, false); in f2fs_compress_write_end()
1258 static int f2fs_write_compressed_pages(struct compress_ctx *cc, in f2fs_write_compressed_pages() argument
1263 struct inode *inode = cc->inode; in f2fs_write_compressed_pages()
1268 .ino = cc->inode->i_ino, in f2fs_write_compressed_pages()
1278 .encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ? in f2fs_write_compressed_pages()
1284 pgoff_t start_idx = start_idx_of_cluster(cc); in f2fs_write_compressed_pages()
1285 unsigned int last_index = cc->cluster_size - 1; in f2fs_write_compressed_pages()
1292 mapping_set_error(cc->rpages[0]->mapping, -EIO); in f2fs_write_compressed_pages()
1307 set_new_dnode(&dn, cc->inode, NULL, NULL, 0); in f2fs_write_compressed_pages()
1313 for (i = 0; i < cc->cluster_size; i++) { in f2fs_write_compressed_pages()
1319 psize = (loff_t)(cc->rpages[last_index]->index + 1) << PAGE_SHIFT; in f2fs_write_compressed_pages()
1333 atomic_set(&cic->pending_pages, cc->valid_nr_cpages); in f2fs_write_compressed_pages()
1334 cic->rpages = page_array_alloc(cc->inode, cc->cluster_size); in f2fs_write_compressed_pages()
1338 cic->nr_rpages = cc->cluster_size; in f2fs_write_compressed_pages()
1340 for (i = 0; i < cc->valid_nr_cpages; i++) { in f2fs_write_compressed_pages()
1341 f2fs_set_compressed_page(cc->cpages[i], inode, in f2fs_write_compressed_pages()
1342 cc->rpages[i + 1]->index, cic); in f2fs_write_compressed_pages()
1343 fio.compressed_page = cc->cpages[i]; in f2fs_write_compressed_pages()
1352 fio.page = cc->rpages[i + 1]; in f2fs_write_compressed_pages()
1356 cc->cpages[i] = fio.encrypted_page; in f2fs_write_compressed_pages()
1360 set_cluster_writeback(cc); in f2fs_write_compressed_pages()
1362 for (i = 0; i < cc->cluster_size; i++) in f2fs_write_compressed_pages()
1363 cic->rpages[i] = cc->rpages[i]; in f2fs_write_compressed_pages()
1365 for (i = 0; i < cc->cluster_size; i++, dn.ofs_in_node++) { in f2fs_write_compressed_pages()
1369 fio.page = cc->rpages[i]; in f2fs_write_compressed_pages()
1385 if (i > cc->valid_nr_cpages) { in f2fs_write_compressed_pages()
1396 fio.encrypted_page = cc->cpages[i - 1]; in f2fs_write_compressed_pages()
1398 fio.compressed_page = cc->cpages[i - 1]; in f2fs_write_compressed_pages()
1400 cc->cpages[i - 1] = NULL; in f2fs_write_compressed_pages()
1404 cancel_cluster_writeback(cc, cic, i); in f2fs_write_compressed_pages()
1407 i = cc->valid_nr_cpages; in f2fs_write_compressed_pages()
1413 inode_dec_dirty_pages(cc->inode); in f2fs_write_compressed_pages()
1419 f2fs_i_compr_blocks_update(inode, cc->valid_nr_cpages, true); in f2fs_write_compressed_pages()
1420 add_compr_block_stat(inode, cc->valid_nr_cpages); in f2fs_write_compressed_pages()
1422 set_inode_flag(cc->inode, FI_APPEND_WRITE); in f2fs_write_compressed_pages()
1435 f2fs_put_rpages(cc); in f2fs_write_compressed_pages()
1436 page_array_free(cc->inode, cc->cpages, cc->nr_cpages); in f2fs_write_compressed_pages()
1437 cc->cpages = NULL; in f2fs_write_compressed_pages()
1438 f2fs_destroy_compress_ctx(cc, false); in f2fs_write_compressed_pages()
1442 page_array_free(cc->inode, cic->rpages, cc->cluster_size); in f2fs_write_compressed_pages()
1445 if (!cc->cpages[i]) in f2fs_write_compressed_pages()
1447 fscrypt_finalize_bounce_page(&cc->cpages[i]); in f2fs_write_compressed_pages()
1459 for (i = 0; i < cc->valid_nr_cpages; i++) { in f2fs_write_compressed_pages()
1460 f2fs_compress_free_page(cc->cpages[i]); in f2fs_write_compressed_pages()
1461 cc->cpages[i] = NULL; in f2fs_write_compressed_pages()
1463 page_array_free(cc->inode, cc->cpages, cc->nr_cpages); in f2fs_write_compressed_pages()
1464 cc->cpages = NULL; in f2fs_write_compressed_pages()
1497 static int f2fs_write_raw_pages(struct compress_ctx *cc, in f2fs_write_raw_pages() argument
1502 struct address_space *mapping = cc->inode->i_mapping; in f2fs_write_raw_pages()
1507 compr_blocks = f2fs_compressed_blocks(cc); in f2fs_write_raw_pages()
1509 for (i = 0; i < cc->cluster_size; i++) { in f2fs_write_raw_pages()
1510 if (!cc->rpages[i]) in f2fs_write_raw_pages()
1513 redirty_page_for_writepage(wbc, cc->rpages[i]); in f2fs_write_raw_pages()
1514 unlock_page(cc->rpages[i]); in f2fs_write_raw_pages()
1524 for (i = 0; i < cc->cluster_size; i++) { in f2fs_write_raw_pages()
1525 if (!cc->rpages[i]) in f2fs_write_raw_pages()
1528 lock_page(cc->rpages[i]); in f2fs_write_raw_pages()
1530 if (cc->rpages[i]->mapping != mapping) { in f2fs_write_raw_pages()
1532 unlock_page(cc->rpages[i]); in f2fs_write_raw_pages()
1536 if (!PageDirty(cc->rpages[i])) in f2fs_write_raw_pages()
1539 if (folio_test_writeback(page_folio(cc->rpages[i]))) { in f2fs_write_raw_pages()
1542 f2fs_wait_on_page_writeback(cc->rpages[i], DATA, true, true); in f2fs_write_raw_pages()
1545 if (!clear_page_dirty_for_io(cc->rpages[i])) in f2fs_write_raw_pages()
1548 ret = f2fs_write_single_data_page(page_folio(cc->rpages[i]), in f2fs_write_raw_pages()
1554 unlock_page(cc->rpages[i]); in f2fs_write_raw_pages()
1563 if (IS_NOQUOTA(cc->inode)) in f2fs_write_raw_pages()
1582 int f2fs_write_multi_pages(struct compress_ctx *cc, in f2fs_write_multi_pages() argument
1590 if (cluster_may_compress(cc)) { in f2fs_write_multi_pages()
1591 err = f2fs_compress_pages(cc); in f2fs_write_multi_pages()
1593 add_compr_block_stat(cc->inode, cc->cluster_size); in f2fs_write_multi_pages()
1596 f2fs_put_rpages_wbc(cc, wbc, true, 1); in f2fs_write_multi_pages()
1600 err = f2fs_write_compressed_pages(cc, submitted, in f2fs_write_multi_pages()
1604 f2fs_bug_on(F2FS_I_SB(cc->inode), err != -EAGAIN); in f2fs_write_multi_pages()
1607 f2fs_bug_on(F2FS_I_SB(cc->inode), *submitted); in f2fs_write_multi_pages()
1609 err = f2fs_write_raw_pages(cc, submitted, wbc, io_type); in f2fs_write_multi_pages()
1610 f2fs_put_rpages_wbc(cc, wbc, false, 0); in f2fs_write_multi_pages()
1612 f2fs_destroy_compress_ctx(cc, false); in f2fs_write_multi_pages()
1681 struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc) in f2fs_alloc_dic() argument
1684 pgoff_t start_idx = start_idx_of_cluster(cc); in f2fs_alloc_dic()
1685 struct f2fs_sb_info *sbi = F2FS_I_SB(cc->inode); in f2fs_alloc_dic()
1692 dic->rpages = page_array_alloc(cc->inode, cc->cluster_size); in f2fs_alloc_dic()
1699 dic->inode = cc->inode; in f2fs_alloc_dic()
1700 atomic_set(&dic->remaining_pages, cc->nr_cpages); in f2fs_alloc_dic()
1701 dic->cluster_idx = cc->cluster_idx; in f2fs_alloc_dic()
1702 dic->cluster_size = cc->cluster_size; in f2fs_alloc_dic()
1703 dic->log_cluster_size = cc->log_cluster_size; in f2fs_alloc_dic()
1704 dic->nr_cpages = cc->nr_cpages; in f2fs_alloc_dic()
1707 dic->need_verity = f2fs_need_verity(cc->inode, start_idx); in f2fs_alloc_dic()
1710 dic->rpages[i] = cc->rpages[i]; in f2fs_alloc_dic()
1711 dic->nr_rpages = cc->cluster_size; in f2fs_alloc_dic()
1723 f2fs_set_compressed_page(page, cc->inode, in f2fs_alloc_dic()