From patchwork Wed Oct 16 14:20:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13838540 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94621206971 for ; Wed, 16 Oct 2024 14:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088428; cv=none; b=ot5TXEhmElyhRQSkz4Vv9n6adsumE26qKvBcFJZKmbv2EYRg8qYqIYRtI/9DMB8TXUOKY0XE2sxLMWf847yexe0Gu7VIA1hlFDfleIiTOsY2oubHmoNYsMDG+9hvubEI1i0bQWik+Elw7sfgVdvM6KHnpqdpAPFEn6sKisu4Bgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088428; c=relaxed/simple; bh=kxPosLO7kCCEqa0S1klbJv2hO8XtsWTO4hCAu+6oBCY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sMcayYS2A+xup1dyM+13lecYcmeNTWBafjPnXoKED4pdTlaDwJmibwiJti/o4m4Z35rZAkpT3t2UW0vck8TBj4s1uNwtXGBSEKXCqPyxS5KYoE+Zqzp921bIvgsfAjiWT66yXjEiVkBunnBCsTrHo8jJ3HpHpBox5dbj7XA1uRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h3R8szQa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h3R8szQa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95776C4CEC5 for ; Wed, 16 Oct 2024 14:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729088428; bh=kxPosLO7kCCEqa0S1klbJv2hO8XtsWTO4hCAu+6oBCY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=h3R8szQaHyYP4AUllovtVwfe1A5DFxMDhvHu1hqHvNTDpRyx7GTtMbusm9XWl0G6y csyVtaanFEsC/aL/hCuLta0sGqjprppwKrtujpoXyKxy8k2MkG4QYnSv9fZUbcOixm dd0fuxGWx2/l9E33e+d7elxdObCP8CeSnUHoLCu8309Md395InShiGC350joTxMUM6 YbC8LtzMvQAHO/tzx3LjNYlVnvXnrYZ+2zM0uyglOkzkKA6G/dfyq6BlU2QBPqJJ7+ +mXZPplsCDgpMgEG8i7Zuih8V+Z9zxOqXbjPF6Vh2KX1fAA/+i3otkFHOCIKuaflsX T5SjFFBNKs+8Q== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/4] btrfs: remove redundant level argument from read_block_for_search() Date: Wed, 16 Oct 2024 15:20:20 +0100 Message-Id: <9d4bff651960da766b8d302c784ebf67ed1c54eb.1729075703.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana The level parameter passed to read_block_for_search() always matches the level of the extent buffer passed in the "eb_ret" parameter, which we are also extracting into the "parent_level" local variable. So remove the level parameter and instead use the "parent_level" variable which in fact has a better (it's the level of the parent node from which we are reading a child node/leaf). Signed-off-by: Filipe Manana --- fs/btrfs/ctree.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 4f34208126f7..428c5650559a 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1508,7 +1508,7 @@ static noinline void unlock_up(struct btrfs_path *path, int level, */ static int read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, - struct extent_buffer **eb_ret, int level, int slot, + struct extent_buffer **eb_ret, int slot, const struct btrfs_key *key) { struct btrfs_fs_info *fs_info = root->fs_info; @@ -1542,7 +1542,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, tmp = find_extent_buffer(fs_info, blocknr); if (tmp) { if (p->reada == READA_FORWARD_ALWAYS) - reada_for_search(fs_info, p, level, slot, key->objectid); + reada_for_search(fs_info, p, parent_level, slot, key->objectid); /* first we do an atomic uptodate check */ if (btrfs_buffer_uptodate(tmp, gen, 1) > 0) { @@ -1568,7 +1568,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, } if (!p->skip_locking) { - btrfs_unlock_up_safe(p, level + 1); + btrfs_unlock_up_safe(p, parent_level + 1); tmp_locked = true; btrfs_tree_read_lock(tmp); btrfs_release_path(p); @@ -1595,12 +1595,12 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, } if (!p->skip_locking) { - btrfs_unlock_up_safe(p, level + 1); + btrfs_unlock_up_safe(p, parent_level + 1); ret = -EAGAIN; } if (p->reada != READA_NONE) - reada_for_search(fs_info, p, level, slot, key->objectid); + reada_for_search(fs_info, p, parent_level, slot, key->objectid); tmp = btrfs_find_create_tree_block(fs_info, blocknr, check.owner_root, check.level); if (IS_ERR(tmp)) { @@ -2236,7 +2236,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root, goto done; } - err = read_block_for_search(root, p, &b, level, slot, key); + err = read_block_for_search(root, p, &b, slot, key); if (err == -EAGAIN && !p->nowait) goto again; if (err) { @@ -2363,7 +2363,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key, goto done; } - err = read_block_for_search(root, p, &b, level, slot, key); + err = read_block_for_search(root, p, &b, slot, key); if (err == -EAGAIN && !p->nowait) goto again; if (err) { @@ -4969,8 +4969,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, } next = c; - ret = read_block_for_search(root, path, &next, level, - slot, &key); + ret = read_block_for_search(root, path, &next, slot, &key); if (ret == -EAGAIN && !path->nowait) goto again; @@ -5013,8 +5012,7 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, if (!level) break; - ret = read_block_for_search(root, path, &next, level, - 0, &key); + ret = read_block_for_search(root, path, &next, 0, &key); if (ret == -EAGAIN && !path->nowait) goto again; From patchwork Wed Oct 16 14:20:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13838541 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92C3D20966A for ; Wed, 16 Oct 2024 14:20:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088429; cv=none; b=e05+Bft94ki3BuJl3F08hIbXuwozGrgsci6wY1R5qNLTEdR1/mCiG7sSjE4AqmWJTLGeMTv3i+D+1wAvYVU9j0zl2YHTk6bNVmshCG4VzZzIQpdpx6DYaL6KJWAuvxYh8X51aMO/Mr84OMmLxF6UHXf1WpTlfNEJKy2Zd+Rnz60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088429; c=relaxed/simple; bh=b/x7Q8KRxQMVrbhCD078lZnJzk6LpXtuMI0WtccXevI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MaxYUYHZhxtbjj68Qdqoi9qhHPX8wqDnbOFgDO3Z6bfW4v+sNsUuxFbOXI6sQGp4vqEWQeXWT0w6PAw36NpPWaz5eX1PO1KAtgps7jfvQHsohOzuqpU7m9HXhk233tuJT1ymfmYNREmDwn9GRA5iFROlybFLu7Rx078yiIZ2Zzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VKgIhtsD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VKgIhtsD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 983BBC4CEC7 for ; Wed, 16 Oct 2024 14:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729088429; bh=b/x7Q8KRxQMVrbhCD078lZnJzk6LpXtuMI0WtccXevI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VKgIhtsDvIQ6s6/P2bvK3KdxQkc4DbFogleKgYI5advLg/7qPzdFUg6KFqJZPuvci L3Ik9I5m+NSQb2iNryNBMPHDFLr3tdahR9VudTUjUWOGpOBTrPiEBdSPRfoXttSdSA CMus6kZ2gQnYIDSseCcYIUtaONiJPxQIIlcuYyWW2Y0V4X9/Lqo8QCSM7bpn1XwFhb +3nKXns7Ig/C0fwjN23df/KmLTD4eWqLEwyOvrtTlFuwR9DQaZrwjRKgqIQh1wYJRd qp6EnFzp7Cj5huCC+ZhHmMYhPPOI8CCjzbZknyCiYiqMLm/5nNHcrMkGRoWc7JH52u 34cJlEvC9wzWg== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/4] btrfs: simplify arguments for btrfs_verify_level_key() Date: Wed, 16 Oct 2024 15:20:21 +0100 Message-Id: <8127692fa51b37be7d2e1e770a56f6ab53f75002.1729075703.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana The only caller of btrfs_verify_level_key() is read_block_for_search() and it's passing 3 arguments to it that can be extracted from its on stack variable of type struct btrfs_tree_parent_check. So change btrfs_verify_level_key() to accept an argument of type struct btrfs_tree_parent_check instead of level, first key and parent transid arguments. Signed-off-by: Filipe Manana --- fs/btrfs/ctree.c | 3 +-- fs/btrfs/tree-checker.c | 16 ++++++++-------- fs/btrfs/tree-checker.h | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 428c5650559a..f68a9b586079 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1551,8 +1551,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, * being cached, read from scrub, or have multiple * parents (shared tree blocks). */ - if (btrfs_verify_level_key(tmp, - parent_level - 1, &check.first_key, gen)) { + if (btrfs_verify_level_key(tmp, &check)) { ret = -EUCLEAN; goto out; } diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index 7b50263723bc..148d8cefa40e 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -2183,8 +2183,8 @@ int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner) return 0; } -int btrfs_verify_level_key(struct extent_buffer *eb, int level, - struct btrfs_key *first_key, u64 parent_transid) +int btrfs_verify_level_key(struct extent_buffer *eb, + const struct btrfs_tree_parent_check *check) { struct btrfs_fs_info *fs_info = eb->fs_info; int found_level; @@ -2192,16 +2192,16 @@ int btrfs_verify_level_key(struct extent_buffer *eb, int level, int ret; found_level = btrfs_header_level(eb); - if (found_level != level) { + if (found_level != check->level) { WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG), KERN_ERR "BTRFS: tree level check failed\n"); btrfs_err(fs_info, "tree level mismatch detected, bytenr=%llu level expected=%u has=%u", - eb->start, level, found_level); + eb->start, check->level, found_level); return -EIO; } - if (!first_key) + if (!check->has_first_key) return 0; /* @@ -2226,15 +2226,15 @@ int btrfs_verify_level_key(struct extent_buffer *eb, int level, btrfs_node_key_to_cpu(eb, &found_key, 0); else btrfs_item_key_to_cpu(eb, &found_key, 0); - ret = btrfs_comp_cpu_keys(first_key, &found_key); + ret = btrfs_comp_cpu_keys(&check->first_key, &found_key); if (ret) { WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG), KERN_ERR "BTRFS: tree first key check failed\n"); btrfs_err(fs_info, "tree first key mismatch detected, bytenr=%llu parent_transid=%llu key expected=(%llu,%u,%llu) has=(%llu,%u,%llu)", - eb->start, parent_transid, first_key->objectid, - first_key->type, first_key->offset, + eb->start, check->transid, check->first_key.objectid, + check->first_key.type, check->first_key.offset, found_key.objectid, found_key.type, found_key.offset); } diff --git a/fs/btrfs/tree-checker.h b/fs/btrfs/tree-checker.h index 01669cfa6578..db67f96cbe4b 100644 --- a/fs/btrfs/tree-checker.h +++ b/fs/btrfs/tree-checker.h @@ -69,7 +69,7 @@ int btrfs_check_node(struct extent_buffer *node); int btrfs_check_chunk_valid(struct extent_buffer *leaf, struct btrfs_chunk *chunk, u64 logical); int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner); -int btrfs_verify_level_key(struct extent_buffer *eb, int level, - struct btrfs_key *first_key, u64 parent_transid); +int btrfs_verify_level_key(struct extent_buffer *eb, + const struct btrfs_tree_parent_check *check); #endif From patchwork Wed Oct 16 14:20:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13838542 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D48B20C006 for ; Wed, 16 Oct 2024 14:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088430; cv=none; b=hbsERt/xIKfZWT1A8OgLGfmDeqQshNthmev0JmAPSmG7MLZOD3OUmx7E4eKrZS3V/H/7Habn5VKmyABVB7wlEIjLWAE/lKVDIKX8J3jXoyDG3JkPYL3PsXXLaieobYQS+mEH698swOQ2MdmOhrcXWrqsEIT7CaQKRztiKXvdvAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088430; c=relaxed/simple; bh=Ghs9PQbfpXHaC5oZ1IJAokc81/loWXff3lxU7QgHy5Q=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HzjjSEcwVZi3hohCxHGOE0URA1FWwKCMypnEz8JceOwoYpWagMlF75iUJaJfZsHKGSKvCoYJGVtT+ILhdyRvll/YrCcHWw57CQ0x/bP4LC3M9wnycAdTOAreeX5ucTpW1Wrpa6f/qczHJkENW3JrVyU8m1mMBBvLtvVqlfLqANc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Uw2rxODn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Uw2rxODn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D19EC4CEC5 for ; Wed, 16 Oct 2024 14:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729088430; bh=Ghs9PQbfpXHaC5oZ1IJAokc81/loWXff3lxU7QgHy5Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Uw2rxODnl38e8OyrhR9sT1xJkjoHV6ejTFfQ7Msul4eb7XcULhe7PqQ+U3LAEpXWF RUQqnT7iHvNeeUauSgm1ReWcp9jWiYobhmpejEdvCkJsNi3Ck/9esPuxKnfXsMfbW/ sI0+o61zBw15nsPNgrgj4NxOg6mKzzm6S6Ez4ufHOUsMMAEbHjXQzwaeCbwqXzcyUG 7tVyswTM34QQOy9F+hz5Ymov/awkmvp1IwIE4cke+BH9q/J7j2S0RoI9HE5eriTEgE g6dTvpjmsxqSeAWbkyLwt2pwA2NGZBimls8g/jFhFqBbVZOVuLLnw8pQ2xh25GOxpe Qe/fLT0q4QpfA== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 3/4] btrfs: remove redundant initialization from btrfs_readahead_tree_block() Date: Wed, 16 Oct 2024 15:20:22 +0100 Message-Id: <22e345124a6e35e4dbc07e9564475b5c97b37a41.1729075703.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana It's pointless to initialize the has_first_key field of the stack local btrfs_tree_parent_check structure since it all fields not explicitly initialized are zeroed out, plus it's a bit odd because the field is of type bool and we are assigning 0 instead of false to it (however it's not incorrect since 0 is converted to false). Just remove the explicit initialization due to its redundancy. Signed-off-by: Filipe Manana --- fs/btrfs/extent_io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 09c0d18a7b5a..0a0c84eb1c42 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4285,7 +4285,6 @@ void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, u64 owner_root, u64 gen, int level) { struct btrfs_tree_parent_check check = { - .has_first_key = 0, .level = level, .transid = gen }; From patchwork Wed Oct 16 14:20:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13838543 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E69120C01B for ; Wed, 16 Oct 2024 14:20:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088431; cv=none; b=JZNewWq2aDBJ697My5I/Dg81JhceC2oixhngHZTKNwRSvzCDSWi/NTKoMFBDo23oX03TMvDstBlqZ8FQ41yb5TEG1tZbZrSkKL3H7D9IBh4a9Ftq3IYi3lp0ZFwgJX4SodNqM6Ulg/646knPqN48RVde3uJSjrNdgI/zF7mGrjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729088431; c=relaxed/simple; bh=5GvpSF95Bj0JzBD8AbxRz0xrzWvSJbEAhMa9lrdsiOg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uZ91Ht3vLgL9G6t9u2nh8olcNNW2dQSuBbz35+6qaos5pfv/iDRnzXJ/bfreRIMpbITLvntRyhmhX9PChHEuLbi64hujbIJDNeSC1O0IctcinMl+/D992SdNLAkpvGO//Gectk/9WaGciqiDBsV5IAgSbWU3Q8zoWEwJgh/Dx3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H5Wb6s8w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H5Wb6s8w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A02C9C4CEC7 for ; Wed, 16 Oct 2024 14:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729088431; bh=5GvpSF95Bj0JzBD8AbxRz0xrzWvSJbEAhMa9lrdsiOg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=H5Wb6s8wM8klx5Y28UvBvU47BbbKAOW7AsyAj0CX5ivRRT3RFNnuth14EdNu+1hKZ qJrKv3G202drZd/olz3j2gAajV/bNg0cyGrbUmyWi76LZ5RHaf+tpCWhpFuF/hYNFo gaa4YhVfE36I7JUP6VjkiUo/j6J8ug4xmGm6Oh/T6fJoP1VNhHC4bZPbreg7/6/DRU EK+H/jOdyMBf2/XeXgusFCcJ88IaeyLoG84qr+jD+JqhRjNlUNaQTodZjkpNupSZRF PmbqSemacMpToDwHt/i7w406Pg4hSh0eYrbvArWkqk5Qq3ozGfGh0rMvwBOBoPN9Nf Sx+WygOjJjSwg== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 4/4] btrfs: remove local generation variable from read_block_for_search() Date: Wed, 16 Oct 2024 15:20:23 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana It's reduntant to have the 'gen' variable since we already have the same value in the local btrfs_tree_parent_check structure. So remove it and instead use the structure's field. Signed-off-by: Filipe Manana --- fs/btrfs/ctree.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index f68a9b586079..148648ea1c8b 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1514,7 +1514,6 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_tree_parent_check check = { 0 }; u64 blocknr; - u64 gen; struct extent_buffer *tmp = NULL; int ret = 0; int parent_level; @@ -1524,12 +1523,11 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, bool path_released = false; blocknr = btrfs_node_blockptr(*eb_ret, slot); - gen = btrfs_node_ptr_generation(*eb_ret, slot); parent_level = btrfs_header_level(*eb_ret); btrfs_node_key_to_cpu(*eb_ret, &check.first_key, slot); check.has_first_key = true; check.level = parent_level - 1; - check.transid = gen; + check.transid = btrfs_node_ptr_generation(*eb_ret, slot); check.owner_root = btrfs_root_id(root); /* @@ -1545,7 +1543,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p, reada_for_search(fs_info, p, parent_level, slot, key->objectid); /* first we do an atomic uptodate check */ - if (btrfs_buffer_uptodate(tmp, gen, 1) > 0) { + if (btrfs_buffer_uptodate(tmp, check.transid, 1) > 0) { /* * Do extra check for first_key, eb can be stale due to * being cached, read from scrub, or have multiple