Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp647554pxb; Tue, 2 Feb 2021 14:16:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxE243eR6IhVjDEnKBmmFxubZpRAhTJu0ot5mZG0G/8JaS5xnujcHlMhz8DzVHyZhF6e9/P X-Received: by 2002:aa7:de0f:: with SMTP id h15mr240512edv.198.1612304219525; Tue, 02 Feb 2021 14:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304219; cv=none; d=google.com; s=arc-20160816; b=0CN8zMrs56auwoGTDnj1JIZau0g3rMIR6VNS5JAjzvYJA/e+GDyQcN/FnjGrDvV5aS IevJR1xVwInsQllhU5Ln+KJp960z3oOaytxnRS4ZrVN8xTXZNZrP2n/ue+TMpdPmSJmI RKPM6PzPUySaPeL1jhmJuQIJs1qQnP9UOOL0BhaTi9rvueybtTrTHCO72/9h5ctDjYZy er7oqDqIe5YDDjbhIzT2n5aAslNNuYbnThzErAcHiH+/vV6k/nXRShk5vz5ADLL3ErRG JPbNwKWWqs9S6HRgqF9Cjsv5TCCTrB6oFIjPPDoX3z1YheUUbqgsPzEsyIL3VFKbjC/0 pgSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WmDFiqzoJpnKx2HpTQUoP+z376s0YTh6eo5R83CjEzI=; b=Iaj12zD8rTHG283tsaE47FGJzA4ge5jjueTUkszFB8V8d2596X93bAB9X3svyg6MXK uOKUWViUBloZyWz7wyOxeyk6UB7YYZX9tcp+LFMAqN5D5R3wivdmlC8GnprLnlthF9+i foWmlrsAQIzRbxXc8AJqoM5+h8wFHjsNwsFlE3NfMgSn2TLSzFEOvWkVVEmLpIWcoXBW 5rp0w3PHUHc6roAzTfh2YZt02jH14cT0Tulwmqdmw5MaEwNnHM804FObrz32P/dUrFdL iQeqFYG5u57NaWK0I6QpalqMxqf5Lzlw4Ja7+Y6MlqZQ5uS39XiWY+OdvHma2kp43LHA LYvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GiNFUl4z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n19si109028ejh.295.2021.02.02.14.16.35; Tue, 02 Feb 2021 14:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GiNFUl4z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233011AbhBBNzU (ORCPT + 99 others); Tue, 2 Feb 2021 08:55:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:38986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbhBBNsm (ORCPT ); Tue, 2 Feb 2021 08:48:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 579A964FA0; Tue, 2 Feb 2021 13:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273335; bh=TlU1PPpVYsPUJ2CUgcut7+LkhTW4sv0WodCSO7XcjXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GiNFUl4zGWaqF6xuU0nxmiX6TuKvmPQRYNjEvkZ6p3YmvvLwNzJ2vBmox9Qoyty7I hCAeQgQM2NxLC+yMYcAVf/fDl2hJ1dzPs4bLuWgmnxTLaK1rjoqzuj167b/jr7ngT1 pjgY0a0E1O6gBLz3+hGbCVO/SNUUBngH+q14Baq0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arthur Borsboom , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Juergen Gross Subject: [PATCH 5.10 068/142] xen-blkfront: allow discard-* nodes to be optional Date: Tue, 2 Feb 2021 14:37:11 +0100 Message-Id: <20210202133000.531968120@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roger Pau Monne commit 0549cd67b01016b579047bce045b386202a8bcfc upstream. 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 Signed-off-by: Roger Pau Monné Reviewed-by: Juergen Gross Tested-By: Arthur Borsboom Link: https://lore.kernel.org/r/20210119105727.95173-1-roger.pau@citrix.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/block/xen-blkfront.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -945,7 +945,8 @@ static void blkif_set_queue_limits(struc 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 blkf 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);