Skip to content

Commit b528782

Browse files
amir73iljankara
authored andcommitted
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 <[email protected]> Acked-by: Chuck Lever <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent f1fcbaa commit b528782

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

fs/exportfs/expfs.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,23 @@ int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
393393
}
394394
EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);
395395

396+
/**
397+
* exportfs_encode_fh - encode a file handle from dentry
398+
* @dentry: the object to encode
399+
* @fid: where to store the file handle fragment
400+
* @max_len: maximum length to store there
401+
* @flags: properties of the requested file handle
402+
*
403+
* Returns an enum fid_type or a negative errno.
404+
*/
396405
int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
397-
int connectable)
406+
int flags)
398407
{
399408
int error;
400409
struct dentry *p = NULL;
401410
struct inode *inode = dentry->d_inode, *parent = NULL;
402411

403-
if (connectable && !S_ISDIR(inode->i_mode)) {
412+
if ((flags & EXPORT_FH_CONNECTABLE) && !S_ISDIR(inode->i_mode)) {
404413
p = dget_parent(dentry);
405414
/*
406415
* note that while p might've ceased to be our parent already,

fs/nfsd/nfsfh.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,11 @@ static void _fh_update(struct svc_fh *fhp, struct svc_export *exp,
414414
struct fid *fid = (struct fid *)
415415
(fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1);
416416
int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
417-
int subtreecheck = !(exp->ex_flags & NFSEXP_NOSUBTREECHECK);
417+
int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 :
418+
EXPORT_FH_CONNECTABLE;
418419

419420
fhp->fh_handle.fh_fileid_type =
420-
exportfs_encode_fh(dentry, fid, &maxsize, subtreecheck);
421+
exportfs_encode_fh(dentry, fid, &maxsize, fh_flags);
421422
fhp->fh_handle.fh_size += maxsize * 4;
422423
} else {
423424
fhp->fh_handle.fh_fileid_type = FILEID_ROOT;

include/linux/exportfs.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ struct fid {
135135
};
136136
};
137137

138+
#define EXPORT_FH_CONNECTABLE 0x1 /* Encode file handle with parent */
139+
138140
/**
139141
* struct export_operations - for nfsd to communicate with file systems
140142
* @encode_fh: encode a file handle fragment from a dentry
@@ -150,7 +152,7 @@ struct fid {
150152
* encode_fh:
151153
* @encode_fh should store in the file handle fragment @fh (using at most
152154
* @max_len bytes) information that can be used by @decode_fh to recover the
153-
* file referred to by the &struct dentry @de. If the @connectable flag is
155+
* file referred to by the &struct dentry @de. If @flag has CONNECTABLE bit
154156
* set, the encode_fh() should store sufficient information so that a good
155157
* attempt can be made to find not only the file but also it's place in the
156158
* filesystem. This typically means storing a reference to de->d_parent in
@@ -227,7 +229,7 @@ struct export_operations {
227229
extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
228230
int *max_len, struct inode *parent);
229231
extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
230-
int *max_len, int connectable);
232+
int *max_len, int flags);
231233
extern struct dentry *exportfs_decode_fh_raw(struct vfsmount *mnt,
232234
struct fid *fid, int fh_len,
233235
int fileid_type,

0 commit comments

Comments
 (0)