exportfs: make ->encode_fh() a mandatory method for NFS export
Rename the default helper for encoding FILEID_INO32_GEN* file handles to generic_encode_ino32_fh() and convert the filesystems that used the default implementation to use the generic helper explicitly. After this change, exportfs_encode_inode_fh() no longer has a default implementation to encode FILEID_INO32_GEN* file handles. This is a step towards allowing filesystems to encode non-decodeable file handles for fanotify without having to implement any export_operations. Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Jeff Layton <jlayton@kernel.org> Acked-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20231023180801.2953446-3-amir73il@gmail.com Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
66c62769bc
commit
e21fc2038c
+9
-7
@@ -343,20 +343,21 @@ out:
|
||||
}
|
||||
|
||||
/**
|
||||
* export_encode_fh - default export_operations->encode_fh function
|
||||
* generic_encode_ino32_fh - generic export_operations->encode_fh function
|
||||
* @inode: the object to encode
|
||||
* @fid: where to store the file handle fragment
|
||||
* @max_len: maximum length to store there
|
||||
* @fh: where to store the file handle fragment
|
||||
* @max_len: maximum length to store there (in 4 byte units)
|
||||
* @parent: parent directory inode, if wanted
|
||||
*
|
||||
* This default encode_fh function assumes that the 32 inode number
|
||||
* This generic encode_fh function assumes that the 32 inode number
|
||||
* is suitable for locating an inode, and that the generation number
|
||||
* can be used to check that it is still valid. It places them in the
|
||||
* filehandle fragment where export_decode_fh expects to find them.
|
||||
*/
|
||||
static int export_encode_fh(struct inode *inode, struct fid *fid,
|
||||
int *max_len, struct inode *parent)
|
||||
int generic_encode_ino32_fh(struct inode *inode, __u32 *fh, int *max_len,
|
||||
struct inode *parent)
|
||||
{
|
||||
struct fid *fid = (void *)fh;
|
||||
int len = *max_len;
|
||||
int type = FILEID_INO32_GEN;
|
||||
|
||||
@@ -380,6 +381,7 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
|
||||
*max_len = len;
|
||||
return type;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(generic_encode_ino32_fh);
|
||||
|
||||
/**
|
||||
* exportfs_encode_inode_fh - encode a file handle from inode
|
||||
@@ -402,7 +404,7 @@ int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
|
||||
if (nop && nop->encode_fh)
|
||||
return nop->encode_fh(inode, fid->raw, max_len, parent);
|
||||
|
||||
return export_encode_fh(inode, fid, max_len, parent);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user