linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Jeff Layton <jlayton@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>,  Jan Kara <jack@suse.cz>,
	Amir Goldstein <amir73il@gmail.com>,
	 Simona Vetter <simona@ffwll.ch>
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
	 Christian Brauner <brauner@kernel.org>
Subject: [PATCH v2 09/11] fhandle: add EXPORT_OP_AUTONOMOUS_HANDLES marker
Date: Tue, 24 Jun 2025 10:29:12 +0200	[thread overview]
Message-ID: <20250624-work-pidfs-fhandle-v2-9-d02a04858fe3@kernel.org> (raw)
In-Reply-To: <20250624-work-pidfs-fhandle-v2-0-d02a04858fe3@kernel.org>

Allow a filesystem to indicate that it supports encoding autonomous file
handles that can be decoded without having to pass a filesystem for the
filesystem. In other words, the file handle uniquely identifies the
filesystem.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/fhandle.c             | 7 ++++++-
 include/linux/exportfs.h | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/fhandle.c b/fs/fhandle.c
index 22edced83e4c..ab4891925b52 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -23,12 +23,13 @@ static long do_sys_name_to_handle(const struct path *path,
 	struct file_handle f_handle;
 	int handle_dwords, handle_bytes;
 	struct file_handle *handle = NULL;
+	const struct export_operations *eops = path->dentry->d_sb->s_export_op;
 
 	/*
 	 * We need to make sure whether the file system support decoding of
 	 * the file handle if decodeable file handle was requested.
 	 */
-	if (!exportfs_can_encode_fh(path->dentry->d_sb->s_export_op, fh_flags))
+	if (!exportfs_can_encode_fh(eops, fh_flags))
 		return -EOPNOTSUPP;
 
 	/*
@@ -90,6 +91,10 @@ static long do_sys_name_to_handle(const struct path *path,
 			if (d_is_dir(path->dentry))
 				handle->handle_type |= FILEID_IS_DIR;
 		}
+
+		/* Filesystems supports autonomous file handles. */
+		if (eops->flags & EXPORT_OP_AUTONOMOUS_HANDLES)
+			handle->handle_type |= FILEID_IS_AUTONOMOUS;
 		retval = 0;
 	}
 	/* copy the mount id */
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index 5bb757b51f5c..f7f9038b285e 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -188,7 +188,8 @@ struct handle_to_path_ctx {
 /* Flags supported in encoded handle_type that is exported to user */
 #define FILEID_IS_CONNECTABLE	0x10000
 #define FILEID_IS_DIR		0x20000
-#define FILEID_VALID_USER_FLAGS	(FILEID_IS_CONNECTABLE | FILEID_IS_DIR)
+#define FILEID_IS_AUTONOMOUS	0x40000
+#define FILEID_VALID_USER_FLAGS	(FILEID_IS_CONNECTABLE | FILEID_IS_DIR | FILEID_IS_AUTONOMOUS)
 
 /**
  * struct export_operations - for nfsd to communicate with file systems
@@ -285,6 +286,7 @@ struct export_operations {
 						*/
 #define EXPORT_OP_FLUSH_ON_CLOSE	(0x20) /* fs flushes file data on close */
 #define EXPORT_OP_NOLOCKS		(0x40) /* no file locking support */
+#define EXPORT_OP_AUTONOMOUS_HANDLES	(0x80) /* filesystem supports autonomous file handles */
 	unsigned long	flags;
 };
 

-- 
2.47.2


  parent reply	other threads:[~2025-06-24  8:29 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24  8:29 [PATCH v2 00/11] fhandle, pidfs: allow open_by_handle_at() purely based on file handle Christian Brauner
2025-06-24  8:29 ` [PATCH v2 01/11] fhandle: raise FILEID_IS_DIR in handle_type Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 02/11] fhandle: hoist copy_from_user() above get_path_from_fd() Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 03/11] fhandle: rename to get_path_anchor() Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 04/11] pidfs: add pidfs_root_path() helper Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 05/11] fhandle: reflow get_path_anchor() Christian Brauner
2025-06-24  9:16   ` Jan Kara
2025-06-24 10:16     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 06/11] uapi/fcntl: mark range as reserved Christian Brauner
2025-06-24  9:16   ` Jan Kara
2025-06-24 10:57   ` Amir Goldstein
2025-06-24 13:47     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 07/11] uapi/fcntl: add FD_INVALID Christian Brauner
2025-06-24  9:17   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 08/11] exportfs: add FILEID_PIDFS Christian Brauner
2025-06-24  9:17   ` Jan Kara
2025-06-24 13:15   ` Amir Goldstein
2025-06-24 13:43     ` Christian Brauner
2025-06-24 14:20       ` Amir Goldstein
2025-06-24  8:29 ` Christian Brauner [this message]
2025-06-24  9:18   ` [PATCH v2 09/11] fhandle: add EXPORT_OP_AUTONOMOUS_HANDLES marker Jan Kara
2025-06-24  9:20   ` Jan Kara
2025-06-24 10:16     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 10/11] fhandle, pidfs: support open_by_handle_at() purely based on file handle Christian Brauner
2025-06-24  9:30   ` Jan Kara
2025-06-24 10:15     ` Christian Brauner
2025-06-24 10:53     ` Amir Goldstein
2025-06-24 14:28       ` Amir Goldstein
2025-06-24 14:51         ` Christian Brauner
2025-06-24 15:07           ` Amir Goldstein
2025-06-24 15:23             ` Christian Brauner
2025-06-24 17:45               ` Jan Kara
2025-06-24 19:23               ` Amir Goldstein
2025-06-25  7:52                 ` Christian Brauner
2025-06-24 23:07   ` Al Viro
2025-06-25  7:52     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 11/11] selftests/pidfd: decode pidfd file handles withou having to specify an fd Christian Brauner
2025-06-24  9:39   ` Jan Kara
2025-06-24 10:58 ` [PATCH v2 00/11] fhandle, pidfs: allow open_by_handle_at() purely based on file handle Amir Goldstein
2025-06-24 10:59 ` Christian Brauner
2025-06-24 14:15   ` Jan Kara
2025-06-24 14:34     ` Amir Goldstein
2025-06-24 14:39     ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250624-work-pidfs-fhandle-v2-9-d02a04858fe3@kernel.org \
    --to=brauner@kernel.org \
    --cc=amir73il@gmail.com \
    --cc=chuck.lever@oracle.com \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).