Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1806304rwe; Fri, 2 Sep 2022 04:16:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4kiiQvXoLuqAcSrycNIFuINkkCr9LrYi2w+LBatYdLveNifiFWpeF+itHLsZXFwlYbDcTf X-Received: by 2002:a17:906:9b83:b0:730:b3ae:343 with SMTP id dd3-20020a1709069b8300b00730b3ae0343mr27867127ejc.670.1662117397660; Fri, 02 Sep 2022 04:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662117397; cv=none; d=google.com; s=arc-20160816; b=DEMMBb174xdk2ZQmWzvws3T858+Zt04PJsbcJb+S6NmqnWIx0lfcWF/Ed+PiK/7MfU 7ypNWChdnKQEN8J9JSNnPf6pnMkxgyytFiogiLhlWgOnp3x7HOkz6iJM1oqN/QUkfdGp o58NVoNFgLXw0H2aspduj6H7i9Cwc7UEozldhTb4WIPYdLUEjvUP39BAv3tRnWORSrRm KG4KcVDffQdZSthJ1GqPm2N/Tyjju9NTlWp3OFuW8wO/v8rfKa8sfebM9ZhBJ8SNFohc T3edN7knPPstmztr3empkilmOvz+Xk4H0jQwTszoFy/Qr6XC7BsMihY6D/IhU6K6Mcbt vebw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6syYNqYADgJ/uyZ9pJBWRfO0mouP2N6IJMJoILo4HW0=; b=J8SNkFNex3jvBZ1TDjY5X3rW78fm4uDNnUuxP1qOsyERhk/4iCsYnVUraq6ahbjZUW cLU4M6swbEWnIviCF8YhoFnc7e5wqLX7kqujMJW5g4ddCczxFWCgBIc+RgDAnv/bKjxJ plSm5gCX3P51rrvQgTtcnB8A8ngOEVubrgJfzfOIHOXvOH8EpiG6Wx3lgnXfeicuO5+p Wl/VrKx/HpLEKZgT/20CZrsegJjGR20/81yLj7XEKl91wyw+B3zE3SH4e0Cw4p6ESJt6 8SD30SixlURrCcOd4l/JlY8A6U4NK9pFCyRBa0UAHlgtjdAxwqLtqyvFyG5kr288gMkk d8IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b="P+/xjhKq"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga31-20020a1709070c1f00b00730753784b1si1837068ejc.45.2022.09.02.04.16.12; Fri, 02 Sep 2022 04:16:37 -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=@amazon.de header.s=amazon201209 header.b="P+/xjhKq"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235833AbiIBLMD (ORCPT + 99 others); Fri, 2 Sep 2022 07:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235830AbiIBLLd (ORCPT ); Fri, 2 Sep 2022 07:11:33 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D491EC7B90; Fri, 2 Sep 2022 04:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1662117089; x=1693653089; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=6syYNqYADgJ/uyZ9pJBWRfO0mouP2N6IJMJoILo4HW0=; b=P+/xjhKqYpWc9umHw7ARMbJ163HgF9/nytW7tYnuWORlFdrRcPuaOe+z z9HFreuszZZ9tx9PJcL9+EHkk6kaqS6r68NhGYUJlF744EnCcwb9ersNt 7f8q+r7UTG2J1P8uy5xe2BBzW3fkCyNgN17q0iEw4CfaUDskpuj1aW+XL g=; X-IronPort-AV: E=Sophos;i="5.93,283,1654560000"; d="scan'208";a="236927472" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-92ba9394.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2022 11:11:15 +0000 Received: from EX13D05EUC001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2a-92ba9394.us-west-2.amazon.com (Postfix) with ESMTPS id 9051B4558C; Fri, 2 Sep 2022 11:11:12 +0000 (UTC) Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D05EUC001.ant.amazon.com (10.43.164.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Fri, 2 Sep 2022 11:11:11 +0000 Received: from dev-dsk-mheyne-1b-c1362c4d.eu-west-1.amazon.com (10.15.57.183) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Fri, 2 Sep 2022 11:11:09 +0000 Received: by dev-dsk-mheyne-1b-c1362c4d.eu-west-1.amazon.com (Postfix, from userid 5466572) id 58D8226F6; Fri, 2 Sep 2022 11:11:08 +0000 (UTC) Date: Fri, 2 Sep 2022 11:11:08 +0000 From: Maximilian Heyne To: Pratyush Yadav CC: SeongJae Park , , , , , , , , Subject: Re: [PATCH v2 1/3] xen-blkback: Advertise feature-persistent as user requested Message-ID: <20220902111108.GA27172@dev-dsk-mheyne-1b-c1362c4d.eu-west-1.amazon.com> References: <20220831165824.94815-1-sj@kernel.org> <20220831165824.94815-2-sj@kernel.org> <20220902095207.y3whbc5mw4hyqphg@yadavpratyush.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20220902095207.y3whbc5mw4hyqphg@yadavpratyush.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 On Fri, Sep 02, 2022 at 09:53:22AM +0000, Pratyush Yadav wrote: > On 31/08/22 04:58PM, SeongJae Park wrote: > > 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 persistent grants") > > Cc: # 5.10.x > > Suggested-by: Juergen Gross > > Signed-off-by: SeongJae Park > > --- > > 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; > > Continuing over from the previous version: > > > > If feature_gnt_persistent_parm is always going to be equal to > > > feature_persistent, then why introduce it at all? Why not just use > > > feature_persistent directly? This way you avoid adding an extra flag > > > whose purpose is not immediately clear, and you also avoid all the > > > mess with setting this flag at the right time. > > > > Mainly because the parameter should read twice (once for > > advertisement, and once later just before the negotitation, for > > checking if we advertised or not), and the user might change the > > parameter value between the two reads. > > > > For the detailed available sequence of the race, you could refer to the > > prior conversation[1]. > > > > [1] https://lore.kernel.org/linux-block/20200922111259.GJ19254@Air-de-Roger/ > > Okay, I see. Thanks for the pointer. But still, I think it would be > better to not maintain two copies of the value. How about doing: > > blkif->vbd.feature_gnt_persistent = > xenbus_read_unsigned(dev->nodename, "feature-persistent", 0) && > xenbus_read_unsigned(dev->otherend, "feature-persistent", 0); > > This makes it quite clear that we only enable persistent grants if > _both_ ends support it. We can do the same for blkfront. Currently, the feature-persistent xenstore entry is written to from connect() which is called after connect_ring(). So it's not available like this. Perhaps it's possible to delay the decision whether to use persistent grants until connect(). > > > + /* 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); > > > > err = 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; > > } > > > > - blkif->vbd.feature_gnt_persistent = feature_persistent && > > + blkif->vbd.feature_gnt_persistent_parm = feature_persistent; > > + blkif->vbd.feature_gnt_persistent = > > + blkif->vbd.feature_gnt_persistent_parm && > > xenbus_read_unsigned(dev->otherend, "feature-persistent", 0); > > > > blkif->vbd.overflow_max_grants = 0; > > -- > > 2.25.1 > > > > -- > Amazon Development Center Germany GmbH > Krausenstr. 38 > 10117 Berlin > Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss > Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B > Sitz: Berlin > Ust-ID: DE 289 237 879 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879