All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
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 01/13] nbd: use the correct block_device in nbd_ioctl
Date: Thu, 24 Mar 2022 13:20:41 +0100	[thread overview]
Message-ID: <20220324122041.itc55zladc5sax5p@quack3.lan> (raw)
In-Reply-To: <20220324075119.1556334-2-hch@lst.de>

On Thu 24-03-22 08:51:07, Christoph Hellwig wrote:
> The bdev parameter to ->ioctl contains the block device that the ioctl
> is called on, which can be the partition.  But the code in nbd_ioctl
> that uses it really wants the whole device for things like the bd_openers
> check.  Switch to not pass the bdev along and always use nbd->disk->part0
> instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  drivers/block/nbd.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 5a1f98494dddf..795f65a5c9661 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1217,11 +1217,11 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
>  	return -ENOSPC;
>  }
>  
> -static void nbd_bdev_reset(struct block_device *bdev)
> +static void nbd_bdev_reset(struct nbd_device *nbd)
>  {
> -	if (bdev->bd_openers > 1)
> +	if (nbd->disk->part0->bd_openers > 1)
>  		return;
> -	set_capacity(bdev->bd_disk, 0);
> +	set_capacity(nbd->disk, 0);
>  }
>  
>  static void nbd_parse_flags(struct nbd_device *nbd)
> @@ -1389,7 +1389,7 @@ static int nbd_start_device(struct nbd_device *nbd)
>  	return nbd_set_size(nbd, config->bytesize, nbd_blksize(config));
>  }
>  
> -static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bdev)
> +static int nbd_start_device_ioctl(struct nbd_device *nbd)
>  {
>  	struct nbd_config *config = nbd->config;
>  	int ret;
> @@ -1408,7 +1408,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
>  	flush_workqueue(nbd->recv_workq);
>  
>  	mutex_lock(&nbd->config_lock);
> -	nbd_bdev_reset(bdev);
> +	nbd_bdev_reset(nbd);
>  	/* user requested, ignore socket errors */
>  	if (test_bit(NBD_RT_DISCONNECT_REQUESTED, &config->runtime_flags))
>  		ret = 0;
> @@ -1417,12 +1417,11 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
>  	return ret;
>  }
>  
> -static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
> -				 struct block_device *bdev)
> +static void nbd_clear_sock_ioctl(struct nbd_device *nbd)
>  {
>  	sock_shutdown(nbd);
> -	__invalidate_device(bdev, true);
> -	nbd_bdev_reset(bdev);
> +	__invalidate_device(nbd->disk->part0, true);
> +	nbd_bdev_reset(nbd);
>  	if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF,
>  			       &nbd->config->runtime_flags))
>  		nbd_config_put(nbd);
> @@ -1448,7 +1447,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  	case NBD_DISCONNECT:
>  		return nbd_disconnect(nbd);
>  	case NBD_CLEAR_SOCK:
> -		nbd_clear_sock_ioctl(nbd, bdev);
> +		nbd_clear_sock_ioctl(nbd);
>  		return 0;
>  	case NBD_SET_SOCK:
>  		return nbd_add_socket(nbd, arg, false);
> @@ -1468,7 +1467,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  		config->flags = arg;
>  		return 0;
>  	case NBD_DO_IT:
> -		return nbd_start_device_ioctl(nbd, bdev);
> +		return nbd_start_device_ioctl(nbd);
>  	case NBD_CLEAR_QUE:
>  		/*
>  		 * This is for compatibility only.  The queue is always cleared
> -- 
> 2.30.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2022-03-24 12:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24  7:51 yet another approach to fix the loop lock order inversions v4 Christoph Hellwig
2022-03-24  7:51 ` [PATCH 01/13] nbd: use the correct block_device in nbd_ioctl Christoph Hellwig
2022-03-24 12:20   ` Jan Kara [this message]
2022-03-24 13:23     ` Jan Kara
2022-03-24 17:11       ` Christoph Hellwig
2022-03-25  9:39         ` Jan Kara
2022-03-24  7:51 ` [PATCH 02/13] zram: cleanup reset_store Christoph Hellwig
2022-03-24 12:21   ` Jan Kara
2022-03-24  7:51 ` [PATCH 03/13] zram: cleanup zram_remove Christoph Hellwig
2022-03-24 13:15   ` Jan Kara
2022-03-24  7:51 ` [PATCH 04/13] block: add a disk_openers helper Christoph Hellwig
2022-03-24 13:24   ` Jan Kara
2022-03-24  7:51 ` [PATCH 05/13] block: turn bdev->bd_openers into an atomic_t Christoph Hellwig
2022-03-24 13:31   ` Jan Kara
2022-03-24 17:12     ` Christoph Hellwig
2022-03-24  7:51 ` [PATCH 06/13] loop: de-duplicate the idle worker freeing code Christoph Hellwig
2022-03-24  7:51 ` [PATCH 07/13] loop: initialize the worker tracking fields once Christoph Hellwig
2022-03-24  7:51 ` [PATCH 08/13] loop: remove the racy bd_inode->i_mapping->nrpages asserts Christoph Hellwig
2022-03-24  7:51 ` [PATCH 09/13] loop: don't freeze the queue in lo_release Christoph Hellwig
2022-03-24  7:51 ` [PATCH 10/13] loop: only freeze the queue in __loop_clr_fd when needed Christoph Hellwig
2022-03-24  7:51 ` [PATCH 11/13] loop: implement ->free_disk Christoph Hellwig
2022-03-24  7:51 ` [PATCH 12/13] loop: remove lo_refcount and avoid lo_mutex in ->open / ->release Christoph Hellwig
2022-03-24 14:13   ` Jan Kara
2022-03-24 14:24     ` Tetsuo Handa
2022-03-24 17:23       ` Christoph Hellwig
2022-03-25 10:54         ` Tetsuo Handa
2022-03-25 16:23           ` Christoph Hellwig
2022-03-28  8:30             ` Jan Kara
2022-03-29  6:39               ` Christoph Hellwig
2022-03-29  9:42                 ` Jan Kara
2022-03-29  9:49                   ` Tetsuo Handa
2022-03-29 13:14                   ` Christoph Hellwig
2022-03-30  7:58                     ` Jan Kara
2022-03-24 17:15     ` Christoph Hellwig
2022-03-24 17:47       ` Christoph Hellwig
2022-03-25  9:34         ` Jan Kara
2022-03-24  7:51 ` [PATCH 13/13] loop: don't destroy lo->workqueue in __loop_clr_fd Christoph Hellwig
2022-03-24 14:14   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220324122041.itc55zladc5sax5p@quack3.lan \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=nbd@other.debian.org \
    --cc=ngupta@vflare.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.