From patchwork Thu Feb 21 20:34:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2173121 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 74A3FDF215 for ; Thu, 21 Feb 2013 20:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755611Ab3BUUmd (ORCPT ); Thu, 21 Feb 2013 15:42:33 -0500 Received: from dkim2.fusionio.com ([66.114.96.54]:38432 "EHLO dkim2.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755087Ab3BUU1N (ORCPT ); Thu, 21 Feb 2013 15:27:13 -0500 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim2.fusionio.com (Postfix) with ESMTP id 6A6D49A0359 for ; Thu, 21 Feb 2013 13:27:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1361478432; bh=INExtf9bNdSI96zAdgLlG2oERg0ks/IqsDGBH7D/vY4=; h=From:To:Subject:Date; b=bJpiyLqiGmuk1MD0CBRRfn5+TVxGe2Tzb771x3nTEfD/x2w5589eca+MDNhSdA4U/ 24NrgBBtzAgY4ItfH+hmTg0SFU350I2nr32gjHXOpR8dApHtADaqkOx1ijqDpWJxeu CemtqMXVntDv0XTo7pZCUbXjA//aVlxN/jJ0vwAk= X-ASG-Debug-ID: 1361478431-0421b5479800960001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx2.fusionio.com with ESMTP id AhGVGxtcHliySVyj (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Thu, 21 Feb 2013 13:27:11 -0700 (MST) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (98.26.82.158) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 21 Feb 2013 13:27:11 -0700 From: Josef Bacik To: Subject: [PATCH] Btrfs: make sure NODATACOW also gets NODATASUM set Date: Thu, 21 Feb 2013 15:34:15 -0500 X-ASG-Orig-Subj: [PATCH] Btrfs: make sure NODATACOW also gets NODATASUM set Message-ID: <1361478855-5059-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.7.7.6 MIME-Version: 1.0 X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21] X-Barracuda-Start-Time: 1361478431 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.123223 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org A user reported hitting the BUG_ON() in btrfs_finished_ordered_io() where we had csums on a NOCOW extent. This can happen if we have NODATACOW set but not NODATASUM set, which can happen in two cases, either we mount with -o nodatacow and then write into preallocated space, or chattr +C a directory and move a file into that directory. This patch fixes up those two cases and now we should uniformly have NODATACOW and NODATASUM set always. Thanks, Signed-off-by: Josef Bacik Reviewed-by: Liu Bo --- fs/btrfs/inode.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 40d49da..5d7ceb5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5574,7 +5574,8 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, if (btrfs_test_opt(root, NODATASUM)) BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM; if (btrfs_test_opt(root, NODATACOW)) - BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW; + BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW | + BTRFS_INODE_NODATASUM; } insert_inode_hash(inode); @@ -8069,7 +8070,8 @@ static void fixup_inode_flags(struct inode *dir, struct inode *inode) struct btrfs_inode *b_inode = BTRFS_I(inode); if (b_dir->flags & BTRFS_INODE_NODATACOW) - b_inode->flags |= BTRFS_INODE_NODATACOW; + b_inode->flags |= BTRFS_INODE_NODATACOW | + BTRFS_INODE_NODATASUM; else b_inode->flags &= ~BTRFS_INODE_NODATACOW;