From patchwork Thu Feb 15 13:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 13558368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E482C48BC4 for ; Thu, 15 Feb 2024 13:10:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.681745.1060737 (Exim 4.92) (envelope-from ) id 1rabV4-000483-2K; Thu, 15 Feb 2024 13:10:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 681745.1060737; Thu, 15 Feb 2024 13:10:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rabV3-00047q-UP; Thu, 15 Feb 2024 13:10:01 +0000 Received: by outflank-mailman (input) for mailman id 681745; Thu, 15 Feb 2024 13:10:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rabRU-0002yD-2B for xen-devel@lists.xenproject.org; Thu, 15 Feb 2024 13:06:20 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0275e794-cc03-11ee-8a4d-1f161083a0e0; Thu, 15 Feb 2024 14:06:19 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 006A021FBC; Thu, 15 Feb 2024 13:06:19 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id B8FD1139D0; Thu, 15 Feb 2024 13:06:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id xeCvK0oMzmW0FQAAn2gu4w (envelope-from ); Thu, 15 Feb 2024 13:06:18 +0000 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: 0275e794-cc03-11ee-8a4d-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708002379; 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=X2VtlH36Dxgp8+Z8DrH/UT3snGVBYS8nN8oGoKs6b2w=; b=KDATXNSOJfA0nBe69MLrQTUtsFGMQkggIkAsB8pNY0Tadg16Z429hgUvGCZ6Po5dorEnWb FJqoyL6m5tWPE7k39wAAttK7P8l0eMTkB2ed208Avr7RVdxJGjBXYNqpBBBkjKgdcEGA5J a6PkCmn6zwGFdF3UrUmxK5wTuabOLqQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708002379; 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=X2VtlH36Dxgp8+Z8DrH/UT3snGVBYS8nN8oGoKs6b2w=; b=KDATXNSOJfA0nBe69MLrQTUtsFGMQkggIkAsB8pNY0Tadg16Z429hgUvGCZ6Po5dorEnWb FJqoyL6m5tWPE7k39wAAttK7P8l0eMTkB2ed208Avr7RVdxJGjBXYNqpBBBkjKgdcEGA5J a6PkCmn6zwGFdF3UrUmxK5wTuabOLqQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD , Jason Andryuk Subject: [PATCH v7 12/21] tools/xen-9pfsd: add 9pfs write request support Date: Thu, 15 Feb 2024 14:05:00 +0100 Message-Id: <20240215130509.24008-13-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240215130509.24008-1-jgross@suse.com> References: <20240215130509.24008-1-jgross@suse.com> MIME-Version: 1.0 X-Spamd-Bar: +++ Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=KDATXNSO X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [3.49 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.com:+]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[19.25%]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:email,citrix.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[suse.com,xen.org,citrix.com,gmail.com]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Queue-Id: 006A021FBC Add the write request of the 9pfs protocol. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Acked-by: Anthony PERARD --- tools/9pfsd/io.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c index 8c36106d90..1832c6b06e 100644 --- a/tools/9pfsd/io.c +++ b/tools/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 @@ -1244,6 +1245,55 @@ static void p9_stat(struct ring *ring, struct p9_header *hdr) free_fid(device, fidp); } +static void p9_write(struct ring *ring, struct p9_header *hdr) +{ + device *device = ring->device; + uint32_t fid; + uint64_t off; + unsigned int len; + uint32_t written; + void *buf; + struct p9_fid *fidp; + int ret; + + ret = fill_data(ring, "ULD", &fid, &off, &len, ring->buffer); + if ( ret != 3 ) + { + p9_error(ring, hdr->tag, EINVAL); + return; + } + + fidp = get_fid_ref(device, fid); + if ( !fidp || !fidp->opened || fidp->isdir ) + { + p9_error(ring, hdr->tag, EBADF); + goto out; + } + + buf = ring->buffer; + + while ( len != 0 ) + { + ret = pwrite(fidp->fd, buf, len, off); + if ( ret < 0 ) + break; + len -= ret; + buf += ret; + off += ret; + } + + written = buf - ring->buffer; + if ( written == 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 = arg; @@ -1319,6 +1369,10 @@ void *io_thread(void *arg) p9_create(ring, &hdr); break; + case P9_CMD_WRITE: + p9_write(ring, &hdr); + break; + case P9_CMD_CLUNK: p9_clunk(ring, &hdr); break;