Re: [PATCH 03/13] zram: cleanup zram_remove
- 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 03/13] zram: cleanup zram_remove
- From: Jan Kara <jack@suse.cz>
- Date: Thu, 24 Mar 2022 14:15:47 +0100
- Message-id: <[🔎] 20220324131547.btqbrcf4ynlunhj4@quack3.lan>
- In-reply-to: <[🔎] 20220324075119.1556334-4-hch@lst.de>
- References: <[🔎] 20220324075119.1556334-1-hch@lst.de> <[🔎] 20220324075119.1556334-4-hch@lst.de>
On Thu 24-03-22 08:51:09, Christoph Hellwig wrote:
> Remove the bdev variable and just use the gendisk pointed to by the
> zram_device directly.
>
> 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 | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index fd83fad59beb1..863606f1722b1 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1987,19 +1987,18 @@ static int zram_add(void)
>
> 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);
> }
>
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
Reply to: