Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3436831pxu; Mon, 30 Nov 2020 03:12:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyn9kVuo6W0WXf/yS8hJKqtVydkQuReRER/jgFwvIe6eo/xAMuZ192KvEMldjwZWnu/0EAX X-Received: by 2002:a17:906:7d98:: with SMTP id v24mr17801788ejo.129.1606734751594; Mon, 30 Nov 2020 03:12:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606734751; cv=none; d=google.com; s=arc-20160816; b=wDt0swtwQBLXNN4H3OzSRAtNZda6oS7Fb98QvNemGcMUrL5kTD3Q8KRqycY2rs+5XA wekVuRTwriaQL8NPB4fjECdMxa9PlS754rKsZZmQ4H/LgUkaSrcR3WFhZWhm88Gclu6P GeDuJ9hlRdjDC2uFSbdIOozmn6FbAyqCR9lqScW0+aCbZUX3ZQK1UXHSau3sQKH1j9VV c5VW1sqBj5AxfQ6rQ648ZlNKc93JxiAPMj+2o9hHcv/G/NCCH3f4jrk/9aCJrdcuIFPc ttWsbVUyw+wKRVXergETnYwCatpApdmq6T+ltJAdho2XM4srRa/USuaAqw+aFUoZEVvd tv8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=g+4njBXcirHJCL3DQ1RFf48zRCHizeggk1XBMK3pkS8=; b=hjnlVEjt0U9ShYPVH/dZSCyrIBxbkZqI7MphmHFipvDU0mK4CbqM/VZlK739DL7lJW HR9Y7xOjMHZFw2SX0N5mHaLwzcSGhYh0O2F8MYBV1NnNMEksZTFtEpG17SRaEemoiLRg 3Be4/NPPdiY1eg8LqfSAT677N8aq/Es5Fy8AvGvDGuffzSHGWhCRLkmKO/PzSj/tOnWg dTyWiZ0MC4ZaQYU4pDKRwIM30OSxD3M9el7eYhLjc5WeRNTwlA2XzWw4CqoqbG9Ggn1o 7KnnmKSZX8LwxCf0UhiYWLJZF68Q/bXfmVftcrf5uYSrvJex/+PTMqaioJxI0KeR8iwi 78cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=TyPUISpI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l25si7988876edf.392.2020.11.30.03.12.08; Mon, 30 Nov 2020 03:12:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=TyPUISpI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727785AbgK3LJX (ORCPT + 99 others); Mon, 30 Nov 2020 06:09:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727571AbgK3LJX (ORCPT ); Mon, 30 Nov 2020 06:09:23 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A83C0613D2 for ; Mon, 30 Nov 2020 03:08:42 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id 64so15589176wra.11 for ; Mon, 30 Nov 2020 03:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g+4njBXcirHJCL3DQ1RFf48zRCHizeggk1XBMK3pkS8=; b=TyPUISpItLAjJvF4hDb3xsrJ8mSrb+Sj3mga2hq5CcAUvvLxir1/oOAy6C8BGWqvM5 gxUcNtLaZjKyBeAwJ5nCj3ESdfdcw9ZDHeT0ZTl9a1xp4adLRDinGVAQqcS12nmJ6eLL y0HOFmO9bd2GopLWU+BihcpjTiJznXAIBYKbe09Wbx9ua7WKLRIOxyJ5fht2DC3YhZFH oXbRH5KHclfGczRK7ir+nw23Aa+3gnFeJ8Gh8S2p+aZnosEew6N2g3ubYZ6Jiqa1qQvc RhXPXrmpQzvhLQ6Wh+2fAzGOt16H9Ti7yFc//MMm1Kg5Vq8R0bM4fqWB/aHE9PyEBHya k8hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g+4njBXcirHJCL3DQ1RFf48zRCHizeggk1XBMK3pkS8=; b=LIiL2Z0iT7tC5Ntqmuy2CO8qci1qdRvbiZzQEoJKfDeHE0TipPzo+bx0QQVUxtIaAi EPf6g2nWRNTzJ/IltNkOf7Ar3wFpSocBczt6bcFiETcOv6Lg/3EI4pmteavlPeRDvP3e QyCsdQccPyE3e5KCbS/oZnS+tHopqo8cKf+8mrlA002FQ9FHUOQJQnCI+zh4RI/qG8i7 xFdXSuCW8X8Mw4MRPOW5GnC6qsNI9UJ6S6W9Drwvi/88IhAmsnuSIazSkn5ABIV9CxPt L47UBC7IMtnnCpPeX9DzY0OiMhIMIYQm5/YhyvACXFYYKEd93HKrMSGH+7+OrRdHpLXA S0ww== X-Gm-Message-State: AOAM530TNSAqAN4BT1M8PWeDBiUicIsBkJ4/T8VXbI0N4KL/HOiFTT06 v3nTYZ6kc5OGcbDD+fgY8lpgEg== X-Received: by 2002:a5d:49ce:: with SMTP id t14mr27651862wrs.75.1606734521373; Mon, 30 Nov 2020 03:08:41 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:7220:84ff:fe09:7d5c]) by smtp.gmail.com with ESMTPSA id s4sm6270738wra.91.2020.11.30.03.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 03:08:40 -0800 (PST) Date: Mon, 30 Nov 2020 11:08:39 +0000 From: Alessio Balsini To: Peng Tao Cc: Alessio Balsini , Miklos Szeredi , Akilesh Kailash , Amir Goldstein , Antonio SJ Musumeci , David Anderson , Giuseppe Scrivano , Jann Horn , Jens Axboe , Martijn Coenen , Palmer Dabbelt , Paul Lawrence , Stefano Duo , Zimuzo Ezeozue , fuse-devel@lists.sourceforge.net, kernel-team@android.com, "linux-fsdevel@vger.kernel.org" , Linux Kernel Mailing List Subject: Re: [PATCH V10 0/5] fuse: Add support for passthrough read/write Message-ID: <20201130110839.GA1980518@google.com> References: <20201026125016.1905945-1-balsini@android.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 28, 2020 at 10:10:37AM +0800, Peng Tao wrote: > On Tue, Oct 27, 2020 at 1:00 AM Alessio Balsini wrote: > > > > This is the 10th version of the series. Please find the changelog at the > > bottom of this cover letter. > > > > Add support for file system passthrough read/write of files when enabled in > > userspace through the option FUSE_PASSTHROUGH. > > > > There are file systems based on FUSE that are intended to enforce special > > policies or trigger complicated decision makings at the file operations > > level. Android, for example, uses FUSE to enforce fine-grained access > > policies that also depend on the file contents. > > Sometimes it happens that at open or create time a file is identified as > > not requiring additional checks for consequent reads/writes, thus FUSE > > would simply act as a passive bridge between the process accessing the FUSE > > file system and the lower file system. Splicing and caching help reduce the > > FUSE overhead, but there are still read/write operations forwarded to the > > userspace FUSE daemon that could be avoided. > > > > This series has been inspired by the original patches from Nikhilesh Reddy, > > the idea and code of which has been elaborated and improved thanks to the > > community support. > > > > When the FUSE_PASSTHROUGH capability is enabled, the FUSE daemon may decide > > while handling the open/create operations, if the given file can be > > accessed in passthrough mode. This means that all the further read and > > write operations would be forwarded by the kernel directly to the lower > > file system using the VFS layer rather than to the FUSE daemon. > > All the requests other than reads or writes are still handled by the > > userspace FUSE daemon. > > This allows for improved performance on reads and writes, especially in the > > case of reads at random offsets, for which no (readahead) caching mechanism > > would help. > > Benchmarks show improved performance that is close to native file system > > access when doing massive manipulations on a single opened file, especially > > in the case of random reads, for which the bandwidth increased by almost 2X > > or sequential writes for which the improvement is close to 3X. > > > > The creation of this direct connection (passthrough) between FUSE file > > objects and file objects in the lower file system happens in a way that > > reminds of passing file descriptors via sockets: > > - a process requests the opening of a file handled by FUSE, so the kernel > > forwards the request to the FUSE daemon; > > - the FUSE daemon opens the target file in the lower file system, getting > > its file descriptor; > > - the FUSE daemon also decides according to its internal policies if > > passthrough can be enabled for that file, and, if so, can perform a > > FUSE_DEV_IOC_PASSTHROUGH_OPEN ioctl() on /dev/fuse, passing the file > > descriptor obtained at the previous step and the fuse_req unique > > identifier; > > - the kernel translates the file descriptor to the file pointer navigating > > through the opened files of the "current" process and temporarily stores > > it in the associated open/create fuse_req's passthrough_filp; > > - when the FUSE daemon has done with the request and it's time for the > > kernel to close it, it checks if the passthrough_filp is available and in > > case updates the additional field in the fuse_file owned by the process > > accessing the FUSE file system. > > From now on, all the read/write operations performed by that process will > > be redirected to the corresponding lower file system file by creating new > > VFS requests. > > Since the read/write operation to the lower file system is executed with > > the current process's credentials, it might happen that it does not have > > enough privileges to succeed. For this reason, the process temporarily > > receives the same credentials as the FUSE daemon, that are reverted as soon > > as the read/write operation completes, emulating the behavior of the > > request to be performed by the FUSE daemon itself. This solution has been > > inspired by the way overlayfs handles read/write operations. > > Asynchronous IO is supported as well, handled by creating separate AIO > > requests for the lower file system that will be internally tracked by FUSE, > > that intercepts and propagates their completion through an internal > > ki_completed callback similar to the current implementation of overlayfs. > > The ioctl() has been designed taking as a reference and trying to converge > > to the fuse2 implementation. For example, the fuse_passthrough_out data > > structure has extra fields that will allow for further extensions of the > > feature. > > > > > > Performance on SSD > > > > What follows has been performed with this change [V6] rebased on top of > > vanilla v5.8 Linux kernel, using a custom passthrough_hp FUSE daemon that > > enables pass-through for each file that is opened during both "open" and > > "create". Tests were run on an Intel Xeon E5-2678V3, 32GiB of RAM, with an > > ext4-formatted SSD as the lower file system, with no special tuning, e.g., > > all the involved processes are SCHED_OTHER, ondemand is the frequency > > governor with no frequency restrictions, and turbo-boost, as well as > > p-state, are active. This is because I noticed that, for such high-level > > benchmarks, results consistency was minimally affected by these features. > > The source code of the updated libfuse library and passthrough_hp is shared > > at the following repository: > > > > https://github.com/balsini/libfuse/tree/fuse-passthrough-stable-v.3.9.4 > The libfuse changes are not updated with the latest ioctl UAPI change yet. > > > * UAPI updated: ioctl() now returns an ID that will be used at > > open/create response time to reference the passthrough file > > Cheers, > Tao > -- > Into Sth. Rich & Strange Hi Tao, You are right, sorry, this is the correct branch that uses the FUSE_DEV_IOC_PASSTHROUGH_OPEN ioctl with the current patch set: https://github.com/balsini/libfuse/tree/fuse-passthrough-v10-linux-5.8-v.3.9.4 I think I'll stick to this libfuse branch naming pattern from now on. :) Thanks, Alessio