From patchwork Mon Jan 30 11:30:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 50224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2133051wrn; Mon, 30 Jan 2023 03:47:19 -0800 (PST) X-Google-Smtp-Source: AK7set/pQbZNOG3u0qHqixD0RkmC7IIJF2zz+02yyEw+iByZB15ycRYBXs5uYxid3Zd7gzbbKqCg X-Received: by 2002:a17:906:e2d1:b0:878:702c:bd86 with SMTP id gr17-20020a170906e2d100b00878702cbd86mr14082877ejb.74.1675079239695; Mon, 30 Jan 2023 03:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675079239; cv=none; d=google.com; s=arc-20160816; b=XqkVF12psnsp9NM6hBU7X/9qFsuBTR4Q/kJPzDJJUUN7T/K8B/KQZ8JrBDTQjoORal y0JBUJIrrjIYTKnSSkaaem5SXTffnn7mDWBS6x+9OysMRIkensH/IhWe5UvQmjcamYJH ecg3wU4PO+IUWXZjP0O9d9sfHhakNC4n+5D0csSFGNVOVB4nNJ9f/BHDEMEMGUU4ObJy rWy1D+eG+Sy2QpoqSJEEWSIUyYVQ2PdgwTWUhQQu3MvEPI2O2f+bAFEMNNs7naCZv1ZF +Xy0DfKfo9jgW2jTF0aAx9NvuLtwM7H7nQOYew6wB1rjhn/PiAw5L8HTqlxpxW+28lfD nxFg== 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=qviUM8UM8K0sUVl1CBj5NTWfqEBaR5N6NdZBj3tn208=; b=vZoMqVK567TBXnhBVDmWrMlQfjq10os3OJBpziuR7Gr1Hu0E8LtvfUiFAj423DOGiv sprOv1DTljV7a0rszNVZ/0dl1gIDl0mzLKMUYx8+gV5DguclhO/EIyI6C23/HX5MCUTM ftfY2zgpDnsg22ue09WQR67x7FRYBJu9c0GgKe8z3xeyFgE/1Itv3qcv5MhLqm39O5C1 0y3dcjkT1mh/OH0Ae34gBafPkv3QR7jRNjo1tYH6D+qYPM2D/T2nPlzgmJUsXuZ6PBzr VNdo7NPl2xtA1+1ub+mJaJ23/aF95GGRsZKrx+MoOHmbxNnKoMqK8gXfy+Djo8DlZ/JF 7Y4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=UF2rIHgn; 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=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 12-20020a170906000c00b008786a9dcae3si15035883eja.296.2023.01.30.03.46.56; Mon, 30 Jan 2023 03:47:19 -0800 (PST) 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=@suse.com header.s=susede1 header.b=UF2rIHgn; 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=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236637AbjA3La6 (ORCPT + 99 others); Mon, 30 Jan 2023 06:30:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236630AbjA3Lav (ORCPT ); Mon, 30 Jan 2023 06:30:51 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0DCEB4D; Mon, 30 Jan 2023 03:30:47 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D2B541FDCD; Mon, 30 Jan 2023 11:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1675078245; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qviUM8UM8K0sUVl1CBj5NTWfqEBaR5N6NdZBj3tn208=; b=UF2rIHgnaUIktM11KSYG5U2h+oe0l5FVKifw+ts67xZlu7np7lB4W0YPS91C8aWC4rGXhT MQwbi7wGYlC7ZgR0TYC3rlYk4mj7RRCLc6xiH2GIZCR58u9Se2h3uxH5G0OFhVG8w8/y+4 uTXHK70Ch/j0XnnNNmv0prDLt+JrpdU= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 87DC813A06; Mon, 30 Jan 2023 11:30:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RkIKIGWq12PQJQAAMHmgww (envelope-from ); Mon, 30 Jan 2023 11:30:45 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: Juergen Gross , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH 1/2] 9p/xen: fix version parsing Date: Mon, 30 Jan 2023 12:30:35 +0100 Message-Id: <20230130113036.7087-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230130113036.7087-1-jgross@suse.com> References: <20230130113036.7087-1-jgross@suse.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756447888413085026?= X-GMAIL-MSGID: =?utf-8?q?1756447888413085026?= When connecting the Xen 9pfs frontend to the backend, the "versions" Xenstore entry written by the backend is parsed in a wrong way. The "versions" entry is defined to contain the versions supported by the backend separated by commas (e.g. "1,2"). Today only version "1" is defined. Unfortunately the frontend doesn't look for "1" being listed in the entry, but it is expecting the entry to have the value "1". This will result in failure as soon as the backend will support e.g. versions "1" and "2". Fix that by scanning the entry correctly. Fixes: 71ebd71921e4 ("xen/9pfs: connect to the backend") Signed-off-by: Juergen Gross Reviewed-by: Simon Horman --- net/9p/trans_xen.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index 82c7005ede65..ad2947a3b376 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -378,13 +378,19 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev, int ret, i; struct xenbus_transaction xbt; struct xen_9pfs_front_priv *priv = NULL; - char *versions; + char *versions, *v; unsigned int max_rings, max_ring_order, len = 0; versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len); if (IS_ERR(versions)) return PTR_ERR(versions); - if (strcmp(versions, "1")) { + for (v = versions; *v; v++) { + if (simple_strtoul(v, &v, 10) == 1) { + v = NULL; + break; + } + } + if (v) { kfree(versions); return -EINVAL; } From patchwork Mon Jan 30 11:30:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 50225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2133055wrn; Mon, 30 Jan 2023 03:47:20 -0800 (PST) X-Google-Smtp-Source: AK7set/llp8LEs1QgVnhZRfdRxx3l33oScmbAksisrTE1tgv6YgSK0IOTkybTdjzIZ+Dgz+ZLhRI X-Received: by 2002:a50:9559:0:b0:4a2:3d3d:a3d9 with SMTP id v25-20020a509559000000b004a23d3da3d9mr5732953eda.2.1675079240618; Mon, 30 Jan 2023 03:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675079240; cv=none; d=google.com; s=arc-20160816; b=jbvD+jZpTy+jEVZ88j3iNSQVvDsXPXiAICPdtJ2hiPzY1ppBjoRaaStB31bAfgM7zI DZPxLeFh1QKhzbjVjS/0+jl5FF6GdEl3D1u39LaVMdHQzhs8gbKo+5hGq3pK0KysFVSh FilbqTVdUc89nshSlFE5Ocki2DzQiyS8Tsx21B3wcZmw54q25s5Ks191GWWyjQJhhXUc Bc/1M62olYpkiqRPkOKNEQXZ92C45OrglcrIahdLKRGftrK8Ti3fUEi8psuckrr+dk/f 4I8iF/UAvidQea8gIX/06eZCOl2VjwjGmLqx1aDI+HdzdAFIuUhZlJaMDDThugKa10hR w9VQ== 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=7yVMurcsGHiv7+xYW4/H+27IaQd8JYSho/wI2BZnRUo=; b=dY8ZJK76O5WbmzOiJx1PfIu6VowJdCS4O/nc118bjZ8Nx5PftxaB6kQKnWO62fVee1 kZGzy/25SZ1I9vEOdkAaAMKyDhha6DHbG92iBYtSxmgJUwborO7VD3m09HS52y8C7FmS EeD/ZhHdmuONcdSjpYl8zA/ATBgNvA6rvNobGuADrPC5nG9ZLY7YMOolSGa1zyBOXIik 71JvGg3PjS+vC168lrwi4kue+dkgQjcTuHwoi5CMPam+AMWjkzxtbiAPfZGfdHc9K7aa MZEbywOJ2WTxb/7ktO5uW0IJnHSG+WVFrEkZbZ6/v250h96EO8If7Psx5pahtBJh/bxV rfpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=aijfbGWy; 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=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz14-20020a0564021d4e00b004a0e53007desi16129797edb.287.2023.01.30.03.46.57; Mon, 30 Jan 2023 03:47:20 -0800 (PST) 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=@suse.com header.s=susede1 header.b=aijfbGWy; 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=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236090AbjA3LbD (ORCPT + 99 others); Mon, 30 Jan 2023 06:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236287AbjA3Lax (ORCPT ); Mon, 30 Jan 2023 06:30:53 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4713A5F8; Mon, 30 Jan 2023 03:30:52 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 92B7C1FDCA; Mon, 30 Jan 2023 11:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1675078251; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7yVMurcsGHiv7+xYW4/H+27IaQd8JYSho/wI2BZnRUo=; b=aijfbGWyINlAMInGEsZDxevlTHYbORDnN3QQ1jpwwDmlpS36DxGTeiXH1lzJ9NItp7Pbv6 TPATiiNGtSYQgYhqv2TlPHK5iViEifKoKRva0J5rrzRmKoLmfEbjpc08KqSDnKvFUCzCTS GtVXKwps13Vht1WSzXCF3ILjfYWwvLA= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 41C6613A06; Mon, 30 Jan 2023 11:30:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XTO2Dmuq12PWJQAAMHmgww (envelope-from ); Mon, 30 Jan 2023 11:30:51 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: Juergen Gross , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH 2/2] 9p/xen: fix connection sequence Date: Mon, 30 Jan 2023 12:30:36 +0100 Message-Id: <20230130113036.7087-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230130113036.7087-1-jgross@suse.com> References: <20230130113036.7087-1-jgross@suse.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756447889484782377?= X-GMAIL-MSGID: =?utf-8?q?1756447889484782377?= Today the connection sequence of the Xen 9pfs frontend doesn't match the documented sequence. It can work reliably only for a PV 9pfs device having been added at boot time already, as the frontend is not waiting for the backend to have set its state to "XenbusStateInitWait" before reading the backend properties from Xenstore. Fix that by following the documented sequence [1] (the documentation has a bug, so the reference is for the patch fixing that). [1]: https://lore.kernel.org/xen-devel/20230130090937.31623-1-jgross@suse.com/T/#u Fixes: 868eb122739a ("xen/9pfs: introduce Xen 9pfs transport driver") Signed-off-by: Juergen Gross Reviewed-by: Simon Horman --- net/9p/trans_xen.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index ad2947a3b376..c64050e839ac 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -372,12 +372,11 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev, return ret; } -static int xen_9pfs_front_probe(struct xenbus_device *dev, - const struct xenbus_device_id *id) +static int xen_9pfs_front_init(struct xenbus_device *dev) { int ret, i; struct xenbus_transaction xbt; - struct xen_9pfs_front_priv *priv = NULL; + struct xen_9pfs_front_priv *priv = dev_get_drvdata(&dev->dev); char *versions, *v; unsigned int max_rings, max_ring_order, len = 0; @@ -405,11 +404,6 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev, if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order)) p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->dev = dev; priv->num_rings = XEN_9PFS_NUM_RINGS; priv->rings = kcalloc(priv->num_rings, sizeof(*priv->rings), GFP_KERNEL); @@ -468,23 +462,35 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev, goto error; } - write_lock(&xen_9pfs_lock); - list_add_tail(&priv->list, &xen_9pfs_devs); - write_unlock(&xen_9pfs_lock); - dev_set_drvdata(&dev->dev, priv); - xenbus_switch_state(dev, XenbusStateInitialised); - return 0; error_xenbus: xenbus_transaction_end(xbt, 1); xenbus_dev_fatal(dev, ret, "writing xenstore"); error: - dev_set_drvdata(&dev->dev, NULL); xen_9pfs_front_free(priv); return ret; } +static int xen_9pfs_front_probe(struct xenbus_device *dev, + const struct xenbus_device_id *id) +{ + struct xen_9pfs_front_priv *priv = NULL; + + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = dev; + dev_set_drvdata(&dev->dev, priv); + + write_lock(&xen_9pfs_lock); + list_add_tail(&priv->list, &xen_9pfs_devs); + write_unlock(&xen_9pfs_lock); + + return 0; +} + static int xen_9pfs_front_resume(struct xenbus_device *dev) { dev_warn(&dev->dev, "suspend/resume unsupported\n"); @@ -503,6 +509,8 @@ static void xen_9pfs_front_changed(struct xenbus_device *dev, break; case XenbusStateInitWait: + if (!xen_9pfs_front_init(dev)) + xenbus_switch_state(dev, XenbusStateInitialised); break; case XenbusStateConnected: