Btrfs: make sure NODATACOW also gets NODATASUM set
authorJosef Bacik <jbacik@fusionio.com>
Thu, 21 Feb 2013 20:28:28 +0000 (15:28 -0500)
committerJosef Bacik <jbacik@fusionio.com>
Tue, 26 Feb 2013 15:57:48 +0000 (10:57 -0500)
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.  Liu has fixed the move case in a different place, but this
fixes the mount -o nodatacow case.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/inode.c

index 40d49da5e846ae97be4ab440d14d8c30da832990..14c82cdbb69637ff82923992ac1aaee27ad50911 100644 (file)
@@ -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);