summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-12-27 16:41:08 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2017-12-27 17:06:16 -0500
commit6d860af4c9cf76830baf4966f70d546ed430738a (patch)
tree05fb2febf2fd83be664667dda8cfdd9461f403b7
parent503d2b555e8d207c170ed3e23d2599fe967d501d (diff)
bcachefs: kill bucket_lock
-rw-r--r--fs/bcachefs/alloc.c31
-rw-r--r--fs/bcachefs/alloc_types.h7
-rw-r--r--fs/bcachefs/bcachefs.h2
-rw-r--r--fs/bcachefs/super.c6
4 files changed, 19 insertions, 27 deletions
diff --git a/fs/bcachefs/alloc.c b/fs/bcachefs/alloc.c
index 4b6038db40e1..53d764d97d74 100644
--- a/fs/bcachefs/alloc.c
+++ b/fs/bcachefs/alloc.c
@@ -305,12 +305,15 @@ int bch2_alloc_read(struct bch_fs *c, struct list_head *journal_replay_list)
bch2_alloc_read_key(c, bkey_i_to_s_c(k));
}
- mutex_lock(&c->bucket_lock);
- for_each_member_device(ca, c, i) {
+ mutex_lock(&c->prio_clock[READ].lock);
+ for_each_member_device(ca, c, i)
bch2_recalc_min_prio(c, ca, READ);
+ mutex_unlock(&c->prio_clock[READ].lock);
+
+ mutex_lock(&c->prio_clock[WRITE].lock);
+ for_each_member_device(ca, c, i)
bch2_recalc_min_prio(c, ca, WRITE);
- }
- mutex_unlock(&c->bucket_lock);
+ mutex_unlock(&c->prio_clock[WRITE].lock);
return 0;
}
@@ -470,7 +473,7 @@ static void bch2_recalc_min_prio(struct bch_fs *c, struct bch_dev *ca, int rw)
u16 max_delta = 1;
unsigned i;
- lockdep_assert_held(&c->bucket_lock);
+ lockdep_assert_held(&c->prio_clock[rw].lock);
/* Determine min prio for this particular device */
for_each_bucket(g, ca)
@@ -517,7 +520,7 @@ static void bch2_inc_clock_hand(struct io_timer *timer)
struct bch_fs, prio_clock[clock->rw]);
u64 capacity;
- mutex_lock(&c->bucket_lock);
+ mutex_lock(&clock->lock);
clock->hand++;
@@ -525,7 +528,7 @@ static void bch2_inc_clock_hand(struct io_timer *timer)
if (clock->hand == (u16) (clock->min_prio - 1))
bch2_rescale_prios(c, clock->rw);
- mutex_unlock(&c->bucket_lock);
+ mutex_unlock(&clock->lock);
capacity = READ_ONCE(c->capacity);
@@ -548,11 +551,12 @@ static void bch2_inc_clock_hand(struct io_timer *timer)
static void bch2_prio_timer_init(struct bch_fs *c, int rw)
{
struct prio_clock *clock = &c->prio_clock[rw];
- struct io_timer *timer = &clock->rescale;
- clock->rw = rw;
- timer->fn = bch2_inc_clock_hand;
- timer->expire = c->capacity >> 10;
+ clock->hand = 1;
+ clock->rw = rw;
+ clock->rescale.fn = bch2_inc_clock_hand;
+ clock->rescale.expire = c->capacity >> 10;
+ mutex_init(&clock->lock);
}
/*
@@ -672,9 +676,8 @@ static void invalidate_buckets_lru(struct bch_fs *c, struct bch_dev *ca)
ca->alloc_heap.used = 0;
- mutex_lock(&c->bucket_lock);
+ mutex_lock(&c->prio_clock[READ].lock);
bch2_recalc_min_prio(c, ca, READ);
- bch2_recalc_min_prio(c, ca, WRITE);
/*
* Find buckets with lowest read priority, by building a maxheap sorted
@@ -705,7 +708,7 @@ static void invalidate_buckets_lru(struct bch_fs *c, struct bch_dev *ca)
heap_pop(&ca->alloc_heap, e, bucket_alloc_cmp))
bch2_invalidate_one_bucket(c, ca, &ca->buckets[e.bucket]);
- mutex_unlock(&c->bucket_lock);
+ mutex_unlock(&c->prio_clock[READ].lock);
}
static void invalidate_buckets_fifo(struct bch_fs *c, struct bch_dev *ca)
diff --git a/fs/bcachefs/alloc_types.h b/fs/bcachefs/alloc_types.h
index 90123ff7b6d9..10e67d48e35a 100644
--- a/fs/bcachefs/alloc_types.h
+++ b/fs/bcachefs/alloc_types.h
@@ -6,11 +6,7 @@
#include "clock_types.h"
-/*
- * There's two of these clocks, one for reads and one for writes:
- *
- * All fields protected by bucket_lock
- */
+/* There's two of these clocks, one for reads and one for writes: */
struct prio_clock {
/*
* "now" in (read/write) IO time - incremented whenever we do X amount
@@ -31,6 +27,7 @@ struct prio_clock {
int rw;
struct io_timer rescale;
+ struct mutex lock;
};
/* There is one reserve for each type of btree, one for prios and gens
diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h
index e25baf56f37f..648555241aec 100644
--- a/fs/bcachefs/bcachefs.h
+++ b/fs/bcachefs/bcachefs.h
@@ -575,8 +575,6 @@ struct bch_fs {
struct bch_fs_usage usage_cached;
struct lglock usage_lock;
- struct mutex bucket_lock;
-
struct closure_waitlist freelist_wait;
/*
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index a7ae8e07eed0..527773dcf380 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -480,7 +480,6 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
mutex_init(&c->state_lock);
mutex_init(&c->sb_lock);
mutex_init(&c->replicas_gc_lock);
- mutex_init(&c->bucket_lock);
mutex_init(&c->btree_root_lock);
INIT_WORK(&c->read_only_work, bch2_fs_read_only_work);
@@ -512,11 +511,6 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
seqcount_init(&c->gc_pos_lock);
- c->prio_clock[READ].hand = 1;
- c->prio_clock[READ].min_prio = 0;
- c->prio_clock[WRITE].hand = 1;
- c->prio_clock[WRITE].min_prio = 0;
-
init_waitqueue_head(&c->writeback_wait);
c->writeback_pages_max = (256 << 10) / PAGE_SIZE;