Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4453040rwb; Tue, 6 Sep 2022 07:45:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR5EoMzHe9g+GRiT9lm60Sl0SCcR2YGBjTeNYjRzdY5ISZIFSLT3khkqDni0+ww+WkctGVXU X-Received: by 2002:a17:906:cc15:b0:73d:d87f:f039 with SMTP id ml21-20020a170906cc1500b0073dd87ff039mr37593631ejb.253.1662475536774; Tue, 06 Sep 2022 07:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662475536; cv=none; d=google.com; s=arc-20160816; b=klsRjjrACbxrO65f7vXTl9IzUCPpEmfSUbuKuupMv8KRm/6N84jyoV7jnhSK4tJUEZ Rbsfe6gsvLV5Th3xfkN8MDHij/396RT+ebVrOhgF8jXq8sa5tof7dOtB3gOhPN92sQAb oY5+3eIwXzLnBB8N0yzE0w0pud1fvTleuAKqt3CoJmV11E6Jy9uMYKq/kz3qWmTwp6J4 Hcyiw3sO0lkoX4A/yb0VHezWZvgkUV3ij3iBj4ZnoS2irKdyAfMEj3UM5IflvzsGvl2n X674QeZ+L67P0fgZ6nhGOVCNDJbwwymdzgVvf8P6Xj9l8dzp49qgb4X7HzTgAh/bWuTy ux6g== 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=aINVcFMdbr5LrPA7GdBb7hDzz9V09+Uz0Rbg9mrH4AU=; b=bZV7Zpyrd5znjxArBzPxaGpDQF1Xr64SJRBSD+4CuuLws9387lm8l0bff5lz9otRSb EWuEk7EX3CYXnelnyqkEipUZCIx4iC8LJCeKUAzIfIhkaI2TRAus6TSQyz1tQEq9Pl9T WAVdPNN3srY0OOmLGtcBPOf89gtP6AszwtJSyI/wOtKjSsSpTPWhhW53Qc8Y3qUv0fCD baou+nTSNaGAPr1pcIcOtbYEmnNoaWRBzh+Oe9Jb3+i04mHyWcOp6MZWQ/ng0VVZv4D+ WP+oO6oaDx01TL1LRXqoM/P8n3yxyoRdmPk8iilnDWDpQ5TvUZvIyJ3hqS80CF9V09MN b+yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PxYzoS80; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t29-20020a056402241d00b0044e9f2b1df9si3539382eda.151.2022.09.06.07.45.09; Tue, 06 Sep 2022 07:45:36 -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=@linuxfoundation.org header.s=korg header.b=PxYzoS80; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241090AbiIFONE (ORCPT + 99 others); Tue, 6 Sep 2022 10:13:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241055AbiIFOLO (ORCPT ); Tue, 6 Sep 2022 10:11:14 -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 177277F245; Tue, 6 Sep 2022 06:47:43 -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 659EEB818C0; Tue, 6 Sep 2022 13:47:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8784C433C1; Tue, 6 Sep 2022 13:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662472062; bh=++nv/m53/md5yXVdGeZsva9dHsSMfYqBvS09rVdX744=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxYzoS80VMe4aPtbu0xgg+psHdwJI9SSNq+jv/HZCX+d+otNrFRclOT/Qa+IHV8fU jV6WS7VkYodZSZHvJDeqAaXWkXj1hRzAW18wvhN3yLgtz/BFF3ZGNALxlOeCxlB3gi pgxdpjGb7zFlyRtJNw5INdcB0PR8iJiwO037jCFE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , SeongJae Park , Juergen Gross Subject: [PATCH 5.19 104/155] xen-blkfront: Cache feature_persistent value before advertisement Date: Tue, 6 Sep 2022 15:30:52 +0200 Message-Id: <20220906132833.855662213@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@linuxfoundation.org> User-Agent: quilt/0.67 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 From: SeongJae Park commit fe8f65b018effbf473f53af3538d0c1878b8b329 upstream. 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 Tested-by: Marek Marczykowski-Górecki Reviewed-by: Juergen Gross Link: https://lore.kernel.org/r/20220831165824.94815-4-sj@kernel.org Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/block/xen-blkfront.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1759,6 +1759,12 @@ abort_transaction: 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 @@ again: 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_ 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_feat 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,