diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2012-08-29 03:07:56 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-10-01 15:19:06 -0400 |
commit | d2794405113cd04f13a58e32e4d541dc87ec86e4 (patch) | |
tree | 66e0cf6f3826641f2f46782cd98f3715ea15ae18 /fs/btrfs/tree-log.c | |
parent | 46d8bc34248f3a94dea910137d1ddf5fb1e3a1cc (diff) |
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: Liu Bo <bo.li.liu@oracle.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r-- | fs/btrfs/tree-log.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index fc0df95c2862..5e2ffb95cc64 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -2680,13 +2680,14 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans, | |||
2680 | } | 2680 | } |
2681 | 2681 | ||
2682 | static noinline int copy_items(struct btrfs_trans_handle *trans, | 2682 | static noinline int copy_items(struct btrfs_trans_handle *trans, |
2683 | struct btrfs_root *log, | 2683 | struct inode *inode, |
2684 | struct btrfs_path *dst_path, | 2684 | struct btrfs_path *dst_path, |
2685 | struct extent_buffer *src, | 2685 | struct extent_buffer *src, |
2686 | int start_slot, int nr, int inode_only) | 2686 | int start_slot, int nr, int inode_only) |
2687 | { | 2687 | { |
2688 | unsigned long src_offset; | 2688 | unsigned long src_offset; |
2689 | unsigned long dst_offset; | 2689 | unsigned long dst_offset; |
2690 | struct btrfs_root *log = BTRFS_I(inode)->root->log_root; | ||
2690 | struct btrfs_file_extent_item *extent; | 2691 | struct btrfs_file_extent_item *extent; |
2691 | struct btrfs_inode_item *inode_item; | 2692 | struct btrfs_inode_item *inode_item; |
2692 | int ret; | 2693 | int ret; |
@@ -2695,6 +2696,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, | |||
2695 | char *ins_data; | 2696 | char *ins_data; |
2696 | int i; | 2697 | int i; |
2697 | struct list_head ordered_sums; | 2698 | struct list_head ordered_sums; |
2699 | int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; | ||
2698 | 2700 | ||
2699 | INIT_LIST_HEAD(&ordered_sums); | 2701 | INIT_LIST_HEAD(&ordered_sums); |
2700 | 2702 | ||
@@ -2745,7 +2747,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, | |||
2745 | * or deletes of this inode don't have to relog the inode | 2747 | * or deletes of this inode don't have to relog the inode |
2746 | * again | 2748 | * again |
2747 | */ | 2749 | */ |
2748 | if (btrfs_key_type(ins_keys + i) == BTRFS_EXTENT_DATA_KEY) { | 2750 | if (btrfs_key_type(ins_keys + i) == BTRFS_EXTENT_DATA_KEY && |
2751 | !skip_csum) { | ||
2749 | int found_type; | 2752 | int found_type; |
2750 | extent = btrfs_item_ptr(src, start_slot + i, | 2753 | extent = btrfs_item_ptr(src, start_slot + i, |
2751 | struct btrfs_file_extent_item); | 2754 | struct btrfs_file_extent_item); |
@@ -2873,7 +2876,7 @@ next_slot: | |||
2873 | args->start_slot + args->nr == path->slots[0]) { | 2876 | args->start_slot + args->nr == path->slots[0]) { |
2874 | args->nr++; | 2877 | args->nr++; |
2875 | } else if (args->nr) { | 2878 | } else if (args->nr) { |
2876 | ret = copy_items(trans, log, dst_path, args->src, | 2879 | ret = copy_items(trans, inode, dst_path, args->src, |
2877 | args->start_slot, args->nr, | 2880 | args->start_slot, args->nr, |
2878 | LOG_INODE_ALL); | 2881 | LOG_INODE_ALL); |
2879 | if (ret) | 2882 | if (ret) |
@@ -2910,7 +2913,7 @@ next_slot: | |||
2910 | } | 2913 | } |
2911 | 2914 | ||
2912 | if (args->nr) { | 2915 | if (args->nr) { |
2913 | ret = copy_items(trans, log, dst_path, args->src, | 2916 | ret = copy_items(trans, inode, dst_path, args->src, |
2914 | args->start_slot, args->nr, | 2917 | args->start_slot, args->nr, |
2915 | LOG_INODE_ALL); | 2918 | LOG_INODE_ALL); |
2916 | if (ret) | 2919 | if (ret) |
@@ -2930,7 +2933,6 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, | |||
2930 | struct btrfs_path *dst_path) | 2933 | struct btrfs_path *dst_path) |
2931 | { | 2934 | { |
2932 | struct log_args args; | 2935 | struct log_args args; |
2933 | struct btrfs_root *log = root->log_root; | ||
2934 | struct extent_map *em, *n; | 2936 | struct extent_map *em, *n; |
2935 | struct list_head extents; | 2937 | struct list_head extents; |
2936 | struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree; | 2938 | 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 | * our search | 2973 | * our search |
2972 | */ | 2974 | */ |
2973 | if (args.nr && em->mod_start != args.next_offset) { | 2975 | if (args.nr && em->mod_start != args.next_offset) { |
2974 | ret = copy_items(trans, log, dst_path, args.src, | 2976 | ret = copy_items(trans, inode, dst_path, args.src, |
2975 | args.start_slot, args.nr, | 2977 | args.start_slot, args.nr, |
2976 | LOG_INODE_ALL); | 2978 | LOG_INODE_ALL); |
2977 | if (ret) | 2979 | if (ret) |
@@ -2984,7 +2986,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, | |||
2984 | } | 2986 | } |
2985 | 2987 | ||
2986 | if (!ret && args.nr) | 2988 | if (!ret && args.nr) |
2987 | ret = copy_items(trans, log, dst_path, args.src, | 2989 | ret = copy_items(trans, inode, dst_path, args.src, |
2988 | args.start_slot, args.nr, LOG_INODE_ALL); | 2990 | args.start_slot, args.nr, LOG_INODE_ALL); |
2989 | btrfs_release_path(path); | 2991 | btrfs_release_path(path); |
2990 | WARN_ON(!list_empty(&extents)); | 2992 | WARN_ON(!list_empty(&extents)); |
@@ -3109,7 +3111,7 @@ again: | |||
3109 | goto next_slot; | 3111 | goto next_slot; |
3110 | } | 3112 | } |
3111 | 3113 | ||
3112 | ret = copy_items(trans, log, dst_path, src, ins_start_slot, | 3114 | ret = copy_items(trans, inode, dst_path, src, ins_start_slot, |
3113 | ins_nr, inode_only); | 3115 | ins_nr, inode_only); |
3114 | if (ret) { | 3116 | if (ret) { |
3115 | err = ret; | 3117 | err = ret; |
@@ -3127,7 +3129,7 @@ next_slot: | |||
3127 | goto again; | 3129 | goto again; |
3128 | } | 3130 | } |
3129 | if (ins_nr) { | 3131 | if (ins_nr) { |
3130 | ret = copy_items(trans, log, dst_path, src, | 3132 | ret = copy_items(trans, inode, dst_path, src, |
3131 | ins_start_slot, | 3133 | ins_start_slot, |
3132 | ins_nr, inode_only); | 3134 | ins_nr, inode_only); |
3133 | if (ret) { | 3135 | if (ret) { |
@@ -3148,8 +3150,7 @@ next_slot: | |||
3148 | break; | 3150 | break; |
3149 | } | 3151 | } |
3150 | if (ins_nr) { | 3152 | if (ins_nr) { |
3151 | ret = copy_items(trans, log, dst_path, src, | 3153 | ret = copy_items(trans, inode, dst_path, src, ins_start_slot, |
3152 | ins_start_slot, | ||
3153 | ins_nr, inode_only); | 3154 | ins_nr, inode_only); |
3154 | if (ret) { | 3155 | if (ret) { |
3155 | err = ret; | 3156 | err = ret; |