Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp656546ybh; Wed, 11 Mar 2020 08:15:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuNG30YZWJoSSq9K/dXWvecpW61cf2nlZafmYiPjB6XxNAKZv+Buyhim5JH2CtJKkBAKTsu X-Received: by 2002:aca:f086:: with SMTP id o128mr2241133oih.41.1583939732505; Wed, 11 Mar 2020 08:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583939732; cv=none; d=google.com; s=arc-20160816; b=yLN/UM3pnhv9mPdTO7FZ7smD8enroDA0y30OPBG+ZQRWwhiBznlY5lBbHDjszYQCw3 A34xEgyW6v6AKZxnTMISgDt/bDl9XZ/EnNl/xcx6WrV3sCsc3QNQOZa3olH6KM16VSQe 8R+wYKmVhKWJveBiPzvDZiJdsWZt15A6M/gMDsPlUl75CHcY6JmKiQgswp80/WrgFaMW Oc7kziilno4eEmkVTsM9lG5Y5V2ThdAKxIjyJ58utO36MxMSClGUKt9Rxmn9asZA6AqP Yv2MdDc/jdbg7kFj1ykTxaJS+HojQFlWDUNx4a+6xxBzl8A9OtspWrPmKLXNs3wkx7fP 7ZjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zDINA0vZuHEOMHgRG8O8q8Cv6r3DuQRO69eZhFF5eEI=; b=flZc+fdfh/bIrcGpDw3Uxzc/cXtP9C7rxtTs9TFyqg53bSi6g7QdYLHBZx24qEU/s7 nY2za5ji+pnU2Tw/HJcYtc4Aw7iuUQd3Keq8uU5PzM+U4M8ZFGtvP3kpz/nPS3sykQE2 c3qNDJ2+f+0VKMEknRRiGAaKMcqfaUnqpm4/0TKLrT0lCTMGR3lsqCguoiOwe7GcIjjQ yC4Im1NQ/uYepwtXHZPnnjIGiOWiSmy0dCIq17quT6BZO5hxt8NSuBOXVtVrF0R8biBC CFhmJDWhucg8jtZ3j/2M33i1N9Z3kXfwqG15XA5Lmo2BM9d8jupY5xoGThXicupfsVjR wJzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=LPUXGEF5; 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 l25si1203855otq.76.2020.03.11.08.15.18; Wed, 11 Mar 2020 08:15:32 -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; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=LPUXGEF5; 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 S1729931AbgCKPM3 (ORCPT + 99 others); Wed, 11 Mar 2020 11:12:29 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:38676 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729521AbgCKPM3 (ORCPT ); Wed, 11 Mar 2020 11:12:29 -0400 Received: by mail-io1-f68.google.com with SMTP id c25so1633347ioi.5 for ; Wed, 11 Mar 2020 08:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zDINA0vZuHEOMHgRG8O8q8Cv6r3DuQRO69eZhFF5eEI=; b=LPUXGEF5amYOBlrop1rcjSx8ZchMVTTL0Q8j/pP8BHayJceQuBOOq8WUjqMDAPx895 9IIyKqEalpT/MkO9z+NdQ49IQUNX1zj6RNQIdOLxH8Ewy+cMoKO32n73pUaLUprt9QaW PJp5aNh7zDbiZn+7g0tDB0pJIQuBIRNfXjjoA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zDINA0vZuHEOMHgRG8O8q8Cv6r3DuQRO69eZhFF5eEI=; b=Ao4asG1CPjOq7YUy2J/+8R/3TY1QgjQ+nOESJC4YMh0MHcdzFUlkVws/e5EL2MQjVz kAMAQONABvrbGTkMiXTMUp1qkZh8OUXJezkvge3vCWeQwe+eAUdOXsazxYQeuAcVE8sZ uSlru1NZTkbkhwfU8olyXK2p8x2cSz6LKDhRLcuvLtRyMWZZucw7I1lhRFmkdIvgtSWO KR1JxMm7UMxhh86mKx6YMZF4Mil34Yg+1XtItiYB9RkUSVJSBIJrWrzAYUYA9a0dIFaf NaU0I+7lXC15kjFtmTVDP3bWERBOVBrCSAB3gWnAdqHnZWTYFGIEg6LUdibK+vec82gn AHWA== X-Gm-Message-State: ANhLgQ0JSsE+U7LWUieCbTohba4pe7qnai06mKQ82nWUrU47Dz27I9zi e9wA9iZ1Bbb2r41njUxJEFuZ3S5DaRlCSJ+QjM+nfg== X-Received: by 2002:a6b:9386:: with SMTP id v128mr3374290iod.15.1583939546534; Wed, 11 Mar 2020 08:12:26 -0700 (PDT) MIME-Version: 1.0 References: <20200304165845.3081-1-vgoyal@redhat.com> <20200304165845.3081-13-vgoyal@redhat.com> <20200310203321.GF38440@redhat.com> <20200311144124.GB83257@redhat.com> In-Reply-To: <20200311144124.GB83257@redhat.com> From: Miklos Szeredi Date: Wed, 11 Mar 2020 16:12:15 +0100 Message-ID: Subject: Re: [PATCH 12/20] fuse: Introduce setupmapping/removemapping commands To: Vivek Goyal Cc: Amir Goldstein , linux-fsdevel , linux-kernel , linux-nvdimm , virtio-fs@redhat.com, Stefan Hajnoczi , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Peng Tao Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 3:41 PM Vivek Goyal wrote: > > On Wed, Mar 11, 2020 at 03:19:18PM +0100, Miklos Szeredi wrote: > > On Wed, Mar 11, 2020 at 8:03 AM Amir Goldstein wrote: > > > > > > On Tue, Mar 10, 2020 at 10:34 PM Vivek Goyal wrote: > > > > > > > > On Tue, Mar 10, 2020 at 08:49:49PM +0100, Miklos Szeredi wrote: > > > > > On Wed, Mar 4, 2020 at 5:59 PM Vivek Goyal wrote: > > > > > > > > > > > > Introduce two new fuse commands to setup/remove memory mappings. This > > > > > > will be used to setup/tear down file mapping in dax window. > > > > > > > > > > > > Signed-off-by: Vivek Goyal > > > > > > Signed-off-by: Peng Tao > > > > > > --- > > > > > > include/uapi/linux/fuse.h | 37 +++++++++++++++++++++++++++++++++++++ > > > > > > 1 file changed, 37 insertions(+) > > > > > > > > > > > > diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h > > > > > > index 5b85819e045f..62633555d547 100644 > > > > > > --- a/include/uapi/linux/fuse.h > > > > > > +++ b/include/uapi/linux/fuse.h > > > > > > @@ -894,4 +894,41 @@ struct fuse_copy_file_range_in { > > > > > > uint64_t flags; > > > > > > }; > > > > > > > > > > > > +#define FUSE_SETUPMAPPING_ENTRIES 8 > > > > > > +#define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) > > > > > > +struct fuse_setupmapping_in { > > > > > > + /* An already open handle */ > > > > > > + uint64_t fh; > > > > > > + /* Offset into the file to start the mapping */ > > > > > > + uint64_t foffset; > > > > > > + /* Length of mapping required */ > > > > > > + uint64_t len; > > > > > > + /* Flags, FUSE_SETUPMAPPING_FLAG_* */ > > > > > > + uint64_t flags; > > > > > > + /* Offset in Memory Window */ > > > > > > + uint64_t moffset; > > > > > > +}; > > > > > > + > > > > > > +struct fuse_setupmapping_out { > > > > > > + /* Offsets into the cache of mappings */ > > > > > > + uint64_t coffset[FUSE_SETUPMAPPING_ENTRIES]; > > > > > > + /* Lengths of each mapping */ > > > > > > + uint64_t len[FUSE_SETUPMAPPING_ENTRIES]; > > > > > > +}; > > > > > > > > > > fuse_setupmapping_out together with FUSE_SETUPMAPPING_ENTRIES seem to be unused. > > > > > > > > This looks like leftover from the old code. I will get rid of it. Thanks. > > > > > > > > > > Hmm. I wonder if we should keep some out args for future extensions. > > > Maybe return the mapped size even though it is all or nothing at this > > > point? > > > > > > I have interest in a similar FUSE mapping functionality that was prototyped > > > by Miklos and published here: > > > https://lore.kernel.org/linux-fsdevel/CAJfpegtjEoE7H8tayLaQHG9fRSBiVuaspnmPr2oQiOZXVB1+7g@mail.gmail.com/ > > > > > > In this prototype, a FUSE_MAP command is used by the server to map a > > > range of file to the kernel for io. The command in args are quite similar to > > > those in fuse_setupmapping_in, but since the server is on the same host, > > > the mapping response is {mapfd, offset, size}. > > > > Right. So the difference is in which entity allocates the mapping. > > IOW whether the {fd, offset, size} is input or output in the protocol. > > > > I don't remember the reasons for going with the mapping being > > allocated by the client, not the other way round. Vivek? > > I think one of the main reasons is memory reclaim. Once all ranges in > a cache range are allocated, we need to free a memory range which can be > reused. And client has all the logic to free up that range so that it can > be remapped and reused for a different file/offset. Server will not know > any of this. So I will think that for virtiofs, server might not be > able to decide where to map a section of file and it has to be told > explicitly by the client. Okay. > > > > If the allocation were to be by the server, we could share the request > > type and possibly some code between the two, although the I/O > > mechanism would still be different. > > > > So input parameters of both FUSE_SETUPMAPPING and FUSE_MAP seem > similar (except the moffset field). Given output of FUSE_MAP reqeust > is very different, I would think it will be easier to have it as a > separate command. > > Or can it be some sort of optional output args which can differentiate > between two types of requests. > > /me personally finds it simpler to have separate command instead of > overloading FUSE_SETUPMAPPING. But its your call. :-) I too prefer a separate request type. Thanks, Miklos