From nobody Sat May 18 22:15:04 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=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1670755747; cv=none; d=zohomail.com; s=zohoarc; b=mX/XhXJv94tQBE2Bpv8cKChliAF2LOtqOBj1doPDZqC6JbztGUckUNM698B+JVmIhrJLqNS4tlhxyn8iXE0db0MW0OohjX9V5DKCerGsx79hWG3JVnuIQNmrXz8qC/o//ObdHCjyaGMUvTXx83fP0T8VobMLWTrW8+r6vag32GE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670755747; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=AiDm+83/VDbozzVf3AWSlrdlCGBECNCktU5HJHthiAs=; b=iw9UDY8dJHSEpKUy8EqUZ126f7BtKzmDzoBBGrC12lXVQcwdX7O0BcolQ1Ck0PMAA+VyhOjFXFmAgyghHQhe0nmaTFyf7+4BbTJ7I/TeT9uxB01eat0XpZiF7pmrsnKQmNNQDiE7EtXWUHe/xADFdLd6ZCa682cr/GSWxMpiOU8= 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=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670755747034905.3767615493067; Sun, 11 Dec 2022 02:49:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4JsY-0004Br-PP; Sun, 11 Dec 2022 05:48:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4JsU-0004Bf-Fi for qemu-devel@nongnu.org; Sun, 11 Dec 2022 05:48:14 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p4JsR-0007UY-9w for qemu-devel@nongnu.org; Sun, 11 Dec 2022 05:48:14 -0500 Received: by mail-pl1-x634.google.com with SMTP id t2so6261124ply.2 for ; Sun, 11 Dec 2022 02:48:09 -0800 (PST) Received: from localhost.localdomain ([139.177.225.230]) by smtp.gmail.com with ESMTPSA id b2-20020a1709027e0200b0018963b8e131sm4115118plm.290.2022.12.11.02.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Dec 2022 02:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AiDm+83/VDbozzVf3AWSlrdlCGBECNCktU5HJHthiAs=; b=VS6+ksV8eaaAXSlBA5ZSltuFWyms6zYCinT4+IDsZ/vZMCPFmSHFKvag971CGJ5O/l 0A4QNLMTwrEm4L2ow9KccAZJEqIAvLmI2q0805bosSmK94it4jcGFD5z2Vagb0F8Hu7H V/CeXGpDJVupb+lJ9Uwem17Ms9CIsUxTleeEwzHkIUaTIDSyxCZ/xo3dl2R7jM6TlPgf XK4AioBF0Avg/jRx8zt5xivG98lwuuYfKogCx3AtlAktQwRH4Z0EtLNneaZPALrshDbj oNzlEaoe9YgRDuSuzWh8nEs7vU3Lo44vSn2YzW7FQl+/BfWjoFEQrTtrC+r2pnPnvh9W G7bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AiDm+83/VDbozzVf3AWSlrdlCGBECNCktU5HJHthiAs=; b=qGvQxYV8jPJlI6vtEEzgs0jcTa1IZAOcEhahseFIDkIFL9O+5+aHL1AHfREoD8FnSc LXwOc/lJNYXlU87pRr4t7asZavmPEmhA2WL2tm0+E30tVZ3DO5pofj4Rmu/ZVoadxish zXMJKMUossaWFeR9/09LIAV49mBYBAx8pxmU78nf3UvnPf5fqP1+cwNotA8VN32JNv7B t2M/yS6ONQA59/+z3cLl4X67Mlkojv8KFvAOJ8g4HUvHKpG668Hw0+clXOc2jUnwsX5n Pa0pURm5xYhJuBvKfIP+xCG942ZucYFiwQNn6GOTNgxV8+PH8GjeC2BqFpSOI5a1z840 w02A== X-Gm-Message-State: ANoB5pnFgn4V1/d/g00ORG/wmD31a9tOYOIMfVdWtkfmvSpqTQTqFugz oD6MaY2aMLNlkXmR+6oGty9DLA== X-Google-Smtp-Source: AA0mqf4RgQmEqN5LawTq4ZemZtoCyxmFmF2Ij5zFlJElCdtjVDBVa77NhAfO+taoo3oYOedjtLrQlw== X-Received: by 2002:a17:902:6b08:b0:186:644f:bef1 with SMTP id o8-20020a1709026b0800b00186644fbef1mr13052972plk.6.1670755688566; Sun, 11 Dec 2022 02:48:08 -0800 (PST) From: Jiachen Zhang To: "Dr. David Alan Gilbert" , Stefan Hajnoczi Cc: virtio-fs@redhat.com, qemu-devel@nongnu.org, Jiachen Zhang , Connor Kuehl Subject: [PATCH] virtiofsd: support setting multiple request virtqueues Date: Sun, 11 Dec 2022 18:47:43 +0800 Message-Id: <20221211104743.27333-1-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2607:f8b0:4864:20::634; envelope-from=zhangjiachen.jaycee@bytedance.com; helo=mail-pl1-x634.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bytedance-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1670755747744100001 Content-Type: text/plain; charset="utf-8" Add an option '-o num_request_queues' to configure the queue number, currently the total number of vqs should be (1 hiprio queue + num_request_queues). The code is based on Connor's previous version in the virtio-fs mailing-list [1], but change the semantic of the new option from total queue number to request queue number. The corresponding virtio-fs kernel part modification can be found at the mail [2]. Link: [1] https://www.mail-archive.com/virtio-fs@redhat.com/msg03333.html [2] https://lore.kernel.org/linux-fsdevel/20221211103857.25805-1-zhangjiach= en.jaycee@bytedance.com/ Suggested-by: Stefan Hajnoczi Cc: Connor Kuehl Signed-off-by: Jiachen Zhang --- tools/virtiofsd/fuse_lowlevel.c | 4 ++-- tools/virtiofsd/fuse_lowlevel.h | 2 +- tools/virtiofsd/fuse_virtio.c | 20 +++----------------- tools/virtiofsd/fuse_virtio.h | 2 +- tools/virtiofsd/helper.c | 4 ++++ tools/virtiofsd/passthrough_ll.c | 12 +++++++++++- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowleve= l.c index 2f08471627..528492d2cf 100644 --- a/tools/virtiofsd/fuse_lowlevel.c +++ b/tools/virtiofsd/fuse_lowlevel.c @@ -2708,9 +2708,9 @@ out1: return NULL; } =20 -int fuse_session_mount(struct fuse_session *se) +int fuse_session_mount(struct fuse_session *se, unsigned int num_queues) { - return virtio_session_mount(se); + return virtio_session_mount(se, num_queues); } =20 int fuse_session_fd(struct fuse_session *se) diff --git a/tools/virtiofsd/fuse_lowlevel.h b/tools/virtiofsd/fuse_lowleve= l.h index b889dae4de..aee02d3e91 100644 --- a/tools/virtiofsd/fuse_lowlevel.h +++ b/tools/virtiofsd/fuse_lowlevel.h @@ -1856,7 +1856,7 @@ struct fuse_session *fuse_session_new(struct fuse_arg= s *args, * * @return 0 on success, -1 on failure. **/ -int fuse_session_mount(struct fuse_session *se); +int fuse_session_mount(struct fuse_session *se, unsigned int num_queues); =20 /** * Enter a single threaded, blocking event loop. diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 9368e292e4..a3ebcbea8e 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -762,20 +762,6 @@ static void fv_queue_set_started(VuDev *dev, int qidx,= bool started) started); assert(qidx >=3D 0); =20 - /* - * Ignore additional request queues for now. passthrough_ll.c must be - * audited for thread-safety issues first. It was written with a - * well-behaved client in mind and may not protect against all types of - * races yet. - */ - if (qidx > 1) { - fuse_log(FUSE_LOG_ERR, - "%s: multiple request queues not yet implemented, please = only " - "configure 1 request queue\n", - __func__); - exit(EXIT_FAILURE); - } - if (started) { /* Fire up a thread to watch this queue */ if (qidx >=3D vud->nqueues) { @@ -1011,7 +997,7 @@ static int fv_create_listen_socket(struct fuse_session= *se) return 0; } =20 -int virtio_session_mount(struct fuse_session *se) +int virtio_session_mount(struct fuse_session *se, unsigned int num_queues) { int ret; =20 @@ -1057,8 +1043,8 @@ int virtio_session_mount(struct fuse_session *se) se->vu_socketfd =3D data_sock; se->virtio_dev->se =3D se; pthread_rwlock_init(&se->virtio_dev->vu_dispatch_rwlock, NULL); - if (!vu_init(&se->virtio_dev->dev, 2, se->vu_socketfd, fv_panic, NULL, - fv_set_watch, fv_remove_watch, &fv_iface)) { + if (!vu_init(&se->virtio_dev->dev, num_queues, se->vu_socketfd, + fv_panic, NULL, fv_set_watch, fv_remove_watch, &fv_iface))= { fuse_log(FUSE_LOG_ERR, "%s: vu_init failed\n", __func__); return -1; } diff --git a/tools/virtiofsd/fuse_virtio.h b/tools/virtiofsd/fuse_virtio.h index 111684032c..a0e78b9b84 100644 --- a/tools/virtiofsd/fuse_virtio.h +++ b/tools/virtiofsd/fuse_virtio.h @@ -18,7 +18,7 @@ =20 struct fuse_session; =20 -int virtio_session_mount(struct fuse_session *se); +int virtio_session_mount(struct fuse_session *se, unsigned int num_queues); void virtio_session_close(struct fuse_session *se); int virtio_loop(struct fuse_session *se); =20 diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c index f5f66f292c..b5138ce17d 100644 --- a/tools/virtiofsd/helper.c +++ b/tools/virtiofsd/helper.c @@ -191,6 +191,10 @@ void fuse_cmdline_help(void) " -o killpriv_v2/no_killpriv_v2\n" " Enable/Disable FUSE_HANDLE_KILL= PRIV_V2.\n" " (default: enabled as long as cl= ient supports it)\n" + " -o num_request_queues=3D\n" + " set maximum number of request v= irtqueues\n" + " supported by virtiofsd" + " default: 1\n" ); } =20 diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 20f0f41f99..f9d8075835 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -182,6 +182,7 @@ struct lo_data { /* Keeps track if /proc//attr/fscreate should be used or not */ bool use_fscreate; int user_security_label; + int num_request_queues; }; =20 static const struct fuse_opt lo_opts[] =3D { @@ -218,6 +219,8 @@ static const struct fuse_opt lo_opts[] =3D { { "no_posix_acl", offsetof(struct lo_data, user_posix_acl), 0 }, { "security_label", offsetof(struct lo_data, user_security_label), 1 }, { "no_security_label", offsetof(struct lo_data, user_security_label), = 0 }, + { "num_request_queues=3D%d", + offsetof(struct lo_data, num_request_queues), 1 }, FUSE_OPT_END }; static bool use_syslog =3D false; @@ -4479,6 +4482,12 @@ int main(int argc, char *argv[]) =20 lo.use_statx =3D true; =20 + if (lo.num_request_queues < 1) { + fuse_log(FUSE_LOG_ERR, "num_request_queues must be at least 1 (got= %d)" + "\n", lo.num_request_queues); + exit(1); + } + se =3D fuse_session_new(&args, &lo_oper, sizeof(lo_oper), &lo); if (se =3D=3D NULL) { goto err_out1; @@ -4488,7 +4497,8 @@ int main(int argc, char *argv[]) goto err_out2; } =20 - if (fuse_session_mount(se) !=3D 0) { + /* There will be 1 hirpio queue plus lo.num_request_queues request que= ues */ + if (fuse_session_mount(se, lo.num_request_queues + 1) !=3D 0) { goto err_out3; } =20 --=20 2.20.1