From nobody Sat May 18 10:07:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1622828145; cv=none; d=zohomail.com; s=zohoarc; b=XCjSy8q+mXr5UzWgt77VRZ5MBeg/+fc8i0dsOThMMCa9gVxuGJJ/X8rzCRy3BYc1s6tFo19+gk7DissxyXqxfTMN+Va3bIr334y56cg6Vcz9NqS7y8kMlCfnSVUEM+QF2kKlwsTYaEJGhqzqREg3PkOWtcpkITfw0uyoMnidTrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622828145; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=T+lQuspu33wgxRAA04EmrtYl0EHAhUewwRdhgr8o94A=; b=dZh8Yg/zvymwekUoiw8BBLpwXWYQz/3EjfMzusraTeLTGCJyNuXksHeaCPHHksYlTLOx1lxwdDFJURoNiQedvECCHEGzWSs1WE2QTRyi0XyfnBB0Mfur6QEyS5Db2sO8WrjO33A3Xgp85/YIZz7mTJCXYd9vtsPQq38D89Npuww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622828145239957.3984590369029; Fri, 4 Jun 2021 10:35:45 -0700 (PDT) Received: from localhost ([::1]:43826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpDjU-0001mH-3s for importer@patchew.org; Fri, 04 Jun 2021 13:35:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCsy-0000yN-3K for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:41:28 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:49103) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCsu-0005Wc-RH for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:41:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=T+lQuspu33wgxRAA04EmrtYl0EHAhUewwRdhgr8o94A=; b=TiEyo ldI+cASiF21aApsCo0AFQCrJZhq6+U/Q9KUPwtX/bpRcUi4/KGy3iSQ/Go4Ks+EgMjTIOXwtekuVW i2E+7c5xDCFWRx830SVCfqufKgGSApkYcKuBksW3e6cl4kXdpOGoxwyug9Z0kDsrdYeMPOcqSdyJ4 95k1KLsi5fd6Ln4H2QsIqm1EN+Gl14RbEniElmIEV5aEilzYWwRTcE7LdO346mm89XyQNU55y/fpF +EwwnbTymSszQD4WNeuGeTXKvA2vdYC6ZkMY7QGgE7Bm5HUEk6EHa51cQxeLK/ssl+0bW8GqR+nsz ixOLEuji0NrmEdubtGHr5YxwXxNVw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 4 Jun 2021 16:46:45 +0200 Subject: [PATCH v2 1/7] 9pfs: fix not_same_qid() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=ca0abae4a899d81c6e87f683732d6c1f56915232@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is only one user of not_same_qid() which is v9fs_walk() and the latter is using it for comparing a client supplied path with the 9p export root path, for the sole purpose to prevent a Twalk request from escaping from the exported 9p tree via "..". However for that specific purpose the implementation of not_same_qid() is wrong; if mtime of the 9p export root path changed between Tattach and Twalk then not_same_qid() returns true when actually comparing against the export root path. To fix for the actual semantic being used, only compare QID path members, but do not compare version or type members. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 89aa07db78..e10a02f71d 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1707,10 +1707,7 @@ static bool name_is_illegal(const char *name) =20 static bool not_same_qid(const V9fsQID *qid1, const V9fsQID *qid2) { - return - qid1->type !=3D qid2->type || - qid1->version !=3D qid2->version || - qid1->path !=3D qid2->path; + return qid1->path !=3D qid2->path; } =20 static void coroutine_fn v9fs_walk(void *opaque) --=20 2.20.1 From nobody Sat May 18 10:07:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1622825802; cv=none; d=zohomail.com; s=zohoarc; b=GIquNOBs8YQy8RccmuAq6geKaspc8TeNxCJ60/VIKG5AP3ut20w8HdlxevDpLFGioYk57cr/zUP7voJS0RxKn3Gk77MR5gfRUMzUrk+1yI2syLoHgJRQgwpO0fOHSFW4rPJIUCx7F3RjMZ2GEoviO6lleIabEMliQPIwA59Hmy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622825802; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=F+zcqFLh8DFiVXFYYi8rgDfObpfpt7catkfkcaYSDRA=; b=KDFp3sIxBWEoDABIRvPNWVeyh8dhmCXz2Tsmu1r8LoN6BPzLMVky7P7oL6COqXjiAYZe1h1soEXdLXpmYeabCNRPEolyc++tUG2bLJwe3bJOmkYitJFAqEwrSRh0mScbDd8qRilYXoKszUJQxjtoUISdwF+AttMQFFDRSJGsrGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162282580223963.91991529601853; Fri, 4 Jun 2021 09:56:42 -0700 (PDT) Received: from localhost ([::1]:52864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpD7h-0002rd-8T for importer@patchew.org; Fri, 04 Jun 2021 12:56:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCmc-0004Ru-Hw for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:34:54 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:35679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCma-0002cX-Nu for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:34:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=F+zcqFLh8DFiVXFYYi8rgDfObpfpt7catkfkcaYSDRA=; b=W+75G OC319uyuv8AerJXS7QzQUL6L73KXaCCEyXVyDNlrBiERM7B93/audOz6hXziJB+7AY5ZdMjEQWfqP bJkh6gTnF/NyafOrbc75nt6kauOYOX2upt/DUMNh2UjiRi6k9sXlvx6r+sptq8Q/X9yVPdGBcf+mG Le3B/Fo7qZabl4WBt9dxcBODf4CICu36Sk1SswBtxNQ4nh6SdmufLyJw1+aOKu6zRShxPIh4JS7Jy BNj6+d+65QdsTCu9+WyGrg4dsTLzKzMh5lToS1/oKyoTigRO3ow3K2vee0r5zUWK9KnDN6BVEY1Ie mmgcBAnvr5jfFTlI42B75dQlMKMaA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 27 May 2021 19:03:17 +0200 Subject: [PATCH v2 2/7] 9pfs: Twalk benchmark To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=e43c658ec76b394005d514034c2defd0eacb7ea0@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is not intentended to be merged, it just acts as performance A/B comparison benchmark for the subsequent patches. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 41fed41de1..2cd9e427b4 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -20,6 +20,18 @@ #include "libqos/virtio-9p.h" #include "libqos/qgraph.h" =20 +/* + * to benchmark the real time (not CPU time) that elapsed between start of + * a request and arrival of its response + */ +static double wall_time(void) +{ + struct timeval t; + struct timezone tz; + gettimeofday(&t, &tz); + return t.tv_sec + t.tv_usec * 0.000001; +} + #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000) static QGuestAllocator *alloc; =20 @@ -646,12 +658,30 @@ static void fs_walk(void *obj, void *data, QGuestAllo= cator *t_alloc) } =20 do_attach(v9p); + const double start =3D wall_time(); req =3D v9fs_twalk(v9p, 0, 1, P9_MAXWELEM, wnames, 0); + const double twalk =3D wall_time(); v9fs_req_wait_for_reply(req, NULL); + const double waitforreply =3D wall_time(); v9fs_rwalk(req, &nwqid, &wqid); + const double end =3D wall_time(); =20 g_assert_cmpint(nwqid, =3D=3D, P9_MAXWELEM); =20 + printf("\nTime client spent on sending Twalk: %fs\n\n", + twalk - start); + + printf("Time client spent for waiting for reply from server: %fs " + "[MOST IMPORTANT]\n", waitforreply - start); + printf("(This is the most important value, because it reflects the tim= e\n" + "the 9p server required to process and return the result of the= \n" + "Twalk request.)\n\n"); + + printf("Total client time: %fs\n", end - start); + + //printf("Details of response message data: R_readddir nentries=3D%d " + // "rbytes=3D%d\n", nentries, count); + for (i =3D 0; i < P9_MAXWELEM; i++) { g_free(wnames[i]); } --=20 2.20.1 From nobody Sat May 18 10:07:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1622825917; cv=none; d=zohomail.com; s=zohoarc; b=JpUynzYVypkLdEw5X0v0XQpbKoKYPDHyRRCkwL8gdGnVAjX+JScQXdYe/SNzJ1sVuD0boU5hyTLtHprP/VDF92KFlheVa1sWvUw0urjypJgHLe9ojRvTsLukGD30iaoaqRq+vUoVxmktTGQsHE0Upi2ce5EWOKQ1YC0WS6djDLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622825917; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=l47oMoSMNbrULRusWIR736AGGv4CeFqHaRee2bj/oNI=; b=XZCtHdHFXZfw+C55GmHbMHYFLCUhRI+mbUZkou1VHFgImfRrv5+V4o3daf5k6sMGbqiVekuunWQdltHfJf8psMofu4EvYeBV8dOIePCF5JqxdMOoGFdCx4okNVvfnLkBEyCHzh8AFlryyxWGp9MDA384bp3VRyg4AsCeij5PHs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622825917569692.2750885676497; Fri, 4 Jun 2021 09:58:37 -0700 (PDT) Received: from localhost ([::1]:33136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpD9Y-00006c-B2 for importer@patchew.org; Fri, 04 Jun 2021 12:58:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCpo-0002sg-7N for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:38:12 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:39435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCpj-00045R-Js for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:38:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=l47oMoSMNbrULRusWIR736AGGv4CeFqHaRee2bj/oNI=; b=aCuly BL5O0hfnOCaPo/wkqW90xYEGwSzDRqPmRD4UbcMEjgi++NWjuPb7OLzcP3clJMqS0ySvBhhVhKdQR nX2TZR/n/lLRhq3adBOxy27y5Z9fQM8aJdox/lX/EyuCUynQ6CuT2xUo1geqi31QBItlI0bKZNVCC JWD3OeAGEnwRNCCIaVXHoWl93BUhjZQqsvWJ6H2NX6XrbMBGxXEJ/lvivtBRitkL+5p0xnRrIfIPa 1i2K578jc0sph06RUX8W6GDWDi65hGZUsZ53g9kH/FO6xgCcNBdZlkP7KYu7sYWNmbZ11REmOA9az 82W0rZXn5a86cIkMa9aOkrrM1v2eQ==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 27 May 2021 19:04:11 +0200 Subject: [PATCH v2 3/7] 9pfs: capture root stat To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=eb07d6c2e9925788454cfe33d3802e4ffb23ea9a@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We already capture the QID of the exported 9p root path, i.e. to prevent client access outside the defined, exported filesystem's tree. This is currently checked by comparing the root QID with another FID's QID. The problem with the latter is that resolving a QID of any given 9p path can only be done on 9p server's main thread, that's because it might mutate the server's state if inode remapping is enabled. For that reason also capture the POSIX stat info of the root path for being able to identify on any (e.g. worker) thread whether an arbitrary given path is identical to the export root. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 10 +++++++++- hw/9pfs/9p.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index e10a02f71d..eb15ec2082 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1400,6 +1400,7 @@ static void coroutine_fn v9fs_attach(void *opaque) size_t offset =3D 7; V9fsQID qid; ssize_t err; + struct stat stbuf; =20 v9fs_string_init(&uname); v9fs_string_init(&aname); @@ -1422,7 +1423,13 @@ static void coroutine_fn v9fs_attach(void *opaque) clunk_fid(s, fid); goto out; } - err =3D fid_to_qid(pdu, fidp, &qid); + err =3D v9fs_co_lstat(pdu, &fidp->path, &stbuf); + if (err < 0) { + err =3D -EINVAL; + clunk_fid(s, fid); + goto out; + } + err =3D stat_to_qid(pdu, &stbuf, &qid); if (err < 0) { err =3D -EINVAL; clunk_fid(s, fid); @@ -1455,6 +1462,7 @@ static void coroutine_fn v9fs_attach(void *opaque) err +=3D offset; =20 memcpy(&s->root_qid, &qid, sizeof(qid)); + memcpy(&s->root_st, &stbuf, sizeof(stbuf)); trace_v9fs_attach_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path); out: diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 00381591ff..6f0b4c78c0 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -356,6 +356,7 @@ struct V9fsState { Error *migration_blocker; V9fsConf fsconf; V9fsQID root_qid; + struct stat root_st; dev_t dev_id; struct qht qpd_table; struct qht qpp_table; --=20 2.20.1 From nobody Sat May 18 10:07:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1622827511; cv=none; d=zohomail.com; s=zohoarc; b=P0ZNxBU6/DnPVdg6feXama8OEcEHEsalshfMB6AqjmMP2Aj/gUXx/TUCvmgcWVXKB7Kt5QVNpN9FuTTxGn4DAfF7P8yW4i1VaDJh/4SfjDmGK1M2Tdeo1VgMPD2JVpwKPT+wvzNKtEEB1yCTTTnvPtyGRo4wHHu+mKOLfSgyNUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622827511; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=PazLJKZiQEVaGIIPZt1TFDxdCexiLb9bZg3fN3Mxfng=; b=AXJpQowtZ+LGAl/S9uVjcyOVMh4fJCfk642PgB3GgFcYRYhGV1sCpgsG2+7Z25QcFA5odDQ+nzbVfvZr6ppdQOCF/XKQnmLxTbDcQPPR1uWeKmlrejYVEQKcX4UdjYGBrutzMd6TIr9HsVpIQcCYZdq36WfzbCInMLtj029kaIU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162282751140747.70617138053933; Fri, 4 Jun 2021 10:25:11 -0700 (PDT) Received: from localhost ([::1]:38386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpDZG-00045z-1V for importer@patchew.org; Fri, 04 Jun 2021 13:25:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCoj-0001Pv-0B for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:37:06 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:46441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCoc-0003ci-Sj for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:37:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=PazLJKZiQEVaGIIPZt1TFDxdCexiLb9bZg3fN3Mxfng=; b=Qhg0c 9kvDbb+PQ7ANf42FN1CNIFpriwXxqrd55k5OvF5I9BCyQRbdt5o72zxY5cBCY5FoPTjr0KNBvph5s GR2GCNcCyby4uRvwqlkLzK+pV4Gp1/erXuKuJdX0RnMzCs4v086nrSMtyXQoSZScUX9jqucZCBtqd R85a0L0Udj6Guh+7d9oJ0n0eBf4dsQ9I63/CWc639AK3uXpb4NmnI267R6qfGWM9NKG4qINes5GiQ jz+kfwVydeRlUe79wp52mWAmsfMTl+V3T1+xUUjO/Qcxv7agZfctyUQAsHIBGfXRjad3UeFkD+8bc 0pIRrRB1f8qpPHrBFP+aH0QpaJ/dg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 4 Jun 2021 17:13:17 +0200 Subject: [PATCH v2 4/7] 9pfs: drop fid_to_qid() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=e9a4c9c7a0792ed4db6578d105a0823ea05bc324@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is only one user of fid_to_qid() which is v9fs_walk(). Let's open-code fid_to_qid() directly within v9fs_walk(), because fid_to_qid() hides the POSIX stat buffer which we are going to need in the subsequent patch. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index eb15ec2082..0e3857798d 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -971,23 +971,6 @@ static int stat_to_qid(V9fsPDU *pdu, const struct stat= *stbuf, V9fsQID *qidp) return 0; } =20 -static int coroutine_fn fid_to_qid(V9fsPDU *pdu, V9fsFidState *fidp, - V9fsQID *qidp) -{ - struct stat stbuf; - int err; - - err =3D v9fs_co_lstat(pdu, &fidp->path, &stbuf); - if (err < 0) { - return err; - } - err =3D stat_to_qid(pdu, &stbuf, qidp); - if (err < 0) { - return err; - } - return 0; -} - V9fsPDU *pdu_alloc(V9fsState *s) { V9fsPDU *pdu =3D NULL; @@ -1772,7 +1755,11 @@ static void coroutine_fn v9fs_walk(void *opaque) v9fs_path_init(&dpath); v9fs_path_init(&path); =20 - err =3D fid_to_qid(pdu, fidp, &qid); + err =3D v9fs_co_lstat(pdu, &fidp->path, &stbuf); + if (err < 0) { + goto out; + } + err =3D stat_to_qid(pdu, &stbuf, &qid); if (err < 0) { goto out; } --=20 2.20.1 From nobody Sat May 18 10:07:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1622828024; cv=none; d=zohomail.com; s=zohoarc; b=gdY5+g75aPFE8Pz8n2TVt8XeTIc16/RjpnJgzR87A93yeR6TJQAVcWD6sDNS8T8pvMYw9N7toCMVr5RCdL1QHH0AIEj6o0ihk5kz4M9ou5HP2LWB3lPLLvPFNpc7jPyzJ4gAVwbr5ey68h99PkVv8+7xqj8gIfYGnDY3q+OVHFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622828024; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=buL4vtQqomvNC9pu6gOlE7wmMrN3KK9Mem6DNoh4RjU=; b=eMHzXTPrm6PZfcRc+tkhhq5Lked5vStIT9amuyII9i0OMdh8DarAaNiLxQs0zGFWjDi+crraZjV3Bddv1DQywC5QxUwd2IDSWp4GHj5fEObJ6ZRAXE6YQbZEIG2TrLZy/77aCFtKv17JfAyksbGsbZCW/Yy262uOFKV6ah/9QaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622828024896252.93026957804602; Fri, 4 Jun 2021 10:33:44 -0700 (PDT) Received: from localhost ([::1]:35810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpDhX-0004oU-QX for importer@patchew.org; Fri, 04 Jun 2021 13:33:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <26aa465ff9cc9c07e053331554a02fdae3994417@lizzy.crudebyte.com>) id 1lpCty-0002qi-V9 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:42:30 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:58385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <26aa465ff9cc9c07e053331554a02fdae3994417@lizzy.crudebyte.com>) id 1lpCtx-00060r-CA for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:42:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=buL4vtQqomvNC9pu6gOlE7wmMrN3KK9Mem6DNoh4RjU=; b=SGl4W mdotLcbMvM8MdU5j6N5bxNrXd1KY8oU/hzrkgs9yInOmlGiZrWoz1/5LPIajjdROmEERF0o+80mqB XoQnnZu2JipYgUDbuskMSPKnvLOFaEwRLmw6mrkuMm3EjuluymoGwvpxphEDxf4KQLWFZxxd90GKJ U2s/mcjCvYdox9narDIAqAzIePNJUnxiU0XwI6/HdjSyYzXN4XT5Ku/sZCyc9/I0PIh9WkENjo/cb QIYqFVoE02MH+g9r1i7pZZQnGju1XclERZvEfJG1cmz2gol4w/KcAOxa1PnrRtgEVr0SR2MVcbASG 00xOgyR8946pbissMl/+LgclSI7DA==; Message-Id: <26aa465ff9cc9c07e053331554a02fdae3994417.1622821729.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 4 Jun 2021 17:21:43 +0200 Subject: [PATCH v2 5/7] 9pfs: replace not_same_qid() by same_stat_id() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=26aa465ff9cc9c07e053331554a02fdae3994417@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As we are actually only comparing the filesystem ID (i.e. device number and inode number pair) let's use the POSIX stat buffer instead of QIDs, because resolving QIDs requires to be done on 9p server's main thread only as it might mutate the server state if inode remapping is enabled. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 0e3857798d..47b000d3a9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1696,9 +1696,9 @@ static bool name_is_illegal(const char *name) return !*name || strchr(name, '/') !=3D NULL; } =20 -static bool not_same_qid(const V9fsQID *qid1, const V9fsQID *qid2) +static bool same_stat_id(const struct stat *a, const struct stat *b) { - return qid1->path !=3D qid2->path; + return a->st_dev =3D=3D b->st_dev && a->st_ino =3D=3D b->st_ino; } =20 static void coroutine_fn v9fs_walk(void *opaque) @@ -1771,7 +1771,7 @@ static void coroutine_fn v9fs_walk(void *opaque) v9fs_path_copy(&dpath, &fidp->path); v9fs_path_copy(&path, &fidp->path); for (name_idx =3D 0; name_idx < nwnames; name_idx++) { - if (not_same_qid(&pdu->s->root_qid, &qid) || + if (!same_stat_id(&pdu->s->root_st, &stbuf) || strcmp("..", wnames[name_idx].data)) { err =3D v9fs_co_name_to_path(pdu, &dpath, wnames[name_idx].dat= a, &path); --=20 2.20.1 From nobody Sat May 18 10:07:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1622827358; cv=none; d=zohomail.com; s=zohoarc; b=OUclDxEnPVuEYBm76YK6PUm0Kj4pqQhl4hi2oDyuWR9cYh46IqYEJW2Euawxh9lNAXoY4t5yHSICnvSHPh1KbMyRqi7Ox4WEniPTUXQkGC0m4qnPe5HsWmi0p2DbAOMu6UOfb/e+6ayALCjcdoUgvuTUWWXQbSz2AJnM5eGI1bA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622827358; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=AvlYVgDbCFL+PEEhnM2x/fDjDGnHpevXDoiTtJfZ0OY=; b=n9//qJPMKhlpZSt2uksZBFyk1I1NvnIpCZiQCzkAwPaHkuu8pT0ozZr5sjqHZeqwjadhyc3dHNK4K0WYTbmxQ9f0eqKacqfCG4buLsByVUt2x0FGU1hNLPnTxqLgRw6EFiXXMgt9m4am+i6PlWC4ZSn9b04LWG2Z1A+tFe1lRrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622827358740607.2888098859976; Fri, 4 Jun 2021 10:22:38 -0700 (PDT) Received: from localhost ([::1]:57986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpDWn-0006gA-N6 for importer@patchew.org; Fri, 04 Jun 2021 13:22:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6896dd161d3257db6b0513842a14f87ca191fdf6@lizzy.crudebyte.com>) id 1lpCnc-0007El-UK for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:35:57 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:59311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6896dd161d3257db6b0513842a14f87ca191fdf6@lizzy.crudebyte.com>) id 1lpCnb-00037N-FV for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:35:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=AvlYVgDbCFL+PEEhnM2x/fDjDGnHpevXDoiTtJfZ0OY=; b=AVrYa CYrpDbt+Rv0lwGY5xyQ3zwWGF3KyL0hbSUb/UygKDpX643e5dPZGTUv0yLjXtUJhYOmI+L2ycYZDP Q03X/ic+LEiyubsecABdcWW1tEeAiS7VCxUuWwec96XFxXhF3p5l30lhxASUT/o0forWRiAeHaAr8 aiiiqGkJEccIRP18gLUA14fAsrSUOlyrv5wYuKgV6HCxAG6Jv4Z6s623M4zDvS7KGJEj68Swi83z7 Rdc88v6Q7ftvzUbCrO8V1Ug98rho/WU6Zumf1G8JK92p+nAgK52rKV6JLI34P0v2OLEwamJUb1rwX UHha8q/ZvnTcw7t+E0YEEDgQkFx9w==; Message-Id: <6896dd161d3257db6b0513842a14f87ca191fdf6.1622821729.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 4 Jun 2021 17:32:48 +0200 Subject: [PATCH v2 6/7] 9pfs: drop root_qid To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=6896dd161d3257db6b0513842a14f87ca191fdf6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is no longer a user of root_qid, so drop it. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 1 - hw/9pfs/9p.h | 1 - 2 files changed, 2 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 47b000d3a9..7be07f2d68 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1444,7 +1444,6 @@ static void coroutine_fn v9fs_attach(void *opaque) } err +=3D offset; =20 - memcpy(&s->root_qid, &qid, sizeof(qid)); memcpy(&s->root_st, &stbuf, sizeof(stbuf)); trace_v9fs_attach_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path); diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 6f0b4c78c0..1567b67841 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -355,7 +355,6 @@ struct V9fsState { int32_t root_fid; Error *migration_blocker; V9fsConf fsconf; - V9fsQID root_qid; struct stat root_st; dev_t dev_id; struct qht qpd_table; --=20 2.20.1 From nobody Sat May 18 10:07:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1622827884; cv=none; d=zohomail.com; s=zohoarc; b=Xc+s5mE1hNBULG15l+Oi+sV/W9u+tdRfyIjCtZEi0S5Gd18/7GyRVtEj5h+pfAK+KWS9iHWQKtb0w2lgCKEallwvHhGqFqQjuKDJTBkJkdKUPx4ZkC6cBpOb8cIa/G5dqoYbbxQoKKb38qLgQq2b5D6eruyqWrdNr+ICOlRr/hc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622827884; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=3mSMktzPM7x/Zr9u1yWyuv2LYWx7aj6+VgFdfRJb+Ls=; b=njtD6TRUBm79GQP7EbQ30GZefI6eVJ3y6ZSDHK9n/1EMBrjN5frCSSW3V5mSvZUnTwYknedFHEE5dGM/g5pOdVB8F6H5D22jMAv7Mu+95agdmAVt+CbQrZh4Y5awEiPP0YI2LqmTty1k06LswM3f37WTwCL4UH2w55SCLkrPjZo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622827884895800.5726406793879; Fri, 4 Jun 2021 10:31:24 -0700 (PDT) Received: from localhost ([::1]:55690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpDfH-0007RL-LN for importer@patchew.org; Fri, 04 Jun 2021 13:31:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1a6701674afc4f08d40396e3aa2631e18a4dbb33@lizzy.crudebyte.com>) id 1lpCqp-00052u-MH for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:39:15 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:47509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1a6701674afc4f08d40396e3aa2631e18a4dbb33@lizzy.crudebyte.com>) id 1lpCqn-0004hW-Ga for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:39:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=3mSMktzPM7x/Zr9u1yWyuv2LYWx7aj6+VgFdfRJb+Ls=; b=LPUuY 5FWXAIoaJ/1aULloq4L26pFU6rDXh0Xg2WzsKo8KFPpuGXDJ5LDUqCnbG9SpKFwF3MDftp6M4S+To elxq5WD4aplVVlyVGVN8ShgDVIwIi191z4u5uv1nAXWLjOpDm/7Yl/xtnZWH2B1QaIWol+GgyDiy1 MDAC6a0ZOMUYQDxGw5sHNq5VqumJcLzMvVW7vu04ZRHSp5HTBh5BJF4fFnLgnzDN64Qq39Asb+sUu cUiRETk2XPhhKbWFVd4SNydW7+Fgtr/axcO3pmPz/rOAONbJwipzHwAwV2R8PQne9hrzfK9o6FV9+ KS/NaSFRvWFqWwwTUEPoG0zxDJQEg==; Message-Id: <1a6701674afc4f08d40396e3aa2631e18a4dbb33.1622821729.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 4 Jun 2021 17:38:31 +0200 Subject: [PATCH v2 7/7] 9pfs: reduce latency of Twalk To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=1a6701674afc4f08d40396e3aa2631e18a4dbb33@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As with previous performance optimization on Treaddir handling; reduce the overall latency, i.e. overall time spent on processing a Twalk request by reducing the amount of thread hops between the 9p server's main thread and fs worker thread(s). In fact this patch even reduces the thread hops for Twalk handling to its theoritical minimum of exactly 2 thread hops: main thread -> fs worker thread -> main thread This is achieved by doing all the required fs driver tasks altogether in a single v9fs_co_run_in_worker({ ... }); code block. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 89 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 19 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 7be07f2d68..2815257f42 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1705,9 +1705,9 @@ static void coroutine_fn v9fs_walk(void *opaque) int name_idx; V9fsQID *qids =3D NULL; int i, err =3D 0; - V9fsPath dpath, path; + V9fsPath dpath, path, *pathes =3D NULL; uint16_t nwnames; - struct stat stbuf; + struct stat stbuf, fidst, *stbufs =3D NULL; size_t offset =3D 7; int32_t fid, newfid; V9fsString *wnames =3D NULL; @@ -1733,6 +1733,8 @@ static void coroutine_fn v9fs_walk(void *opaque) if (nwnames) { wnames =3D g_new0(V9fsString, nwnames); qids =3D g_new0(V9fsQID, nwnames); + stbufs =3D g_new0(struct stat, nwnames); + pathes =3D g_new0(V9fsPath, nwnames); for (i =3D 0; i < nwnames; i++) { err =3D pdu_unmarshal(pdu, offset, "s", &wnames[i]); if (err < 0) { @@ -1753,39 +1755,85 @@ static void coroutine_fn v9fs_walk(void *opaque) =20 v9fs_path_init(&dpath); v9fs_path_init(&path); + /* + * Both dpath and path initially point to fidp. + * Needed to handle request with nwnames =3D=3D 0 + */ + v9fs_path_copy(&dpath, &fidp->path); + v9fs_path_copy(&path, &fidp->path); =20 - err =3D v9fs_co_lstat(pdu, &fidp->path, &stbuf); + /* + * To keep latency (i.e. overall execution time for processing this + * Twalk client request) as small as possible, run all the required fs + * driver code altogether inside the following block. + */ + v9fs_co_run_in_worker({ + if (v9fs_request_cancelled(pdu)) { + err =3D -EINTR; + break; + } + err =3D s->ops->lstat(&s->ctx, &dpath, &fidst); + if (err < 0) { + err =3D -errno; + break; + } + stbuf =3D fidst; + for (name_idx =3D 0; name_idx < nwnames; name_idx++) { + if (v9fs_request_cancelled(pdu)) { + err =3D -EINTR; + break; + } + if (!same_stat_id(&pdu->s->root_st, &stbuf) || + strcmp("..", wnames[name_idx].data)) + { + err =3D s->ops->name_to_path(&s->ctx, &dpath, + wnames[name_idx].data, &path); + if (err < 0) { + err =3D -errno; + break; + } + if (v9fs_request_cancelled(pdu)) { + err =3D -EINTR; + break; + } + err =3D s->ops->lstat(&s->ctx, &path, &stbuf); + if (err < 0) { + err =3D -errno; + break; + } + stbufs[name_idx] =3D stbuf; + v9fs_path_copy(&dpath, &path); + v9fs_path_copy(&pathes[name_idx], &path); + } + } + }); + /* + * Handle all the rest of this Twalk request on main thread ... + */ if (err < 0) { goto out; } - err =3D stat_to_qid(pdu, &stbuf, &qid); + + err =3D stat_to_qid(pdu, &fidst, &qid); if (err < 0) { goto out; } + stbuf =3D fidst; =20 - /* - * Both dpath and path initially poin to fidp. - * Needed to handle request with nwnames =3D=3D 0 - */ + /* reset dpath and path */ v9fs_path_copy(&dpath, &fidp->path); v9fs_path_copy(&path, &fidp->path); + for (name_idx =3D 0; name_idx < nwnames; name_idx++) { if (!same_stat_id(&pdu->s->root_st, &stbuf) || - strcmp("..", wnames[name_idx].data)) { - err =3D v9fs_co_name_to_path(pdu, &dpath, wnames[name_idx].dat= a, - &path); - if (err < 0) { - goto out; - } - - err =3D v9fs_co_lstat(pdu, &path, &stbuf); - if (err < 0) { - goto out; - } + strcmp("..", wnames[name_idx].data)) + { + stbuf =3D stbufs[name_idx]; err =3D stat_to_qid(pdu, &stbuf, &qid); if (err < 0) { goto out; } + v9fs_path_copy(&path, &pathes[name_idx]); v9fs_path_copy(&dpath, &path); } memcpy(&qids[name_idx], &qid, sizeof(qid)); @@ -1821,9 +1869,12 @@ out_nofid: if (nwnames && nwnames <=3D P9_MAXWELEM) { for (name_idx =3D 0; name_idx < nwnames; name_idx++) { v9fs_string_free(&wnames[name_idx]); + v9fs_path_free(&pathes[name_idx]); } g_free(wnames); g_free(qids); + g_free(stbufs); + g_free(pathes); } } =20 --=20 2.20.1