提交 d54c795b 编写于 作者: C Chao Yu 提交者: Jaegeuk Kim

f2fs: fix error path when fail to read inline data

We should unlock page in ->readpage() path and also should unlock & release page
in error path of ->write_begin() to avoid deadlock or memory leak.
So let's add release code to fix the problem when we fail to read inline data.
Signed-off-by: NChao Yu <chao2.yu@samsung.com>
Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
上级 2d7b822a
...@@ -942,13 +942,19 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -942,13 +942,19 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
if (dn.data_blkaddr == NEW_ADDR) { if (dn.data_blkaddr == NEW_ADDR) {
zero_user_segment(page, 0, PAGE_CACHE_SIZE); zero_user_segment(page, 0, PAGE_CACHE_SIZE);
} else { } else {
if (f2fs_has_inline_data(inode)) if (f2fs_has_inline_data(inode)) {
err = f2fs_read_inline_data(inode, page); err = f2fs_read_inline_data(inode, page);
else if (err) {
page_cache_release(page);
return err;
}
} else {
err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr, err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
READ_SYNC); READ_SYNC);
if (err) if (err)
return err; return err;
}
lock_page(page); lock_page(page);
if (unlikely(!PageUptodate(page))) { if (unlikely(!PageUptodate(page))) {
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
......
...@@ -45,8 +45,10 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page) ...@@ -45,8 +45,10 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page)
} }
ipage = get_node_page(sbi, inode->i_ino); ipage = get_node_page(sbi, inode->i_ino);
if (IS_ERR(ipage)) if (IS_ERR(ipage)) {
unlock_page(page);
return PTR_ERR(ipage); return PTR_ERR(ipage);
}
zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE); zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册