From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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) -- 1.7.1