Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

expfs: Fix exportfs_can_encode_fh() for EXPORT_FH_FID

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 <brauner@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>

Jan Kara 48b77733 fd94619c

+4 -3
+4 -3
include/linux/exportfs.h
··· 320 320 static inline bool exportfs_can_encode_fh(const struct export_operations *nop, 321 321 int fh_flags) 322 322 { 323 - if (!nop) 324 - return false; 325 - 326 323 /* 327 324 * If a non-decodeable file handle was requested, we only need to make 328 325 * sure that filesystem did not opt-out of encoding fid. 329 326 */ 330 327 if (fh_flags & EXPORT_FH_FID) 331 328 return exportfs_can_encode_fid(nop); 329 + 330 + /* Normal file handles cannot be created without export ops */ 331 + if (!nop) 332 + return false; 332 333 333 334 /* 334 335 * If a connectable file handle was requested, we need to make sure that