]> www.infradead.org Git - users/hch/block.git/commitdiff
zram: cleanup zram_remove
authorChristoph Hellwig <hch@lst.de>
Wed, 23 Mar 2022 08:44:40 +0000 (09:44 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 29 Mar 2022 15:44:31 +0000 (17:44 +0200)
Remove the bdev variable and just use the gendisk pointed to by the
zram_device directly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
drivers/block/zram/zram_drv.c

index fd83fad59beb19b9e21e1c906211c9877f0991d5..863606f1722b117b37fa0b4a8e559d461a9bca95 100644 (file)
@@ -1987,19 +1987,18 @@ out_free_dev:
 
 static int zram_remove(struct zram *zram)
 {
-       struct block_device *bdev = zram->disk->part0;
        bool claimed;
 
-       mutex_lock(&bdev->bd_disk->open_mutex);
-       if (bdev->bd_openers) {
-               mutex_unlock(&bdev->bd_disk->open_mutex);
+       mutex_lock(&zram->disk->open_mutex);
+       if (zram->disk->part0->bd_openers) {
+               mutex_unlock(&zram->disk->open_mutex);
                return -EBUSY;
        }
 
        claimed = zram->claim;
        if (!claimed)
                zram->claim = true;
-       mutex_unlock(&bdev->bd_disk->open_mutex);
+       mutex_unlock(&zram->disk->open_mutex);
 
        zram_debugfs_unregister(zram);
 
@@ -2011,7 +2010,7 @@ static int zram_remove(struct zram *zram)
                ;
        } else {
                /* Make sure all the pending I/O are finished */
-               sync_blockdev(bdev);
+               sync_blockdev(zram->disk->part0);
                zram_reset_device(zram);
        }