Re: [PATCH 02/13] zram: cleanup reset_store
- To: Christoph Hellwig <hch@lst.de>
- Cc: Jens Axboe <axboe@kernel.dk>, Josef Bacik <josef@toxicpanda.com>, Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>, Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>, Jan Kara <jack@suse.cz>, "Darrick J . Wong" <djwong@kernel.org>, Ming Lei <ming.lei@redhat.com>, linux-block@vger.kernel.org, nbd@other.debian.org
- Subject: Re: [PATCH 02/13] zram: cleanup reset_store
- From: Jan Kara <jack@suse.cz>
- Date: Thu, 24 Mar 2022 13:21:49 +0100
- Message-id: <[🔎] 20220324122149.iu63vrljelo6jq2x@quack3.lan>
- In-reply-to: <[🔎] 20220324075119.1556334-3-hch@lst.de>
- References: <[🔎] 20220324075119.1556334-1-hch@lst.de> <[🔎] 20220324075119.1556334-3-hch@lst.de>
On Thu 24-03-22 08:51:08, Christoph Hellwig wrote:
> 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: Christoph Hellwig <hch@lst.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> drivers/block/zram/zram_drv.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index e9474b02012de..fd83fad59beb1 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1786,7 +1786,7 @@ static ssize_t reset_store(struct device *dev,
> int ret;
> unsigned short do_reset;
> struct zram *zram;
> - struct block_device *bdev;
> + struct gendisk *disk;
>
> ret = kstrtou16(buf, 10, &do_reset);
> if (ret)
> @@ -1796,26 +1796,26 @@ static ssize_t reset_store(struct device *dev,
> return -EINVAL;
>
> 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 */
> - if (bdev->bd_openers || zram->claim) {
> - mutex_unlock(&bdev->bd_disk->open_mutex);
> + if (disk->part0->bd_openers || zram->claim) {
> + mutex_unlock(&disk->open_mutex);
> return -EBUSY;
> }
>
> /* From now on, anyone can't open /dev/zram[0-9] */
> zram->claim = true;
> - mutex_unlock(&bdev->bd_disk->open_mutex);
> + mutex_unlock(&disk->open_mutex);
>
> /* Make sure all the pending I/O are finished */
> - sync_blockdev(bdev);
> + sync_blockdev(disk->part0);
> zram_reset_device(zram);
>
> - mutex_lock(&bdev->bd_disk->open_mutex);
> + mutex_lock(&disk->open_mutex);
> zram->claim = false;
> - mutex_unlock(&bdev->bd_disk->open_mutex);
> + mutex_unlock(&disk->open_mutex);
>
> return len;
> }
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
Reply to: