btrfs: make btrfs_ordered_extent naming consistent with btrfs_file_extent_item

ordered->start, ordered->len, and ordered->disk_len correspond to
fi->disk_bytenr, fi->num_bytes, and fi->disk_num_bytes, respectively.
It's confusing to translate between the two naming schemes. Since a
btrfs_ordered_extent is basically a pending btrfs_file_extent_item,
let's make the former use the naming from the latter.

Note that I didn't touch the names in tracepoints just in case there are
scripts depending on the current naming.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Omar Sandoval 2019-12-02 17:34:19 -08:00 committed by David Sterba
parent 313facc5bd
commit bffe633e00
7 changed files with 90 additions and 95 deletions

View File

@ -481,8 +481,8 @@ blk_status_t btrfs_csum_one_bio(struct inode *inode, struct bio *bio,
- 1); - 1);
for (i = 0; i < nr_sectors; i++) { for (i = 0; i < nr_sectors; i++) {
if (offset >= ordered->file_offset + ordered->len || if (offset >= ordered->file_offset + ordered->num_bytes ||
offset < ordered->file_offset) { offset < ordered->file_offset) {
unsigned long bytes_left; unsigned long bytes_left;
sums->len = this_sum_bytes; sums->len = this_sum_bytes;

View File

@ -1501,7 +1501,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
ordered = btrfs_lookup_ordered_range(inode, start_pos, ordered = btrfs_lookup_ordered_range(inode, start_pos,
last_pos - start_pos + 1); last_pos - start_pos + 1);
if (ordered && if (ordered &&
ordered->file_offset + ordered->len > start_pos && ordered->file_offset + ordered->num_bytes > start_pos &&
ordered->file_offset <= last_pos) { ordered->file_offset <= last_pos) {
unlock_extent_cached(&inode->io_tree, start_pos, unlock_extent_cached(&inode->io_tree, start_pos,
last_pos, cached_state); last_pos, cached_state);
@ -2426,7 +2426,7 @@ static int btrfs_punch_hole_lock_range(struct inode *inode,
* we need to try again. * we need to try again.
*/ */
if ((!ordered || if ((!ordered ||
(ordered->file_offset + ordered->len <= lockstart || (ordered->file_offset + ordered->num_bytes <= lockstart ||
ordered->file_offset > lockend)) && ordered->file_offset > lockend)) &&
!filemap_range_has_page(inode->i_mapping, !filemap_range_has_page(inode->i_mapping,
lockstart, lockend)) { lockstart, lockend)) {
@ -3248,7 +3248,7 @@ static long btrfs_fallocate(struct file *file, int mode,
ordered = btrfs_lookup_first_ordered_extent(inode, locked_end); ordered = btrfs_lookup_first_ordered_extent(inode, locked_end);
if (ordered && if (ordered &&
ordered->file_offset + ordered->len > alloc_start && ordered->file_offset + ordered->num_bytes > alloc_start &&
ordered->file_offset < alloc_end) { ordered->file_offset < alloc_end) {
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
unlock_extent_cached(&BTRFS_I(inode)->io_tree, unlock_extent_cached(&BTRFS_I(inode)->io_tree,

View File

@ -2419,9 +2419,10 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
struct btrfs_trans_handle *trans = NULL; struct btrfs_trans_handle *trans = NULL;
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
struct extent_state *cached_state = NULL; struct extent_state *cached_state = NULL;
u64 start, end;
int compress_type = 0; int compress_type = 0;
int ret = 0; int ret = 0;
u64 logical_len = ordered_extent->len; u64 logical_len = ordered_extent->num_bytes;
bool freespace_inode; bool freespace_inode;
bool truncated = false; bool truncated = false;
bool range_locked = false; bool range_locked = false;
@ -2429,6 +2430,9 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
bool clear_reserved_extent = true; bool clear_reserved_extent = true;
unsigned int clear_bits; unsigned int clear_bits;
start = ordered_extent->file_offset;
end = start + ordered_extent->num_bytes - 1;
if (!test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) && if (!test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) &&
!test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags) && !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags) &&
!test_bit(BTRFS_ORDERED_DIRECT, &ordered_extent->flags)) !test_bit(BTRFS_ORDERED_DIRECT, &ordered_extent->flags))
@ -2441,10 +2445,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
goto out; goto out;
} }
btrfs_free_io_failure_record(BTRFS_I(inode), btrfs_free_io_failure_record(BTRFS_I(inode), start, end);
ordered_extent->file_offset,
ordered_extent->file_offset +
ordered_extent->len - 1);
if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) { if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) {
truncated = true; truncated = true;
@ -2462,8 +2463,8 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
* space for NOCOW range. * space for NOCOW range.
* As NOCOW won't cause a new delayed ref, just free the space * As NOCOW won't cause a new delayed ref, just free the space
*/ */
btrfs_qgroup_free_data(inode, NULL, ordered_extent->file_offset, btrfs_qgroup_free_data(inode, NULL, start,
ordered_extent->len); ordered_extent->num_bytes);
btrfs_ordered_update_i_size(inode, 0, ordered_extent); btrfs_ordered_update_i_size(inode, 0, ordered_extent);
if (freespace_inode) if (freespace_inode)
trans = btrfs_join_transaction_spacecache(root); trans = btrfs_join_transaction_spacecache(root);
@ -2482,9 +2483,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
} }
range_locked = true; range_locked = true;
lock_extent_bits(io_tree, ordered_extent->file_offset, lock_extent_bits(io_tree, start, end, &cached_state);
ordered_extent->file_offset + ordered_extent->len - 1,
&cached_state);
if (freespace_inode) if (freespace_inode)
trans = btrfs_join_transaction_spacecache(root); trans = btrfs_join_transaction_spacecache(root);
@ -2502,31 +2501,30 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
compress_type = ordered_extent->compress_type; compress_type = ordered_extent->compress_type;
if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) {
BUG_ON(compress_type); BUG_ON(compress_type);
btrfs_qgroup_free_data(inode, NULL, ordered_extent->file_offset, btrfs_qgroup_free_data(inode, NULL, start,
ordered_extent->len); ordered_extent->num_bytes);
ret = btrfs_mark_extent_written(trans, BTRFS_I(inode), ret = btrfs_mark_extent_written(trans, BTRFS_I(inode),
ordered_extent->file_offset, ordered_extent->file_offset,
ordered_extent->file_offset + ordered_extent->file_offset +
logical_len); logical_len);
} else { } else {
BUG_ON(root == fs_info->tree_root); BUG_ON(root == fs_info->tree_root);
ret = insert_reserved_file_extent(trans, inode, ret = insert_reserved_file_extent(trans, inode, start,
ordered_extent->file_offset, ordered_extent->disk_bytenr,
ordered_extent->start, ordered_extent->disk_num_bytes,
ordered_extent->disk_len,
logical_len, logical_len, logical_len, logical_len,
compress_type, 0, 0, compress_type, 0, 0,
BTRFS_FILE_EXTENT_REG); BTRFS_FILE_EXTENT_REG);
if (!ret) { if (!ret) {
clear_reserved_extent = false; clear_reserved_extent = false;
btrfs_release_delalloc_bytes(fs_info, btrfs_release_delalloc_bytes(fs_info,
ordered_extent->start, ordered_extent->disk_bytenr,
ordered_extent->disk_len); ordered_extent->disk_num_bytes);
} }
} }
unpin_extent_cache(&BTRFS_I(inode)->extent_tree, unpin_extent_cache(&BTRFS_I(inode)->extent_tree,
ordered_extent->file_offset, ordered_extent->len, ordered_extent->file_offset,
trans->transid); ordered_extent->num_bytes, trans->transid);
if (ret < 0) { if (ret < 0) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
@ -2551,27 +2549,22 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
clear_bits |= EXTENT_LOCKED; clear_bits |= EXTENT_LOCKED;
if (clear_new_delalloc_bytes) if (clear_new_delalloc_bytes)
clear_bits |= EXTENT_DELALLOC_NEW; clear_bits |= EXTENT_DELALLOC_NEW;
clear_extent_bit(&BTRFS_I(inode)->io_tree, clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, clear_bits,
ordered_extent->file_offset, (clear_bits & EXTENT_LOCKED) ? 1 : 0, 0,
ordered_extent->file_offset + ordered_extent->len - 1,
clear_bits, (clear_bits & EXTENT_LOCKED) ? 1 : 0, 0,
&cached_state); &cached_state);
if (trans) if (trans)
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
if (ret || truncated) { if (ret || truncated) {
u64 start, end; u64 unwritten_start = start;
if (truncated) if (truncated)
start = ordered_extent->file_offset + logical_len; unwritten_start += logical_len;
else clear_extent_uptodate(io_tree, unwritten_start, end, NULL);
start = ordered_extent->file_offset;
end = ordered_extent->file_offset + ordered_extent->len - 1;
clear_extent_uptodate(io_tree, start, end, NULL);
/* Drop the cache for the part of the extent we didn't write. */ /* Drop the cache for the part of the extent we didn't write. */
btrfs_drop_extent_cache(BTRFS_I(inode), start, end, 0); btrfs_drop_extent_cache(BTRFS_I(inode), unwritten_start, end, 0);
/* /*
* If the ordered extent had an IOERR or something else went * If the ordered extent had an IOERR or something else went
@ -2593,15 +2586,15 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
*/ */
if (ret && btrfs_test_opt(fs_info, DISCARD)) if (ret && btrfs_test_opt(fs_info, DISCARD))
btrfs_discard_extent(fs_info, btrfs_discard_extent(fs_info,
ordered_extent->start, ordered_extent->disk_bytenr,
ordered_extent->disk_len, NULL); ordered_extent->disk_num_bytes,
NULL);
btrfs_free_reserved_extent(fs_info, btrfs_free_reserved_extent(fs_info,
ordered_extent->start, ordered_extent->disk_bytenr,
ordered_extent->disk_len, 1); ordered_extent->disk_num_bytes, 1);
} }
} }
/* /*
* This needs to be done to make sure anybody waiting knows we are done * This needs to be done to make sure anybody waiting knows we are done
* updating everything for this ordered extent. * updating everything for this ordered extent.
@ -8228,7 +8221,8 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,
ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), start, ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), start,
page_end - start + 1); page_end - start + 1);
if (ordered) { if (ordered) {
end = min(page_end, ordered->file_offset + ordered->len - 1); end = min(page_end,
ordered->file_offset + ordered->num_bytes - 1);
/* /*
* IO on this page will never be started, so we need * IO on this page will never be started, so we need
* to account for any ordered extents now * to account for any ordered extents now
@ -8753,7 +8747,7 @@ void btrfs_destroy_inode(struct inode *inode)
else { else {
btrfs_err(fs_info, btrfs_err(fs_info,
"found ordered extent %llu %llu on inode cleanup", "found ordered extent %llu %llu on inode cleanup",
ordered->file_offset, ordered->len); ordered->file_offset, ordered->num_bytes);
btrfs_remove_ordered_extent(inode, ordered); btrfs_remove_ordered_extent(inode, ordered);
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);

View File

@ -20,9 +20,9 @@ static struct kmem_cache *btrfs_ordered_extent_cache;
static u64 entry_end(struct btrfs_ordered_extent *entry) static u64 entry_end(struct btrfs_ordered_extent *entry)
{ {
if (entry->file_offset + entry->len < entry->file_offset) if (entry->file_offset + entry->num_bytes < entry->file_offset)
return (u64)-1; return (u64)-1;
return entry->file_offset + entry->len; return entry->file_offset + entry->num_bytes;
} }
/* returns NULL if the insertion worked, or it returns the node it did find /* returns NULL if the insertion worked, or it returns the node it did find
@ -112,7 +112,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
static int offset_in_entry(struct btrfs_ordered_extent *entry, u64 file_offset) static int offset_in_entry(struct btrfs_ordered_extent *entry, u64 file_offset)
{ {
if (file_offset < entry->file_offset || if (file_offset < entry->file_offset ||
entry->file_offset + entry->len <= file_offset) entry->file_offset + entry->num_bytes <= file_offset)
return 0; return 0;
return 1; return 1;
} }
@ -121,7 +121,7 @@ static int range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset,
u64 len) u64 len)
{ {
if (file_offset + len <= entry->file_offset || if (file_offset + len <= entry->file_offset ||
entry->file_offset + entry->len <= file_offset) entry->file_offset + entry->num_bytes <= file_offset)
return 0; return 0;
return 1; return 1;
} }
@ -153,19 +153,14 @@ static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree,
} }
/* allocate and add a new ordered_extent into the per-inode tree. /* allocate and add a new ordered_extent into the per-inode tree.
* file_offset is the logical offset in the file
*
* start is the disk block number of an extent already reserved in the
* extent allocation tree
*
* len is the length of the extent
* *
* The tree is given a single reference on the ordered extent that was * The tree is given a single reference on the ordered extent that was
* inserted. * inserted.
*/ */
static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
u64 start, u64 len, u64 disk_len, u64 disk_bytenr, u64 num_bytes,
int type, int dio, int compress_type) u64 disk_num_bytes, int type, int dio,
int compress_type)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
@ -179,10 +174,10 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
return -ENOMEM; return -ENOMEM;
entry->file_offset = file_offset; entry->file_offset = file_offset;
entry->start = start; entry->disk_bytenr = disk_bytenr;
entry->len = len; entry->num_bytes = num_bytes;
entry->disk_len = disk_len; entry->disk_num_bytes = disk_num_bytes;
entry->bytes_left = len; entry->bytes_left = num_bytes;
entry->inode = igrab(inode); entry->inode = igrab(inode);
entry->compress_type = compress_type; entry->compress_type = compress_type;
entry->truncated_len = (u64)-1; entry->truncated_len = (u64)-1;
@ -190,7 +185,7 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
set_bit(type, &entry->flags); set_bit(type, &entry->flags);
if (dio) { if (dio) {
percpu_counter_add_batch(&fs_info->dio_bytes, len, percpu_counter_add_batch(&fs_info->dio_bytes, num_bytes,
fs_info->delalloc_batch); fs_info->delalloc_batch);
set_bit(BTRFS_ORDERED_DIRECT, &entry->flags); set_bit(BTRFS_ORDERED_DIRECT, &entry->flags);
} }
@ -241,27 +236,30 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
} }
int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
u64 start, u64 len, u64 disk_len, int type) u64 disk_bytenr, u64 num_bytes, u64 disk_num_bytes,
int type)
{ {
return __btrfs_add_ordered_extent(inode, file_offset, start, len, return __btrfs_add_ordered_extent(inode, file_offset, disk_bytenr,
disk_len, type, 0, num_bytes, disk_num_bytes, type, 0,
BTRFS_COMPRESS_NONE); BTRFS_COMPRESS_NONE);
} }
int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset, int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset,
u64 start, u64 len, u64 disk_len, int type) u64 disk_bytenr, u64 num_bytes,
u64 disk_num_bytes, int type)
{ {
return __btrfs_add_ordered_extent(inode, file_offset, start, len, return __btrfs_add_ordered_extent(inode, file_offset, disk_bytenr,
disk_len, type, 1, num_bytes, disk_num_bytes, type, 1,
BTRFS_COMPRESS_NONE); BTRFS_COMPRESS_NONE);
} }
int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset, int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset,
u64 start, u64 len, u64 disk_len, u64 disk_bytenr, u64 num_bytes,
int type, int compress_type) u64 disk_num_bytes, int type,
int compress_type)
{ {
return __btrfs_add_ordered_extent(inode, file_offset, start, len, return __btrfs_add_ordered_extent(inode, file_offset, disk_bytenr,
disk_len, type, 0, num_bytes, disk_num_bytes, type, 0,
compress_type); compress_type);
} }
@ -322,8 +320,8 @@ int btrfs_dec_test_first_ordered_pending(struct inode *inode,
} }
dec_start = max(*file_offset, entry->file_offset); dec_start = max(*file_offset, entry->file_offset);
dec_end = min(*file_offset + io_size, entry->file_offset + dec_end = min(*file_offset + io_size,
entry->len); entry->file_offset + entry->num_bytes);
*file_offset = dec_end; *file_offset = dec_end;
if (dec_start > dec_end) { if (dec_start > dec_end) {
btrfs_crit(fs_info, "bad ordering dec_start %llu end %llu", btrfs_crit(fs_info, "bad ordering dec_start %llu end %llu",
@ -465,10 +463,11 @@ void btrfs_remove_ordered_extent(struct inode *inode,
btrfs_mod_outstanding_extents(btrfs_inode, -1); btrfs_mod_outstanding_extents(btrfs_inode, -1);
spin_unlock(&btrfs_inode->lock); spin_unlock(&btrfs_inode->lock);
if (root != fs_info->tree_root) if (root != fs_info->tree_root)
btrfs_delalloc_release_metadata(btrfs_inode, entry->len, false); btrfs_delalloc_release_metadata(btrfs_inode, entry->num_bytes,
false);
if (test_bit(BTRFS_ORDERED_DIRECT, &entry->flags)) if (test_bit(BTRFS_ORDERED_DIRECT, &entry->flags))
percpu_counter_add_batch(&fs_info->dio_bytes, -entry->len, percpu_counter_add_batch(&fs_info->dio_bytes, -entry->num_bytes,
fs_info->delalloc_batch); fs_info->delalloc_batch);
tree = &btrfs_inode->ordered_tree; tree = &btrfs_inode->ordered_tree;
@ -528,8 +527,8 @@ u64 btrfs_wait_ordered_extents(struct btrfs_root *root, u64 nr,
ordered = list_first_entry(&splice, struct btrfs_ordered_extent, ordered = list_first_entry(&splice, struct btrfs_ordered_extent,
root_extent_list); root_extent_list);
if (range_end <= ordered->start || if (range_end <= ordered->disk_bytenr ||
ordered->start + ordered->disk_len <= range_start) { ordered->disk_bytenr + ordered->disk_num_bytes <= range_start) {
list_move_tail(&ordered->root_extent_list, &skipped); list_move_tail(&ordered->root_extent_list, &skipped);
cond_resched_lock(&root->ordered_extent_lock); cond_resched_lock(&root->ordered_extent_lock);
continue; continue;
@ -613,7 +612,7 @@ void btrfs_start_ordered_extent(struct inode *inode,
int wait) int wait)
{ {
u64 start = entry->file_offset; u64 start = entry->file_offset;
u64 end = start + entry->len - 1; u64 end = start + entry->num_bytes - 1;
trace_btrfs_ordered_extent_start(inode, entry); trace_btrfs_ordered_extent_start(inode, entry);
@ -674,7 +673,7 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
break; break;
} }
if (ordered->file_offset + ordered->len <= start) { if (ordered->file_offset + ordered->num_bytes <= start) {
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
break; break;
} }

View File

@ -67,14 +67,13 @@ struct btrfs_ordered_extent {
/* logical offset in the file */ /* logical offset in the file */
u64 file_offset; u64 file_offset;
/* disk byte number */ /*
u64 start; * These fields directly correspond to the same fields in
* btrfs_file_extent_item.
/* ram length of the extent in bytes */ */
u64 len; u64 disk_bytenr;
u64 num_bytes;
/* extent length on disk */ u64 disk_num_bytes;
u64 disk_len;
/* number of bytes that still need writing */ /* number of bytes that still need writing */
u64 bytes_left; u64 bytes_left;
@ -161,12 +160,15 @@ int btrfs_dec_test_first_ordered_pending(struct inode *inode,
u64 *file_offset, u64 io_size, u64 *file_offset, u64 io_size,
int uptodate); int uptodate);
int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
u64 start, u64 len, u64 disk_len, int type); u64 disk_bytenr, u64 num_bytes, u64 disk_num_bytes,
int type);
int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset, int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset,
u64 start, u64 len, u64 disk_len, int type); u64 disk_bytenr, u64 num_bytes,
u64 disk_num_bytes, int type);
int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset, int btrfs_add_ordered_extent_compress(struct inode *inode, u64 file_offset,
u64 start, u64 len, u64 disk_len, u64 disk_bytenr, u64 num_bytes,
int type, int compress_type); u64 disk_num_bytes, int type,
int compress_type);
void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry, void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry,
struct btrfs_ordered_sum *sum); struct btrfs_ordered_sum *sum);
struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode, struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode,

