diff mbox series

[6/8] btrfs: use btrfs_next_item() at scrub.c:find_first_extent_item()

Message ID c0e14c7d6dd2bad6889e6f5226febb84dca90ce9.1700573314.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: add a btrfs_chunk_map structure and preparatory cleanups | expand

Commit Message

Filipe Manana Nov. 21, 2023, 1:38 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

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 <fdmanana@suse.com>
---
 fs/btrfs/scrub.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
diff mbox series

Patch

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);