lkml.org 
[lkml]   [2021]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] xen-blkfront: don't make discard-alignment mandatory
    Date
    Don't require the discard-alignment xenstore node to be present in
    order to correctly setup the feature. This can happen with versions of
    QEMU that only write the discard-granularity but not the
    discard-alignment node.

    Assume discard-alignment is 0 if not present. While there also fix the
    logic to not enable the discard feature if discard-granularity is not
    present.

    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>
    ---
    drivers/block/xen-blkfront.c | 25 +++++++++++++------------
    1 file changed, 13 insertions(+), 12 deletions(-)

    diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
    index 5265975b3fba..5a93f7cc2939 100644
    --- a/drivers/block/xen-blkfront.c
    +++ b/drivers/block/xen-blkfront.c
    @@ -2179,22 +2179,23 @@ 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;
    + unsigned int discard_granularity = 0;
    + unsigned int discard_alignment = 0;
    + unsigned int discard_secure = 0;

    - info->feature_discard = 1;
    - err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
    + xenbus_gather(XBT_NIL, info->xbdev->otherend,
    "discard-granularity", "%u", &discard_granularity,
    "discard-alignment", "%u", &discard_alignment,
    + "discard-secure", "%u", &discard_secure,
    NULL);
    - if (!err) {
    - info->discard_granularity = discard_granularity;
    - info->discard_alignment = discard_alignment;
    - }
    - info->feature_secdiscard =
    - !!xenbus_read_unsigned(info->xbdev->otherend, "discard-secure",
    - 0);
    +
    + if (!discard_granularity)
    + return;
    +
    + info->feature_discard = 1;
    + info->discard_granularity = discard_granularity;
    + info->discard_alignment = discard_alignment;
    + info->feature_secdiscard = !!discard_secure;
    }

    static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo)
    --
    2.29.2
    \
     
     \ /
      Last update: 2021-01-18 16:22    [W:3.134 / U:0.956 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site