aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/tree-log.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 9e1f2cd5e67a..7e0e6e3029dd 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3298,7 +3298,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
3298 struct list_head ordered_sums; 3298 struct list_head ordered_sums;
3299 int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; 3299 int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
3300 bool has_extents = false; 3300 bool has_extents = false;
3301 bool need_find_last_extent = (*last_extent == 0); 3301 bool need_find_last_extent = true;
3302 bool done = false; 3302 bool done = false;
3303 3303
3304 INIT_LIST_HEAD(&ordered_sums); 3304 INIT_LIST_HEAD(&ordered_sums);
@@ -3352,8 +3352,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
3352 */ 3352 */
3353 if (ins_keys[i].type == BTRFS_EXTENT_DATA_KEY) { 3353 if (ins_keys[i].type == BTRFS_EXTENT_DATA_KEY) {
3354 has_extents = true; 3354 has_extents = true;
3355 if (need_find_last_extent && 3355 if (first_key.objectid == (u64)-1)
3356 first_key.objectid == (u64)-1)
3357 first_key = ins_keys[i]; 3356 first_key = ins_keys[i];
3358 } else { 3357 } else {
3359 need_find_last_extent = false; 3358 need_find_last_extent = false;
@@ -3427,6 +3426,16 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
3427 if (!has_extents) 3426 if (!has_extents)
3428 return ret; 3427 return ret;
3429 3428
3429 if (need_find_last_extent && *last_extent == first_key.offset) {
3430 /*
3431 * We don't have any leafs between our current one and the one
3432 * we processed before that can have file extent items for our
3433 * inode (and have a generation number smaller than our current
3434 * transaction id).
3435 */
3436 need_find_last_extent = false;
3437 }
3438
3430 /* 3439 /*
3431 * Because we use btrfs_search_forward we could skip leaves that were 3440 * Because we use btrfs_search_forward we could skip leaves that were
3432 * not modified and then assume *last_extent is valid when it really 3441 * not modified and then assume *last_extent is valid when it really
@@ -3537,7 +3546,7 @@ fill_holes:
3537 0, 0); 3546 0, 0);
3538 if (ret) 3547 if (ret)
3539 break; 3548 break;
3540 *last_extent = offset + len; 3549 *last_extent = extent_end;
3541 } 3550 }
3542 /* 3551 /*
3543 * Need to let the callers know we dropped the path so they should 3552 * Need to let the callers know we dropped the path so they should