Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp754750rwe; Wed, 31 Aug 2022 10:21:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR6pB2Z00aN+MNsZOwMNXh0qw32GQQfsV22xthNjNZ9cIG18BGY/2p5gmbOd0dC+QxykDFqZ X-Received: by 2002:a05:6a00:b8a:b0:537:f81:203a with SMTP id g10-20020a056a000b8a00b005370f81203amr27199445pfj.80.1661966468870; Wed, 31 Aug 2022 10:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661966468; cv=none; d=google.com; s=arc-20160816; b=p+luPXt60Sb2JEN+pHE7N/vOA/9JlMKTwb1hav1f3Jun8dKranU0G3xWSYSdEkA8Fc WZE1qiWoPfC2nWRb1PkmQZ835Ndr2kLn9nkj9EeufIg0AKTMTpP6hQNB8CF9lmJDR1Va PwAp9GPOGKDaVMy9I3QxL+FLipbfH/nDjNgVZf+bkqpQ3a2WvBLN38uNALKe2xDYxG7w zhS8HZcFb24cs/PTIbdyYs2z6riKmmDXwGUsrXH/0VhdvqoCtFrTP5x/VWOcy1MPsAcG cVzqMpobavlwTI34ULLyRUYJbig9SJi6TUgcFkKleJk/XkiLU59WfJInb4KjrNQ9doRl LLqA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SiYqX/gF3hznlyzn4P9O1j27Hb6OW0DJvAaWlM+ZRl4=; b=uuHJm76XaGGKt+yaYPBH0wzTHmSmMQo8k5QnhhZ5KcD5lfbO58OJFRmqGQPQ6mW1NV nzL3zplEuwkq7K+49opvLMLcRBGKRlDM17hbNFGk2xa3DcPrbLOygz0jtAweZ4fp68cR SRWsyTDxL4APhkBG5igxxfBsAirEP/cDpFsZcYkBvNkjgkIi+rYx6y2ooDtuwQbX1J7f 7/qCLoo1BeSxzBvybu3kKqVvmulCSuMfycVQCryTMqDiVb0iDAnxEWoT4erCEcn7tsJr fzn/iunXA4FSGVq7XiIhVKU5Q1WQBdN/JH2LbPnvASsA+3n2YiCbqQHVcIORKtkrVtob JHqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VJsN+GwL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a170902ccc100b00172889e9ea9si8926166ple.583.2022.08.31.10.20.37; Wed, 31 Aug 2022 10:21:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VJsN+GwL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbiHaRAS (ORCPT + 99 others); Wed, 31 Aug 2022 13:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbiHaQ7k (ORCPT ); Wed, 31 Aug 2022 12:59:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F408DDA99; Wed, 31 Aug 2022 09:58:39 -0700 (PDT) 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 EE3A2B8220D; 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) 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: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 when connect") Cc: # 5.10.x Reported-by: Marek Marczykowski-Górecki Signed-off-by: SeongJae Park --- 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_transaction xbt, return err; } +/* Enable the persistent grants feature. */ +static bool feature_persistent = 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 = "writing protocol"; goto abort_transaction; } + info->feature_persistent_parm = feature_persistent; err = 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; } -/* Enable the persistent grants feature. */ -static bool feature_persistent = 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 basic * structures and the ring buffer for communication with the backend, and @@ -2284,7 +2285,6 @@ static void blkfront_gather_backend_features(struct blkfront_info *info) if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0)) blkfront_setup_discard(info); - info->feature_persistent_parm = feature_persistent; if (info->feature_persistent_parm) info->feature_persistent = !!xenbus_read_unsigned(info->xbdev->otherend, -- 2.25.1