Commit 7a69fa65 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Add missing barriers before wake_up_bit()



wake_up() doesn't require a barrier - but wake_up_bit() does.

This only affected non x86, and primarily lead to lost wakeups after
btree node reads.

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 50a7b899
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ void bch2_btree_node_io_unlock(struct btree *b)

	clear_btree_node_write_in_flight_inner(b);
	clear_btree_node_write_in_flight(b);
	smp_mb__after_atomic();
	wake_up_bit(&b->flags, BTREE_NODE_write_in_flight);
}

@@ -1400,6 +1401,7 @@ static void btree_node_read_work(struct work_struct *work)

	printbuf_exit(&buf);
	clear_btree_node_read_in_flight(b);
	smp_mb__after_atomic();
	wake_up_bit(&b->flags, BTREE_NODE_read_in_flight);
}

@@ -1595,6 +1597,7 @@ static CLOSURE_CALLBACK(btree_node_read_all_replicas_done)
	printbuf_exit(&buf);

	clear_btree_node_read_in_flight(b);
	smp_mb__after_atomic();
	wake_up_bit(&b->flags, BTREE_NODE_read_in_flight);
}

@@ -1721,6 +1724,7 @@ void bch2_btree_node_read(struct btree_trans *trans, struct btree *b,
		set_btree_node_read_error(b);
		bch2_btree_lost_data(c, b->c.btree_id);
		clear_btree_node_read_in_flight(b);
		smp_mb__after_atomic();
		wake_up_bit(&b->flags, BTREE_NODE_read_in_flight);
		printbuf_exit(&buf);
		return;
@@ -2061,9 +2065,11 @@ static void __btree_node_write_done(struct bch_fs *c, struct btree *b, u64 start

	if (new & (1U << BTREE_NODE_write_in_flight))
		__bch2_btree_node_write(c, b, BTREE_WRITE_ALREADY_STARTED|type);
	else
	else {
		smp_mb__after_atomic();
		wake_up_bit(&b->flags, BTREE_NODE_write_in_flight);
	}
}

static void btree_node_write_done(struct bch_fs *c, struct btree *b, u64 start_time)
{
@@ -2175,6 +2181,7 @@ static void btree_node_write_endio(struct bio *bio)
	}

	clear_btree_node_write_in_flight_inner(b);
	smp_mb__after_atomic();
	wake_up_bit(&b->flags, BTREE_NODE_write_in_flight_inner);
	INIT_WORK(&wb->work, btree_node_write_work);
	queue_work(c->btree_io_complete_wq, &wb->work);
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ static inline void bucket_unlock(struct bucket *b)
	BUILD_BUG_ON(!((union ulong_byte_assert) { .ulong = 1UL << BUCKET_LOCK_BITNR }).byte);

	clear_bit_unlock(BUCKET_LOCK_BITNR, (void *) &b->lock);
	smp_mb__after_atomic();
	wake_up_bit((void *) &b->lock, BUCKET_LOCK_BITNR);
}

+1 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ static inline void gc_stripe_unlock(struct gc_stripe *s)
	BUILD_BUG_ON(!((union ulong_byte_assert) { .ulong = 1UL << BUCKET_LOCK_BITNR }).byte);

	clear_bit_unlock(BUCKET_LOCK_BITNR, (void *) &s->lock);
	smp_mb__after_atomic();
	wake_up_bit((void *) &s->lock, BUCKET_LOCK_BITNR);
}