Skip to content

Commit

Permalink
bcache: move the del_gendisk call out of bcache_device_free
Browse files Browse the repository at this point in the history
Let the callers call del_gendisk so that we can check if add_disk
has been called properly for the cached device case instead of relying
on the block layer internal GENHD_FL_UP flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20210809064028.1198327-8-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Aug 12, 2021
1 parent 224b068 commit b75f4ae
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/md/bcache/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,6 @@ static void bcache_device_free(struct bcache_device *d)
bcache_device_detach(d);

if (disk) {
bool disk_added = (disk->flags & GENHD_FL_UP) != 0;

if (disk_added)
del_gendisk(disk);

blk_cleanup_disk(disk);
ida_simple_remove(&bcache_device_idx,
first_minor_to_idx(disk->first_minor));
Expand Down Expand Up @@ -1371,8 +1366,10 @@ static void cached_dev_free(struct closure *cl)

mutex_lock(&bch_register_lock);

if (atomic_read(&dc->running))
if (atomic_read(&dc->running)) {
bd_unlink_disk_holder(dc->bdev, dc->disk.disk);
del_gendisk(dc->disk.disk);
}
bcache_device_free(&dc->disk);
list_del(&dc->list);

Expand Down Expand Up @@ -1518,6 +1515,7 @@ static void flash_dev_free(struct closure *cl)
mutex_lock(&bch_register_lock);
atomic_long_sub(bcache_dev_sectors_dirty(d),
&d->c->flash_dev_dirty_sectors);
del_gendisk(d->disk);
bcache_device_free(d);
mutex_unlock(&bch_register_lock);
kobject_put(&d->kobj);
Expand Down

0 comments on commit b75f4ae

Please sign in to comment.