#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
#define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
BTRFS_MOUNT_##opt)
-
+/*
+ * Inode flags
+ */
+#define BTRFS_INODE_NODATASUM 0x1
+#define BTRFS_INODE_NODATACOW 0x2
+
+#define btrfs_clear_flag(inode, flag) (BTRFS_I(inode)->flags &= \
+ ~BTRFS_INODE_##flag)
+#define btrfs_set_flag(inode, flag) (BTRFS_I(inode)->flags |= \
+ BTRFS_INODE_##flag)
+#define btrfs_test_flag(inode, flag) (BTRFS_I(inode)->flags & \
+ BTRFS_INODE_##flag)
/* some macros to generate set/get funcs for the struct fields. This
* assumes there is a lefoo_to_cpu for every type, so lets make a simple
* one for u8:
struct btrfs_root *root = BTRFS_I(inode)->root;
u64 num_bytes;
int ret;
-
mutex_lock(&root->fs_info->fs_mutex);
- if (btrfs_test_opt(root, NODATACOW))
+ if (btrfs_test_opt(root, NODATACOW) ||
+ btrfs_test_flag(inode, NODATACOW))
ret = run_delalloc_nocow(inode, start, end);
else
ret = cow_file_range(inode, start, end);
int ret = 0;
u64 page_start = (u64)page->index << PAGE_CACHE_SHIFT;
size_t offset = start - page_start;
-
- if (btrfs_test_opt(root, NODATASUM))
+ if (btrfs_test_opt(root, NODATASUM) ||
+ btrfs_test_flag(inode, NODATASUM))
return 0;
-
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
btrfs_set_trans_block_group(trans, inode);
struct btrfs_csum_item *item;
struct btrfs_path *path = NULL;
u32 csum;
-
- if (btrfs_test_opt(root, NODATASUM))
+ if (btrfs_test_opt(root, NODATASUM) ||
+ btrfs_test_flag(inode, 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);
struct btrfs_root *root = BTRFS_I(inode)->root;
u32 csum = ~(u32)0;
unsigned long flags;
-
- if (btrfs_test_opt(root, NODATASUM))
+ if (btrfs_test_opt(root, NODATASUM) ||
+ btrfs_test_flag(inode, NODATASUM))
return 0;
-
ret = get_state_private(em_tree, start, &private);
local_irq_save(flags);
kaddr = kmap_atomic(page, KM_IRQ0);
alloc_group_block = btrfs_inode_block_group(leaf, inode_item);
BTRFS_I(inode)->block_group = btrfs_lookup_block_group(root->fs_info,
alloc_group_block);
-
+ BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item);
if (!BTRFS_I(inode)->block_group) {
BTRFS_I(inode)->block_group = btrfs_find_block_group(root,
NULL, 0, 0, 0);
btrfs_set_inode_nblocks(leaf, item, inode->i_blocks);
btrfs_set_inode_generation(leaf, item, inode->i_generation);
btrfs_set_inode_rdev(leaf, item, inode->i_rdev);
+ btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags);
btrfs_set_inode_block_group(leaf, item,
BTRFS_I(inode)->block_group->key.objectid);
}
owner = 1;
group = btrfs_find_block_group(root, group, 0, 0, owner);
BTRFS_I(inode)->block_group = group;
-
+ BTRFS_I(inode)->flags = 0;
ret = btrfs_insert_empty_inode(trans, root, path, objectid);
if (ret)
goto fail;