Skip to contentSkip to conversation

btrfs-progs: ctree: Don't return error if first key mismatch on leaf

RFC PATCH New Qu Wenruo 1 participant 1 message Apr 10, 2018 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

RFC PATCH 1/1 btrfs-progs: ctree: Don't return error if first key mismatch on leaf

When running btrfs/074 with enough CPUs, it's possible (around 1%) to hit first key mismatch warning.

Most of such warning happens in split_leaf() where it can ignore error from push_leaf_right(), some of such problem also happens in btrfs_search_forward().

Since it could break normal tree operations, at least keep the warning for debug build but change its return to 0 for leaf, so we won't break normal tree operations.

And, any suggest/advice on this tree locking problem is welcome.

---
 fs/btrfs/disk-io.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/btrfs/disk-io.c +9 -0
index bb38f4098e9c..cf58e9babe34 100644
@@ -442,6 +442,7 @@ static int verify_level_key(struct btrfs_fs_info *fs_info,
 		btrfs_err(fs_info,
 "tree level mismatch detected, bytenr=%llu level expected=%u has=%u",
 			  eb->start, level, found_level);
+		btrfs_print_tree(eb, false);
 #endif
 		return -EIO;
 	}
@@ -463,8 +464,16 @@ static int verify_level_key(struct btrfs_fs_info *fs_info,
 			  eb->start, first_key->objectid, first_key->type,
 			  first_key->offset, found_key.objectid,
 			  found_key.type, found_key.offset);
+		btrfs_print_tree(eb, false);
 	}
 #endif
+	/*
+	 * XXX: We seems to have locking problem for leaf, where we have race
+	 * updating parent nodeptr's first key.
+	 * So if this eb is leaf and first key doesn't match, still let it go.
+	 */
+	if (level == 0 && ret)
+		ret = 0;
 	return ret;
 }
 
Signature · 1 line
2.17.0