summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bcache/btree.c26
-rw-r--r--drivers/md/bcache/journal.h4
2 files changed, 26 insertions, 4 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index ba434d9ac720..00523cd1db80 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -528,6 +528,32 @@ 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);
diff --git a/drivers/md/bcache/journal.h b/drivers/md/bcache/journal.h
index f2ea34d5f431..06b3eaab7d16 100644
--- a/drivers/md/bcache/journal.h
+++ b/drivers/md/bcache/journal.h
@@ -157,10 +157,6 @@ 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) \