Skip to content

Commit a763706

Browse files
committed
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
2 parents 13d4ef0 + 887554a commit a763706

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

drivers/md/bcache/btree.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,9 +2060,11 @@ int bch_btree_check(struct cache_set *c)
20602060
}
20612061
}
20622062

2063+
/*
2064+
* Must wait for all threads to stop.
2065+
*/
20632066
wait_event_interruptible(check_state->wait,
2064-
atomic_read(&check_state->started) == 0 ||
2065-
test_bit(CACHE_SET_IO_DISABLE, &c->flags));
2067+
atomic_read(&check_state->started) == 0);
20662068

20672069
for (i = 0; i < check_state->total_threads; i++) {
20682070
if (check_state->infos[i].result) {

drivers/md/bcache/writeback.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,13 @@ void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned int inode,
585585

586586
sectors_dirty = atomic_add_return(s,
587587
d->stripe_sectors_dirty + stripe);
588-
if (sectors_dirty == d->stripe_size)
589-
set_bit(stripe, d->full_dirty_stripes);
590-
else
591-
clear_bit(stripe, d->full_dirty_stripes);
588+
if (sectors_dirty == d->stripe_size) {
589+
if (!test_bit(stripe, d->full_dirty_stripes))
590+
set_bit(stripe, d->full_dirty_stripes);
591+
} else {
592+
if (test_bit(stripe, d->full_dirty_stripes))
593+
clear_bit(stripe, d->full_dirty_stripes);
594+
}
592595

593596
nr_sectors -= s;
594597
stripe_offset = 0;
@@ -998,9 +1001,11 @@ void bch_sectors_dirty_init(struct bcache_device *d)
9981001
}
9991002
}
10001003

1004+
/*
1005+
* Must wait for all threads to stop.
1006+
*/
10011007
wait_event_interruptible(state->wait,
1002-
atomic_read(&state->started) == 0 ||
1003-
test_bit(CACHE_SET_IO_DISABLE, &c->flags));
1008+
atomic_read(&state->started) == 0);
10041009

10051010
out:
10061011
kfree(state);

0 commit comments

Comments
 (0)