mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Yury Kamenev <damtev@yandex-team.ru>,
	mst@redhat.com, pbonzini@redhat.com, stefanha@redhat.com,
	axboe@kernel.dk, hch@lst.de, cand@gmx.com,
	virtualization@lists.linux-foundation.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] virtio: disable partitions scanning for no partitions block
Date: Fri, 16 Jul 2021 10:57:48 +0800	[thread overview]
Message-ID: <eada95b1-a1fb-3877-9b04-ac2bd16f5fe0@redhat.com> (raw)
In-Reply-To: <20210715094707.19997-2-damtev@yandex-team.ru>


在 2021/7/15 下午5:47, Yury Kamenev 写道:
> Signed-off-by: Yury Kamenev <damtev@yandex-team.ru>


I think we need a better commit log here.

And why do we need a Kconfig for this? If there's a good reason, I guess 
the right approach is to invent something in the virtio core (via /sys)?

Thanks


> ---
>   .../admin-guide/kernel-parameters.txt         |  3 +++
>   drivers/block/Kconfig                         |  7 +++++
>   drivers/block/virtio_blk.c                    | 26 +++++++++++++++++++
>   include/uapi/linux/virtio_blk.h               |  2 ++
>   4 files changed, 38 insertions(+)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index bdb22006f713..941bdaf5c167 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -6076,6 +6076,9 @@
>   			brightness level.
>   			default: 1
>
> +	virtiopartscan
> +		Enable virtio block device partition scanning omission based on VIRTIO_BLK_F_NO_PART_SCAN feature flag.
> +
>   	virtio_mmio.device=
>   			[VMMIO] Memory mapped virtio (platform) device.
>
> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> index 63056cfd4b62..69ecd3fd7037 100644
> --- a/drivers/block/Kconfig
> +++ b/drivers/block/Kconfig
> @@ -399,6 +399,13 @@ config VIRTIO_BLK
>   	  This is the virtual block driver for virtio.  It can be used with
>             QEMU based VMMs (like KVM or Xen).  Say Y or M.
>
> +config VIRTIO_BLK_NO_PART_SCAN
> +	bool "Disable partition scanning for devices with no partitions"
> +	depends on VIRTIO_BLK
> +	help
> +	  Disable partition scanning for devices with no partitions.
> +	  Can reduce the kernel start time for tiny systems like squashfs images.
> +
>   config BLK_DEV_RBD
>   	tristate "Rados block device (RBD)"
>   	depends on INET && BLOCK
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 4b49df2dfd23..479711d3791c 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -692,6 +692,19 @@ static const struct blk_mq_ops virtio_mq_ops = {
>   static unsigned int virtblk_queue_depth;
>   module_param_named(queue_depth, virtblk_queue_depth, uint, 0444);
>
> +#ifndef MODULE
> +#ifdef CONFIG_VIRTIO_BLK_NO_PART_SCAN
> +static int partitions_scanning_disable __read_mostly;
> +
> +static int __init partitions_scanning_setup(char *__unused)
> +{
> +	partitions_scanning_disable = 1;
> +	return 1;
> +}
> +__setup("nopartscan", partitions_scanning_setup);
> +#endif
> +#endif
> +
>   static int virtblk_probe(struct virtio_device *vdev)
>   {
>   	struct virtio_blk *vblk;
> @@ -790,6 +803,13 @@ static int virtblk_probe(struct virtio_device *vdev)
>   	vblk->disk->flags |= GENHD_FL_EXT_DEVT;
>   	vblk->index = index;
>
> +#ifdef CONFIG_VIRTIO_BLK_NO_PART_SCAN
> +	if (unlikely(partitions_scanning_disable))
> +		/* disable partitions scanning if it was stated in virtio features*/
> +		if (virtio_has_feature(vdev, VIRTIO_BLK_F_NO_PART_SCAN))
> +			vblk->disk->flags |= GENHD_FL_NO_PART_SCAN;
> +#endif
> +
>   	/* configure queue flush support */
>   	virtblk_update_cache_mode(vdev);
>
> @@ -966,6 +986,9 @@ static unsigned int features_legacy[] = {
>   	VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
>   	VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE,
>   	VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_DISCARD, VIRTIO_BLK_F_WRITE_ZEROES,
> +#ifdef CONFIG_VIRTIO_BLK_NO_PART_SCAN
> +	VIRTIO_BLK_F_NO_PART_SCAN,
> +#endif
>   }
>   ;
>   static unsigned int features[] = {
> @@ -973,6 +996,9 @@ static unsigned int features[] = {
>   	VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
>   	VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE,
>   	VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_DISCARD, VIRTIO_BLK_F_WRITE_ZEROES,
> +#ifdef CONFIG_VIRTIO_BLK_NO_PART_SCAN
> +	VIRTIO_BLK_F_NO_PART_SCAN,
> +#endif
>   };
>
>   static struct virtio_driver virtio_blk = {
> diff --git a/include/uapi/linux/virtio_blk.h b/include/uapi/linux/virtio_blk.h
> index d888f013d9ff..9b381675342a 100644
> --- a/include/uapi/linux/virtio_blk.h
> +++ b/include/uapi/linux/virtio_blk.h
> @@ -40,6 +40,7 @@
>   #define VIRTIO_BLK_F_MQ		12	/* support more than one vq */
>   #define VIRTIO_BLK_F_DISCARD	13	/* DISCARD is supported */
>   #define VIRTIO_BLK_F_WRITE_ZEROES	14	/* WRITE ZEROES is supported */
> +#define VIRTIO_BLK_F_NO_PART_SCAN	16	/* Disable partition scanning */
>
>   /* Legacy feature bits */
>   #ifndef VIRTIO_BLK_NO_LEGACY
> --
> 2.24.3 (Apple Git-128)
>


  parent reply	other threads:[~2021-07-16  2:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15  9:47 [PATCH 0/1] " Yury Kamenev
2021-07-15  9:47 ` [PATCH 1/1] " Yury Kamenev
2021-07-15 11:22   ` Paolo Bonzini
2021-07-16  1:09   ` kernel test robot
2021-07-16  2:57   ` Jason Wang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-05-20 13:39 [PATCH 0/1] " Yury Kamenev
2021-05-20 13:39 ` [PATCH 1/1] " Yury Kamenev
2021-05-24 14:29   ` Stefan Hajnoczi
2021-05-24 14:56     ` Christoph Hellwig
2021-05-24 16:25       ` Ulf Hansson
     [not found]     ` <90021621883891@mail.yandex-team.ru>
2021-05-24 19:41       ` Paolo Bonzini
2021-05-25 12:00         ` Iurii Kamenev

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=eada95b1-a1fb-3877-9b04-ac2bd16f5fe0@redhat.com \
    --to=jasowang@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=cand@gmx.com \
    --cc=damtev@yandex-team.ru \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®