Skip to content

Commit 887347a

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: clean up {cic,dic}.ref handling
{cic,dic}.ref should be initialized to number of compressed pages, let's initialize it directly rather than doing w/ f2fs_set_compressed_page(). Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 7496aff commit 887347a

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

fs/f2fs/compress.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,14 @@ bool f2fs_is_compressed_page(struct page *page)
5252
}
5353

5454
static void f2fs_set_compressed_page(struct page *page,
55-
struct inode *inode, pgoff_t index, void *data, refcount_t *r)
55+
struct inode *inode, pgoff_t index, void *data)
5656
{
5757
SetPagePrivate(page);
5858
set_page_private(page, (unsigned long)data);
5959

6060
/* i_crypto_info and iv index */
6161
page->index = index;
6262
page->mapping = inode->i_mapping;
63-
if (r)
64-
refcount_inc(r);
6563
}
6664

6765
static void f2fs_put_compressed_page(struct page *page)
@@ -478,7 +476,7 @@ void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)
478476
vunmap(dic->rbuf);
479477
out_free_dic:
480478
if (verity)
481-
refcount_add(dic->nr_cpages - 1, &dic->ref);
479+
refcount_set(&dic->ref, dic->nr_cpages);
482480
if (!verity)
483481
f2fs_decompress_end_io(dic->rpages, dic->cluster_size,
484482
ret, false);
@@ -834,7 +832,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
834832

835833
cic->magic = F2FS_COMPRESSED_PAGE_MAGIC;
836834
cic->inode = inode;
837-
refcount_set(&cic->ref, 1);
835+
refcount_set(&cic->ref, cc->nr_cpages);
838836
cic->rpages = f2fs_kzalloc(sbi, sizeof(struct page *) <<
839837
cc->log_cluster_size, GFP_NOFS);
840838
if (!cic->rpages)
@@ -844,8 +842,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
844842

845843
for (i = 0; i < cc->nr_cpages; i++) {
846844
f2fs_set_compressed_page(cc->cpages[i], inode,
847-
cc->rpages[i + 1]->index,
848-
cic, i ? &cic->ref : NULL);
845+
cc->rpages[i + 1]->index, cic);
849846
fio.compressed_page = cc->cpages[i];
850847
if (fio.encrypted) {
851848
fio.page = cc->rpages[i + 1];
@@ -1095,7 +1092,7 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)
10951092

10961093
dic->magic = F2FS_COMPRESSED_PAGE_MAGIC;
10971094
dic->inode = cc->inode;
1098-
refcount_set(&dic->ref, 1);
1095+
refcount_set(&dic->ref, cc->nr_cpages);
10991096
dic->cluster_idx = cc->cluster_idx;
11001097
dic->cluster_size = cc->cluster_size;
11011098
dic->log_cluster_size = cc->log_cluster_size;
@@ -1119,8 +1116,7 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)
11191116
goto out_free;
11201117

11211118
f2fs_set_compressed_page(page, cc->inode,
1122-
start_idx + i + 1,
1123-
dic, i ? &dic->ref : NULL);
1119+
start_idx + i + 1, dic);
11241120
dic->cpages[i] = page;
11251121
}
11261122

0 commit comments

Comments
 (0)