Commit d2794405 authored by Liu Bo's avatar Liu Bo Committed by Chris Mason

Btrfs: check if an inode has no checksum when logging it

This is based on Josef's "Btrfs: turbo charge fsync".

If an inode is a BTRFS_INODE_NODATASUM one, we don't need to look for csum
items any more.
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
parent 46d8bc34
...@@ -2680,13 +2680,14 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans, ...@@ -2680,13 +2680,14 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
} }
static noinline int copy_items(struct btrfs_trans_handle *trans, static noinline int copy_items(struct btrfs_trans_handle *trans,
struct btrfs_root *log, struct inode *inode,
struct btrfs_path *dst_path, struct btrfs_path *dst_path,
struct extent_buffer *src, struct extent_buffer *src,
int start_slot, int nr, int inode_only) int start_slot, int nr, int inode_only)
{ {
unsigned long src_offset; unsigned long src_offset;
unsigned long dst_offset; unsigned long dst_offset;
struct btrfs_root *log = BTRFS_I(inode)->root->log_root;
struct btrfs_file_extent_item *extent; struct btrfs_file_extent_item *extent;
struct btrfs_inode_item *inode_item; struct btrfs_inode_item *inode_item;
int ret; int ret;
...@@ -2695,6 +2696,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, ...@@ -2695,6 +2696,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
char *ins_data; char *ins_data;
int i; int i;
struct list_head ordered_sums; struct list_head ordered_sums;
int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
INIT_LIST_HEAD(&ordered_sums); INIT_LIST_HEAD(&ordered_sums);
...@@ -2745,7 +2747,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, ...@@ -2745,7 +2747,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
* or deletes of this inode don't have to relog the inode * or deletes of this inode don't have to relog the inode
* again * again
*/ */
if (btrfs_key_type(ins_keys + i) == BTRFS_EXTENT_DATA_KEY) { if (btrfs_key_type(ins_keys + i) == BTRFS_EXTENT_DATA_KEY &&
!skip_csum) {
int found_type; int found_type;
extent = btrfs_item_ptr(src, start_slot + i, extent = btrfs_item_ptr(src, start_slot + i,
struct btrfs_file_extent_item); struct btrfs_file_extent_item);
...@@ -2873,7 +2876,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans, ...@@ -2873,7 +2876,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
args->start_slot + args->nr == path->slots[0]) { args->start_slot + args->nr == path->slots[0]) {
args->nr++; args->nr++;
} else if (args->nr) { } else if (args->nr) {
ret = copy_items(trans, log, dst_path, args->src, ret = copy_items(trans, inode, dst_path, args->src,
args->start_slot, args->nr, args->start_slot, args->nr,
LOG_INODE_ALL); LOG_INODE_ALL);
if (ret) if (ret)
...@@ -2910,7 +2913,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans, ...@@ -2910,7 +2913,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
} }
if (args->nr) { if (args->nr) {
ret = copy_items(trans, log, dst_path, args->src, ret = copy_items(trans, inode, dst_path, args->src,
args->start_slot, args->nr, args->start_slot, args->nr,
LOG_INODE_ALL); LOG_INODE_ALL);
if (ret) if (ret)
...@@ -2930,7 +2933,6 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, ...@@ -2930,7 +2933,6 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
struct btrfs_path *dst_path) struct btrfs_path *dst_path)
{ {
struct log_args args; struct log_args args;
struct btrfs_root *log = root->log_root;
struct extent_map *em, *n; struct extent_map *em, *n;
struct list_head extents; struct list_head extents;
struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree; struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree;
...@@ -2971,7 +2973,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, ...@@ -2971,7 +2973,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
* our search * our search
*/ */
if (args.nr && em->mod_start != args.next_offset) { if (args.nr && em->mod_start != args.next_offset) {
ret = copy_items(trans, log, dst_path, args.src, ret = copy_items(trans, inode, dst_path, args.src,
args.start_slot, args.nr, args.start_slot, args.nr,
LOG_INODE_ALL); LOG_INODE_ALL);
if (ret) if (ret)
...@@ -2984,7 +2986,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, ...@@ -2984,7 +2986,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
} }
if (!ret && args.nr) if (!ret && args.nr)
ret = copy_items(trans, log, dst_path, args.src, ret = copy_items(trans, inode, dst_path, args.src,
args.start_slot, args.nr, LOG_INODE_ALL); args.start_slot, args.nr, LOG_INODE_ALL);
btrfs_release_path(path); btrfs_release_path(path);
WARN_ON(!list_empty(&extents)); WARN_ON(!list_empty(&extents));
...@@ -3109,7 +3111,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, ...@@ -3109,7 +3111,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
goto next_slot; goto next_slot;
} }
ret = copy_items(trans, log, dst_path, src, ins_start_slot, ret = copy_items(trans, inode, dst_path, src, ins_start_slot,
ins_nr, inode_only); ins_nr, inode_only);
if (ret) { if (ret) {
err = ret; err = ret;
...@@ -3127,7 +3129,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, ...@@ -3127,7 +3129,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
goto again; goto again;
} }
if (ins_nr) { if (ins_nr) {
ret = copy_items(trans, log, dst_path, src, ret = copy_items(trans, inode, dst_path, src,
ins_start_slot, ins_start_slot,
ins_nr, inode_only); ins_nr, inode_only);
if (ret) { if (ret) {
...@@ -3148,8 +3150,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, ...@@ -3148,8 +3150,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
break; break;
} }
if (ins_nr) { if (ins_nr) {
ret = copy_items(trans, log, dst_path, src, ret = copy_items(trans, inode, dst_path, src, ins_start_slot,
ins_start_slot,
ins_nr, inode_only); ins_nr, inode_only);
if (ret) { if (ret) {
err = ret; err = ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment