summaryrefslogtreecommitdiff
path: root/libbcachefs/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/alloc.c')
-rw-r--r--libbcachefs/alloc.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libbcachefs/alloc.c b/libbcachefs/alloc.c
index 256adb51..44f9479e 100644
--- a/libbcachefs/alloc.c
+++ b/libbcachefs/alloc.c
@@ -1393,12 +1393,10 @@ static void writepoint_drop_ptrs(struct bch_fs *c,
{
int i;
- for (i = wp->first_ptr - 1; i >= 0; --i) {
- struct bch_dev *ca = bch_dev_bkey_exists(c, wp->ptrs[i]->ptr.dev);
-
- if (dev_in_target(ca, target) == in_target)
+ for (i = wp->first_ptr - 1; i >= 0; --i)
+ if (bch2_dev_in_target(c, wp->ptrs[i]->ptr.dev,
+ target) == in_target)
writepoint_drop_ptr(c, wp, i);
- }
}
static void verify_not_stale(struct bch_fs *c, const struct write_point *wp)
@@ -1555,7 +1553,7 @@ struct write_point *bch2_alloc_sectors_start(struct bch_fs *c,
/* does writepoint have ptrs we don't want to use? */
if (target)
writepoint_for_each_ptr(wp, ob, i)
- if (!dev_idx_in_target(c, ob->ptr.dev, target)) {
+ if (!bch2_dev_in_target(c, ob->ptr.dev, target)) {
swap(wp->ptrs[i], wp->ptrs[wp->first_ptr]);
wp->first_ptr++;
}
@@ -1590,7 +1588,8 @@ alloc_done:
* one in the target we want:
*/
if (cache_idx >= 0) {
- if (!dev_in_target(ca, target)) {
+ if (!bch2_dev_in_target(c, wp->ptrs[i]->ptr.dev,
+ target)) {
writepoint_drop_ptr(c, wp, i);
} else {
writepoint_drop_ptr(c, wp, cache_idx);
@@ -1621,7 +1620,7 @@ alloc_done:
if (ca->mi.durability &&
ca->mi.durability <= nr_ptrs_effective - nr_replicas &&
- !dev_idx_in_target(c, ob->ptr.dev, target)) {
+ !bch2_dev_in_target(c, ob->ptr.dev, target)) {
swap(wp->ptrs[i], wp->ptrs[wp->first_ptr]);
wp->first_ptr++;
nr_ptrs_effective -= ca->mi.durability;
@@ -1890,8 +1889,9 @@ void bch2_dev_allocator_add(struct bch_fs *c, struct bch_dev *ca)
/* stop allocator thread: */
void bch2_dev_allocator_stop(struct bch_dev *ca)
{
- struct task_struct *p = ca->alloc_thread;
+ struct task_struct *p;
+ p = rcu_dereference_protected(ca->alloc_thread, 1);
ca->alloc_thread = NULL;
/*
@@ -1926,7 +1926,7 @@ int bch2_dev_allocator_start(struct bch_dev *ca)
return PTR_ERR(p);
get_task_struct(p);
- ca->alloc_thread = p;
+ rcu_assign_pointer(ca->alloc_thread, p);
wake_up_process(p);
return 0;
}
@@ -2099,7 +2099,7 @@ again:
if (btree_node_dirty(b) && (!b->written || b->level)) {
if (btree_node_may_write(b)) {
rcu_read_unlock();
- six_lock_read(&b->lock);
+ btree_node_lock_type(c, b, SIX_LOCK_read);
bch2_btree_node_write(c, b, SIX_LOCK_read);
six_unlock_read(&b->lock);
goto again;