This is a note to let you know that I've just added the patch titled Btrfs: do a full search everytime in btrfs_search_old_slot to the 3.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-do-a-full-search-everytime-in-btrfs_search_old_slot.patch and it can be found in the queue-3.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From d4b4087c43cc00a196c5be57fac41f41309f1d56 Mon Sep 17 00:00:00 2001 From: Josef Bacik <jbacik@xxxxxxxxxxxx> Date: Tue, 24 Sep 2013 14:09:34 -0400 Subject: Btrfs: do a full search everytime in btrfs_search_old_slot From: Josef Bacik <jbacik@xxxxxxxxxxxx> commit d4b4087c43cc00a196c5be57fac41f41309f1d56 upstream. While running some snashot aware defrag tests I noticed I was panicing every once and a while in key_search. This is because of the optimization that says if we find a key at slot 0 it will be at slot 0 all the way down the rest of the tree. This isn't the case for btrfs_search_old_slot since it will likely replay changes to a buffer if something has changed since we took our sequence number. So short circuit this optimization by setting prev_cmp to -1 every time we call key_search so we will do our normal binary search. With this patch I am no longer seeing the panics I was seeing before. Thanks, Signed-off-by: Josef Bacik <jbacik@xxxxxxxxxxxx> Signed-off-by: Chris Mason <chris.mason@xxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/ctree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2758,7 +2758,7 @@ int btrfs_search_old_slot(struct btrfs_r int level; int lowest_unlock = 1; u8 lowest_level = 0; - int prev_cmp; + int prev_cmp = -1; lowest_level = p->lowest_level; WARN_ON(p->nodes[0] != NULL); @@ -2769,7 +2769,6 @@ int btrfs_search_old_slot(struct btrfs_r } again: - prev_cmp = -1; b = get_old_root(root, time_seq); level = btrfs_header_level(b); p->locks[level] = BTRFS_READ_LOCK; @@ -2787,6 +2786,11 @@ again: */ btrfs_unlock_up_safe(p, level + 1); + /* + * Since we can unwind eb's we want to do a real search every + * time. + */ + prev_cmp = -1; ret = key_search(b, key, level, &prev_cmp, &slot); if (level != 0) { Patches currently in stable-queue which might be from jbacik@xxxxxxxxxxxx are queue-3.12/btrfs-fix-memory-leak-of-chunks-extent-map.patch queue-3.12/btrfs-fix-lockdep-error-in-async-commit.patch queue-3.12/btrfs-fix-incorrect-inode-acl-reset.patch queue-3.12/btrfs-reset-intwrite-on-transaction-abort.patch queue-3.12/btrfs-do-not-run-snapshot-aware-defragment-on-error.patch queue-3.12/btrfs-do-a-full-search-everytime-in-btrfs_search_old_slot.patch queue-3.12/btrfs-take-ordered-root-lock-when-removing-ordered-operations-inode.patch queue-3.12/btrfs-fix-hole-check-in-log_one_extent.patch queue-3.12/btrfs-fix-a-crash-when-running-balance-and-defrag-concurrently.patch queue-3.12/btrfs-stop-using-vfs_read-in-send.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html