[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] xen-blkfront: allow discard-* nodes to be optional


  • To: <stable@xxxxxxxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 19 Jan 2021 13:36:22 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sFPsOAnU70E2xyKto+FlF8WZfChgs7qL+Toh6ErifDE=; b=i42r9NcE521M019cfFKcLMR5DYHX8j4L3JP4TDjkBV5gmm5ANV+12gQj7NivkbxtGAiscgIaWGFimznDtM10gR/zuyLNcL/3EPDgZoksUJ2fgjL8SMdkcqsw+6qbPpo78jLru6Ye38RSBQqbfAdyG7wYwCMEoi85UK6WaMdAkmzJVYx9u8pFCLFpYP2i2IoCuJXBzFerYEukjMpBnL60p9pMzjdN5xLg7w+BlYh6GSx3cLOUvNBgcMg+6uRKob/lXS4KYzAbqXeWG1pJTsgB9YynRNbO8Idt9kJDvgoP70Uv/aeWrJZOi1f6sWFj9DaWLvEn4ayX0mknDpIoMEbhIg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PmwEwBjblmtA8nvnrXS0t8IjgLm/8qZqayyyBAplxXuSkaDcdz18K368UcV4oCQFaD1iVHFy8MSCT6p9fBbgzcwMMxaezSWkogf/292i9p0TyVfrKltQFgIQHnvFE44ahQnht9Z6VVKx4/dGJE+X80RBpyUIdmN/wk3W+S85PUXH9Sd1+wupzUjVjhydSG6c7uDYELrpxQbeynDQe25Bc9zF9J0+n5aCz/pmKBjcpSQa6ziQ7UUhdLFCDmxzh7qxKP3NWgTMGcYzH1ngpy+3aPIFSlNteareGUb2fLII7Ezcuw/w+ekL4MU7gWCCn/yEeED9yRdnOgY1wD+krso/dA==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <linux-kernel@xxxxxxxxxxxxxxx>, Arthur Borsboom <arthurborsboom@xxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <linux-block@xxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 19 Jan 2021 12:36:42 +0000
  • Ironport-sdr: qdR1QlMhc1X0qGfzlM7yiCeJmw8+lQQ7b1b/dyJL9c6pFtAJebzg6o1wAI/XrLP8VNMQmXZbfl gvTBBiszFVNAE7wjtbsGx+EXVKHSR9wyrCv/Rte5eHUkR3MjR4TGM6bib39ZDrlsra9aGDIyM9 Ug+uxMBq9K7PZpJZHq8p5fjAIZXFNqBQDC8xs4kAoAYicT89aoBgxYtKSAL0D2Qe5PdkPmbmb4 rNY8OZqcDDuV4FxZQhVUSf5phM+F6hMZu5YrI073kdv83xmEuVfN7qDBG/hqzVE+8Iser8DtmZ tEQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Forgot to Cc stable for the Fixes tag. Doing it now.

On Tue, Jan 19, 2021 at 11:57:27AM +0100, Roger Pau Monne wrote:
> This is inline with the specification described in blkif.h:
> 
>  * discard-granularity: should be set to the physical block size if
>    node is not present.
>  * discard-alignment, discard-secure: should be set to 0 if node not
>    present.
> 
> This was detected as QEMU would only create the discard-granularity
> node but not discard-alignment, and thus the setup done in
> blkfront_setup_discard would fail.
> 
> Fix blkfront_setup_discard to not fail on missing nodes, and also fix
> blkif_set_queue_limits to set the discard granularity to the physical
> block size if none is specified in xenbus.
> 
> Fixes: ed30bf317c5ce ('xen-blkfront: Handle discard requests.')
> Reported-by: Arthur Borsboom <arthurborsboom@xxxxxxxxx>
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> Cc: Juergen Gross <jgross@xxxxxxxx>
> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> Cc: "Roger Pau Monné" <roger.pau@xxxxxxxxxx>
> Cc: Jens Axboe <axboe@xxxxxxxxx>
> Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: linux-block@xxxxxxxxxxxxxxx
> Cc: Arthur Borsboom <arthurborsboom@xxxxxxxxx>
> ---
> Changes since v2:
>  - Allow all discard-* nodes to be optional.
> ---
>  drivers/block/xen-blkfront.c | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index 5265975b3fba..e1c6798889f4 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -945,7 +945,8 @@ static void blkif_set_queue_limits(struct blkfront_info 
> *info)
>       if (info->feature_discard) {
>               blk_queue_flag_set(QUEUE_FLAG_DISCARD, rq);
>               blk_queue_max_discard_sectors(rq, get_capacity(gd));
> -             rq->limits.discard_granularity = info->discard_granularity;
> +             rq->limits.discard_granularity = info->discard_granularity ?:
> +                                              info->physical_sector_size;
>               rq->limits.discard_alignment = info->discard_alignment;
>               if (info->feature_secdiscard)
>                       blk_queue_flag_set(QUEUE_FLAG_SECERASE, rq);
> @@ -2179,19 +2180,12 @@ static void blkfront_closing(struct blkfront_info 
> *info)
>  
>  static void blkfront_setup_discard(struct blkfront_info *info)
>  {
> -     int err;
> -     unsigned int discard_granularity;
> -     unsigned int discard_alignment;
> -
>       info->feature_discard = 1;
> -     err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
> -             "discard-granularity", "%u", &discard_granularity,
> -             "discard-alignment", "%u", &discard_alignment,
> -             NULL);
> -     if (!err) {
> -             info->discard_granularity = discard_granularity;
> -             info->discard_alignment = discard_alignment;
> -     }
> +     info->discard_granularity = xenbus_read_unsigned(info->xbdev->otherend,
> +                                                      "discard-granularity",
> +                                                      0);
> +     info->discard_alignment = xenbus_read_unsigned(info->xbdev->otherend,
> +                                                    "discard-alignment", 0);
>       info->feature_secdiscard =
>               !!xenbus_read_unsigned(info->xbdev->otherend, "discard-secure",
>                                      0);
> -- 
> 2.29.2
> 



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.