Commit d666e20e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

zram: cleanup reset_store

Use a local variable for the gendisk instead of the part0 block_device,
as the gendisk is what this function actually operates on.
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-3-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 2a852a69
...@@ -1786,7 +1786,7 @@ static ssize_t reset_store(struct device *dev, ...@@ -1786,7 +1786,7 @@ static ssize_t reset_store(struct device *dev,
int ret; int ret;
unsigned short do_reset; unsigned short do_reset;
struct zram *zram; struct zram *zram;
struct block_device *bdev; struct gendisk *disk;
ret = kstrtou16(buf, 10, &do_reset); ret = kstrtou16(buf, 10, &do_reset);
if (ret) if (ret)
...@@ -1796,26 +1796,26 @@ static ssize_t reset_store(struct device *dev, ...@@ -1796,26 +1796,26 @@ static ssize_t reset_store(struct device *dev,
return -EINVAL; return -EINVAL;
zram = dev_to_zram(dev); zram = dev_to_zram(dev);
bdev = zram->disk->part0; disk = zram->disk;
mutex_lock(&bdev->bd_disk->open_mutex); mutex_lock(&disk->open_mutex);
/* Do not reset an active device or claimed device */ /* Do not reset an active device or claimed device */
if (bdev->bd_openers || zram->claim) { if (disk->part0->bd_openers || zram->claim) {
mutex_unlock(&bdev->bd_disk->open_mutex); mutex_unlock(&disk->open_mutex);
return -EBUSY; return -EBUSY;
} }
/* From now on, anyone can't open /dev/zram[0-9] */ /* From now on, anyone can't open /dev/zram[0-9] */
zram->claim = true; zram->claim = true;
mutex_unlock(&bdev->bd_disk->open_mutex); mutex_unlock(&disk->open_mutex);
/* Make sure all the pending I/O are finished */ /* Make sure all the pending I/O are finished */
sync_blockdev(bdev); sync_blockdev(disk->part0);
zram_reset_device(zram); zram_reset_device(zram);
mutex_lock(&bdev->bd_disk->open_mutex); mutex_lock(&disk->open_mutex);
zram->claim = false; zram->claim = false;
mutex_unlock(&bdev->bd_disk->open_mutex); mutex_unlock(&disk->open_mutex);
return len; return len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment