Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3834898ybf; Tue, 3 Mar 2020 13:50:45 -0800 (PST) X-Google-Smtp-Source: ADFU+vvrVCR3utXTd4SHICpwc50X6zDb8YsJj24sRdBILX0NeI5P2LFtC5luRgF+wLr6eoHnruJH X-Received: by 2002:a9d:6648:: with SMTP id q8mr5032225otm.105.1583272245069; Tue, 03 Mar 2020 13:50:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583272245; cv=none; d=google.com; s=arc-20160816; b=GeFhhX80sZEi5ziblcZTaTMKT0GzIaBexq0W0vSAgHLWrvyFkDAN1GSr1AJEDRdath x8Xr2Hz8BStOGKKixt19vAN2+hdpnZTO3RGzZzbFFPbnu90Yq1Mcz6bX4goduc1Oe7me LEAj7DInBErcMnJmT2HGovBg0FvrwRvd72Pq3DKxZ8JkqhkU49/kAubFO8BSUSAs81UG 67M1hKUWLd34aaMwVWwf6+a2cJYZ1gLjdNnAHlRW9edcPeTGtlodtNlgE/6oWh2gEVxT hEE0z/PreL3No6MA7oN8s1SPmoSIZZEhbzP1ekd+VY4WvEpWE1Yol/fmMaxFYdN85y7P zkEg== 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:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=hdeXcMk3U34nSzpFrgjZ1THcmC1Q5azbGvmFBKGBDEc=; b=A1wLH9SCvPgnCwzDurxP6jx61IbkFhVtz9FJpT2ozEigwcCfL+7rOrlGpUmUFCkxq2 Y2nCoMYEb4Ei48KijY38rkWTKsodIIJy8/oa6nnhLR9bJLhldd1LczmyWJ35gFGR/f0u b36UWJgfpEuLTTFKizPLRT85lnrSkFF4q/m9Gh4Y+QLjorKWbDJ55fkCvwaWlTi05ogH IRjmQFxt/JUu+c8R/dLYQHRhbj42etzpWGAd92hiW4SLsUKELNHFk0KGUDCe+kGjHBLj nnpGWaC2157qZqWDBAzA87K23z2OwV0T7BAmMkNa9T7cGuU0UCE25PDGuuAnwYKCLCF7 xTgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="MuW4/BP1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si8098839otc.130.2020.03.03.13.50.33; Tue, 03 Mar 2020 13:50:45 -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.org header.s=default header.b="MuW4/BP1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732170AbgCCVDq (ORCPT + 99 others); Tue, 3 Mar 2020 16:03:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:45324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729880AbgCCVDq (ORCPT ); Tue, 3 Mar 2020 16:03:46 -0500 Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net [68.20.15.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F091E20728; Tue, 3 Mar 2020 21:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583269424; bh=P324o9tus2K6UdEaIBu5qm77rhmlVisGvzD3wMHwH3Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=MuW4/BP1yEisJGZudxNcoiXAXhxEjxUT9z3yGd4XGdLtHSCe9XdlIumZCiRa/zbTN 6ZQY3B+MV2M6uGG7MKxJJuldYoy7d8+dboTMc9wfN25UbMLAmuBuCe2njdiZ6e56Om Jbp6l8+s9pltZwwbA/+jXwo5rO9z6ZdlIfyqKTA0= Message-ID: <8b42bcc526a890395e8f25c2f209475101861257.camel@kernel.org> Subject: Re: [PATCH 00/17] VFS: Filesystem information and notifications [ver #17] From: Jeff Layton To: Jens Axboe , 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 Date: Tue, 03 Mar 2020 16:03:41 -0500 In-Reply-To: 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> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-03-03 at 13:33 -0700, Jens Axboe wrote: > 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. > Yep. > 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. > Yeah sorry, I didn't word that correctly. Let me try again: My thinking was that you would still return the result of the open to userland, but also stash a struct file pointer in the internal chain representation. Then you just refer to that when you get the "magic" fd. You'd still need to explicitly close the file though if you didn't want to use it past the end of the current chain. So, I guess you _do_ need the actual fd to properly close the file in that case. On another note, what happens if you do open+write+close and the write fails? Does the close still happen, or would you have to issue one separately after getting the result? -- Jeff Layton