From patchwork Fri Feb 22 08:11:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 2175391 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 17423DFABD for ; Fri, 22 Feb 2013 08:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754376Ab3BVIMx (ORCPT ); Fri, 22 Feb 2013 03:12:53 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:27163 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752776Ab3BVIMw (ORCPT ); Fri, 22 Feb 2013 03:12:52 -0500 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r1M8CnZi004691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Feb 2013 08:12:50 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r1M8CkQG014092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 22 Feb 2013 08:12:46 GMT Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r1M8CkYC014354; Fri, 22 Feb 2013 02:12:46 -0600 Received: from liubo.cn.oracle.com (/10.182.228.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Feb 2013 00:12:45 -0800 From: Liu Bo To: linux-btrfs@vger.kernel.org Cc: Marios Titas Subject: [PATCH] Btrfs: update inode flags when renaming Date: Fri, 22 Feb 2013 16:11:31 +0800 Message-Id: <1361520691-22665-1-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 1.7.7.6 X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org A user reported some weird behaviours, if we move a file with the noCow flag to a directory without the noCow flag, the file is now without the flag, but after remount, we'll find the file's noCow flag comes back. This is because we missed a proper inode update after inheriting parent directory's flags, Reported-by: Marios Titas Signed-off-by: Liu Bo --- fs/btrfs/inode.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d9984fa..d2e3352 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7478,8 +7478,6 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, old_dentry->d_inode, old_dentry->d_name.name, old_dentry->d_name.len); - if (!ret) - ret = btrfs_update_inode(trans, root, old_inode); } if (ret) { btrfs_abort_transaction(trans, root, ret); @@ -7514,6 +7512,11 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, } fixup_inode_flags(new_dir, old_inode); + ret = btrfs_update_inode(trans, root, old_inode); + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto out_fail; + } ret = btrfs_add_link(trans, new_dir, old_inode, new_dentry->d_name.name,