Btrfs: Set nodatasum on the inode when written by a nodatasum mount
authorChris Mason <chris.mason@oracle.com>
Tue, 22 Apr 2008 13:24:20 +0000 (09:24 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:04:02 +0000 (11:04 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/file.c

index 3f5525f0834c687b36a3e0169bfb74907ba6ed49..5d537f26dc832557bb4df79e3d9cd4e579b2cd5f 100644 (file)
@@ -863,6 +863,14 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
        first_index = pos >> PAGE_CACHE_SHIFT;
        last_index = (pos + count) >> PAGE_CACHE_SHIFT;
 
+       /*
+        * if this is a nodatasum mount, force summing off for the inode
+        * all the time.  That way a later mount with summing on won't
+        * get confused
+        */
+       if (btrfs_test_opt(root, NODATASUM))
+               btrfs_set_flag(inode, NODATASUM);
+
        /*
         * there are lots of better ways to do this, but this code
         * makes sure the first and last page in the file range are