exportfs: change connectable argument to bit flags
Convert the bool connectable arguemnt into a bit flags argument and define the EXPORT_FS_CONNECTABLE flag as a requested property of the file handle. We are going to add a flag for requesting non-decodeable file handles. Acked-by: Jeff Layton <jlayton@kernel.org> Acked-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Message-Id: <20230502124817.3070545-2-amir73il@gmail.com>
This commit is contained in:
parent
f1fcbaa18b
commit
b52878275c
@ -393,14 +393,23 @@ int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);
|
EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* exportfs_encode_fh - encode a file handle from dentry
|
||||||
|
* @dentry: the object to encode
|
||||||
|
* @fid: where to store the file handle fragment
|
||||||
|
* @max_len: maximum length to store there
|
||||||
|
* @flags: properties of the requested file handle
|
||||||
|
*
|
||||||
|
* Returns an enum fid_type or a negative errno.
|
||||||
|
*/
|
||||||
int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
|
int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
|
||||||
int connectable)
|
int flags)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
struct dentry *p = NULL;
|
struct dentry *p = NULL;
|
||||||
struct inode *inode = dentry->d_inode, *parent = NULL;
|
struct inode *inode = dentry->d_inode, *parent = NULL;
|
||||||
|
|
||||||
if (connectable && !S_ISDIR(inode->i_mode)) {
|
if ((flags & EXPORT_FH_CONNECTABLE) && !S_ISDIR(inode->i_mode)) {
|
||||||
p = dget_parent(dentry);
|
p = dget_parent(dentry);
|
||||||
/*
|
/*
|
||||||
* note that while p might've ceased to be our parent already,
|
* note that while p might've ceased to be our parent already,
|
||||||
|
@ -414,10 +414,11 @@ static void _fh_update(struct svc_fh *fhp, struct svc_export *exp,
|
|||||||
struct fid *fid = (struct fid *)
|
struct fid *fid = (struct fid *)
|
||||||
(fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1);
|
(fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1);
|
||||||
int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
|
int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
|
||||||
int subtreecheck = !(exp->ex_flags & NFSEXP_NOSUBTREECHECK);
|
int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 :
|
||||||
|
EXPORT_FH_CONNECTABLE;
|
||||||
|
|
||||||
fhp->fh_handle.fh_fileid_type =
|
fhp->fh_handle.fh_fileid_type =
|
||||||
exportfs_encode_fh(dentry, fid, &maxsize, subtreecheck);
|
exportfs_encode_fh(dentry, fid, &maxsize, fh_flags);
|
||||||
fhp->fh_handle.fh_size += maxsize * 4;
|
fhp->fh_handle.fh_size += maxsize * 4;
|
||||||
} else {
|
} else {
|
||||||
fhp->fh_handle.fh_fileid_type = FILEID_ROOT;
|
fhp->fh_handle.fh_fileid_type = FILEID_ROOT;
|
||||||
|
@ -135,6 +135,8 @@ struct fid {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define EXPORT_FH_CONNECTABLE 0x1 /* Encode file handle with parent */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct export_operations - for nfsd to communicate with file systems
|
* struct export_operations - for nfsd to communicate with file systems
|
||||||
* @encode_fh: encode a file handle fragment from a dentry
|
* @encode_fh: encode a file handle fragment from a dentry
|
||||||
@ -150,7 +152,7 @@ struct fid {
|
|||||||
* encode_fh:
|
* encode_fh:
|
||||||
* @encode_fh should store in the file handle fragment @fh (using at most
|
* @encode_fh should store in the file handle fragment @fh (using at most
|
||||||
* @max_len bytes) information that can be used by @decode_fh to recover the
|
* @max_len bytes) information that can be used by @decode_fh to recover the
|
||||||
* file referred to by the &struct dentry @de. If the @connectable flag is
|
* file referred to by the &struct dentry @de. If @flag has CONNECTABLE bit
|
||||||
* set, the encode_fh() should store sufficient information so that a good
|
* set, the encode_fh() should store sufficient information so that a good
|
||||||
* attempt can be made to find not only the file but also it's place in the
|
* attempt can be made to find not only the file but also it's place in the
|
||||||
* filesystem. This typically means storing a reference to de->d_parent in
|
* filesystem. This typically means storing a reference to de->d_parent in
|
||||||
@ -227,7 +229,7 @@ struct export_operations {
|
|||||||
extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
|
extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
|
||||||
int *max_len, struct inode *parent);
|
int *max_len, struct inode *parent);
|
||||||
extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
|
extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
|
||||||
int *max_len, int connectable);
|
int *max_len, int flags);
|
||||||
extern struct dentry *exportfs_decode_fh_raw(struct vfsmount *mnt,
|
extern struct dentry *exportfs_decode_fh_raw(struct vfsmount *mnt,
|
||||||
struct fid *fid, int fh_len,
|
struct fid *fid, int fh_len,
|
||||||
int fileid_type,
|
int fileid_type,
|
||||||
|
Loading…
Reference in New Issue
Block a user