View File

@ -4668,7 +4668,7 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
LIST_HEAD(list); LIST_HEAD(list);
ordered = btrfs_lookup_ordered_extent(inode, file_pos); ordered = btrfs_lookup_ordered_extent(inode, file_pos);
BUG_ON(ordered->file_offset != file_pos || ordered->len != len); BUG_ON(ordered->file_offset != file_pos || ordered->num_bytes != len);
disk_bytenr = file_pos + BTRFS_I(inode)->index_cnt; disk_bytenr = file_pos + BTRFS_I(inode)->index_cnt;
ret = btrfs_lookup_csums_range(fs_info->csum_root, disk_bytenr, ret = btrfs_lookup_csums_range(fs_info->csum_root, disk_bytenr,
@ -4692,7 +4692,7 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
* disk_len vs real len like with real inodes since it's all * disk_len vs real len like with real inodes since it's all
* disk length. * disk length.
*/ */
new_bytenr = ordered->start + (sums->bytenr - disk_bytenr); new_bytenr = ordered->disk_bytenr + sums->bytenr - disk_bytenr;
sums->bytenr = new_bytenr; sums->bytenr = new_bytenr;
btrfs_add_ordered_sum(ordered, sums); btrfs_add_ordered_sum(ordered, sums);

View File

@ -496,9 +496,9 @@ DECLARE_EVENT_CLASS(btrfs__ordered_extent,
TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
__entry->ino = btrfs_ino(BTRFS_I(inode)); __entry->ino = btrfs_ino(BTRFS_I(inode));
__entry->file_offset = ordered->file_offset; __entry->file_offset = ordered->file_offset;
__entry->start = ordered->start; __entry->start = ordered->disk_bytenr;
__entry->len = ordered->len; __entry->len = ordered->num_bytes;
__entry->disk_len = ordered->disk_len; __entry->disk_len = ordered->disk_num_bytes;
__entry->bytes_left = ordered->bytes_left; __entry->bytes_left = ordered->bytes_left;
__entry->flags = ordered->flags; __entry->flags = ordered->flags;
__entry->compress_type = ordered->compress_type; __entry->compress_type = ordered->compress_type;