From patchwork Tue Nov 21 13:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13463053 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 0A647524A8 for ; Tue, 21 Nov 2023 13:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F+MqKLtD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 223CDC433C9 for ; Tue, 21 Nov 2023 13:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700573929; bh=PUYVlSxOBYGqVYk4s1rhMlrO5hOBjdKLim9fGaYKC0Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=F+MqKLtD8yvxjkVKBiw6eY8TI0W92Lokha4NJ51aSfcfJ/n3rwt8OYFX4lZgOnsa6 ZH16f4a4vm7w5WlDjwnI/fz9vLWaYE2lPgghUKUzhWJ3BHdkrlqZAIHAseg7/IfC0Y zetDWCT4u6r3eBhoy0NjCmZkgoIpcJ/uBIIjH0XIDnuhdgseFZJpp2atBVi13gyH0M Ry6qjIyul/WPnUMYIHigeCg1eJnTV93u/POt2BnjSNkao9bixzYgJ3ITh3KG3sza/n e0YXIwUwV8fafOEroQO7ji+lHQk2KxUyJKsJpndyt7rbgOZ+/h6NDcizGbmdvvPmpc DCGdumijq3Brw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 6/8] btrfs: use btrfs_next_item() at scrub.c:find_first_extent_item() Date: Tue, 21 Nov 2023 13:38:37 +0000 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 There's no reason to open code what btrfs_next_item() does when searching for extent items at scrub.c:scrub.c:find_first_extent_item(), so remove the logic to find the next item and use btrfs_next_item() instead, making the code shorter and less nested code blocks. While at it also fix the comment to the plural "items" instead of "item" and end it with proper punctuation. Signed-off-by: Filipe Manana --- fs/btrfs/scrub.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 9ce5be21b036..63ac78006f1c 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1409,14 +1409,11 @@ static int find_first_extent_item(struct btrfs_root *extent_root, if (ret > 0) break; next: - path->slots[0]++; - if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { - ret = btrfs_next_leaf(extent_root, path); - if (ret) { - /* Either no more item or fatal error */ - btrfs_release_path(path); - return ret; - } + ret = btrfs_next_item(extent_root, path); + if (ret) { + /* Either no more items or a fatal error. */ + btrfs_release_path(path); + return ret; } } btrfs_release_path(path);