From nobody Fri Oct 18 08:36:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1707130657187893.8670720537522; Mon, 5 Feb 2024 02:57:37 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.675831.1051412 (Exim 4.92) (envelope-from ) id 1rWwfE-0001Vv-Ec; Mon, 05 Feb 2024 10:57:24 +0000 Received: by outflank-mailman (output) from mailman id 675831.1051412; Mon, 05 Feb 2024 10:57:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rWwfE-0001Vo-Bg; Mon, 05 Feb 2024 10:57:24 +0000 Received: by outflank-mailman (input) for mailman id 675831; Mon, 05 Feb 2024 10:57:22 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rWwZL-0000qL-2S for xen-devel@lists.xenproject.org; Mon, 05 Feb 2024 10:51:19 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7d259515-c414-11ee-98f5-efadbce2ee36; Mon, 05 Feb 2024 11:51:17 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3AB8D2228A; Mon, 5 Feb 2024 10:51:17 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0AF08132DD; Mon, 5 Feb 2024 10:51:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id x5wxAaW9wGVeNgAAD6G6ig (envelope-from ); Mon, 05 Feb 2024 10:51:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7d259515-c414-11ee-98f5-efadbce2ee36 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD , Jason Andryuk Subject: [PATCH v4 13/32] tools/xen-9pfsd: add 9pfs write request support Date: Mon, 5 Feb 2024 11:49:42 +0100 Message-Id: <20240205105001.24171-14-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240205105001.24171-1-jgross@suse.com> References: <20240205105001.24171-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 3AB8D2228A X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Flag: NO X-ZM-MESSAGEID: 1707130659232100001 Content-Type: text/plain; charset="utf-8" Add the write request of the 9pfs protocol. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Acked-by: Anthony PERARD --- tools/xen-9pfsd/io.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tools/xen-9pfsd/io.c b/tools/xen-9pfsd/io.c index 031cff9f0e..b763e3d8d9 100644 --- a/tools/xen-9pfsd/io.c +++ b/tools/xen-9pfsd/io.c @@ -33,6 +33,7 @@ #define P9_CMD_WALK 110 #define P9_CMD_OPEN 112 #define P9_CMD_CREATE 114 +#define P9_CMD_WRITE 118 #define P9_CMD_CLUNK 120 #define P9_CMD_STAT 124 =20 @@ -1246,6 +1247,55 @@ static void p9_stat(struct ring *ring, struct p9_hea= der *hdr) free_fid(device, fidp); } =20 +static void p9_write(struct ring *ring, struct p9_header *hdr) +{ + device *device =3D ring->device; + uint32_t fid; + uint64_t off; + unsigned int len; + uint32_t written; + void *buf; + struct p9_fid *fidp; + int ret; + + ret =3D fill_data(ring, "ULD", &fid, &off, &len, ring->buffer); + if ( ret !=3D 3 ) + { + p9_error(ring, hdr->tag, EINVAL); + return; + } + + fidp =3D get_fid_ref(device, fid); + if ( !fidp || !fidp->opened || fidp->isdir ) + { + p9_error(ring, hdr->tag, EBADF); + goto out; + } + + buf =3D ring->buffer; + + while ( len !=3D 0 ) + { + ret =3D pwrite(fidp->fd, buf, len, off); + if ( ret < 0 ) + break; + len -=3D ret; + buf +=3D ret; + off +=3D ret; + } + + written =3D buf - ring->buffer; + if ( written =3D=3D 0 ) + { + p9_error(ring, hdr->tag, errno); + goto out; + } + fill_buffer(ring, hdr->cmd + 1, hdr->tag, "U", &written); + + out: + free_fid(device, fidp); +} + void *io_thread(void *arg) { struct ring *ring =3D arg; @@ -1321,6 +1371,10 @@ void *io_thread(void *arg) p9_create(ring, &hdr); break; =20 + case P9_CMD_WRITE: + p9_write(ring, &hdr); + break; + case P9_CMD_CLUNK: p9_clunk(ring, &hdr); break; --=20 2.35.3