Commit 7a86d6dc authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

zram: cleanup zram_remove



Remove the bdev variable and just use the gendisk pointed to by the
zram_device directly.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220330052917.2566582-4-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d666e20e
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -1986,19 +1986,18 @@ static int zram_add(void)


static int zram_remove(struct zram *zram)
static int zram_remove(struct zram *zram)
{
{
	struct block_device *bdev = zram->disk->part0;
	bool claimed;
	bool claimed;


	mutex_lock(&bdev->bd_disk->open_mutex);
	mutex_lock(&zram->disk->open_mutex);
	if (bdev->bd_openers) {
	if (zram->disk->part0->bd_openers) {
		mutex_unlock(&bdev->bd_disk->open_mutex);
		mutex_unlock(&zram->disk->open_mutex);
		return -EBUSY;
		return -EBUSY;
	}
	}


	claimed = zram->claim;
	claimed = zram->claim;
	if (!claimed)
	if (!claimed)
		zram->claim = true;
		zram->claim = true;
	mutex_unlock(&bdev->bd_disk->open_mutex);
	mutex_unlock(&zram->disk->open_mutex);


	zram_debugfs_unregister(zram);
	zram_debugfs_unregister(zram);


@@ -2010,7 +2009,7 @@ static int zram_remove(struct zram *zram)
		;
		;
	} else {
	} else {
		/* Make sure all the pending I/O are finished */
		/* Make sure all the pending I/O are finished */
		sync_blockdev(bdev);
		sync_blockdev(zram->disk->part0);
		zram_reset_device(zram);
		zram_reset_device(zram);
	}
	}