Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp658411ybb; Wed, 8 Apr 2020 07:31:33 -0700 (PDT) X-Google-Smtp-Source: APiQypITEUgIM1XyN7GAMq0cfP/tBVvPjF4XITpkzrLdVUHEecpJ00pjfB6/AG5jpUQjDURYvI5y X-Received: by 2002:aca:5b04:: with SMTP id p4mr2794022oib.105.1586356293412; Wed, 08 Apr 2020 07:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586356293; cv=none; d=google.com; s=arc-20160816; b=0ropkEaQwKqx53WkvkiRLU683H9eFHdIw1ttoFwc620u/ZlOBx3Vqr6Zn5HYQIAovU SxOPkUPIudVU45mguhMEN4uOgX9yJEhhQYH0fld9scYnq5MO+LU1HpJLkDk5ulbifxXT wwpY3EN77WWEbldTZITX4V6DJxfvZYzNP+86i9XlYv8HRNcZkf9n+6yXCe7zTL9NLfKp oD8YSioUxvf829NyxX++VN1kS9JwMll9lNjphwNt0JtJLQo2eQfPJtLpEzjxWc1Q/4Jo dqt+kDF3VLDa9HsC7lrmjmtkFN2CeXY+V2gQr6UfuDmZPwujWA9MDdpLN7zhmRgqKjWY sN+A== 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=3Pur/SF5hB2DclYX783PIXK8CXMbF0IljxdFLYy8sjc=; b=z0feeJDCOwzD/5GvyPaU4nZlt0CWAwPoRwIYY2kcxc3ydbImPGzOMx/n9H78P5/wBZ jNntFGEJa0HXVLJNvtUGxXaW4RTajPKWYkD1fVx7hD7Zoqpra41Yrm4jo7R5keDxd6Op 7zLoLrg5LYR51gu4HLY6x86MZl6LdBWHuUnKxppkaXAtXE96ftxKI93PHJgCCq0gnxZ+ nIF1baEDFLuHmcDP6YH07VyIrip1Wt/wUWLkgVXa5WhmcXu7gDANYFnWQznouPl1kQaD ih7KpKaO9CihaGUTgBQUV56pNGUCN8lgJu4nTubTCICcaTHu6G/JvRAL55qDrcaT974G t9Kg== ARC-Authentication-Results: i=1; mx.google.com; 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 y62si765705otb.292.2020.04.08.07.31.12; Wed, 08 Apr 2020 07:31:33 -0700 (PDT) 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; 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 S1728576AbgDHM0c (ORCPT + 99 others); Wed, 8 Apr 2020 08:26:32 -0400 Received: from mout-p-103.mailbox.org ([80.241.56.161]:58328 "EHLO mout-p-103.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgDHM0c (ORCPT ); Wed, 8 Apr 2020 08:26:32 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 48y3RT1xT9zKmXH; Wed, 8 Apr 2020 14:26:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id m9ZmrmVd4PFA; Wed, 8 Apr 2020 14:26:25 +0200 (CEST) Date: Wed, 8 Apr 2020 22:26:01 +1000 From: Aleksa Sarai To: Josh Triplett Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, linux-arch@vger.kernel.org, Alexander Viro , Arnd Bergmann , Jens Axboe Subject: Re: [PATCH v3 0/3] Support userspace-selected fds Message-ID: <20200408122601.kvrdjksjkl7ktgt4@yavin.dot.cyphar.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="753o2egv4zmh6vyt" Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: DDA58175B X-Rspamd-Score: -6.44 / 15.00 / 15.00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --753o2egv4zmh6vyt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-04-07, Josh Triplett wrote: > (Note: numbering this updated version v3, to avoid confusion with Jens' > v2 that built on my v1. Jens, if you like this approach, please feel > free to stack your additional patches from the io_uring-fd-select branch > atop this series. 5.8 material, not intended for the current merge window= =2E) >=20 > Inspired by the X protocol's handling of XIDs, allow userspace to select > the file descriptor opened by a call like openat2, so that it can use > the resulting file descriptor in subsequent system calls without waiting > for the response to the initial openat2 syscall. >=20 > The first patch is independent of the other two; it allows reserving > file descriptors below a certain minimum for userspace-selected fd > allocation only. >=20 > The second patch implements userspace-selected fd allocation for > openat2, introducing a new O_SPECIFIC_FD flag and an fd field in struct > open_how. 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. >=20 > The third patch adds userspace-selected fd allocation to pipe2 as well. > I did this partly as a demonstration of how simple it is to wire up > O_SPECIFIC_FD support for any fd-allocating system call, and partly in > the hopes that this may make it more useful to wire up io_uring support > for pipe2 in the future. >=20 > If this gets accepted, I'm happy to also write corresponding manpage > patches. >=20 > v3: > This new version has an API to atomically increase the minimum fd and > return the previous minimum, rather than just getting and setting the > minimum; this makes it easier to allocate a range. (A library that might > initialize after the program has already opened other file descriptors > may need to check for existing open fds in the range after reserving it, > and reserve more fds if needed; this can be done entirely in userspace, > and we can't really do anything simpler in the kernel due to limitations > on file-descriptor semantics, so this patch series avoids introducing > any extra complexity in the kernel.) >=20 > This new version also supports a __get_specific_unused_fd_flags call > which accepts the limit for RLIMIT_NOFILE as an argument, analogous to > __get_unused_fd_flags, since io_uring needs that to correctly handle > RLIMIT_NOFILE. >=20 > Josh Triplett (3): > fs: Support setting a minimum fd for "lowest available fd" allocation > fs: openat2: Extend open_how to allow userspace-selected fds > fs: pipe2: Support O_SPECIFIC_FD Aside from my specific comments and questions, the changes to openat2 deserve at least one or two selftests. > fs/fcntl.c | 2 +- > fs/file.c | 62 ++++++++++++++++++++++++++++---- > fs/io_uring.c | 3 +- > fs/open.c | 6 ++-- > fs/pipe.c | 16 ++++++--- > include/linux/fcntl.h | 5 +-- > include/linux/fdtable.h | 1 + > include/linux/file.h | 4 +++ > include/uapi/asm-generic/fcntl.h | 4 +++ > include/uapi/linux/openat2.h | 2 ++ > include/uapi/linux/prctl.h | 3 ++ > kernel/sys.c | 5 +++ > 12 files changed, 97 insertions(+), 16 deletions(-) --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --753o2egv4zmh6vyt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQSxZm6dtfE8gxLLfYqdlLljIbnQEgUCXo3C0QAKCRCdlLljIbnQ EhhjAQDFUJ5VOPLwbFaGpNlrcUpjPunloiKcWks6ACx6gv1cSwEA9Ii9QQBfqGMO K8HrFWauN6ip0V8Sf5777xDP7rGWww8= =OtzS -----END PGP SIGNATURE----- --753o2egv4zmh6vyt--