diff mbox series

[3/4] btrfs-progs: Move btrfs_num_copies() call out of the loop in read_tree_block()

Message ID 20190307113133.27003-3-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series [1/4] btrfs-progs: Use @fs_info to replace @root for btrfs_check_leaf/node() | expand

Commit Message

Qu Wenruo March 7, 2019, 11:31 a.m. UTC
btrfs_num_copies really only needs to be called once, so move it out of
the verification loop in read_tree_block().

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 disk-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/disk-io.c b/disk-io.c
index 369592eb7b5c..1736d4a1f94b 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -349,6 +349,7 @@  struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
 	if (btrfs_buffer_uptodate(eb, parent_transid))
 		return eb;
 
+	num_copies = btrfs_num_copies(fs_info, eb->start, eb->len);
 	while (1) {
 		ret = read_whole_eb(fs_info, eb, mirror_num);
 		if (ret == 0 && csum_tree_block(fs_info, eb, 1) == 0 &&
@@ -376,7 +377,6 @@  struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
 			ret = -EIO;
 			break;
 		}
-		num_copies = btrfs_num_copies(fs_info, eb->start, eb->len);
 		if (num_copies == 1) {
 			ignore = 1;
 			continue;