Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2864792lqo; Mon, 20 May 2024 22:04:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX34y4PXV54CohZo+ESKOHAqPg12c4EsYnqAg3sqpWba9d2pshLx5RdwAlJr0LVm2nw1UedgD8Rk/DbovwLZjQN5uatf7ThFbH6LHvl6w== X-Google-Smtp-Source: AGHT+IHwsVL5GEqsNGcXD1fOPcueRpcQf8sTl6Lrz+cGUU/TIu9tMtadG1Iogp+dXbtHSGgifkZW X-Received: by 2002:a05:6a00:a1e:b0:6e8:f57d:f1ec with SMTP id d2e1a72fcca58-6f4e02cee46mr39849314b3a.17.1716267865858; Mon, 20 May 2024 22:04:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716267865; cv=pass; d=google.com; s=arc-20160816; b=eHeC6hF0GEUW07bCjzmDhHq5nGA+MATBFyYR83Td/HpG5tLPA/j+EHrOZla4p5R0l2 Jf68xIRS9Ddk1XGdUyhptIIDB7ZX4iyFNZ3xQEPa80qQFrZhYkK0DvSiN9kBSDrp6Vqb BeWr5CEDGl/dzoTEfjhMF8jqCDXgOtXc5zZapQ37YQiE27D773BxfN4CaTUMGwjf2mju hffdZ98fKgt9dKH0FS6dq0om4+nanMkJiWAqDK8w16qyBQnzrs/bnwCzPpvhRfzNM3cn rAIrTH4UUCgtiLLTenWGMcTIHkqsV4PUYamgfB4Tsz15DSmZjT4XFnZlul9twYqpSyoW pdxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=7QDbtlT09zWn+TAG8clpVDLU8Z+ZeH0+DkEI12Wz3R4=; fh=lmY/W3YgNFKIbi2V5yVy4Gk0fbCU4LLP3duC50UiyPs=; b=G3xKEl3a51EHYv3Ga1FBPFAgSgVmAnY+2Ux70WRleEjgblydF5FZ1qD3STlSqLcsUW Tct3nJA742KwOQ1z9lNzx8/Lb/VDCxrobWb3vqWQ0V+AjDRY8A+4Yi6b4qBf1N/aPTOX z8B3TbtHjkt1Kp/wgoOuRuF9w8LSkDufELKZXvJHF8YcSlu1VpANOqiababuP70ie/RW 2F/HwtyL0WBBgJExTY7XCjGFxLuC6YQaVQZI7S7jk5URgKpGtyNpvCTyeXEkmJxUWmVt wmNl8p0FMBe2ouLBXaZlIDNetU+/2z5nUlIvt0jA56y3tJ0TyiGopcRfCCLVLFbDK2Ma xADg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=krQXJ+iv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-nfs+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f6695a9f44si3524018b3a.192.2024.05.20.22.04.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 22:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=krQXJ+iv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-nfs+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 42487281B9A for ; Tue, 21 May 2024 05:04:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7C54224D4; Tue, 21 May 2024 05:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="krQXJ+iv" X-Original-To: linux-nfs@vger.kernel.org Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A65B610C; Tue, 21 May 2024 05:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716267863; cv=none; b=OCtZ46ssT98TfvRzR5Z79l1vmClCiPGL6uc0rDcUa9/251QiyhNtFHvDnfDd4BB4OaGCO4LQwQnHQYnmfqEvtrLRR/YiepS+w44Am+9jTeUrhrocJYmlAFg9SdD2D9Yymw/PSiXEmRXG/Hh5dCm88v9RaXPsCrBjGqocrI1mKvM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716267863; c=relaxed/simple; bh=97PxihTc9hshgLJfsF3ImXlIAmhViSK96qjnNgOAQgw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=iIXNRHPc4xtJnfaBUkfreySI/9PntBEmOpUW7C/Fh7P6npY7L9EhuXLVGYRqCpuNZtUBG8TS6JH8Nj6e0rzK7BE43zI6Tm9cEKWxcDwoSYF+3N72ain2kJq0ppd5et4pYJOHGl57OQlf+U0MVDGLJlrzEXkFtrypYNxmfQQJnWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=krQXJ+iv; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-61b4cbb8834so28487307b3.0; Mon, 20 May 2024 22:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716267861; x=1716872661; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7QDbtlT09zWn+TAG8clpVDLU8Z+ZeH0+DkEI12Wz3R4=; b=krQXJ+ivbSxkKKtshRBNG2kYcMqe368oPriMH/PjXjx1PvXD9JPjW72dETLZXGMKM+ S/BicnzamBfHLG4YZe4mgGX6a1QBdYkfvp+TZu+MR8qTJCYkktn7TWkK+Vx//d6S5qEl C8GMAQ7xz+XCjNYidCmPG18decEqjRmNv9vOsSyzGu7VmUMrsN92/64InDaC8MSRxX4A gM2BYKCHhLn8YRfumA7hA+CY2tTFx0jSdNE9t4y9zDHCWNVL9fgzVKNaEIpwJ/6ZausV ASv65/1WApiRPfKIGA2VoGC3OfL5imAI7PtJmLfNVB2Bu31ATe1fkq0P++ZuYUpmNGky zM8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716267861; x=1716872661; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7QDbtlT09zWn+TAG8clpVDLU8Z+ZeH0+DkEI12Wz3R4=; b=PDJs/UtUEXh7njDtc/b1saaS4IPx2ousnE7rnSVaAPbPHk+O1VH+220xiO+sUX+Wik kwUzqMWKfxg+O+MMkfwkhPVcKA0YEsensMASkDN9UIOCv60xaiLTJpkgfJ6LfWlBmOX2 ogJuifbWvcb/Sb6aOqVRDXbCqoY0I4kwSbcco3jb0ChZgVoTz8nQqyU5jnu31c9MCt7Z nvGfCEZonEoXM624aewCcpFzSK8qM4YCZtAHQzTf0mTWN78g5xtp/Bt3bRa6qYdKBy0S NmglV3fznsUX9DG+UglNUYdxp6ejXztSmEvMqfLOfP9EvsWcoSB3oTZoEtEgZILBiQMr EFsQ== X-Forwarded-Encrypted: i=1; AJvYcCXk66P+F8MRA/NGwdBIDD3S+e1gidef5f40HXqFD3XNPnkb+YDJuciG/NbszQTbzL4U+nVVZvuHOuJQk9odwD+RN0VVnPHkaWu4F4XeTn+pxf1EwJyeFtRzsgHPZOLvjDVMBctnltErmNBkRcZXyuLcx8FN68KE4UnaPOMvvAsDdLfaAEtIng== X-Gm-Message-State: AOJu0YwV5Nmx/uTFsSvwgWtnjr8vVwM23LomL+YT2fa00vTH6R0eE6bn aHp47Ws8g/FQG839H9HN6uargb6uXe6b/AxzfOO06Mg+YmkLWsiYRZdRq82df4+AEBi1CoSd/Sq OWFNPz6ZODivg37rMJ+RPBmUNB27/c5lQ X-Received: by 2002:a81:4503:0:b0:61b:bd65:3025 with SMTP id 00721157ae682-622b00218bcmr305383337b3.40.1716267860942; Mon, 20 May 2024 22:04:20 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240520-exportfs-u64-mount-id-v1-1-f55fd9215b8e@cyphar.com> <20240520.221843-swanky.buyers.maroon.prison-MAgYEXR0vg7P@cyphar.com> In-Reply-To: <20240520.221843-swanky.buyers.maroon.prison-MAgYEXR0vg7P@cyphar.com> From: Amir Goldstein Date: Tue, 21 May 2024 08:04:09 +0300 Message-ID: Subject: Re: [PATCH RFC] fhandle: expose u64 mount id to name_to_handle_at(2) To: Aleksa Sarai Cc: Jeff Layton , Alexander Viro , Christian Brauner , Jan Kara , Chuck Lever , Alexander Aring , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Christian_G=C3=B6ttsche?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 21, 2024 at 1:28=E2=80=AFAM Aleksa Sarai wr= ote: > > On 2024-05-20, Jeff Layton wrote: > > On Mon, 2024-05-20 at 17:35 -0400, Aleksa Sarai wrote: > > > Now that we have stabilised the unique 64-bit mount ID interface in > > > statx, we can now provide a race-free way for name_to_handle_at(2) to > > > provide a file handle and corresponding mount without needing to worr= y > > > about racing with /proc/mountinfo parsing. Both statx() and name_to_handle_at() support AT_EMPTY_PATH, so there is a race-free way to get a file handle and unique mount id for statmount(). Why do you mean /proc/mountinfo parsing? > > > > > > As with AT_HANDLE_FID, AT_HANDLE_UNIQUE_MNT_ID reuses a statx AT_* bi= t > > > that doesn't make sense for name_to_handle_at(2). Christian is probably regretting merging AT_HANDLE_FID now ;-) Seriously, I would rearrange the AT_* flags namespace this way to explicitly declare the overloaded per-syscall AT_* flags and possibly prepare for the upcoming setxattrat(2) syscall [1]. [1] https://lore.kernel.org/linux-fsdevel/20240426162042.191916-1-cgoettsch= e@seltendoof.de/ The reason I would avoid overloading the AT_STATX_* flags is that they describe a generic behavior that could potentially be relevant to other syscalls in the future, e.g.: renameat2(..., AT_RENAME_TEMPFILE | AT_FORCE_SYNC); But then again, I don't understand why you need to extend name_to_handle_at= () at all for your purpose... Thanks, Amir. --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h [...] + +#define AT_PRIVATE_FLAGS 0x2ff /* Per-syscall flags mask. */ + +/* Common flags for *at() syscalls */ #define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. *= / -#define AT_EACCESS 0x200 /* Test access permitted for - effective IDs, not real IDs. *= / -#define AT_REMOVEDIR 0x200 /* Remove directory instead of - unlinking file. */ #define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ #define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */ #define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */ +/* Flags for statx(2) */ #define AT_STATX_SYNC_TYPE 0x6000 /* Type of synchronisation required from statx() */ #define AT_STATX_SYNC_AS_STAT 0x0000 /* - Do whatever stat() does */ #define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ [...] #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */ -/* Flags for name_to_handle_at(2). We reuse AT_ flag space to save bits...= */ -#define AT_HANDLE_FID AT_REMOVEDIR /* file handle is needed to +/* Flags for name_to_handle_at(2) */ +#define AT_HANDLE_FID 0x200 /* file handle is needed to compare object identity and may not be usable to open_by_handle_at(2) *= / +/* Flags for faccessat(2) */ +#define AT_EACCESS 0x200 /* Test access permitted for + effective IDs, not real IDs. *= / +/* Flags for unlinkat(2) */ +#define AT_REMOVEDIR 0x200 /* Remove directory instead of + unlinking file. */ + +/* Flags for renameat2(2) (should match legacy RENAME_* flags) */ +#define AT_RENAME_NOREPLACE 0x001 /* Don't overwrite target */ +#define AT_RENAME_EXCHANGE 0x002 /* Exchange source and dest */ +#define AT_RENAME_WHITEOUT 0x004 /* Whiteout source */ +#define AT_RENAME_TEMPFILE 0x008 /* Source file is O_TMPFILE */ + +/* Flags for setxattrat(2) (should match legacy XATTR_* flags) */ +#define AT_XATTR_CREATE 0x001 /* set value, fail if attr already exists */ +#define AT_XATTR_REPLACE 0x002 /* set value, fail if attr does not exist */ +