aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c643433629a7..1d7f043152b0 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4440,7 +4440,7 @@ static noinline int replace_one_extent(struct btrfs_trans_handle *trans,
4440 u64 lock_end = 0; 4440 u64 lock_end = 0;
4441 u64 num_bytes; 4441 u64 num_bytes;
4442 u64 ext_offset; 4442 u64 ext_offset;
4443 u64 first_pos; 4443 u64 search_end = (u64)-1;
4444 u32 nritems; 4444 u32 nritems;
4445 int nr_scaned = 0; 4445 int nr_scaned = 0;
4446 int extent_locked = 0; 4446 int extent_locked = 0;
@@ -4448,7 +4448,6 @@ static noinline int replace_one_extent(struct btrfs_trans_handle *trans,
4448 int ret; 4448 int ret;
4449 4449
4450 memcpy(&key, leaf_key, sizeof(key)); 4450 memcpy(&key, leaf_key, sizeof(key));
4451 first_pos = INT_LIMIT(loff_t) - extent_key->offset;
4452 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS) { 4451 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS) {
4453 if (key.objectid < ref_path->owner_objectid || 4452 if (key.objectid < ref_path->owner_objectid ||
4454 (key.objectid == ref_path->owner_objectid && 4453 (key.objectid == ref_path->owner_objectid &&
@@ -4497,7 +4496,7 @@ next:
4497 if ((key.objectid > ref_path->owner_objectid) || 4496 if ((key.objectid > ref_path->owner_objectid) ||
4498 (key.objectid == ref_path->owner_objectid && 4497 (key.objectid == ref_path->owner_objectid &&
4499 key.type > BTRFS_EXTENT_DATA_KEY) || 4498 key.type > BTRFS_EXTENT_DATA_KEY) ||
4500 (key.offset >= first_pos + extent_key->offset)) 4499 key.offset >= search_end)
4501 break; 4500 break;
4502 } 4501 }
4503 4502
@@ -4530,8 +4529,10 @@ next:
4530 num_bytes = btrfs_file_extent_num_bytes(leaf, fi); 4529 num_bytes = btrfs_file_extent_num_bytes(leaf, fi);
4531 ext_offset = btrfs_file_extent_offset(leaf, fi); 4530 ext_offset = btrfs_file_extent_offset(leaf, fi);
4532 4531
4533 if (first_pos > key.offset - ext_offset) 4532 if (search_end == (u64)-1) {
4534 first_pos = key.offset - ext_offset; 4533 search_end = key.offset - ext_offset +
4534 btrfs_file_extent_ram_bytes(leaf, fi);
4535 }
4535 4536
4536 if (!extent_locked) { 4537 if (!extent_locked) {
4537 lock_start = key.offset; 4538 lock_start = key.offset;
@@ -4720,7 +4721,7 @@ next:
4720 } 4721 }
4721skip: 4722skip:
4722 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS && 4723 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS &&
4723 key.offset >= first_pos + extent_key->offset) 4724 key.offset >= search_end)
4724 break; 4725 break;
4725 4726
4726 cond_resched(); 4727 cond_resched();