From patchwork Fri Aug 2 17:15:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 11073975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E348A13B1 for ; Fri, 2 Aug 2019 17:15:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6AAE2866D for ; Fri, 2 Aug 2019 17:15:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA8222870D; Fri, 2 Aug 2019 17:15:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B3252866D for ; Fri, 2 Aug 2019 17:15:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391609AbfHBRPa (ORCPT ); Fri, 2 Aug 2019 13:15:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54592 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391600AbfHBRPa (ORCPT ); Fri, 2 Aug 2019 13:15:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A289F30EA18A; Fri, 2 Aug 2019 17:15:29 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-230.ams2.redhat.com [10.36.117.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E91E60605; Fri, 2 Aug 2019 17:15:28 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: linux-fsdevel@vger.kernel.org, miklos@szeredi.hu, Nikolaus@rath.org Cc: stefanha@redhat.com, vgoyal@redhat.com, tao.peng@linux.alibaba.com Subject: [PATCH 1/3] fuse: Add 'setupmapping' Date: Fri, 2 Aug 2019 18:15:19 +0100 Message-Id: <20190802171521.21807-2-dgilbert@redhat.com> In-Reply-To: <20190802171521.21807-1-dgilbert@redhat.com> References: <20190802171521.21807-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 02 Aug 2019 17:15:29 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Dr. David Alan Gilbert" 'setupmapping' is a command for use with 'virtiofsd', a fuse-over-virtio implementation; it may find use in other fuse impelementations as well in which the kernel does not have access to the address space of the daemon directly. A 'setupmapping' operation causes a section of a file to be mapped into a memory window visible to the kernel. The offsets in the file and the window are defined by the kernel performing the operation. The daemon may reject the request, for reasons including permissions and limited resources. When a request perfectly overlaps a previous mapping, the previous mapping is replaced. When a mapping partially overlaps a previous mapping, the previous mapping is split into one or two smaller mappings. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Vivek Goyal Signed-off-by: Stefan Hajnoczi --- include/uapi/linux/fuse.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 2971d29a42e4..fb79d4d0b3a7 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -133,6 +133,7 @@ * * 7.31 * - add FUSE_WRITE_KILL_PRIV flag + * - add FUSE_SETUPMAPPING */ #ifndef _LINUX_FUSE_H @@ -422,6 +423,7 @@ enum fuse_opcode { FUSE_RENAME2 = 45, FUSE_LSEEK = 46, FUSE_COPY_FILE_RANGE = 47, + FUSE_SETUPMAPPING = 48, /* CUSE specific operations */ CUSE_INIT = 4096, @@ -845,4 +847,19 @@ struct fuse_copy_file_range_in { uint64_t flags; }; +#define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) +#define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1) +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; +}; + #endif /* _LINUX_FUSE_H */ From patchwork Fri Aug 2 17:15:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 11073977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C139013B1 for ; Fri, 2 Aug 2019 17:15:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B22A42866D for ; Fri, 2 Aug 2019 17:15:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A41FE2870D; Fri, 2 Aug 2019 17:15:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C5702866D for ; Fri, 2 Aug 2019 17:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391613AbfHBRPc (ORCPT ); Fri, 2 Aug 2019 13:15:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53282 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391600AbfHBRPb (ORCPT ); Fri, 2 Aug 2019 13:15:31 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 550AF307D848; Fri, 2 Aug 2019 17:15:31 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-230.ams2.redhat.com [10.36.117.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECF0860623; Fri, 2 Aug 2019 17:15:29 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: linux-fsdevel@vger.kernel.org, miklos@szeredi.hu, Nikolaus@rath.org Cc: stefanha@redhat.com, vgoyal@redhat.com, tao.peng@linux.alibaba.com Subject: [PATCH 2/3] fuse: add 'removemapping' Date: Fri, 2 Aug 2019 18:15:20 +0100 Message-Id: <20190802171521.21807-3-dgilbert@redhat.com> In-Reply-To: <20190802171521.21807-1-dgilbert@redhat.com> References: <20190802171521.21807-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 02 Aug 2019 17:15:31 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Dr. David Alan Gilbert" 'removemapping' is the complement to 'setupmapping', it unmaps a range of mapped files from the window visible to the kernel. A 'removemapping' call consists of 'count' regions to unmap, each consisting of an offset and length. Signed-off-by: Vivek Goyal Signed-off-by: Peng Tao Signed-off-by: Dr. David Alan Gilbert --- include/uapi/linux/fuse.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index fb79d4d0b3a7..f14eeb5cfc14 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -133,7 +133,7 @@ * * 7.31 * - add FUSE_WRITE_KILL_PRIV flag - * - add FUSE_SETUPMAPPING + * - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING */ #ifndef _LINUX_FUSE_H @@ -424,6 +424,7 @@ enum fuse_opcode { FUSE_LSEEK = 46, FUSE_COPY_FILE_RANGE = 47, FUSE_SETUPMAPPING = 48, + FUSE_REMOVEMAPPING = 49, /* CUSE specific operations */ CUSE_INIT = 4096, @@ -862,4 +863,16 @@ struct fuse_setupmapping_in { uint64_t moffset; }; +struct fuse_removemapping_in { + /* number of fuse_removemapping_one following */ + uint32_t count; +}; + +struct fuse_removemapping_one { + /* Offset into the dax window at start of unmapping */ + uint64_t moffset; + /* Length of unmapping required */ + uint64_t len; +}; + #endif /* _LINUX_FUSE_H */ From patchwork Fri Aug 2 17:15:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 11073979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E366913AC for ; Fri, 2 Aug 2019 17:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D41EF2866D for ; Fri, 2 Aug 2019 17:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C71772870D; Fri, 2 Aug 2019 17:15:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6559E2866D for ; Fri, 2 Aug 2019 17:15:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391628AbfHBRPf (ORCPT ); Fri, 2 Aug 2019 13:15:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22292 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391600AbfHBRPd (ORCPT ); Fri, 2 Aug 2019 13:15:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 016BB307D851; Fri, 2 Aug 2019 17:15:33 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-230.ams2.redhat.com [10.36.117.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C67760623; Fri, 2 Aug 2019 17:15:31 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: linux-fsdevel@vger.kernel.org, miklos@szeredi.hu, Nikolaus@rath.org Cc: stefanha@redhat.com, vgoyal@redhat.com, tao.peng@linux.alibaba.com Subject: [PATCH 3/3] fuse: Add map_alignment for setup/remove mapping Date: Fri, 2 Aug 2019 18:15:21 +0100 Message-Id: <20190802171521.21807-4-dgilbert@redhat.com> In-Reply-To: <20190802171521.21807-1-dgilbert@redhat.com> References: <20190802171521.21807-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 02 Aug 2019 17:15:33 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Dr. David Alan Gilbert" This new FUSE_INIT field communicates the alignment constraint for FUSE_SETUPMAPPING/FUSE_REMOVEMAPPING and allows the daemon to constrain the addresses and file offsets chosen by the kernel. Signed-off-by: Stefan Hajnoczi Signed-off-by: Dr. David Alan Gilbert --- include/uapi/linux/fuse.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index f14eeb5cfc14..65c2136d112e 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -134,6 +134,7 @@ * 7.31 * - add FUSE_WRITE_KILL_PRIV flag * - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING + * - add map_alignment to fuse_init_out */ #ifndef _LINUX_FUSE_H @@ -275,6 +276,9 @@ struct fuse_file_lock { * FUSE_CACHE_SYMLINKS: cache READLINK responses * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request + * FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for + * foffset and moffset fields in struct + * fuse_setupmapping_in and fuse_removemapping_one. */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -302,6 +306,8 @@ struct fuse_file_lock { #define FUSE_CACHE_SYMLINKS (1 << 23) #define FUSE_NO_OPENDIR_SUPPORT (1 << 24) #define FUSE_EXPLICIT_INVAL_DATA (1 << 25) +#define FUSE_MAP_ALIGNMENT (1 << 26) + /** * CUSE INIT request/reply flags @@ -655,7 +661,7 @@ struct fuse_init_out { uint32_t max_write; uint32_t time_gran; uint16_t max_pages; - uint16_t padding; + uint16_t map_alignment; uint32_t unused[8]; };