From patchwork Mon Dec 1 14:25:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenjie6@huawei.com X-Patchwork-Id: 416302 X-Patchwork-Delegate: dwmw2@infradead.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A5F2A140160 for ; Mon, 1 Dec 2014 17:30:58 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XvKUD-0006Lz-Pd; Mon, 01 Dec 2014 06:29:29 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XvKUB-0006HK-1k for linux-mtd@lists.infradead.org; Mon, 01 Dec 2014 06:29:28 +0000 Received: from 172.24.2.119 (EHLO szxeml411-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CFI14635; Mon, 01 Dec 2014 14:28:40 +0800 (CST) Received: from linux-git.site (10.67.54.28) by szxeml411-hub.china.huawei.com (10.82.67.138) with Microsoft SMTP Server id 14.3.158.1; Mon, 1 Dec 2014 14:28:31 +0800 From: To: , Subject: | [PATCH] jffs2: bug fix of rename when jffs2_do_unlink failed Date: Mon, 1 Dec 2014 22:25:07 +0800 Message-ID: <1417443907-25150-1-git-send-email-chenjie6@huawei.com> X-Mailer: git-send-email 1.8.0 MIME-Version: 1.0 X-Originating-IP: [10.67.54.28] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141130_222927_510929_A7C73A9E X-CRM114-Status: UNSURE ( 8.72 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [119.145.14.64 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [119.145.14.64 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 DATE_IN_FUTURE_06_12 Date: is 6 to 12 hours after Received: date -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: lizefan@huawei.com, zengweilin@huawei.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: chenjie when jffs2_do_unlink return error will lead the jffs2 panic Testcase "touch a b; mv a b" when jffs2_do_unlink return error jffs2_rename(): Link succeeded, unlink failed (err -4). You now have a hard link ------------[ cut here ]------------ kernel BUG at fs/dcache.c:1018! Oops: Exception in kernel mode, sig: 5 [#1] PREEMPT SMP NR_CPUS=4 LTT NESTING LEVEL : 0 P2041 RDB last sysfs file: /sys/devices/virtual/kbox/kbox/dev Modules linked in: xt_tcpudp x_tables ip_tables ipt_REJECT iptable_filter i2c_mpc rtc_lib rtc_core rtc_ds3232 xgmac_mdio(P) fsl_mac fsl_oh fsl_dpaa cpld wdt kbox ddrramdriver rtos_kbox_panic rsm [last unloaded: hello] NIP: c0132b8c LR: c02051ec CTR: 0000001e REGS: ca4d9d10 TRAP: 0700 Tainted: P (2.6.34.13) MSR: 00029002 CR: 28828428 XER: 20000000 TASK = cb48c380[19475] 'rename14' THREAD: ca4d8000 CPU: 2 GPR00: 00000001 ca4d9dc0 cb48c380 c8aea360 c8969078 c0680ee8 ebc01dcc 61206861 GPR08: 00021002 c8968e40 cb48c380 0129f000 28828424 1001915c 100cf6e0 100cf7bc GPR16: 00000000 10131d08 00000000 00000000 10151f08 10157c08 c5eb1518 10151f08 GPR24: fffffffc cbcfae00 000d8e52 c5eb1518 c8968de0 c8aea360 c8969078 c8aea360 NIP [c0132b8c] d_instantiate+0x2c/0x80 LR [c02051ec] jffs2_rename+0x29c/0x2e0 Call Trace: [ca4d9dc0] [cb48c380] 0xcb48c380 (unreliable) [ca4d9de0] [c02051ec] jffs2_rename+0x29c/0x2e0 [ca4d9e10] [c0128908] vfs_rename+0x488/0x4f0 [ca4d9e50] [c012ad48] sys_renameat+0x1f8/0x210 [ca4d9f40] [c0010b70] ret_from_syscall+0x0/0x4 --- Exception: c01 at 0xfe95d5c LR = 0x1000088c Instruction dump: 60000000 9421ffe0 7c0802a6 bfa10014 7c7f1b78 90010024 3803004c 7c9e2378 8123004c 7f890000 38000001 7c00079e <0f000000> 3fa0c06b 3bbd4ac0 7fa3eb78 Kernel panic - not syncing: Fatal exception Call Trace: [ca4d9b10] [c0007970] show_stack+0x50/0x160 (unreliable) [ca4d9b40] [c04f4db4] panic+0x12c/0x1ac [ca4d9b90] [c000e65c] die+0x14c/0x230 [ca4d9bc0] [c000ea10] _exception+0x150/0x270 [ca4d9cd0] [c04ee800] program_check_exception+0xb0/0x660 [ca4d9d00] [c0011174] ret_from_except_full+0x0/0x4c --- Exception: 700 at d_instantiate+0x2c/0x80 LR = jffs2_rename+0x29c/0x2e0 [ca4d9dc0] [cb48c380] 0xcb48c380 (unreliable) [ca4d9de0] [c02051ec] jffs2_rename+0x29c/0x2e0 [ca4d9e10] [c0128908] vfs_rename+0x488/0x4f0 [ca4d9e50] [c012ad48] sys_renameat+0x1f8/0x210 [ca4d9f40] [c0010b70] ret_from_syscall+0x0/0x4 Cc: Signed-off-by: Chen Jie --- fs/jffs2/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 9385560..feb0213 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -846,7 +846,8 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, pr_notice("%s(): Link succeeded, unlink failed (err %d). You now have a hard link\n", __func__, ret); /* Might as well let the VFS know */ - d_instantiate(new_dentry, old_dentry->d_inode); + if (list_empty(&new_dentry->d_alias)) + d_instantiate(new_dentry, old_dentry->d_inode); ihold(old_dentry->d_inode); new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now); return ret;