Btrfs: Add mount -o nodatasum to turn of file data checksumming
Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e535c50..11885cb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -116,10 +116,13 @@
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_trans_handle *trans;
char *kaddr;
- int ret;
+ int ret = 0;
u64 page_start = (u64)page->index << PAGE_CACHE_SHIFT;
size_t offset = start - page_start;
+ if (btrfs_test_opt(root, NODATASUM))
+ return 0;
+
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
btrfs_set_trans_block_group(trans, inode);
@@ -143,6 +146,9 @@
struct btrfs_path *path = NULL;
u32 csum;
+ if (btrfs_test_opt(root, NODATASUM))
+ return 0;
+
mutex_lock(&root->fs_info->fs_mutex);
path = btrfs_alloc_path();
item = btrfs_lookup_csum(NULL, root, path, inode->i_ino, start, 0);
@@ -176,6 +182,9 @@
u32 csum = ~(u32)0;
unsigned long flags;
+ if (btrfs_test_opt(root, NODATASUM))
+ return 0;
+
ret = get_state_private(em_tree, start, &private);
local_irq_save(flags);
kaddr = kmap_atomic(page, KM_IRQ0);