Commit b5d85ce8 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: nfsd4: encode_dirent: more readdir attribute encoding to new function

Move readdir attribute encoding to nfsd4_encode_dirent_fattr(), remove
the (no-longer used) error label.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ee7bf1c3
......@@ -1769,6 +1769,46 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
goto out;
}
static int
nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd,
const char *name, int namlen, u32 *p, int *buflen)
{
struct svc_export *exp = cd->rd_fhp->fh_export;
struct dentry *dentry;
int nfserr;
dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen);
if (IS_ERR(dentry)) {
nfserr = nfserrno(PTR_ERR(dentry));
return nfserr;
}
exp_get(exp);
if (d_mountpoint(dentry)) {
if (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);
exp_put(exp);
nfserr = nfserr_dropit;
return nfserr;
}
}
nfserr = nfsd4_encode_fattr(NULL, exp,
dentry, p, buflen, cd->rd_bmval,
cd->rd_rqstp);
dput(dentry);
exp_put(exp);
return nfserr;
}
static int
nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
loff_t offset, ino_t ino, unsigned int d_type)
......@@ -1777,8 +1817,6 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
int buflen;
u32 *p = cd->buffer;
u32 *attrlenp;
struct dentry *dentry;
struct svc_export *exp = cd->rd_fhp->fh_export;
int nfserr = 0;
/* In nfsv4, "." and ".." never make it onto the wire.. */
......@@ -1802,35 +1840,7 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
/*
* Now we come to the ugly part: writing the fattr for this entry.
*/
dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen);
if (IS_ERR(dentry)) {
nfserr = nfserrno(PTR_ERR(dentry));
goto error;
}
exp_get(exp);
if (d_mountpoint(dentry)) {
if (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);
exp_put(exp);
nfserr = nfserr_dropit;
goto error;
}
}
nfserr = nfsd4_encode_fattr(NULL, exp,
dentry, p, &buflen, cd->rd_bmval,
cd->rd_rqstp);
dput(dentry);
exp_put(exp);
nfserr = nfsd4_encode_dirent_fattr(cd, name, namlen, p, &buflen);
if (!nfserr) {
p += buflen;
goto out;
......@@ -1838,7 +1848,6 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
if (nfserr == nfserr_resource)
goto nospc;
error:
/*
* If we get here, we experienced a miscellaneous
* failure while writing the attributes. If the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment