summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2022-03-06 18:13:09 +0300
committerJens Axboe <axboe@kernel.dk>2022-03-06 18:13:09 +0300
commita76370690c3b382ee1c91a93a447c8e25865c8e2 (patch)
tree0570e2ced54a9570d4d179770b14ce9a206646cf /drivers/md
parent13d4ef0f66b7ee9415e101e213acaf94a0cb28ee (diff)
parent887554ab96588de2917b6c8c73e552da082e5368 (diff)
downloadlinux-a76370690c3b382ee1c91a93a447c8e25865c8e2.tar.xz
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
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bcache/btree.c6
-rw-r--r--drivers/md/bcache/writeback.c17
2 files changed, 15 insertions, 8 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 88c573eeb598..ad9f16689419 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.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,
- atomic_read(&check_state->started) == 0 ||
- test_bit(CACHE_SET_IO_DISABLE, &c->flags));
+ atomic_read(&check_state->started) == 0);
for (i = 0; i < check_state->total_threads; i++) {
if (check_state->infos[i].result) {
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index d42301e6309d..9ee0005874cd 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -585,10 +585,13 @@ void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned int inode,
sectors_dirty = atomic_add_return(s,
d->stripe_sectors_dirty + stripe);
- if (sectors_dirty == d->stripe_size)
- set_bit(stripe, d->full_dirty_stripes);
- else
- clear_bit(stripe, d->full_dirty_stripes);
+ if (sectors_dirty == d->stripe_size) {
+ if (!test_bit(stripe, d->full_dirty_stripes))
+ set_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;
stripe_offset = 0;
@@ -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,
- atomic_read(&state->started) == 0 ||
- test_bit(CACHE_SET_IO_DISABLE, &c->flags));
+ atomic_read(&state->started) == 0);
out:
kfree(state);