|
@@ -902,7 +902,7 @@ static void cached_dev_detach_finish(struct work_struct *w)
|
|
closure_init_stack(&cl);
|
|
closure_init_stack(&cl);
|
|
|
|
|
|
BUG_ON(!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags));
|
|
BUG_ON(!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags));
|
|
- BUG_ON(atomic_read(&dc->count));
|
|
|
|
|
|
+ BUG_ON(refcount_read(&dc->count));
|
|
|
|
|
|
mutex_lock(&bch_register_lock);
|
|
mutex_lock(&bch_register_lock);
|
|
|
|
|
|
@@ -1029,7 +1029,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
|
|
* dc->c must be set before dc->count != 0 - paired with the mb in
|
|
* dc->c must be set before dc->count != 0 - paired with the mb in
|
|
* cached_dev_get()
|
|
* cached_dev_get()
|
|
*/
|
|
*/
|
|
- atomic_set(&dc->count, 1);
|
|
|
|
|
|
+ refcount_set(&dc->count, 1);
|
|
|
|
|
|
/* Block writeback thread, but spawn it */
|
|
/* Block writeback thread, but spawn it */
|
|
down_write(&dc->writeback_lock);
|
|
down_write(&dc->writeback_lock);
|
|
@@ -1041,7 +1041,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
|
|
if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
|
|
if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
|
|
bch_sectors_dirty_init(&dc->disk);
|
|
bch_sectors_dirty_init(&dc->disk);
|
|
atomic_set(&dc->has_dirty, 1);
|
|
atomic_set(&dc->has_dirty, 1);
|
|
- atomic_inc(&dc->count);
|
|
|
|
|
|
+ refcount_inc(&dc->count);
|
|
bch_writeback_queue(dc);
|
|
bch_writeback_queue(dc);
|
|
}
|
|
}
|
|
|
|
|