From nobody Sun May 19 05:22:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1661965136; cv=none; d=zohomail.com; s=zohoarc; b=ePutn623pyQhEUirKrChOVqovtXmxNh4C0mxD4uREQ3MrCsFeZc+JFuZYhJGJRK+iUJvhncOPo2VShB7iqEa8Ar+Qkc3kTsiA+EGjpUAtSDXWD0CmkwvEZ0GfVys7k0/MtApjmTkffoimjP5Hf+i/CJEHRMBK+03vs5bBC7jWnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661965136; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z2+IGLOpSO6K8qyo9HP8AwNK8BBJgR6HN3jCRBRQEnE=; b=H9v9lNHJq9v20Ek4xAVJwfyqR+a6Gqslxe3eEoZDu9t8Qfncctn8Vo7zEaZhpRsnnu+PdbKkuCKH5FrzKrJ/wFs4VgJwzWWB3x3jw0GxOSbPdXlYksDW/lFADVrn2iPuu2hNrZDxtA0V8SV5qY98nBv3amyj4c+PHBEXgdPCp0M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1661965136974899.292939681518; Wed, 31 Aug 2022 09:58:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.395941.635843 (Exim 4.92) (envelope-from ) id 1oTR2z-0002mg-Q4; Wed, 31 Aug 2022 16:58:37 +0000 Received: by outflank-mailman (output) from mailman id 395941.635843; Wed, 31 Aug 2022 16:58:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTR2z-0002mZ-LQ; Wed, 31 Aug 2022 16:58:37 +0000 Received: by outflank-mailman (input) for mailman id 395941; Wed, 31 Aug 2022 16:58:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTR2x-0002W4-O6 for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 16:58:35 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2678888c-294e-11ed-934f-f50d60e1c1bd; Wed, 31 Aug 2022 18:58:34 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2713EB821AD; Wed, 31 Aug 2022 16:58:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22B88C433C1; Wed, 31 Aug 2022 16:58:32 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2678888c-294e-11ed-934f-f50d60e1c1bd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661965112; bh=2M6XIQVeSqrPrYytDvGmk8JSZnX1cUCppYJ4t0zteug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+yj2nUL8cBvYHbhNGByKXHfolByjrFRe687uj1BUUB6mIbeXN2akLAiQRdvStbqP NMb5qiC+ThAz7uY10jHDz33BEKstZU2iTWJpSn0pPMwG29otA0+v7b4oevDXX9xywt daiS3FmM4D7SFz4ZS2QhL+z/hmZONNOucXCZH3i5gYjg1q8QBAYtaXJ65YwQKdQzb0 vUEOeCFozOnzBRrMkAQ5iuwNZdviUg+Q7J75Jt4uuZwxML8bP5XUh9fA3KShUEsq9Y 3L8j6pjOgw50j/r6rdnjpE4dC/uRqcRZVpRbxbOCphVbmdYWOEHGFNP8VkJoa9oNlQ OeAJ+c6yTMvqA== From: SeongJae Park To: jgross@suse.com, roger.pau@citrix.com Cc: SeongJae Park , marmarek@invisiblethingslab.com, mheyne@amazon.de, xen-devel@lists.xenproject.org, axboe@kernel.dk, ptyadav@amazon.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/3] xen-blkback: Advertise feature-persistent as user requested Date: Wed, 31 Aug 2022 16:58:22 +0000 Message-Id: <20220831165824.94815-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831165824.94815-1-sj@kernel.org> References: <20220831165824.94815-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1661965138092100003 Content-Type: text/plain; charset="utf-8" The advertisement of the persistent grants feature (writing 'feature-persistent' to xenbus) should mean not the decision for using the feature but only the availability of the feature. However, commit aac8a70db24b ("xen-blkback: add a parameter for disabling of persistent grants") made a field of blkback, which was a place for saving only the negotiation result, to be used for yet another purpose: caching of the 'feature_persistent' parameter value. As a result, the advertisement, which should follow only the parameter value, becomes inconsistent. This commit fixes the misuse of the semantic by making blkback saves the parameter value in a separate place and advertises the support based on only the saved value. Fixes: aac8a70db24b ("xen-blkback: add a parameter for disabling of persist= ent grants") Cc: # 5.10.x Suggested-by: Juergen Gross Signed-off-by: SeongJae Park Reviewed-by: Juergen Gross Reviewed-by: Pratyush Yadav Tested-by: Marek Marczykowski-G=C3=B3recki Tested-by: Maximilian Heyne --- drivers/block/xen-blkback/common.h | 3 +++ drivers/block/xen-blkback/xenbus.c | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback= /common.h index bda5c815e441..a28473470e66 100644 --- a/drivers/block/xen-blkback/common.h +++ b/drivers/block/xen-blkback/common.h @@ -226,6 +226,9 @@ struct xen_vbd { sector_t size; unsigned int flush_support:1; unsigned int discard_secure:1; + /* Connect-time cached feature_persistent parameter value */ + unsigned int feature_gnt_persistent_parm:1; + /* Persistent grants feature negotiation result */ unsigned int feature_gnt_persistent:1; unsigned int overflow_max_grants:1; }; diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback= /xenbus.c index ee7ad2fb432d..c0227dfa4688 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -907,7 +907,7 @@ static void connect(struct backend_info *be) xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support); =20 err =3D xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", - be->blkif->vbd.feature_gnt_persistent); + be->blkif->vbd.feature_gnt_persistent_parm); if (err) { xenbus_dev_fatal(dev, err, "writing %s/feature-persistent", dev->nodename); @@ -1085,7 +1085,9 @@ static int connect_ring(struct backend_info *be) return -ENOSYS; } =20 - blkif->vbd.feature_gnt_persistent =3D feature_persistent && + blkif->vbd.feature_gnt_persistent_parm =3D feature_persistent; + blkif->vbd.feature_gnt_persistent =3D + blkif->vbd.feature_gnt_persistent_parm && xenbus_read_unsigned(dev->otherend, "feature-persistent", 0); =20 blkif->vbd.overflow_max_grants =3D 0; --=20 2.25.1 From nobody Sun May 19 05:22:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1661965138; cv=none; d=zohomail.com; s=zohoarc; b=btHfTDC3AkEdIZs+3nrnNYZI6XKQ5s7s/kQ6quE+BX1g/k4yZNlCtvAHsZ1KRaK39ZBmGVU6E3E3ArR+wOQwp4IPTtRiL8jIvw4gfMmse0PQCmRapP8P6kNGkxglqwtP5Jgoj5mySQy5UR6eScjYFNBVJL05Pobz5S6nkp51qSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661965138; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GBzFZDyJvDSbPFm40elD/KarihRwvExl2QTVCdoIeBU=; b=EGG2UpQZgrB7AVyKU0k3KgT9XrnJRa+W+W3x8tYUq3YzJAE6eCe4/YbRBukWhigwu5SKRcEpAKVXw0lT+R71g+UIlSxcKlleUTRQBDeT3h7sOzze4B2eVDXnTluIaQzbm9gC22zfK55cv5R62GatsPXxwqu/Gmr9S+WF05RbjlI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1661965138826678.6598349284295; Wed, 31 Aug 2022 09:58:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.395942.635854 (Exim 4.92) (envelope-from ) id 1oTR31-00032v-2M; Wed, 31 Aug 2022 16:58:39 +0000 Received: by outflank-mailman (output) from mailman id 395942.635854; Wed, 31 Aug 2022 16:58:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTR30-00032m-TT; Wed, 31 Aug 2022 16:58:38 +0000 Received: by outflank-mailman (input) for mailman id 395942; Wed, 31 Aug 2022 16:58:37 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTR2z-0002mU-Qt for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 16:58:37 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2781847d-294e-11ed-82f2-63bd783d45fa; Wed, 31 Aug 2022 18:58:36 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3C85DB8220A; Wed, 31 Aug 2022 16:58:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16ED3C433D6; Wed, 31 Aug 2022 16:58:34 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2781847d-294e-11ed-82f2-63bd783d45fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661965114; bh=dAXL0+XNvWx5LNwHQHyifRYahh/pbyejlx7Mrbu9GZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Unrckl/0xd5p4L0eslkX+ocOVnSTxmyJWLFH/U+QruZmKX8gJdrduY6/CKskFoEWd ISKZ9pHw2Q/FycQa5vEi4tVNKULPLkBLgmNwT1C2W/w8DAo8qh4Cy3auUpwCxehnB0 8LstTa/XU6ZZ0YxZbVsssX+To30Ks8YUt+o9BArCX6fGGv2Vvq65I2nUKzK116hIA+ MI27LA9tMdpy0d7c5dmH++0KKz2eefkDA0N57lPA4Vl5L5nGk1wsuhlV1WbZKvd3X3 fUptPXshdHkX8Fuoq+D9EglqVBVXgoAzpgDhaRHDEr+f2EjjxQZpAPWWYg3zQSbnjv 0/GI1hfVVorcQ== From: SeongJae Park To: jgross@suse.com, roger.pau@citrix.com Cc: SeongJae Park , marmarek@invisiblethingslab.com, mheyne@amazon.de, xen-devel@lists.xenproject.org, axboe@kernel.dk, ptyadav@amazon.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/3] xen-blkfront: Advertise feature-persistent as user requested Date: Wed, 31 Aug 2022 16:58:23 +0000 Message-Id: <20220831165824.94815-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831165824.94815-1-sj@kernel.org> References: <20220831165824.94815-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1661965140096100009 Content-Type: text/plain; charset="utf-8" The advertisement of the persistent grants feature (writing 'feature-persistent' to xenbus) should mean not the decision for using the feature but only the availability of the feature. However, commit 74a852479c68 ("xen-blkfront: add a parameter for disabling of persistent grants") made a field of blkfront, which was a place for saving only the negotiation result, to be used for yet another purpose: caching of the 'feature_persistent' parameter value. As a result, the advertisement, which should follow only the parameter value, becomes inconsistent. This commit fixes the misuse of the semantic by making blkfront saves the parameter value in a separate place and advertises the support based on only the saved value. Fixes: 74a852479c68 ("xen-blkfront: add a parameter for disabling of persis= tent grants") Cc: # 5.10.x Suggested-by: Juergen Gross Signed-off-by: SeongJae Park Reviewed-by: Juergen Gross Tested-by: Marek Marczykowski-G=C3=B3recki Tested-by: Maximilian Heyne --- drivers/block/xen-blkfront.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 8e56e69fb4c4..dfae08115450 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -213,6 +213,9 @@ struct blkfront_info unsigned int feature_fua:1; unsigned int feature_discard:1; unsigned int feature_secdiscard:1; + /* Connect-time cached feature_persistent parameter */ + unsigned int feature_persistent_parm:1; + /* Persistent grants feature negotiation result */ unsigned int feature_persistent:1; unsigned int bounce:1; unsigned int discard_granularity; @@ -1848,7 +1851,7 @@ static int talk_to_blkback(struct xenbus_device *dev, goto abort_transaction; } err =3D xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", - info->feature_persistent); + info->feature_persistent_parm); if (err) dev_warn(&dev->dev, "writing persistent grants feature to xenbus"); @@ -2281,7 +2284,8 @@ static void blkfront_gather_backend_features(struct b= lkfront_info *info) if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0)) blkfront_setup_discard(info); =20 - if (feature_persistent) + info->feature_persistent_parm =3D feature_persistent; + if (info->feature_persistent_parm) info->feature_persistent =3D !!xenbus_read_unsigned(info->xbdev->otherend, "feature-persistent", 0); --=20 2.25.1 From nobody Sun May 19 05:22:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1661965137; cv=none; d=zohomail.com; s=zohoarc; b=RYoeCNbVjtP5G7ZAreyRCaCU18ePkvCvQ/H0+vdfvB4iAmshvq8gv3nj2MwfxtEJO2NYdlAxSPgNxzU4W+Dm10Ft8w6ZELcXJfuchhU8CV5YYjD9gOBUXrRYibUQgjnL98WbTevhEnCDS6Ewkt/7Rrv+diICOxEup8skldC0YxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661965137; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SiYqX/gF3hznlyzn4P9O1j27Hb6OW0DJvAaWlM+ZRl4=; b=VRrPi1JXFimGUkN6jTIjxx2jo/+0ERb0ruczPoTKibcOzJAIjyP1vRF2sZkjBTR4YfbjTUZi1y3FSW3oYsCH9x8zswV1oVotJ73advkOol4YdQxnNLMV8StwA/Evn3aJuoiGRj0g+7fo2fPcV9w6FXtb2HngU+myOYJZ3NHmYCg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16619651379326.8887492129568955; Wed, 31 Aug 2022 09:58:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.395943.635865 (Exim 4.92) (envelope-from ) id 1oTR32-0003KA-8v; Wed, 31 Aug 2022 16:58:40 +0000 Received: by outflank-mailman (output) from mailman id 395943.635865; Wed, 31 Aug 2022 16:58:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTR32-0003K1-53; Wed, 31 Aug 2022 16:58:40 +0000 Received: by outflank-mailman (input) for mailman id 395943; Wed, 31 Aug 2022 16:58:39 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTR30-0002W4-Ql for xen-devel@lists.xenproject.org; Wed, 31 Aug 2022 16:58:38 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [2604:1380:4601:e00::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 27f29054-294e-11ed-934f-f50d60e1c1bd; Wed, 31 Aug 2022 18:58:38 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 10148B8220E; Wed, 31 Aug 2022 16:58:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0A36C433B5; Wed, 31 Aug 2022 16:58:35 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 27f29054-294e-11ed-934f-f50d60e1c1bd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661965116; bh=VwhcFoR15fxSac+d9djkuB0nYm46oJiHPCPL6ttzYrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJsN+GwLzB1o/aocdkfe9uukB4vLCbbUgu8WeVfHMhA7ledCcsrJzIw/RKG0Q8c0r p2enaJwAn3AKNgdzMextUO/knmPPDWMEIdOz/47v1GGtj8mW67V8pSLsf4HCp11IpS 1koV2MmWi4Cmy1oJqviP21B9cN4J0f+zf60DlBP7loUnYI7JtJ6oiHtz23LW7wUMm9 1hTMReYwfvChFniNUnD1/0kNLo8g4KcO1aK1cwOKIA6I/mgWaIQufr0AcrX2YJEjOV f7Khyyto6R2BwBEN7MtOok8iaHn25/XoLtpbA/73fpxcbjNwMpgJmlgDzX35+veJiW 9uBUVRlhFuAkg== From: SeongJae Park To: jgross@suse.com, roger.pau@citrix.com Cc: SeongJae Park , marmarek@invisiblethingslab.com, mheyne@amazon.de, xen-devel@lists.xenproject.org, axboe@kernel.dk, ptyadav@amazon.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 3/3] xen-blkfront: Cache feature_persistent value before advertisement Date: Wed, 31 Aug 2022 16:58:24 +0000 Message-Id: <20220831165824.94815-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831165824.94815-1-sj@kernel.org> References: <20220831165824.94815-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1661965139807100006 Xen blkfront advertises its support of the persistent grants feature when it first setting up and when resuming in 'talk_to_blkback()'. Then, blkback reads the advertised value when it connects with blkfront and decides if it will use the persistent grants feature or not, and advertises its decision to blkfront. Blkfront reads the blkback's decision and it also makes the decision for the use of the feature. Commit 402c43ea6b34 ("xen-blkfront: Apply 'feature_persistent' parameter when connect"), however, made the blkfront's read of the parameter for disabling the advertisement, namely 'feature_persistent', to be done when it negotiate, not when advertise. Therefore blkfront advertises without reading the parameter. As the field for caching the parameter value is zero-initialized, it always advertises as the feature is disabled, so that the persistent grants feature becomes always disabled. This commit fixes the issue by making the blkfront does parmeter caching just before the advertisement. Fixes: 402c43ea6b34 ("xen-blkfront: Apply 'feature_persistent' parameter wh= en connect") Cc: # 5.10.x Reported-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: SeongJae Park Reviewed-by: Juergen Gross Tested-by: Marek Marczykowski-G=C3=B3recki Tested-by: Maximilian Heyne --- drivers/block/xen-blkfront.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index dfae08115450..35b9bcad9db9 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1759,6 +1759,12 @@ static int write_per_ring_nodes(struct xenbus_transa= ction xbt, return err; } =20 +/* Enable the persistent grants feature. */ +static bool feature_persistent =3D true; +module_param(feature_persistent, bool, 0644); +MODULE_PARM_DESC(feature_persistent, + "Enables the persistent grants feature"); + /* Common code used when first setting up, and when resuming. */ static int talk_to_blkback(struct xenbus_device *dev, struct blkfront_info *info) @@ -1850,6 +1856,7 @@ static int talk_to_blkback(struct xenbus_device *dev, message =3D "writing protocol"; goto abort_transaction; } + info->feature_persistent_parm =3D feature_persistent; err =3D xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", info->feature_persistent_parm); if (err) @@ -1919,12 +1926,6 @@ static int negotiate_mq(struct blkfront_info *info) return 0; } =20 -/* Enable the persistent grants feature. */ -static bool feature_persistent =3D true; -module_param(feature_persistent, bool, 0644); -MODULE_PARM_DESC(feature_persistent, - "Enables the persistent grants feature"); - /* * Entry point to this code when a new device is created. Allocate the ba= sic * structures and the ring buffer for communication with the backend, and @@ -2284,7 +2285,6 @@ static void blkfront_gather_backend_features(struct b= lkfront_info *info) if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0)) blkfront_setup_discard(info); =20 - info->feature_persistent_parm =3D feature_persistent; if (info->feature_persistent_parm) info->feature_persistent =3D !!xenbus_read_unsigned(info->xbdev->otherend, --=20 2.25.1