From 66c62769bcf6aa142e2309278980a2e52f4b08db Mon Sep 17 00:00:00 2001 From: Amir Goldstein Date: Mon, 23 Oct 2023 21:07:58 +0300 Subject: exportfs: add helpers to check if filesystem can encode/decode file handles The logic of whether filesystem can encode/decode file handles is open coded in many places. In preparation to changing the logic, move the open coded logic into inline helpers. Reviewed-by: Jan Kara Reviewed-by: Jeff Layton Signed-off-by: Amir Goldstein Link: https://lore.kernel.org/r/20231023180801.2953446-2-amir73il@gmail.com Signed-off-by: Christian Brauner --- fs/exportfs/expfs.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'fs/exportfs') diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index c20704aa21b3..9ee205df8fa7 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c @@ -396,11 +396,7 @@ int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid, { const struct export_operations *nop = inode->i_sb->s_export_op; - /* - * If a decodeable file handle was requested, we need to make sure that - * filesystem can decode file handles. - */ - if (nop && !(flags & EXPORT_FH_FID) && !nop->fh_to_dentry) + if (!exportfs_can_encode_fh(nop, flags)) return -EOPNOTSUPP; if (nop && nop->encode_fh) @@ -456,7 +452,7 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len, /* * Try to get any dentry for the given file handle from the filesystem. */ - if (!nop || !nop->fh_to_dentry) + if (!exportfs_can_decode_fh(nop)) return ERR_PTR(-ESTALE); result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type); if (IS_ERR_OR_NULL(result)) -- cgit