From: Jan Kara Date: Wed, 1 Oct 2025 13:19:07 +0000 (+0200) Subject: expfs: Fix exportfs_can_encode_fh() for EXPORT_FH_FID X-Git-Tag: v6.17.6~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d699453de799cd33ce5d85d7631f51fc8b85b282;p=thirdparty%2Fkernel%2Fstable.git expfs: Fix exportfs_can_encode_fh() for EXPORT_FH_FID [ Upstream commit 48b77733d0dbaf8cd0a122712072f92b2d95d894 ] After commit 5402c4d4d200 ("exportfs: require ->fh_to_parent() to encode connectable file handles") we will fail to create non-decodable file handles for filesystems without export operations. Fix it. Fixes: 5402c4d4d200 ("exportfs: require ->fh_to_parent() to encode connectable file handles") Reviewed-by: Christian Brauner Reviewed-by: Amir Goldstein Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index cfb0dd1ea49c7..b80286a73d0a9 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h @@ -314,9 +314,6 @@ 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. @@ -324,6 +321,10 @@ static inline bool exportfs_can_encode_fh(const struct export_operations *nop, if (fh_flags & EXPORT_FH_FID) return exportfs_can_encode_fid(nop); + /* Normal file handles cannot be created without export ops */ + if (!nop) + return false; + /* * If a connectable file handle was requested, we need to make sure that * filesystem can also decode connected file handles.