Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3862042pxm; Tue, 1 Mar 2022 06:53:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNT/+yhxRoO0DeojkaDG/OZRlQ4kAOVf4+4jorZaofP586Z+OC3mG0G90lKuAGj31HY9ar X-Received: by 2002:a17:906:b052:b0:6ce:88a5:e42a with SMTP id bj18-20020a170906b05200b006ce88a5e42amr19407612ejb.237.1646146434530; Tue, 01 Mar 2022 06:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646146434; cv=none; d=google.com; s=arc-20160816; b=aL5Lzm6lv7+VGtoM1YI1rrN+PRyXv3tyrtGFtwDsXPPUJv+LXtx1z56DNN38xfXusZ XEZVzI+a65ERJzAkbp5vCVsXMWuE02+fFFbVstUTlBlMNTZCQnlQltcEVKyQmvxCm7ZH dLI+lKfKJkVLLPtBU3H61XDZvOBRQ8JDKAG4zwZErYct328EJQvRG2SzNF4w60O9zTQ+ 6Wxtb7DWrGQ+tCpNiyIWuYnvpF+L4dmVnwopXqJg2EIhvIwfq3FQGRyd1jWPn6smyPQz 9EdZiQDlPGtckKZeGnJBMk6h53apBCeJ16d+u0mgV1qArcbHQgqtpHXu040UnyUYfFoW 5fig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MU2HWPXy4mAk2gUeuMPfPjZpOmd7MfczuTjNa/BKYeM=; b=QcWeCNByXLnWQcndq0ju0UkTYZGF+mrHAnco2ln4/PKk4yFG+qViKxUVbDVTLb+MN/ CMw+pEvEEuadM0Wx+ntxqC3uTgNjeSZuLYSREAFlejlGSojllb/yzkScXuh6eWptZe6z y2x12Gr60W1eFOb1o0qiEhq0LKsW44V5nHMCVilfS/vzlvmPKtS7m1TMtjuomLDuqSOc boXnPl5jh2VOmg9jwKdzf80f34vOXyfP0UnMYLmghBhPTSSgLt+ZVLlgSmyWh+1Igbek SsnZ1/D6Ju6IxbrbeewsAUc3xvGYrPWEu4dW4cFioe/sEKEUEU0NjIP/+TC2JJfLVW1h pJlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=J5tf+w9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a170906248600b006d6dd9c1311si1955279ejb.448.2022.03.01.06.53.31; Tue, 01 Mar 2022 06:53:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=J5tf+w9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233960AbiCAJl7 (ORCPT + 99 others); Tue, 1 Mar 2022 04:41:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233957AbiCAJlz (ORCPT ); Tue, 1 Mar 2022 04:41:55 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9288BE12 for ; Tue, 1 Mar 2022 01:41:13 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id c14so17768351ioa.12 for ; Tue, 01 Mar 2022 01:41:13 -0800 (PST) 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=MU2HWPXy4mAk2gUeuMPfPjZpOmd7MfczuTjNa/BKYeM=; b=J5tf+w9wJrpI84ECFWJeCND7fgEugL1Y44J/PeJZI5J8YWiyX+HtHV4sQLIs8Lv9MP AiUX5b0cP+UUp70Ks5gg6JCXGhXNEB31VGMNwDkGqc4ab+pW5kH6WmTWwpL+CKmhYNqt hYeXF8Y3fWhW9T+GCnaXz+kYm7c1vnceiDEm4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MU2HWPXy4mAk2gUeuMPfPjZpOmd7MfczuTjNa/BKYeM=; b=eFeWnwE4wQzhdXGNraonyHxm6E10PBju5Yv8HJpdsajZqBqnMS4/oEZ6T+L5uSQNzV RRWuUSLwelos0Lj+GDPvmjlrgVkDB2HxdeBVbXHK1bgHOOW8li+2tGVLRdDrX/3R1ShR eiW2S8fFz/cK5t486IkpmTkmcTSvWa9hsQxH9rp9FeUIn7cD7wJ0JDOex+sHNlRaSirP 6r7RDZDh48bpg5PzVtRYwfIsS/T8E+1CZQjb6EbiV9r44C8DV5VQ5vbDUKNtTJ3cTWZM 9FpGmLTpj3cMCzGZZmzD/nWUxduGcDJhA6PNHuo0DVmWtGgRFG+BkbcLlWmEPw1JrzVv pOLA== X-Gm-Message-State: AOAM533rMHWdvPkypl+MZO740/ztSur/sCDafv0+EiyOm9lPdH+MYpWn 7Pg8bqVmxDCQ4JgyAkq1Lqi8wx8UReQC/LI8v1q42w== X-Received: by 2002:a02:95a2:0:b0:30f:61cc:346f with SMTP id b31-20020a0295a2000000b0030f61cc346fmr20276611jai.273.1646127672760; Tue, 01 Mar 2022 01:41:12 -0800 (PST) MIME-Version: 1.0 References: <20220227093434.2889464-1-jhubbard@nvidia.com> <20220227093434.2889464-7-jhubbard@nvidia.com> In-Reply-To: From: Miklos Szeredi Date: Tue, 1 Mar 2022 10:41:01 +0100 Message-ID: Subject: Re: [PATCH 6/6] fuse: convert direct IO paths to use FOLL_PIN To: John Hubbard Cc: jhubbard.send.patches@gmail.com, Jens Axboe , Jan Kara , Christoph Hellwig , Dave Chinner , "Darrick J . Wong" , "Theodore Ts'o" , Alexander Viro , Andrew Morton , Chaitanya Kulkarni , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs , linux-mm , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Feb 2022 at 22:16, John Hubbard wrote: > > On 2/28/22 07:59, Miklos Szeredi wrote: > > On Sun, 27 Feb 2022 at 10:34, wrote: > >> > >> From: John Hubbard > >> > >> Convert the fuse filesystem to support the new iov_iter_get_pages() > >> behavior. That routine now invokes pin_user_pages_fast(), which means > >> that such pages must be released via unpin_user_page(), rather than via > >> put_page(). > >> > >> This commit also removes any possibility of kernel pages being handled, > >> in the fuse_get_user_pages() call. Although this may seem like a steep > >> price to pay, Christoph Hellwig actually recommended it a few years ago > >> for nearly the same situation [1]. > > > > This might work for O_DIRECT, but fuse has this mode of operation > > which turns normal "buffered" I/O into direct I/O. And that in turn > > will break execve of such files. > > > > So AFAICS we need to keep kvec handing in some way. > > > > Thanks for bringing that up! Do you have any hints for me, to jump start How about just leaving that special code in place? It bypasses page refs and directly copies to the kernel buffer, so it should not have any affect on the user page code. > a deeper look? And especially, sample programs that exercise this? Here's one: # uncomment as appropriate: #sudo dnf install fuse3-devel #sudo apt install libfuse3-dev cat < fuse-dio-exec.c #define FUSE_USE_VERSION 31 #include #include #include static const char *filename = "/bin/true"; static int test_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi) { return lstat(filename, stbuf) == -1 ? -errno : 0; } static int test_open(const char *path, struct fuse_file_info *fi) { int res; res = open(filename, fi->flags); if (res == -1) return -errno; fi->fh = res; fi->direct_io = 1; return 0; } static int test_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { int res = pread(fi->fh, buf, size, offset); return res == -1 ? -errno : res; } static int test_release(const char *path, struct fuse_file_info *fi) { close(fi->fh); return 0; } static const struct fuse_operations test_oper = { .getattr = test_getattr, .open = test_open, .release = test_release, .read = test_read, }; int main(int argc, char *argv[]) { return fuse_main(argc, argv, &test_oper, NULL); } EOF gcc -W fuse-dio-exec.c `pkg-config fuse3 --cflags --libs` -o fuse-dio-exec touch /tmp/true #run test: ./fuse-dio-exec /tmp/true /tmp/true umount /tmp/true