This is a note to let you know that I've just added the patch titled

    bcache: Fix for handling overlapping extents when reading in a btree node

to the 3.10-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:
     
bcache-fix-for-handling-overlapping-extents-when-reading-in-a-btree-node.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 84786438ed17978d72eeced580ab757e4da8830b Mon Sep 17 00:00:00 2001
From: Kent Overstreet <[email protected]>
Date: Mon, 23 Sep 2013 23:17:35 -0700
Subject: bcache: Fix for handling overlapping extents when reading in a btree 
node

From: Kent Overstreet <[email protected]>

commit 84786438ed17978d72eeced580ab757e4da8830b upstream.

btree_sort_fixup() was overly clever, because it was trying to avoid
pulling a key off the btree iterator in more than one place.

This led to a really obscure bug where we'd break early from the loop in
btree_sort_fixup() if the current key overlapped with keys in more than
one older set, and the next key it overlapped with was zero size.

Signed-off-by: Kent Overstreet <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 drivers/md/bcache/bset.c |   39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

--- a/drivers/md/bcache/bset.c
+++ b/drivers/md/bcache/bset.c
@@ -918,28 +918,45 @@ struct bkey *bch_next_recurse_key(struct
 
 /* Mergesort */
 
+static void sort_key_next(struct btree_iter *iter,
+                         struct btree_iter_set *i)
+{
+       i->k = bkey_next(i->k);
+
+       if (i->k == i->end)
+               *i = iter->data[--iter->used];
+}
+
 static void btree_sort_fixup(struct btree_iter *iter)
 {
        while (iter->used > 1) {
                struct btree_iter_set *top = iter->data, *i = top + 1;
-               struct bkey *k;
 
                if (iter->used > 2 &&
                    btree_iter_cmp(i[0], i[1]))
                        i++;
 
-               for (k = i->k;
-                    k != i->end && bkey_cmp(top->k, &START_KEY(k)) > 0;
-                    k = bkey_next(k))
-                       if (top->k > i->k)
-                               __bch_cut_front(top->k, k);
-                       else if (KEY_SIZE(k))
-                               bch_cut_back(&START_KEY(k), top->k);
-
-               if (top->k < i->k || k == i->k)
+               if (bkey_cmp(top->k, &START_KEY(i->k)) <= 0)
                        break;
 
-               heap_sift(iter, i - top, btree_iter_cmp);
+               if (!KEY_SIZE(i->k)) {
+                       sort_key_next(iter, i);
+                       heap_sift(iter, i - top, btree_iter_cmp);
+                       continue;
+               }
+
+               if (top->k > i->k) {
+                       if (bkey_cmp(top->k, i->k) >= 0)
+                               sort_key_next(iter, i);
+                       else
+                               bch_cut_front(top->k, i->k);
+
+                       heap_sift(iter, i - top, btree_iter_cmp);
+               } else {
+                       /* can't happen because of comparison func */
+                       BUG_ON(!bkey_cmp(&START_KEY(top->k), &START_KEY(i->k)));
+                       bch_cut_back(&START_KEY(i->k), top->k);
+               }
        }
 }
 


Patches currently in stable-queue which might be from [email protected] are

queue-3.10/bcache-fix-a-flush-fua-performance-bug.patch
queue-3.10/bcache-fix-for-when-no-journal-entries-are-found.patch
queue-3.10/block-fix-bio_copy_data.patch
queue-3.10/bcache-fix-for-handling-overlapping-extents-when-reading-in-a-btree-node.patch
queue-3.10/bcache-fix-a-dumb-cpu-spinning-bug-in-writeback.patch
queue-3.10/bcache-strip-endline-when-writing-the-label-through-sysfs.patch
queue-3.10/bcache-fix-flushes-in-writeback-mode.patch
queue-3.10/bcache-fix-a-shrinker-deadlock.patch
queue-3.10/bcache-fix-a-writeback-performance-regression.patch
queue-3.10/bcache-fix-a-dumb-journal-discard-bug.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to