Revert "bcache: fix fifo index swapping condition in journal_pin_cmp()"
authorJens Axboe <axboe@kernel.dk>
Mon, 18 Nov 2019 15:35:47 +0000 (08:35 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Nov 2019 15:35:47 +0000 (08:35 -0700)
Coly says:

"Guoju Fang talked to me today, he told me this change was unnecessary
and I was over-thought.

Then I realize fifo_idx() uses a mask to handle the array index overflow
condition, so the index swap in journal_pin_cmp() won't happen. And yes,
Guoju and Kent are correct.

Since you already applied this patch, can you please to remove this
patch from your for-next branch? This single patch does not break
thing, but it is unecessary at this moment."

This reverts commit c0e0954e909c17b43d176ab219fc598964616ae6.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/btree.c
drivers/md/bcache/journal.h

index 3df5fa4a501ca775cc51bf5612afe329da13cd26..14d6c33b0957ede67b4621b41f655a1057a00ec7 100644 (file)
@@ -528,32 +528,6 @@ static void btree_node_write_work(struct work_struct *w)
        mutex_unlock(&b->write_lock);
 }
 
-/* return true if journal pin 'l' is newer than 'r' */
-static bool journal_pin_cmp(struct cache_set *c,
-                           atomic_t *l,
-                           atomic_t *r)
-{
-       int l_idx, r_idx, f_idx, b_idx;
-       bool ret = false;
-
-       l_idx = fifo_idx(&(c)->journal.pin, (l));
-       r_idx = fifo_idx(&(c)->journal.pin, (r));
-       f_idx = (c)->journal.pin.front;
-       b_idx = (c)->journal.pin.back;
-
-       if (l_idx > r_idx)
-               ret = true;
-       /* in case fifo back pointer is swapped */
-       if (b_idx < f_idx) {
-               if (l_idx <= b_idx && r_idx >= f_idx)
-                       ret = true;
-               else if (l_idx >= f_idx && r_idx <= b_idx)
-                       ret = false;
-       }
-
-       return ret;
-}
-
 static void bch_btree_leaf_dirty(struct btree *b, atomic_t *journal_ref)
 {
        struct bset *i = btree_bset_last(b);
index 06b3eaab7d16b7e5f1ab438292417dc39c2f61be..f2ea34d5f431ba860904d074fca567e772e9daa9 100644 (file)
@@ -157,6 +157,10 @@ struct journal_device {
 };
 
 #define BTREE_FLUSH_NR 8
+
+#define journal_pin_cmp(c, l, r)                               \
+       (fifo_idx(&(c)->journal.pin, (l)) > fifo_idx(&(c)->journal.pin, (r)))
+
 #define JOURNAL_PIN    20000
 
 #define journal_full(j)                                                \