From patchwork Wed Nov 1 09:33:09 2023 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: 13442705 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 87CFFC4332F for ; Wed, 1 Nov 2023 09:54:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626349.976569 (Exim 4.92) (envelope-from ) id 1qy7vZ-0000SR-8L; Wed, 01 Nov 2023 09:54:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626349.976569; Wed, 01 Nov 2023 09:54:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qy7vZ-0000SK-5A; Wed, 01 Nov 2023 09:54:21 +0000 Received: by outflank-mailman (input) for mailman id 626349; Wed, 01 Nov 2023 09:54:19 +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 1qy7cX-0005E0-RO for xen-devel@lists.xenproject.org; Wed, 01 Nov 2023 09:34:41 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e20f467e-7899-11ee-98d6-6d05b1d4d9a1; Wed, 01 Nov 2023 10:34:41 +0100 (CET) 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 287401F74D; Wed, 1 Nov 2023 09:34:41 +0000 (UTC) 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 02A2913460; Wed, 1 Nov 2023 09:34:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id DAT3OrAbQmUZCQAAMHmgww (envelope-from ); Wed, 01 Nov 2023 09:34:40 +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: e20f467e-7899-11ee-98d6-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698831281; 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=3GExNKp/yhu+n6P2BIY5jfXZkhxU99CKU37BbtunsSk=; b=MppCvh+L8QO/WnZb70zdnCMROQq+m03SnlwSi2B8zsq7VvpsfxRwRzoa00hFBPd64pUJ6A FZGNhOZjZp9r9/AORC30jIYPaq+MBY4VA83H/ETdfTaIRn/ofphTyrrAi36CYy9/WMuu5m T3p1LWPe58VjNh+En1lplnIM7bpF/D8= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH 13/29] tools/xenlogd: add 9pfs write request support Date: Wed, 1 Nov 2023 10:33:09 +0100 Message-Id: <20231101093325.30302-14-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231101093325.30302-1-jgross@suse.com> References: <20231101093325.30302-1-jgross@suse.com> MIME-Version: 1.0 Add the write request of the 9pfs protocol. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- tools/xenlogd/io.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tools/xenlogd/io.c b/tools/xenlogd/io.c index 6e92667fab..6b4692ca67 100644 --- a/tools/xenlogd/io.c +++ b/tools/xenlogd/io.c @@ -32,6 +32,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 @@ -1010,6 +1011,51 @@ static void p9_create(device *device, struct p9_header *hdr) fill_buffer(device, hdr->cmd + 1, hdr->tag, "QU", &qid, &iounit); } +static void p9_write(device *device, struct p9_header *hdr) +{ + uint32_t fid; + uint64_t off; + unsigned int len; + uint32_t written; + void *buf; + struct p9_fid *fidp; + int ret; + + ret = fill_data(device, "ULD", &fid, &off, &len, device->buffer); + if ( ret != 3 ) + { + p9_error(device, hdr->tag, EINVAL); + return; + } + + fidp = find_fid(device, fid); + if ( !fidp || !fidp->opened || fidp->isdir ) + { + p9_error(device, hdr->tag, EBADF); + return; + } + + buf = device->buffer; + + while ( len != 0 ) + { + ret = pwrite(fidp->fd, buf, len, off); + if ( ret < 0 ) + break; + len -= ret; + buf += ret; + off += ret; + } + + written = buf - device->buffer; + if ( written == 0 ) + { + p9_error(device, hdr->tag, errno); + return; + } + fill_buffer(device, hdr->cmd + 1, hdr->tag, "U", &written); +} + static void p9_clunk(device *device, struct p9_header *hdr) { uint32_t fid; @@ -1182,6 +1228,10 @@ void *io_thread(void *arg) p9_create(device, &hdr); break; + case P9_CMD_WRITE: + p9_write(device, &hdr); + break; + case P9_CMD_CLUNK: p9_clunk(device, &hdr); break;