aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2014-03-29 03:30:40 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-04-01 20:56:27 -0400
commitd54c795b495b9bd417e482286c832c9a8eb210ae (patch)
treed9cb8d56270bd124e7db2660d336d7afa1c7e6e7 /fs/f2fs
parent2d7b822ad9daf0ea903accacaa89340ddd3f201f (diff)
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: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/data.c14
-rw-r--r--fs/f2fs/inline.c4
2 files changed, 13 insertions, 5 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 598bfa617a7e..45abd60e2bff 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -942,13 +942,19 @@ inline_data:
942 if (dn.data_blkaddr == NEW_ADDR) { 942 if (dn.data_blkaddr == NEW_ADDR) {
943 zero_user_segment(page, 0, PAGE_CACHE_SIZE); 943 zero_user_segment(page, 0, PAGE_CACHE_SIZE);
944 } else { 944 } else {
945 if (f2fs_has_inline_data(inode)) 945 if (f2fs_has_inline_data(inode)) {
946 err = f2fs_read_inline_data(inode, page); 946 err = f2fs_read_inline_data(inode, page);
947 else 947 if (err) {
948 page_cache_release(page);
949 return err;
950 }
951 } else {
948 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr, 952 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
949 READ_SYNC); 953 READ_SYNC);
950 if (err) 954 if (err)
951 return err; 955 return err;
956 }
957
952 lock_page(page); 958 lock_page(page);
953 if (unlikely(!PageUptodate(page))) { 959 if (unlikely(!PageUptodate(page))) {
954 f2fs_put_page(page, 1); 960 f2fs_put_page(page, 1);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 31ee5b164ff9..383db1fabcf4 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -45,8 +45,10 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page)
45 } 45 }
46 46
47 ipage = get_node_page(sbi, inode->i_ino); 47 ipage = get_node_page(sbi, inode->i_ino);
48 if (IS_ERR(ipage)) 48 if (IS_ERR(ipage)) {
49 unlock_page(page);
49 return PTR_ERR(ipage); 50 return PTR_ERR(ipage);
51 }
50 52
51 zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE); 53 zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE);
52 54