Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3833212ybf; Tue, 3 Mar 2020 13:48:22 -0800 (PST) X-Google-Smtp-Source: ADFU+vvQ+bQGwooEhu0Uj8ZOQc5bnTip/u1aObOsuHEUWWeE+Fofik/lgeetoqyhZDYNe7UMQV47 X-Received: by 2002:aca:aa8b:: with SMTP id t133mr403412oie.95.1583272086970; Tue, 03 Mar 2020 13:48:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583272085; cv=none; d=google.com; s=arc-20160816; b=Yt7YdSsV1qa6Pe29r8mJ8AAPsI1YAqMUQQeHjBUT9xzA8J1WYwLji8hmqB5Qy906tX 5zJR9du02Cocbq3cY1keMyGmvWD2P/KGcKhS4cnS49G9iXUFD36xYVynwd7YEwADDhzD ibfi4/670Yfh5XpjyyhHFd15GCjzz9/uA573Oce3EbZphcnH9QL59HruRwC2z10ua45g r4HPqnMavahPDfGt9iPR9k9rZOMbchRW/BGF2LSnRjjxUKqO8pKvFImCSukICMXLdFOn WtwmOSB6B1h7cT7ETw9ZHEIsv0c9rc2UCi5Wszzz62DrEp1kN32jnlnNs5OCpvmZ/UZJ zC3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=NA2tNK/EVxzQPmbB3xl2CeQSQTv5FvhMkwiaUXLKu8k=; b=CZJeRV8nXUKwefLsJaz75cMby5l3eQXSsj1nfRB9jg/v1XLmr/JGSx7S/SjoeMxjtT 3dnrALPRwuqfmaWpI/8bKCiggvr+wVj1lcnqNqXOyvCsXqqrZHBk8Ha78u79dC/49+M7 i/K8GpEp2h2BxpWjmoprqE8aROQyoBn6Nsl45KdbNYACfQltUTxigFrpq4Vj2DKKEdpX aRMJAqGb3rYCxxvYriUmWSP0Ldv1EnprnYqZe+g9JvZo3u03G2nBKanOE7+ABGhi6uyj kYiFHYbo55INbmKR+gF8IYWprmnPIbtroYObd1oQiCLjoQpIIcABTfedWVYHKQAwPqM2 28kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=DpN9m2Xx; 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 f6si6142039otq.50.2020.03.03.13.47.54; Tue, 03 Mar 2020 13:48:05 -0800 (PST) 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=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=DpN9m2Xx; 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 S1731839AbgCCUdF (ORCPT + 99 others); Tue, 3 Mar 2020 15:33:05 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:42743 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731830AbgCCUdF (ORCPT ); Tue, 3 Mar 2020 15:33:05 -0500 Received: by mail-io1-f65.google.com with SMTP id q128so5124859iof.9 for ; Tue, 03 Mar 2020 12:33:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NA2tNK/EVxzQPmbB3xl2CeQSQTv5FvhMkwiaUXLKu8k=; b=DpN9m2XxTJTaWFWLrmhMZf7V1GCIm2YxJek3ns+5tzeuum4/wfQwH9U2ZVWZLuJq// G2CG7cMZ0uQKq6uaHP8VVNjvib+G3RVyvjy7kH1kMoIqA6mVWk7oMvVIx0cQScQFHTeP RoxPHN++33ZpZYk7akbvYSAPI67SVi6AJikPSC380seGBqZGGSBROhHh1amdaWEiTHv/ zGWD9tdG/3wh5hGmAJH+XrjB6dYRvmmltVccjFxf1BEHVmkM1qx9gkGowI4f9RceBYG1 M1a6y9e1ip8ePcFbBhriMn4ip7GfqEce3g3YiwuI1ECwwRU+ZQnZJLtO8KOh8C43TIEv nStA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NA2tNK/EVxzQPmbB3xl2CeQSQTv5FvhMkwiaUXLKu8k=; b=szfGqzf1V3jh5iqoPjz9XxtXMi3XfnTwKzuCrSZl0AIfaPBmyFyFKu/YXSgIjZ9o0L 0iMVfke5CA0uxCi2drRgnTH1PMWW9Hvj8BDIbUhkgK43jPPz3MhkW+laDwt+UOhs5C6y TzBdJX3B80bnt7c7VkrS/D9MFHIhJOJxuf3ih1Dd7V70f5rZ+fQAxGVS8WoS1Nkhrv1k dYXDcr2j8AmTRTSgveWp3qQExox2T8cIlpRYhmtoJCZ2fd7JRenImYNCQjVtlEBU5ELu 5yyJcJOAZQ26kjd1DwsVNcXnko1C3VEatDWNeeqVJDp0sbKl7waxkcGSrzaNSoJ8bElZ xXsQ== X-Gm-Message-State: ANhLgQ0N4NBqSOGB9FiqFfVKsRD3DlOloZAHR3eOI5roPE6H5aHJcAPU GidJ/X6TqhrB52WKH+EKFgrmYPYIp9Y= X-Received: by 2002:a6b:710c:: with SMTP id q12mr5643228iog.167.1583267584182; Tue, 03 Mar 2020 12:33:04 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id f9sm756927ioc.70.2020.03.03.12.33.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Mar 2020 12:33:03 -0800 (PST) Subject: Re: [PATCH 00/17] VFS: Filesystem information and notifications [ver #17] To: Jeff Layton , Greg Kroah-Hartman , Jann Horn Cc: Miklos Szeredi , Karel Zak , David Howells , Ian Kent , Christian Brauner , James Bottomley , Steven Whitehouse , Miklos Szeredi , viro , Christian Brauner , "Darrick J. Wong" , Linux API , linux-fsdevel , lkml References: <1509948.1583226773@warthog.procyon.org.uk> <20200303113814.rsqhljkch6tgorpu@ws.net.home> <20200303130347.GA2302029@kroah.com> <20200303131434.GA2373427@kroah.com> <20200303134316.GA2509660@kroah.com> <20200303141030.GA2811@kroah.com> <20200303142407.GA47158@kroah.com> <030888a2-db3e-919d-d8ef-79dcc10779f9@kernel.dk> <7a05adc8-1ca9-c900-7b24-305f1b3a9b86@kernel.dk> From: Jens Axboe Message-ID: Date: Tue, 3 Mar 2020 13:33:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/20 12:43 PM, Jeff Layton wrote: > On Tue, 2020-03-03 at 12:23 -0700, Jens Axboe wrote: >> On 3/3/20 12:02 PM, Jeff Layton wrote: >>> Basically, all you'd need to do is keep a pointer to struct file in the >>> internal state for the chain. Then, allow userland to specify some magic >>> fd value for subsequent chained operations that says to use that instead >>> of consulting the fdtable. Maybe use -4096 (-MAX_ERRNO - 1)? >> >> BTW, I think we need two magics here. One that says "result from >> previous is fd for next", and one that says "fd from previous is fd for >> next". The former allows inheritance from open -> read, the latter from >> read -> write. >> > > Do we? I suspect that in almost all of the cases, all we'd care about is > the last open. Also if you have unrelated operations in there you still > have to chain the fd through somehow to the next op which is a bit hard > to do with that scheme. > > I'd just have a single magic carveout that means "use the result of last > open call done in this chain". If you do a second open (or pipe, or...), > then that would put the old struct file pointer and drop a new one in > there. > > If we really do want to enable multiple opens in a single chain though, > then we might want to rethink this and consider some sort of slot table > for storing open fds. I think the one magic can work, you just have to define your chain appropriately for the case where you have multiple opens. That's true for the two magic approach as well, of course, I don't want a stack of open fds, just "last open" should suffice. I don't like the implicit close, if your op opens an fd, something should close it again. You pass it back to the application in any case for io_uring, so the app can just close it. Which means that your chain should just include a close for whatever fd you open, unless you plan on using it in the application aftwards. -- Jens Axboe