From patchwork Mon Jun 20 02:51:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhangaihua1@huawei.com X-Patchwork-Id: 9186477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C341E60871 for ; Mon, 20 Jun 2016 02:47:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8F7F223A6 for ; Mon, 20 Jun 2016 02:47:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC624223C7; Mon, 20 Jun 2016 02:47:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAB6A223A6 for ; Mon, 20 Jun 2016 02:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbcFTCrG (ORCPT ); Sun, 19 Jun 2016 22:47:06 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:10780 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbcFTCrF (ORCPT ); Sun, 19 Jun 2016 22:47:05 -0400 Received: from 172.24.1.60 (EHLO szxeml432-hub.china.huawei.com) ([172.24.1.60]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DIZ11092; Mon, 20 Jun 2016 10:44:38 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.235.1; Mon, 20 Jun 2016 10:44:27 +0800 From: To: , , CC: Aihua Zhang Subject: [PATCH] fix error: a bin file can truncate itself while running at overlayfs. Date: Mon, 20 Jun 2016 10:51:29 +0800 Message-ID: <1466391089-17404-1-git-send-email-zhangaihua1@huawei.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090206.57675899.0040, 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: f5dfbb05c20a368ecc74d1aafb9253db Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Aihua Zhang I wrote a testcase to truncate a bin file while it is running at overlayfs. the result as below: Bus error (core dumped) I think it's not appropriate for filesystem, and fixed it by this patch. after the patch, result as below: status:-1 errno:26 ETXTBSY:26 PASS This is because the inode is not correct ,it should point to overlayfs rather than the upper filesystem. Signed-off-by: Aihua Zhang --- include/linux/fs.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index dd28814..54fdbf9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2589,7 +2589,7 @@ static inline int get_write_access(struct inode *inode) } static inline int deny_write_access(struct file *file) { - struct inode *inode = file_inode(file); + struct inode *inode = d_inode(file->f_path.dentry); return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY; } static inline void put_write_access(struct inode * inode)