From patchwork Mon Jan 18 15:15:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12027537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70F70C433E0 for ; Mon, 18 Jan 2021 15:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F0AB227C3 for ; Mon, 18 Jan 2021 15:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392145AbhARPWU (ORCPT ); Mon, 18 Jan 2021 10:22:20 -0500 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]:64665 "EHLO esa1.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393358AbhARPWR (ORCPT ); Mon, 18 Jan 2021 10:22:17 -0500 X-Greylist: delayed 323 seconds by postgrey-1.27 at vger.kernel.org; Mon, 18 Jan 2021 10:22:16 EST DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1610983336; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=ZvoqJAfEketjlKz4zfIY94yJwiVMCNgf7cpnGMh8MQg=; b=aOtp6VGlpqDhx9llVXGXER2cnnpFUDFjk3YBMNtP3laARPQ07+MNse/o 1FCFZcJkb/5J67/qti0lYtNwm5Phy90/wvymtE0QBio1Umgz8IlgJaFkb 7VHAE1J2oc2YSADqSHEJ+ZXCdI0D0Q3C9+bIWSER0KWqC4vQu7MTiw1TL g=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: Y83MYN4NDffAqUbvcFxaH5yKXlhbMq0V3XFE7B9f1x18ewnHbsZtYiX6SMSoyp8/tAoYAUhZcR 4qGfE/Zn8Zcn5CaySklj8hE7YBOGcSgNR6y5jfOLxiI+7ECtfgY/CEWKJy/3WLNT9dB64uhNOx 47PsT1Rj7Vp/WStw3dgWN0lCHwu2iqMraDT9bvnTPElsKzv/8DBwmEgvuInJeFK/UWdxpi3N4B GofwyccRoHg6XfaGF6fPgnM5B2jpspFDkBfz0Ojh4TC1arxm5ZFqmm9QxfQtoa71Mr7n/0qgqv gcU= X-SBRS: 5.2 X-MesageID: 35684672 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.79,356,1602561600"; d="scan'208";a="35684672" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cCnNe4zYfzKqE5QS6cN114pMCkX8zyo/LYMfeCkYIzvA8aSCVM8FXfmWiDGlj1eV9yLwep1CGJjMI+bhoXrEtr3CAIaR+5jvAlptL/SasPAcuVc9/ep0p0EDr/zyaik257Xin4ecxpRm+bqSw2w+k6+CI4lwEJPdoBvfSUKMCNjkbqyjmoq5nP0hd85wtASkscr1ute4w9bnwHs93M6kZzZlHM5pLWY+Zs6F4kV6adRyvFGHZYDMQZFvCsSDDeUPEZ9/LXeCpmcwJNnrglhC7j3+ZXFgqL9ThRbaqC4V/MB4Ldhpa2ktQL6oKPaPRzCl1+N3dXlDnHluYkqJMi2VpA== 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=guD3dwThuVjNlUiHYl4Q2Z+Crgc3pWLg845vDPYqznE=; b=SASDiVJBNSa1zMGKp+a8twOrD3c5XyiKcYtNj/KU341XdlwYpJkSY/4D6u7yeeIOGenGC0iDRSYOhYdBM+qYu6aEojhtSF3uH7MC3e533klNypQ+zyJZGQ61ZAgn6TKGAKb/Dt0+vK+oBpdLS5n800KcXoDqDRW69ZApgyIpBawvrV0DHxr5Gsig8lid390Rh87tcaKR910k/Qad2T4Af5ykCTgt7A2ACRPAPFTs21YiOU6gjuzNIp7gg/KeK8xMfVpLamXefMgERfZfCRm2wCEWntn7atm3yRX6R3BoH+P76Ftj3lApRlW9+VZvdULkwP1P+kn4pt9YZPqPf4hwFg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=guD3dwThuVjNlUiHYl4Q2Z+Crgc3pWLg845vDPYqznE=; b=XWgrzI8kHxQT+Jchgv9QGP852M3fKafE1bb+6/JtnWXSaV5Iz4hG94aSTqrX0P1hTFWjp1/tDW1fS7lQBau6r8GTazuRlzaUywKKSvVvsrSWCbWomfhTV3LZi0JvmWbKjBZgHo36IbIjfebzhGjOIoaulHMMQf5qeEh/MW7Wycs= From: Roger Pau Monne To: CC: Roger Pau Monne , Arthur Borsboom , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Konrad Rzeszutek Wilk , Jens Axboe , , Subject: [PATCH] xen-blkfront: don't make discard-alignment mandatory Date: Mon, 18 Jan 2021 16:15:28 +0100 Message-ID: <20210118151528.81668-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.29.2 X-ClientProxiedBy: MRXP264CA0017.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:15::29) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af7a4c56-e8a7-4d5a-ada6-08d8bbc3ecf1 X-MS-TrafficTypeDiagnostic: DM6PR03MB4538: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xKKfLtZenNpYLG8JUgw+FcApWXdRSV33AWxKWt1J5jxcm/pUiVtWnf57EiSUyJTFnfzVrCxr8LMwvYXI+07ZuipE5YfDi5dYBBqazE2bXFUajQ5f63rOMFBPbiixcQh+9KRHE7yN3JGk3asySMfR4aOmBv/P34LHMXtRTC75y/Sr1oMujxPoyjn0UwjuwfA+t5PW9QyHH1YgsETwRKSa3IJVeOMKcUhaaPUXcnneTZHXBRT0IFtI79Ep36at0VAysDOJ/2iyKr6DPjY9T3dBMMhPxr5orL+KZrKTDUxDL8nDaquqvjBISe9vOOqYVNgEd2cPnSGsQKkVXbC15j3l+tMycewdS/eGDRik9yY41zSrr3pmfCG2jVIbN0sZLUdsg6bE7guY3EnE6HGSUknawFmfhr4d5Qi4f2z4b0aqoxvfIfh+ehONHZAyKfen4ZDpyhc5u/txdW+7jAEPXI9J9E3kh1NY9ARd+w+3HYHDIBby9I/X4xP3QS/Q1Apck/sO/kFGuMNf7VVJ2UtPAMM0zwdWsx5LmZzhBRHRrSN1f0bSs3dJJJygD3vM5xTz+PoStFHSD9hQXuBpIilFu9iKVg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(396003)(136003)(39860400002)(376002)(4326008)(6496006)(478600001)(6916009)(86362001)(956004)(316002)(83380400001)(6486002)(2616005)(66946007)(66556008)(66476007)(54906003)(8936002)(8676002)(186003)(36756003)(6666004)(16526019)(2906002)(26005)(1076003)(5660300002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?h4CkPUtw5235RybiOGQw3NDLAjLcja?= =?utf-8?q?qQYNooUncOP1fQ2YozrnLaM4C8EuWDcVNkDwGKj6vfFCcCVgVMgtN6H3l8J+GKY7+?= =?utf-8?q?pIDuneROBCbsL5F7Ff4NFkKXtWZr7RemYJPdMmGTLpzg70NV0Lor6LEoGfjNtjrnr?= =?utf-8?q?1B8XhpmGf6N1lCPwcolqQMCvkVV7LOOouQ26YOO1nyywfqTiiE0YeHpT/r3lB61uj?= =?utf-8?q?k9QUmuFbwmmcYKMvjl9Uwhc7GDVhnkWrD5IYwemcuhB/Gc4E/UubkdOsysGt4S0FS?= =?utf-8?q?ZZKRUs+4G4NWc0syPE0nENesH7v3zdsfVirc9H4g6FjkI4uf766tNqj9qpjIrxt7I?= =?utf-8?q?mvHSXEhTIM9oN0d8q9B0uz049Fxpw61XAFJNGqJW8urDSjEzSJ+KOW0Npxan8K2ul?= =?utf-8?q?EjZFEvLblkfhceJ4Hivh/OlaaG+52W0i3Y2U7yooOL7mYfiJ2JMyipEAwjhz3scjH?= =?utf-8?q?foQGNUZL6o6/PD0IJ0DbFYJZsfiDJv1lXY9bQ2h5pIK/qzyP5h9QI9KzShIX4QztD?= =?utf-8?q?QFsCGB4JQ92OdpimBLFpi+HeXpSrcjlXAyDtrOdYKf8qycUT2wp1wpmclvNbbmBqe?= =?utf-8?q?iB1eZ5zUl0ZFjYw5Vnzn2o2AdwX8aXmOICEIUYYAG/EgK/ibqCNE2R60CjC49TkQr?= =?utf-8?q?sOYMrE9JF8hMHRIsYC7QdfHAEk9h+k9PONK+K7KmjSE9TocASEBvmb365JkzMF+Wd?= =?utf-8?q?QzVeV6+N9CGGL3blILCy2jA/8Jd6kwWeQoCZbEHogGPH64/JYL7cBL6TM7YJ+UNVX?= =?utf-8?q?Jpe6gMEFTUKK9XG9mm4C1YxlbFSB7Ol+Wu/7QxdL6haLHB545ulGvWL6VEkfzK5Ay?= =?utf-8?q?YaaLuEt1eQ7VfmzSqCKfEQ2fBO1pby+Gmib10BDCl0yi2bueCTP5Gz2pjydiMI4BS?= =?utf-8?q?Fl4vm3FZxhu97HNj+MJc2BIA7ts/pLS5j5T0FekX2YuwvLzIwSOf4y8hgGuRqEsaW?= =?utf-8?q?ikZYcOcGaymWxgE8uBx?= X-MS-Exchange-CrossTenant-Network-Message-Id: af7a4c56-e8a7-4d5a-ada6-08d8bbc3ecf1 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2021 15:15:44.3503 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zd2OJOM8Nih2a0hTWb4Wzt4xEenI0nwfDxlugs89hSdPhLNhOyq+Pvg3aHYpodMmeQA8MvpxaWlyOf9jzluYHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4538 X-OriginatorOrg: citrix.com Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org 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 Signed-off-by: Roger Pau Monné --- Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Cc: Konrad Rzeszutek Wilk Cc: "Roger Pau Monné" Cc: Jens Axboe Cc: xen-devel@lists.xenproject.org Cc: linux-block@vger.kernel.org Cc: Arthur Borsboom --- 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)