Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp287055imw; Fri, 15 Jul 2022 03:18:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRuVDpmwWRYoJ2+EC8waZePCxGEz4PRFQVM08tOzhvv/loDbFfCm8QydrcXbcchIyCV7ZE X-Received: by 2002:a05:6a00:24cc:b0:50d:58bf:5104 with SMTP id d12-20020a056a0024cc00b0050d58bf5104mr13221750pfv.36.1657880282094; Fri, 15 Jul 2022 03:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657880282; cv=none; d=google.com; s=arc-20160816; b=QZYH89nzWh2SaqxWF4eDffW4XqQAQF/zsNO3nkB+tW6hLVJC3B2sheYkT+6gKW9/ZN awt6IoOPzpl/3q/O4XAjvxgwknW2C0VikcNQk3eYBZSpSh/xt3g2MVnDzS74yRNOSjKg gJ7t6st4BQJyTm7pYdBkHZCKIEKhoiESXJu4NAHivQfPZRQrKYQdoEWOigqRNGjwH1qD X42VhlY6MDYvGsF3BuSgc38mvXG02q/Taqn1Pm4rDWDuciodwdSydGYq876wQJm6qW06 uwQA/LUfXuY+yUhsK1Kh4LOVd2nctVzQ9itwjWCADAz3aRanXXKB431o1Gyf5lHuMMBK PLDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=3jL/lfoMTvA3SObDpy7W+GRYeEbbVoydVSs+VhMSyQ8=; b=K3Ac/bYXM5OJa5jEENvpbYjgeOSY6LqmPvJVyBKmn7ouBXFhBC5fqoWHtNKtbI5O1e cHOTfxF6gvMWSMKZzX1I343TR7SjZvyyxEQC0qfkfFikh80LqBdlNZKSA7pf9lVG5VzL VC6m8+SZmIGehqENrkhNgs/fk6TTCjO9uttoCP9goMkMDirq70PSh9ElAodRkfwPeOF0 SH5EmhvxyUY3xzwCKgiWDNFVpT0fVR63NBJIBociynik3boV0IrLhPyUBvEh6BF7O51Q n0d4GU22N32V2fmpIEnt1fiUfU75kdPjS27nc4LjnvH8CZ3l5xjW8xhRVCBTPfRVAHlO yOnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LKqUeJAh; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a170902a60500b0016befc812b0si4329376plq.157.2022.07.15.03.17.40; Fri, 15 Jul 2022 03:18:02 -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=@gmail.com header.s=20210112 header.b=LKqUeJAh; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232685AbiGOKPo (ORCPT + 99 others); Fri, 15 Jul 2022 06:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230407AbiGOKPk (ORCPT ); Fri, 15 Jul 2022 06:15:40 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3370820D2; Fri, 15 Jul 2022 03:15:38 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id u13so7085612lfn.5; Fri, 15 Jul 2022 03:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=3jL/lfoMTvA3SObDpy7W+GRYeEbbVoydVSs+VhMSyQ8=; b=LKqUeJAhYet/E4+FOjDCJ0dKq4cDW2x4E+rfQdu83sWKvClZdCu1e1M0E0f3NVLWeY RXqHP7rrV4Gy0UvBJZ6Bv4RiaH1MNOZ0zYRfjZ35s6KLeY6hYXQcra7SL8Bs6qETPdr5 dYYLgG48qse3A1sQodtQrzuSaIVuhSnWYGOCsfY5B7tL5JDS6Z3SbspiTM2N6zT81LBz GrmAOEmVMPpU117asGxfbCJUPK8r1VAAGAELjEv0s/Ph5p+GAAYDP5wadDJdkdPE4Jv9 Ebcy0Ity1RZ3igPwXdeAet2+5VSr+p+LL13YixBvp19SsNp9YpNMvk/gnMMrJ07RuCcm 55Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=3jL/lfoMTvA3SObDpy7W+GRYeEbbVoydVSs+VhMSyQ8=; b=Y7AlmLyyzzUhLU0Xa4nnzSHExxCy6sgmJ9ZLAfSqcXOWufbtKk1WlSJ9FaWzANZ+22 9PgFI1QNoD2RHSFwQoWyp/x2HH7DVpZfbAQSurGMrw8noaYiRxnvH1JoHURxwdZN7bjN 3qOvD4pXKRS8cIIVqlvpysFLHYlF20Af93B8+fEmsUNvjmQP9vsRyIg6kTpjGaQOogc7 7602wOzgmrF5/kZtCibbw/bXUT/v+Odkev1ts1ph3pto2A2huoiAy7nrlX2BxejMTPdt w5Tx1T9/jONGD9vp10uHzBIzd68qz9K7mGVT80Hsqzh+g1sH40peJksW5GBY0vsxeRr+ SFGg== X-Gm-Message-State: AJIora+b6uOdsYuJVoLDxswHz4dLLL4KAfYgr5A2mzhHmed66rwUKx5C oSNCTtJW+fpjmw3pZT7J4Hs= X-Received: by 2002:a19:4f0b:0:b0:489:c753:5c1d with SMTP id d11-20020a194f0b000000b00489c7535c1dmr7473118lfb.339.1657880136897; Fri, 15 Jul 2022 03:15:36 -0700 (PDT) Received: from [192.168.1.7] ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id e10-20020a19674a000000b00483f8c40c14sm835123lfj.243.2022.07.15.03.15.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Jul 2022 03:15:36 -0700 (PDT) Message-ID: <41207539-f621-1bb2-2f43-0b2b9e3f6866@gmail.com> Date: Fri, 15 Jul 2022 13:15:34 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2] xen-blkback: fix persistent grants negotiation Content-Language: en-US To: SeongJae Park , roger.pau@citrix.com, jgross@suse.com Cc: axboe@kernel.dk, boris.ostrovsky@oracle.com, mheyne@amazon.de, xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, andrii.chepurnyi82@gmail.com References: <20220714224410.51147-1-sj@kernel.org> From: Oleksandr In-Reply-To: <20220714224410.51147-1-sj@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 15.07.22 01:44, SeongJae Park wrote: Hello all. Adding Andrii Chepurnyi to CC who have played with the use-case which required reconnect recently and faced some issues with feature_persistent handling. > Persistent grants feature can be used only when both backend and the > frontend supports the feature. The feature was always supported by > 'blkback', but commit aac8a70db24b ("xen-blkback: add a parameter for > disabling of persistent grants") has introduced a parameter for > disabling it runtime. > > To avoid the parameter be updated while being used by 'blkback', the > commit caches the parameter into 'vbd->feature_gnt_persistent' in > 'xen_vbd_create()', and then check if the guest also supports the > feature and finally updates the field in 'connect_ring()'. > > However, 'connect_ring()' could be called before 'xen_vbd_create()', so > later execution of 'xen_vbd_create()' can wrongly overwrite 'true' to > 'vbd->feature_gnt_persistent'. As a result, 'blkback' could try to use > 'persistent grants' feature even if the guest doesn't support the > feature. > > This commit fixes the issue by moving the parameter value caching to > 'xen_blkif_alloc()', which allocates the 'blkif'. Because the struct > embeds 'vbd' object, which will be used by 'connect_ring()' later, this > should be called before 'connect_ring()' and therefore this should be > the right and safe place to do the caching. > > Fixes: aac8a70db24b ("xen-blkback: add a parameter for disabling of persistent grants") > Cc: # 5.10.x > Signed-off-by: Maximilian Heyne > Signed-off-by: SeongJae Park > --- > > Changes from v1[1] > - Avoid the behavioral change[2] > - Rebase on latest xen/tip/linux-next > - Re-work by SeongJae Park > - Cc stable@ > > [1] https://lore.kernel.org/xen-devel/20220106091013.126076-1-mheyne@amazon.de/ > [2] https://lore.kernel.org/xen-devel/20220121102309.27802-1-sj@kernel.org/ > > drivers/block/xen-blkback/xenbus.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c > index 97de13b14175..16c6785d260c 100644 > --- a/drivers/block/xen-blkback/xenbus.c > +++ b/drivers/block/xen-blkback/xenbus.c > @@ -157,6 +157,11 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif) > 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"); > + > static struct xen_blkif *xen_blkif_alloc(domid_t domid) > { > struct xen_blkif *blkif; > @@ -181,6 +186,8 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid) > __module_get(THIS_MODULE); > INIT_WORK(&blkif->free_work, xen_blkif_deferred_free); > > + blkif->vbd.feature_gnt_persistent = feature_persistent; > + > return blkif; > } > > @@ -472,12 +479,6 @@ static void xen_vbd_free(struct xen_vbd *vbd) > vbd->bdev = NULL; > } > > -/* 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"); > - > static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle, > unsigned major, unsigned minor, int readonly, > int cdrom) > @@ -520,8 +521,6 @@ static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle, > if (bdev_max_secure_erase_sectors(bdev)) > vbd->discard_secure = true; > > - vbd->feature_gnt_persistent = feature_persistent; > - > pr_debug("Successful creation of handle=%04x (dom=%u)\n", > handle, blkif->domid); > return 0; -- Regards, Oleksandr Tyshchenko