summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2016-05-14 19:03:53 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2016-05-16 15:32:01 -0700
commit8975bdf48220cca703ad4586528e04b76b40ea1c (patch)
tree64ef3ff33c927c0c8365e03f15847f9fe4101b65
parente4103849ba784368e802eec4f15832ac54eb7d39 (diff)
downloadlinux-8975bdf48220cca703ad4586528e04b76b40ea1c.tar.gz
linux-8975bdf48220cca703ad4586528e04b76b40ea1c.tar.bz2
linux-8975bdf48220cca703ad4586528e04b76b40ea1c.zip
f2fs: fix incorrect error path handling in f2fs_move_rehashed_dirents
Fix two bugs in error path of f2fs_move_rehashed_dirents: - release dir's inode page if fail to call kmalloc - recover i_current_depth if fail to converting Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/inline.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 60ba7ac808b9..a4bb155dd00a 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -464,12 +464,15 @@ static int f2fs_move_rehashed_dirents(struct inode *dir, struct page *ipage,
struct f2fs_inline_dentry *inline_dentry)
{
struct f2fs_inline_dentry *backup_dentry;
+ struct f2fs_inode_info *fi = F2FS_I(dir);
int err;
backup_dentry = f2fs_kmalloc(sizeof(struct f2fs_inline_dentry),
GFP_F2FS_ZERO);
- if (!backup_dentry)
+ if (!backup_dentry) {
+ f2fs_put_page(ipage, 1);
return -ENOMEM;
+ }
memcpy(backup_dentry, inline_dentry, MAX_INLINE_DATA);
truncate_inline_inode(ipage, 0);
@@ -483,13 +486,14 @@ static int f2fs_move_rehashed_dirents(struct inode *dir, struct page *ipage,
lock_page(ipage);
stat_dec_inline_dir(dir);
- clear_inode_flag(F2FS_I(dir), FI_INLINE_DENTRY);
+ clear_inode_flag(fi, FI_INLINE_DENTRY);
update_inode(dir, ipage);
kfree(backup_dentry);
return 0;
recover:
lock_page(ipage);
memcpy(inline_dentry, backup_dentry, MAX_INLINE_DATA);
+ fi->i_current_depth = 0;
i_size_write(dir, MAX_INLINE_DATA);
update_inode(dir, ipage);
f2fs_put_page(ipage, 1);