linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: <stable@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
	Arthur Borsboom <arthurborsboom@gmail.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Jens Axboe <axboe@kernel.dk>, <xen-devel@lists.xenproject.org>,
	<linux-block@vger.kernel.org>
Subject: Re: [PATCH v2] xen-blkfront: allow discard-* nodes to be optional
Date: Tue, 19 Jan 2021 13:36:22 +0100	[thread overview]
Message-ID: <20210119123622.zweul6uqfg54erj3@Air-de-Roger> (raw)
In-Reply-To: <20210119105727.95173-1-roger.pau@citrix.com>

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@gmail.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: "Roger Pau Monné" <roger.pau@citrix.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: xen-devel@lists.xenproject.org
> Cc: linux-block@vger.kernel.org
> Cc: Arthur Borsboom <arthurborsboom@gmail.com>
> ---
> 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
> 

  parent reply	other threads:[~2021-01-19 13:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 10:57 [PATCH v2] xen-blkfront: allow discard-* nodes to be optional Roger Pau Monne
2021-01-19 11:16 ` Jürgen Groß
2021-01-19 12:36 ` Roger Pau Monné [this message]
2021-01-19 15:23   ` Greg KH
2021-01-20 14:28 ` Arthur Borsboom
     [not found] ` <CALUcmUkd9Eeau6tC9ZWHbLdvHTYfY34LvK6KKpOOxreYF67Myg@mail.gmail.com>
2021-01-20 14:35   ` Roger Pau Monné
2021-01-20 14:37     ` Jan Beulich
2021-01-20 14:44       ` Roger Pau Monné
2021-01-20 15:17     ` Arthur Borsboom
2021-01-22 20:29       ` Arthur Borsboom
2021-01-27  8:09 ` Jürgen Groß

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=20210119123622.zweul6uqfg54erj3@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=arthurborsboom@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jgross@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sstabellini@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).