Skip to contentSkip to conversation

Fix corner case in btrfs_next_leaf

PATCH New Yan Zheng 1 participant 1 message Jul 20, 2009 Btrfs file system

lore
Share & tools
lore

Yan Zheng

author
#0 lore raw

PATCH 1/1 Fix corner case in btrfs_next_leaf

if 1 is returned by btrfs_search_slot, the path already points to the first item with 'key > searching key'. So increasing path->slots[0] by one is superfluous in that case.

---

fs/btrfs/ctree.c +2 -1
diff -urp 1/fs/btrfs/ctree.c 2/fs/btrfs/ctree.c
@@ -4146,7 +4175,8 @@ again:
 	 * advance the path if there are now more items available.
 	 */
 	if (nritems > 0 && path->slots[0] < nritems - 1) {
-		path->slots[0]++;
+		if (ret == 0)
+			path->slots[0]++;
 		ret = 0;
 		goto done;
 	}