Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Jens Axboe committed Mar 6, 2022
2 parents 13d4ef0 + 887554a commit a763706
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions drivers/md/bcache/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 11 additions & 6 deletions drivers/md/bcache/writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a763706

Please sign in to comment.