f2fs: fix to avoid page count leak
PATCH 1/1 f2fs: fix to avoid page count leak
In below error path, we missed to release reference count of pages in compressed cluster, fix it.
- f2fs_mpage_readpages()
- f2fs_read_multi_pages()
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/compress.c | 2 +- fs/f2fs/data.c | 6 +++++- fs/f2fs/f2fs.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-)
fs/f2fs/compress.c +1 -1
@@ -88,7 +88,7 @@ static void f2fs_drop_rpages(struct compress_ctx *cc, int len, bool unlock) } } -static void f2fs_put_rpages (struct compress_ctx *cc) +void f2fs_put_rpages (struct compress_ctx *cc) {f2fs_drop_rpages (cc, cc->cluster_size, false); }
fs/f2fs/data.c +5 -1
@@ -2115,7 +2115,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, }else if (!PageUptodate (page)) {continue ; } -unlock_page (page); +f2fs_put_page (page,1 ); cc->rpages[i] =NULL ; cc->nr_rpages--; }
@@ -2280,6 +2280,8 @@ int f2fs_mpage_readpages(struct address_space *mapping, max_nr_pages, &last_block_in_bio, is_readahead, false); +if (ret) +f2fs_put_rpages (&cc);f2fs_destroy_compress_ctx (&cc);if (ret) goto set_error_page;
@@ -2323,6 +2325,8 @@ int f2fs_mpage_readpages(struct address_space *mapping, max_nr_pages, &last_block_in_bio, is_readahead, false); +if (ret) +f2fs_put_rpages (&cc);f2fs_destroy_compress_ctx (&cc); } }
fs/f2fs/f2fs.h +1 -0
@@ -3790,6 +3790,7 @@ static inline bool f2fs_post_read_required(struct inode *inode)*/ #ifdef CONFIG_F2FS_FS_COMPRESSION bool f2fs_is_compressed_page (struct page *page); +void f2fs_put_rpages (struct compress_ctx *cc);struct page *f2fs_compress_control_page (struct page *page);int f2fs_prepare_compress_overwrite (struct inode *inode,struct page **pagep,pgoff_t index,void **fsdata);
Signature · 1 line
2.18.0.rc1