Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1401083

[PATCH 2/2] f2fs: fix incorrect error path handling in f2fs_move_rehashed_dirents

Path csiph.com!news.mixmin.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From Chao Yu <yuchao0@huawei.com>
Newsgroups linux.kernel
Subject [PATCH 2/2] f2fs: fix incorrect error path handling in f2fs_move_rehashed_dirents
Date Sat, 14 May 2016 13:10:01 +0200
Message-ID <ryFCh-7WC-3@gated-at.bofh.it> (permalink)
References <ryFCh-7WC-1@gated-at.bofh.it>
X-Mailer git-send-email 2.8.2.311.gee88674
MIME-Version 1.0
Content-Type text/plain
X-Originating-IP [10.120.216.130]
X-Cfilter-Loop Reflected
X-Mirapoint-Virus-Rapid-Raw score=unknown(0), refid=str=0001.0A020203.57370626.0183,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32
X-Mirapoint-Loop-ID b1778c70a13b28930df21df7e3ad150f
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 48
Organization linux.* mail to news gateway
X-Original-Cc <linux-f2fs-devel@lists.sourceforge.net>, <linux-kernel@vger.kernel.org>, Chao Yu <yuchao0@huawei.com>
X-Original-Date Sat, 14 May 2016 19:03:53 +0800
X-Original-Message-ID <20160514110353.31981-2-yuchao0@huawei.com>
X-Original-References <20160514110353.31981-1-yuchao0@huawei.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1401083

Show key headers only | View raw


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>
---
 fs/f2fs/inline.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 60ba7ac..a4bb155 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);
-- 
2.8.2.311.gee88674

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] f2fs: fix i_current_depth during inline dentry conversion Chao Yu <yuchao0@huawei.com> - 2016-05-14 13:10 +0200
  [PATCH 2/2] f2fs: fix incorrect error path handling in f2fs_move_rehashed_dirents Chao Yu <yuchao0@huawei.com> - 2016-05-14 13:10 +0200

csiph-web