Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2940732imm; Mon, 16 Jul 2018 17:48:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcFMfAYOg07KNY8vslbMXJrbASZpuzr610GDlQ7rrUuCrSUIiDOR02lyImXSWVDyiHJLAd+ X-Received: by 2002:a62:c60e:: with SMTP id m14-v6mr20241498pfg.40.1531788499770; Mon, 16 Jul 2018 17:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531788499; cv=none; d=google.com; s=arc-20160816; b=vGjVdjWb9KnXKnEcu6CYQONa8jVOAvxrYeYfqTbZg5aS5JaujOVgDOAtD4GfJiqeyr VVGVIFWAiX7b7DsN3kyJKdM3bIW2C5+Y4xjy0GR7ZUVfVhtBRMNGaWOo55C5hffu1Dp2 zfqw4pki4/TALO6ZifSQ4PhJL+ZScfCuO4kBBnG9pmFcbIz1tbdqc3SpMvAS9/Yallbi lbiU0RQUR0A4gdUn2Cr8PM35aA8FdqKM8ScNiWxU+bTvbscg9Ncjt3fLm8Iy4tyww8Im 0ZEaR+npUdf7f6L8CCveTxmLPfow1enRBfJ6bzyz/4XGKgAxAVmIdREpTAhbrMREVD4P xz+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ZTvb8XI/PfUPo4leDMPY3+zMpJX5ksOJ6GNcT9Ku6l0=; b=AHPjgn/BDnRhxEOyPUzcDAs/gt9kKU3TDy8pgMGWwree863/sBOaB+q4XTaWH/Q9AV 839yprR5KeUXU1nar8HVeFS9sYEWLDdN/LEU0B+dFXSPUT5p/b+7JbLJ5XSkC48rgmUD q1EffnG8y6sobnkxHd8mqr88g93mTY32+F4kl669B/p9yV1uYn9XXtQcNn3nAdTv2r/T M8bRbMHD+MGih694xuzY2cb7Nztrr5Bgu4FbmvWgGQu0TgSZvysuLpiyujBuNIibyQ8u Tnb2Dcjc9tdm0yRzBTBBSQtvKLBacMKFj2FnsdYqt3t1vaFo2GWRfa39q0Ug9kqnPWDD Mlcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4-v6si10392738plr.405.2018.07.16.17.48.04; Mon, 16 Jul 2018 17:48:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730840AbeGQBPw (ORCPT + 99 others); Mon, 16 Jul 2018 21:15:52 -0400 Received: from nautica.notk.org ([91.121.71.147]:55050 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729827AbeGQBPw (ORCPT ); Mon, 16 Jul 2018 21:15:52 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 9261BC009; Tue, 17 Jul 2018 02:45:57 +0200 (CEST) Date: Tue, 17 Jul 2018 02:45:42 +0200 From: Dominique Martinet To: Chirantan Ekbote Cc: groug@kaod.org, linux-kernel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, dgreid@chromium.org, groeck@chromium.org Subject: Re: [PATCH v2] Fix zero-copy path in the 9p virtio transport Message-ID: <20180717004542.GA8102@nautica> References: <20180717003529.114368-1-chirantan@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180717003529.114368-1-chirantan@chromium.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Chirantan Ekbote wrote on Mon, Jul 16, 2018: > The zero-copy optimization when reading or writing large chunks of data > is quite useful. However, the 9p messages created through the zero-copy > write path have an incorrect message size: it should be the size of the > header + size of the data being written but instead it's just the size > of the header. > > This only works if the server ignores the size field of the message and > otherwise breaks the framing of the protocol. Fix this by re-writing the > message size field with the correct value. > > Tested by running `dd if=/dev/zero of=out bs=4k count=1` inside a > virtio-9p mount. > > Signed-off-by: Chirantan Ekbote > Reviewed-by: Greg Kurz > Tested-by: Greg Kurz Ack, I've added this to my queue for 4.19 Thanks for moving the memcpy and the updated comment, it makes it more clear that these are different fields of the message. > --- > net/9p/trans_virtio.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c > index 05006cbb3361..65761381c58f 100644 > --- a/net/9p/trans_virtio.c > +++ b/net/9p/trans_virtio.c > @@ -406,6 +406,7 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req, > p9_debug(P9_DEBUG_TRANS, "virtio request\n"); > > if (uodata) { > + __le32 sz; > int n = p9_get_mapped_pages(chan, &out_pages, uodata, > outlen, &offs, &need_drop); > if (n < 0) > @@ -416,6 +417,12 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req, > memcpy(&req->tc->sdata[req->tc->size - 4], &v, 4); > outlen = n; > } > + /* The size field of the message must include the length of the > + * header and the length of the data. We didn't actually know > + * the length of the data until this point so add it in now. > + */ > + sz = cpu_to_le32(req->tc->size + outlen); > + memcpy(&req->tc->sdata[0], &sz, sizeof(sz)); > } else if (uidata) { > int n = p9_get_mapped_pages(chan, &in_pages, uidata, > inlen, &offs, &need_drop); -- Dominique Martinet