Commit a7637069 authored by Jens Axboe's avatar Jens Axboe

Merge branch 'for-next' of...

Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/colyli/linux-bcache into for-5.18/drivers

Pull bcache updates from Coly:

"We have 2 patches for Linux v5.18, both of them are from Mingzhe Zou.
 The first patch improves bcache initialization speed by avoid
 unnecessary cost of cache consistency, the second one fixes a potential
 NULL pointer deference in bcache initialization time."

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/colyli/linux-bcache:
  bcache: fixup multiple threads crash
  bcache: fixup bcache_dev_sectors_dirty_add() multithreaded CPU false sharing
parents 13d4ef0f 887554ab
...@@ -2060,9 +2060,11 @@ int bch_btree_check(struct cache_set *c) ...@@ -2060,9 +2060,11 @@ int bch_btree_check(struct cache_set *c)
} }
} }
/*
* Must wait for all threads to stop.
*/
wait_event_interruptible(check_state->wait, wait_event_interruptible(check_state->wait,
atomic_read(&check_state->started) == 0 || atomic_read(&check_state->started) == 0);
test_bit(CACHE_SET_IO_DISABLE, &c->flags));
for (i = 0; i < check_state->total_threads; i++) { for (i = 0; i < check_state->total_threads; i++) {
if (check_state->infos[i].result) { if (check_state->infos[i].result) {
......
...@@ -585,10 +585,13 @@ void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned int inode, ...@@ -585,10 +585,13 @@ void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned int inode,
sectors_dirty = atomic_add_return(s, sectors_dirty = atomic_add_return(s,
d->stripe_sectors_dirty + stripe); d->stripe_sectors_dirty + stripe);
if (sectors_dirty == d->stripe_size) if (sectors_dirty == d->stripe_size) {
set_bit(stripe, d->full_dirty_stripes); if (!test_bit(stripe, d->full_dirty_stripes))
else set_bit(stripe, d->full_dirty_stripes);
clear_bit(stripe, d->full_dirty_stripes); } else {
if (test_bit(stripe, d->full_dirty_stripes))
clear_bit(stripe, d->full_dirty_stripes);
}
nr_sectors -= s; nr_sectors -= s;
stripe_offset = 0; stripe_offset = 0;
...@@ -998,9 +1001,11 @@ void bch_sectors_dirty_init(struct bcache_device *d) ...@@ -998,9 +1001,11 @@ void bch_sectors_dirty_init(struct bcache_device *d)
} }
} }
/*
* Must wait for all threads to stop.
*/
wait_event_interruptible(state->wait, wait_event_interruptible(state->wait,
atomic_read(&state->started) == 0 || atomic_read(&state->started) == 0);
test_bit(CACHE_SET_IO_DISABLE, &c->flags));
out: out:
kfree(state); kfree(state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment