Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1440663ybz; Wed, 22 Apr 2020 21:46:40 -0700 (PDT) X-Google-Smtp-Source: APiQypJY12bjomviCC4XYlF4XiEwadPkjKmhWD5S08C8i8TJa2KB/SpBG+i9/KcAelHO5ogpzE+I X-Received: by 2002:a17:907:2719:: with SMTP id w25mr1260246ejk.107.1587617200331; Wed, 22 Apr 2020 21:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587617200; cv=none; d=google.com; s=arc-20160816; b=bXavtJ2w1Vn2Jxa+zZBYOa/qjRCWzDVsQYhgMISB4Oyy/QXfhS30TzD6j7KE0Z7GiH 9/PRzHUhHLOxhU5ruYRHXcVtFN/zaFiZZb28iXSB2kd4cz1Mec0xBh/nnTZLY7Rkx/Nj IVtTxgRL+MJqRZNIA+JWn9KuVjdFJlNufgbPiQ1C+gM9yYUip0X1lHUjrbZzVttX5bl6 ea6eme5TRHsN6ex0TG88ygX5bz3APoXtgz5LrCbIuZUwjEoGrAiPAOqXODuCv22ob0S/ D85OAGmFi3vs7JtVBnZl6TDLM2vRfrwV8o5Q38s0GAKG9hgViSDNvLUmO9XbQ7FzmEuN 9oow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=leOBG+7tWBwe1ktHYup8CVoeZAuDJAa7DTS4LiHX8Uk=; b=H8xwOIU58F2zO9B7gZxdWU/eYmee8CfZtsdYsDofoo3d5C2r2QdKB8dqbC2KYhBke6 gB93nadISNRIeJeuXbujEY1NqCYANCwezTP6MVIn46ONhUWEXiMphgeqhqjwUSh/1fwi 8EXhmiFGhQdYTnr8sj18YWDAsdxd8GVhf8EM3QDpv41hCY1l9x6L1BqyrI5J9XMtPXnI Xv3YpNQd6QKAafORlprqS4SD1NJZ9lmritYScYmq25at2zKdMBPP1gcz/0zahLDlzhkR a84+6XsOw4F86jptFzredm5xsgY0ZP3TmP1ITmLDkmlbfT0ZK8g63clZ1TE95/VJ4xTk EXtw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 24si643117ejv.109.2020.04.22.21.46.17; Wed, 22 Apr 2020 21:46:40 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726562AbgDWEmg (ORCPT + 99 others); Thu, 23 Apr 2020 00:42:36 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:41873 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbgDWEmg (ORCPT ); Thu, 23 Apr 2020 00:42:36 -0400 X-Originating-IP: 50.39.163.217 Received: from localhost (50-39-163-217.bvtn.or.frontiernet.net [50.39.163.217]) (Authenticated sender: josh@joshtriplett.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 4D0E620004; Thu, 23 Apr 2020 04:42:28 +0000 (UTC) Date: Wed, 22 Apr 2020 21:42:26 -0700 From: Josh Triplett To: Miklos Szeredi Cc: Michael Kerrisk , io-uring@vger.kernel.org, "linux-fsdevel@vger.kernel.org" , lkml , Alexander Viro , Arnd Bergmann , Jens Axboe , Aleksa Sarai , linux-man , Linux API Subject: Re: [PATCH v5 2/3] fs: openat2: Extend open_how to allow userspace-selected fds Message-ID: <20200423044226.GH161058@localhost> References: <9873b8bd7d14ff8cd2a5782b434b39f076679eeb.1587531463.git.josh@joshtriplett.org> <20200423004807.GC161058@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 23, 2020 at 06:24:14AM +0200, Miklos Szeredi wrote: > On Thu, Apr 23, 2020 at 2:48 AM Josh Triplett wrote: > > On Wed, Apr 22, 2020 at 09:55:56AM +0200, Miklos Szeredi wrote: > > > On Wed, Apr 22, 2020 at 8:06 AM Michael Kerrisk (man-pages) > > > wrote: > > > > > > > > [CC += linux-api] > > > > > > > > On Wed, 22 Apr 2020 at 07:20, Josh Triplett wrote: > > > > > > > > > > Inspired by the X protocol's handling of XIDs, allow userspace to select > > > > > the file descriptor opened by openat2, so that it can use the resulting > > > > > file descriptor in subsequent system calls without waiting for the > > > > > response to openat2. > > > > > > > > > > In io_uring, this allows sequences like openat2/read/close without > > > > > waiting for the openat2 to complete. Multiple such sequences can > > > > > overlap, as long as each uses a distinct file descriptor. > > > > > > If this is primarily an io_uring feature, then why burden the normal > > > openat2 API with this? > > > > This feature was inspired by io_uring; it isn't exclusively of value > > with io_uring. (And io_uring doesn't normally change the semantics of > > syscalls.) > > What's the use case of O_SPECIFIC_FD beyond io_uring? Avoiding a call to dup2 and close, if you need something as a specific file descriptor, such as when setting up to exec something, or when debugging a program. I don't expect it to be as widely used as with io_uring, but I also don't want io_uring versions of syscalls to diverge from the underlying syscalls, and this would be a heavy divergence. > > > This would also allow Implementing a private fd table for io_uring. > > > I.e. add a flag interpreted by file ops (IORING_PRIVATE_FD), including > > > openat2 and freely use the private fd space without having to worry > > > about interactions with other parts of the system. > > > > I definitely don't want to add a special kind of file descriptor that > > doesn't work in normal syscalls taking file descriptors. A file > > descriptor allocated via O_SPECIFIC_FD is an entirely normal file > > descriptor, and works anywhere a file descriptor normally works. > > What's the use case of allocating a file descriptor within io_uring > and using it outside of io_uring? Calling a syscall not provided via io_uring. Calling a library that doesn't use io_uring. Passing the file descriptor via UNIX socket to another program. Passing the file descriptor via exec to another program. Userspace is modular, and file descriptors are widely used.