Skip to contentSkip to conversation

kNFSd - 4 of 8 - Allow nfsv4 readdir to return filehandle when a mountpoint is found is a directory

PATCH New NeilBrown 1 participant 1 message Jun 17, 2003

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 kNFSd - 4 of 8 - Allow nfsv4 readdir to return filehandle when a mountpoint is found is a directory

### Comments for ChangeSet

From: "William A.(Andy) Adamson" <[email protected]>

When readdir is enumerating a directory and finds a mountpoint, it needs to do a bit of extra work to find the filehandle to be returned in the readdir reply.
It is even possible that finding the filehandle requires an up-call, so the request might be dropped to be re-tried later.

----------- Diffstat output ------------

 ./fs/nfsd/nfs4xdr.c         |   26 +++++++++++++----
 ./fs/nfsd/vfs.c             |   66 +++++++++++++++++++++++++++-----------------
 ./include/linux/nfsd/nfsd.h |    2 +
 3 files changed, 63 insertions(+), 31 deletions(-)
fs/nfsd/nfs4xdr.c renamed from fs/nfsd/nfs4xdr.c~current~ +20 -6
diff ./fs/nfsd/nfs4xdr.c~current~ ./fs/nfsd/nfs4xdr.c
@@ -1425,6 +1425,7 @@ nfsd4_encode_dirent(struct readdir_cd *c
 	u32 *p = cd->buffer;
 	u32 *attrlenp;
 	struct dentry *dentry;
+	struct svc_export *exp = cd->rd_fhp->fh_export;
 	u32 bmval0, bmval1;
 	int nfserr = 0;
 
@@ -1454,9 +1455,7 @@ nfsd4_encode_dirent(struct readdir_cd *c
 	if ((bmval0 & ~(FATTR4_WORD0_RDATTR_ERROR | FATTR4_WORD0_FILEID)) || bmval1)  {
 		/*
 		 * "Heavyweight" case: we have no choice except to
-		 * call nfsd4_encode_fattr().  As far as I know,
-		 * only Windows clients will trigger this code
-		 * path.
+		 * call nfsd4_encode_fattr(). 
 		 */
 		dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen);
 		if (IS_ERR(dentry)) {
@@ -1464,10 +1463,25 @@ nfsd4_encode_dirent(struct readdir_cd *c
 			goto error;
 		}
 
-		nfserr = nfsd4_encode_fattr(NULL, cd->rd_fhp->fh_export,
-					    dentry, p, &buflen, cd->rd_bmval);
-		dput(dentry);
+		if (d_mountpoint(dentry)) {
+			if ((nfserr = nfsd_cross_mnt(cd->rd_rqstp, &dentry, 
+					 &exp))) {	
+			/* 
+			 * -EAGAIN is the only error returned from 
+			 * nfsd_cross_mnt() and it indicates that an 
+			 * up-call has  been initiated to fill in the export 
+			 * options on exp.  When the answer comes back,
+			 * this call will be retried.
+			 */
+				dput(dentry);
+				nfserr = nfserr_dropit;
+				goto error;
+			}
 
+		}
+
+		nfserr = nfsd4_encode_fattr(NULL, exp,
+				dentry, p, &buflen, cd->rd_bmval);
 		if (!nfserr) {
 			p += buflen;
 			goto out;
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +41 -25

81 lines not on this page · raw message

include/linux/nfsd/nfsd.h renamed from include/linux/nfsd/nfsd.h~current~ +2 -0
diff ./include/linux/nfsd/nfsd.h~current~ ./include/linux/nfsd/nfsd.h
@@ -69,6 +69,8 @@ int		nfsd_dispatch(struct svc_rqst *rqst
 int		fh_lock_parent(struct svc_fh *, struct dentry *);
 int		nfsd_racache_init(int);
 void		nfsd_racache_shutdown(void);
+int		nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
+		                struct svc_export **expp);
 int		nfsd_lookup(struct svc_rqst *, struct svc_fh *,
 				const char *, int, struct svc_fh *);
 int		nfsd_setattr(struct svc_rqst *, struct svc_fh *,

-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs