linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] exportfs: require ->fh_to_parent() to encode connectable file handles
@ 2025-05-25 10:47 Amir Goldstein
  2025-05-26 15:10 ` Jan Kara
  2025-05-30  5:31 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: Amir Goldstein @ 2025-05-25 10:47 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Jan Kara, Aleksa Sarai, Chuck Lever, Jeff Layton, linux-nfs,
	linux-fsdevel

When user requests a connectable file handle explicitly with the
AT_HANDLE_CONNECTABLE flag, fail the request if filesystem (e.g. nfs)
does not know how to decode a connected non-dir dentry.

Fixes: c374196b2b9f ("fs: name_to_handle_at() support for "explicit connectable" file handles")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 include/linux/exportfs.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Christian,

This fixes fstest failures with nfs client (re-export)
reported by Zoro [1].

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20250525053604.k466kgfcumw2s2qx@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/

diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index fc93f0abf513..25c4a5afbd44 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -314,6 +314,9 @@ static inline bool exportfs_can_decode_fh(const struct export_operations *nop)
 static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
 					  int fh_flags)
 {
+	if (!nop)
+		return false;
+
 	/*
 	 * If a non-decodeable file handle was requested, we only need to make
 	 * sure that filesystem did not opt-out of encoding fid.
@@ -321,6 +324,13 @@ static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
 	if (fh_flags & EXPORT_FH_FID)
 		return exportfs_can_encode_fid(nop);
 
+	/*
+	 * If a connectable file handle was requested, we need to make sure that
+	 * filesystem can also decode connected file handles.
+	 */
+	if ((fh_flags & EXPORT_FH_CONNECTABLE) && !nop->fh_to_parent)
+		return false;
+
 	/*
 	 * If a decodeable file handle was requested, we need to make sure that
 	 * filesystem can also decode file handles.
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] exportfs: require ->fh_to_parent() to encode connectable file handles
  2025-05-25 10:47 [PATCH] exportfs: require ->fh_to_parent() to encode connectable file handles Amir Goldstein
@ 2025-05-26 15:10 ` Jan Kara
  2025-05-30  5:31 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2025-05-26 15:10 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Christian Brauner, Jan Kara, Aleksa Sarai, Chuck Lever,
	Jeff Layton, linux-nfs, linux-fsdevel

On Sun 25-05-25 12:47:31, Amir Goldstein wrote:
> When user requests a connectable file handle explicitly with the
> AT_HANDLE_CONNECTABLE flag, fail the request if filesystem (e.g. nfs)
> does not know how to decode a connected non-dir dentry.
> 
> Fixes: c374196b2b9f ("fs: name_to_handle_at() support for "explicit connectable" file handles")
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/linux/exportfs.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> Christian,
> 
> This fixes fstest failures with nfs client (re-export)
> reported by Zoro [1].
> 
> Thanks,
> Amir.
> 
> [1] https://lore.kernel.org/fstests/20250525053604.k466kgfcumw2s2qx@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
> 
> diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
> index fc93f0abf513..25c4a5afbd44 100644
> --- a/include/linux/exportfs.h
> +++ b/include/linux/exportfs.h
> @@ -314,6 +314,9 @@ static inline bool exportfs_can_decode_fh(const struct export_operations *nop)
>  static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
>  					  int fh_flags)
>  {
> +	if (!nop)
> +		return false;
> +
>  	/*
>  	 * If a non-decodeable file handle was requested, we only need to make
>  	 * sure that filesystem did not opt-out of encoding fid.
> @@ -321,6 +324,13 @@ static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
>  	if (fh_flags & EXPORT_FH_FID)
>  		return exportfs_can_encode_fid(nop);
>  
> +	/*
> +	 * If a connectable file handle was requested, we need to make sure that
> +	 * filesystem can also decode connected file handles.
> +	 */
> +	if ((fh_flags & EXPORT_FH_CONNECTABLE) && !nop->fh_to_parent)
> +		return false;
> +
>  	/*
>  	 * If a decodeable file handle was requested, we need to make sure that
>  	 * filesystem can also decode file handles.
> -- 
> 2.34.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] exportfs: require ->fh_to_parent() to encode connectable file handles
  2025-05-25 10:47 [PATCH] exportfs: require ->fh_to_parent() to encode connectable file handles Amir Goldstein
  2025-05-26 15:10 ` Jan Kara
@ 2025-05-30  5:31 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2025-05-30  5:31 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Christian Brauner, Jan Kara, Aleksa Sarai, Chuck Lever,
	Jeff Layton, linux-nfs, linux-fsdevel

On Sun, 25 May 2025 12:47:31 +0200, Amir Goldstein wrote:
> When user requests a connectable file handle explicitly with the
> AT_HANDLE_CONNECTABLE flag, fail the request if filesystem (e.g. nfs)
> does not know how to decode a connected non-dir dentry.
> 
> 

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] exportfs: require ->fh_to_parent() to encode connectable file handles
      https://git.kernel.org/vfs/vfs/c/5402c4d4d200

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-30  5:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25 10:47 [PATCH] exportfs: require ->fh_to_parent() to encode connectable file handles Amir Goldstein
2025-05-26 15:10 ` Jan Kara
2025-05-30  5:31 ` Christian Brauner

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).