2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Process version 3 NFS requests.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/ext2_fs.h>
|
2009-01-12 03:13:53 +08:00
|
|
|
#include <linux/magic.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-12-04 02:30:56 +08:00
|
|
|
#include "cache.h"
|
|
|
|
#include "xdr3.h"
|
2009-11-05 07:12:35 +08:00
|
|
|
#include "vfs.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define NFSDDBG_FACILITY NFSDDBG_PROC
|
|
|
|
|
|
|
|
#define RETURN_STATUS(st) { resp->status = (st); return (st); }
|
|
|
|
|
|
|
|
static int nfs3_ftypes[] = {
|
|
|
|
0, /* NF3NON */
|
|
|
|
S_IFREG, /* NF3REG */
|
|
|
|
S_IFDIR, /* NF3DIR */
|
|
|
|
S_IFBLK, /* NF3BLK */
|
|
|
|
S_IFCHR, /* NF3CHR */
|
|
|
|
S_IFLNK, /* NF3LNK */
|
|
|
|
S_IFSOCK, /* NF3SOCK */
|
|
|
|
S_IFIFO, /* NF3FIFO */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NULL call.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_null(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return nfs_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a file's attributes
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_getattr(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: GETATTR(3) %s\n",
|
2006-01-06 16:19:58 +08:00
|
|
|
SVCFH_fmt(&argp->fh));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
2008-08-08 01:00:20 +08:00
|
|
|
nfserr = fh_verify(rqstp, &resp->fh, 0,
|
|
|
|
NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
|
2006-01-06 16:19:58 +08:00
|
|
|
if (nfserr)
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
|
2013-01-24 15:18:08 +08:00
|
|
|
nfserr = fh_getattr(&resp->fh, &resp->stat);
|
2006-01-06 16:19:58 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a file's attributes
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_setattr(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_sattrargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: SETATTR(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
|
|
|
|
argp->check_guard, argp->guardtime);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look up a path name component
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_lookup(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_diropargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: LOOKUP(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
|
|
|
|
nfserr = nfsd_lookup(rqstp, &resp->dirfh,
|
|
|
|
argp->name,
|
|
|
|
argp->len,
|
|
|
|
&resp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check file access
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_access(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_accessargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_accessres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: ACCESS(3) %s 0x%x\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->access);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
resp->access = argp->access;
|
|
|
|
nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a symlink.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_readlink(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_readlinkargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readlinkres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
|
|
|
|
|
|
|
|
/* Read the symlink. */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
resp->len = NFS3_MAXPATHLEN;
|
|
|
|
nfserr = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a portion of a file.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_read(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_readargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2006-10-04 17:15:47 +08:00
|
|
|
u32 max_blocksize = svc_max_payload(rqstp);
|
2016-03-22 22:28:36 +08:00
|
|
|
unsigned long cnt = min(argp->count, max_blocksize);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-30 04:28:10 +08:00
|
|
|
dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
(unsigned long) argp->count,
|
2010-11-30 04:28:10 +08:00
|
|
|
(unsigned long long) argp->offset);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Obtain buffer pointer for payload.
|
|
|
|
* 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
|
|
|
|
* + 1 (xdr opaque byte count) = 26
|
|
|
|
*/
|
2016-03-22 22:28:36 +08:00
|
|
|
resp->count = cnt;
|
2007-05-09 17:34:50 +08:00
|
|
|
svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
2010-07-30 23:33:32 +08:00
|
|
|
nfserr = nfsd_read(rqstp, &resp->fh,
|
2005-04-17 06:20:36 +08:00
|
|
|
argp->offset,
|
2006-10-04 17:15:47 +08:00
|
|
|
rqstp->rq_vec, argp->vlen,
|
2005-04-17 06:20:36 +08:00
|
|
|
&resp->count);
|
|
|
|
if (nfserr == 0) {
|
2015-03-18 06:25:59 +08:00
|
|
|
struct inode *inode = d_inode(resp->fh.fh_dentry);
|
2016-03-22 22:28:36 +08:00
|
|
|
resp->eof = nfsd_eof_on_read(cnt, resp->count, argp->offset,
|
|
|
|
inode->i_size);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write data to a file
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_write(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_writeargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_writeres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2009-03-06 09:16:14 +08:00
|
|
|
unsigned long cnt = argp->len;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-11-30 04:28:10 +08:00
|
|
|
dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
2010-11-30 04:28:10 +08:00
|
|
|
(unsigned long long) argp->offset,
|
2005-04-17 06:20:36 +08:00
|
|
|
argp->stable? " stable" : "");
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
resp->committed = argp->stable;
|
2016-12-31 21:00:13 +08:00
|
|
|
nfserr = nfsd_write(rqstp, &resp->fh, argp->offset,
|
|
|
|
rqstp->rq_vec, argp->vlen,
|
|
|
|
&cnt, resp->committed);
|
2009-03-06 09:16:14 +08:00
|
|
|
resp->count = cnt;
|
2005-04-17 06:20:36 +08:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* With NFSv3, CREATE processing is a lot easier than with NFSv2.
|
|
|
|
* At least in theory; we'll see how it fares in practice when the
|
|
|
|
* first reports about SunOS compatibility problems start to pour in...
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_create(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_createargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2005-04-17 06:20:36 +08:00
|
|
|
svc_fh *dirfhp, *newfhp = NULL;
|
|
|
|
struct iattr *attr;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: CREATE(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
dirfhp = fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
attr = &argp->attrs;
|
|
|
|
|
|
|
|
/* Unfudge the mode bits */
|
|
|
|
attr->ia_mode &= ~S_IFMT;
|
|
|
|
if (!(attr->ia_valid & ATTR_MODE)) {
|
|
|
|
attr->ia_valid |= ATTR_MODE;
|
|
|
|
attr->ia_mode = S_IFREG;
|
|
|
|
} else {
|
|
|
|
attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now create the file and set attributes */
|
2011-04-20 17:06:25 +08:00
|
|
|
nfserr = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len,
|
2005-04-17 06:20:36 +08:00
|
|
|
attr, newfhp,
|
2012-07-28 03:50:11 +08:00
|
|
|
argp->createmode, (u32 *)argp->verf, NULL, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make directory. This operation is not idempotent.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_mkdir(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_createargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: MKDIR(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
argp->attrs.ia_valid &= ~ATTR_SIZE;
|
|
|
|
fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
|
|
|
|
&argp->attrs, S_IFDIR, 0, &resp->fh);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-07 04:53:34 +08:00
|
|
|
fh_unlock(&resp->dirfh);
|
2005-04-17 06:20:36 +08:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_symlink(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->ffh),
|
|
|
|
argp->flen, argp->fname,
|
|
|
|
argp->tlen, argp->tname);
|
|
|
|
|
|
|
|
fh_copy(&resp->dirfh, &argp->ffh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
nfserr = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, argp->flen,
|
2014-07-01 17:48:02 +08:00
|
|
|
argp->tname, &resp->fh);
|
2005-04-17 06:20:36 +08:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make socket/fifo/device.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_mknod(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_mknodargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
|
|
|
int type;
|
2005-04-17 06:20:36 +08:00
|
|
|
dev_t rdev = 0;
|
|
|
|
|
|
|
|
dprintk("nfsd: MKNOD(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
|
|
|
|
if (argp->ftype == 0 || argp->ftype >= NF3BAD)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
|
|
|
|
rdev = MKDEV(argp->major, argp->minor);
|
|
|
|
if (MAJOR(rdev) != argp->major ||
|
|
|
|
MINOR(rdev) != argp->minor)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
} else
|
|
|
|
if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
|
|
|
|
type = nfs3_ftypes[argp->ftype];
|
|
|
|
nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
|
|
|
|
&argp->attrs, type, rdev, &resp->fh);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-07 04:53:34 +08:00
|
|
|
fh_unlock(&resp->dirfh);
|
2005-04-17 06:20:36 +08:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove file/fifo/socket etc.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_remove(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_diropargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: REMOVE(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
/* Unlink. -S_IFDIR means file must not be a directory */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-07 04:53:34 +08:00
|
|
|
fh_unlock(&resp->fh);
|
2005-04-17 06:20:36 +08:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a directory
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_rmdir(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_diropargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: RMDIR(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-07 04:53:34 +08:00
|
|
|
fh_unlock(&resp->fh);
|
2005-04-17 06:20:36 +08:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_rename(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_renameargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_renameres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: RENAME(3) %s %.*s ->\n",
|
|
|
|
SVCFH_fmt(&argp->ffh),
|
|
|
|
argp->flen,
|
|
|
|
argp->fname);
|
|
|
|
dprintk("nfsd: -> %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->tfh),
|
|
|
|
argp->tlen,
|
|
|
|
argp->tname);
|
|
|
|
|
|
|
|
fh_copy(&resp->ffh, &argp->ffh);
|
|
|
|
fh_copy(&resp->tfh, &argp->tfh);
|
|
|
|
nfserr = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
|
|
|
|
&resp->tfh, argp->tname, argp->tlen);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_link(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_linkargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_linkres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: LINK(3) %s ->\n",
|
|
|
|
SVCFH_fmt(&argp->ffh));
|
|
|
|
dprintk("nfsd: -> %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->tfh),
|
|
|
|
argp->tlen,
|
|
|
|
argp->tname);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->ffh);
|
|
|
|
fh_copy(&resp->tfh, &argp->tfh);
|
|
|
|
nfserr = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
|
|
|
|
&resp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a portion of a directory.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_readdir(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_readdirargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readdirres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
|
|
|
int count;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->count, (u32) argp->cookie);
|
|
|
|
|
|
|
|
/* Make sure we've room for the NULL ptr & eof flag, and shrink to
|
|
|
|
* client read size */
|
|
|
|
count = (argp->count >> 2) - 2;
|
|
|
|
|
|
|
|
/* Read directory and encode entries on the fly */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
|
|
|
|
resp->buflen = count;
|
|
|
|
resp->common.err = nfs_ok;
|
|
|
|
resp->buffer = argp->buffer;
|
|
|
|
resp->rqstp = rqstp;
|
|
|
|
nfserr = nfsd_readdir(rqstp, &resp->fh, (loff_t*) &argp->cookie,
|
|
|
|
&resp->common, nfs3svc_encode_entry);
|
|
|
|
memcpy(resp->verf, argp->verf, 8);
|
|
|
|
resp->count = resp->buffer - argp->buffer;
|
|
|
|
if (resp->offset)
|
|
|
|
xdr_encode_hyper(resp->offset, argp->cookie);
|
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a portion of a directory, including file handles and attrs.
|
|
|
|
* For now, we choose to ignore the dircount parameter.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_readdirargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readdirres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
|
|
|
int count = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
loff_t offset;
|
2012-12-11 07:01:37 +08:00
|
|
|
struct page **p;
|
2005-04-17 06:20:36 +08:00
|
|
|
caddr_t page_addr = NULL;
|
|
|
|
|
|
|
|
dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->count, (u32) argp->cookie);
|
|
|
|
|
|
|
|
/* Convert byte count to number of words (i.e. >> 2),
|
|
|
|
* and reserve room for the NULL ptr & eof flag (-2 words) */
|
|
|
|
resp->count = (argp->count >> 2) - 2;
|
|
|
|
|
|
|
|
/* Read directory and encode entries on the fly */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
|
|
|
|
resp->common.err = nfs_ok;
|
|
|
|
resp->buffer = argp->buffer;
|
|
|
|
resp->buflen = resp->count;
|
|
|
|
resp->rqstp = rqstp;
|
|
|
|
offset = argp->cookie;
|
nfsd: allow turning off nfsv3 readdir_plus
One of our customer's application only needs file names, not file
attributes. With directories having 10K+ inodes (assuming buffer cache
has directory blocks cached having file names, but inode cache is
limited and hence need eviction of older cached inodes), older inodes
are evicted periodically. So if they keep on doing readdir(2) from NSF
client on multiple directories, some directory's files are periodically
removed from inode cache and hence new readdir(2) on same directory
requires disk access to bring back inodes again to inode cache.
As READDIRPLUS request fetches attributes also, doing getattr on each
file on server, it causes unnecessary disk accesses. If READDIRPLUS on
NFS client is returned with -ENOTSUPP, NFS client uses READDIR request
which just gets the names of the files in a directory, not attributes,
hence avoiding disk accesses on server.
There's already a corresponding client-side mount option, but an export
option reduces the need for configuration across multiple clients.
This flag affects NFSv3 only. If it turns out it's needed for NFSv4 as
well then we may have to figure out how to extend the behavior to NFSv4,
but it's not currently obvious how to do that.
Signed-off-by: Rajesh Ghanekar <rajesh_ghanekar@symantec.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2014-08-02 10:17:30 +08:00
|
|
|
|
|
|
|
nfserr = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
|
|
|
|
if (nfserr)
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
|
|
|
|
if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS)
|
|
|
|
RETURN_STATUS(nfserr_notsupp);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
nfserr = nfsd_readdir(rqstp, &resp->fh,
|
|
|
|
&offset,
|
|
|
|
&resp->common,
|
|
|
|
nfs3svc_encode_entry_plus);
|
|
|
|
memcpy(resp->verf, argp->verf, 8);
|
2012-12-11 07:01:37 +08:00
|
|
|
for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
|
|
|
|
page_addr = page_address(*p);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (((caddr_t)resp->buffer >= page_addr) &&
|
|
|
|
((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
|
|
|
|
count += (caddr_t)resp->buffer - page_addr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
count += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
resp->count = count >> 2;
|
|
|
|
if (resp->offset) {
|
|
|
|
if (unlikely(resp->offset1)) {
|
|
|
|
/* we ended up with offset on a page boundary */
|
|
|
|
*resp->offset = htonl(offset >> 32);
|
|
|
|
*resp->offset1 = htonl(offset & 0xffffffff);
|
|
|
|
resp->offset1 = NULL;
|
|
|
|
} else {
|
|
|
|
xdr_encode_hyper(resp->offset, offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get file system stats
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_fsstat(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_fsstatres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: FSSTAT(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
2008-08-08 01:00:20 +08:00
|
|
|
nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
fh_put(&argp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get file system info
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_fsinfores *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2006-10-04 17:15:47 +08:00
|
|
|
u32 max_blocksize = svc_max_payload(rqstp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: FSINFO(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
2006-10-04 17:15:47 +08:00
|
|
|
resp->f_rtmax = max_blocksize;
|
|
|
|
resp->f_rtpref = max_blocksize;
|
2005-04-17 06:20:36 +08:00
|
|
|
resp->f_rtmult = PAGE_SIZE;
|
2006-10-04 17:15:47 +08:00
|
|
|
resp->f_wtmax = max_blocksize;
|
|
|
|
resp->f_wtpref = max_blocksize;
|
2005-04-17 06:20:36 +08:00
|
|
|
resp->f_wtmult = PAGE_SIZE;
|
|
|
|
resp->f_dtpref = PAGE_SIZE;
|
|
|
|
resp->f_maxfilesize = ~(u32) 0;
|
|
|
|
resp->f_properties = NFS3_FSF_DEFAULT;
|
|
|
|
|
2008-08-08 01:00:20 +08:00
|
|
|
nfserr = fh_verify(rqstp, &argp->fh, 0,
|
|
|
|
NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Check special features of the file system. May request
|
|
|
|
* different read/write sizes for file systems known to have
|
|
|
|
* problems with large blocks */
|
|
|
|
if (nfserr == 0) {
|
2016-04-10 13:33:30 +08:00
|
|
|
struct super_block *sb = argp->fh.fh_dentry->d_sb;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Note that we don't care for remote fs's here */
|
2009-01-12 03:13:53 +08:00
|
|
|
if (sb->s_magic == MSDOS_SUPER_MAGIC) {
|
2005-04-17 06:20:36 +08:00
|
|
|
resp->f_properties = NFS3_FSF_BILLYBOY;
|
|
|
|
}
|
|
|
|
resp->f_maxfilesize = sb->s_maxbytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
fh_put(&argp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get pathconf info for the specified file
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_pathconf(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_pathconfres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: PATHCONF(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
|
|
|
/* Set default pathconf */
|
|
|
|
resp->p_link_max = 255; /* at least */
|
|
|
|
resp->p_name_max = 255; /* at least */
|
|
|
|
resp->p_no_trunc = 0;
|
|
|
|
resp->p_chown_restricted = 1;
|
|
|
|
resp->p_case_insensitive = 0;
|
|
|
|
resp->p_case_preserving = 1;
|
|
|
|
|
2008-06-16 19:20:29 +08:00
|
|
|
nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (nfserr == 0) {
|
2016-04-10 13:33:30 +08:00
|
|
|
struct super_block *sb = argp->fh.fh_dentry->d_sb;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Note that we don't care for remote fs's here */
|
|
|
|
switch (sb->s_magic) {
|
|
|
|
case EXT2_SUPER_MAGIC:
|
|
|
|
resp->p_link_max = EXT2_LINK_MAX;
|
|
|
|
resp->p_name_max = EXT2_NAME_LEN;
|
|
|
|
break;
|
2009-01-12 03:13:53 +08:00
|
|
|
case MSDOS_SUPER_MAGIC:
|
2005-04-17 06:20:36 +08:00
|
|
|
resp->p_case_insensitive = 1;
|
|
|
|
resp->p_case_preserving = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fh_put(&argp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Commit a file (range) to stable storage.
|
|
|
|
*/
|
2006-10-20 14:28:45 +08:00
|
|
|
static __be32
|
2017-05-08 23:35:49 +08:00
|
|
|
nfsd3_proc_commit(struct svc_rqst *rqstp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-05-08 23:35:49 +08:00
|
|
|
struct nfsd3_commitargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_commitres *resp = rqstp->rq_resp;
|
2006-10-20 14:29:00 +08:00
|
|
|
__be32 nfserr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->count,
|
|
|
|
(unsigned long long) argp->offset);
|
|
|
|
|
|
|
|
if (argp->offset > NFS_OFFSET_MAX)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count);
|
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NFSv3 Server procedures.
|
|
|
|
* Only the results of non-idempotent operations are cached.
|
|
|
|
*/
|
|
|
|
#define nfs3svc_decode_fhandleargs nfs3svc_decode_fhandle
|
|
|
|
#define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
|
|
|
|
#define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
|
|
|
|
#define nfsd3_mkdirargs nfsd3_createargs
|
|
|
|
#define nfsd3_readdirplusargs nfsd3_readdirargs
|
|
|
|
#define nfsd3_fhandleargs nfsd_fhandle
|
|
|
|
#define nfsd3_fhandleres nfsd3_attrstat
|
|
|
|
#define nfsd3_attrstatres nfsd3_attrstat
|
|
|
|
#define nfsd3_wccstatres nfsd3_attrstat
|
|
|
|
#define nfsd3_createres nfsd3_diropres
|
|
|
|
#define nfsd3_voidres nfsd3_voidargs
|
|
|
|
struct nfsd3_voidargs { int dummy; };
|
|
|
|
|
|
|
|
#define ST 1 /* status*/
|
|
|
|
#define FH 17 /* filehandle with length */
|
|
|
|
#define AT 21 /* attributes */
|
|
|
|
#define pAT (1+AT) /* post attributes - conditional */
|
|
|
|
#define WC (7+pAT) /* WCC attributes */
|
|
|
|
|
2017-05-12 22:11:49 +08:00
|
|
|
static const struct svc_procedure nfsd_procedures3[22] = {
|
2009-06-09 17:33:34 +08:00
|
|
|
[NFS3PROC_NULL] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_null,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_voidres,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_voidargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_voidres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST,
|
|
|
|
},
|
|
|
|
[NFS3PROC_GETATTR] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_getattr,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_attrstatres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_attrstatres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+AT,
|
|
|
|
},
|
|
|
|
[NFS3PROC_SETATTR] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_setattr,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_sattrargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_wccstatres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_sattrargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_wccstatres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_LOOKUP] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_lookup,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_diropargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_diropres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_diropargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_diropres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+FH+pAT+pAT,
|
|
|
|
},
|
|
|
|
[NFS3PROC_ACCESS] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_access,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_accessargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_accessres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_accessargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_accessres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+1,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READLINK] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_readlink,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_readlinkargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_readlinkres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readlinkargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readlinkres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READ] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_read,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_readargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_readres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
|
|
|
|
},
|
|
|
|
[NFS3PROC_WRITE] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_write,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_writeargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_writeres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_writeargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_writeres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC+4,
|
|
|
|
},
|
|
|
|
[NFS3PROC_CREATE] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_create,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_createargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_createargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_MKDIR] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_mkdir,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_mkdirargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_mkdirargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_SYMLINK] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_symlink,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_symlinkargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_symlinkargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_MKNOD] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_mknod,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_mknodargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_mknodargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_REMOVE] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_remove,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_diropargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_wccstatres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_diropargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_wccstatres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_RMDIR] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_rmdir,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_diropargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_wccstatres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_diropargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_wccstatres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_RENAME] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_rename,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_renameargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_renameres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_renameargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_renameres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_LINK] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_link,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_linkargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_linkres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_linkargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_linkres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+pAT+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READDIR] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_readdir,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_readdirargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_readdirres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readdirargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readdirres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READDIRPLUS] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_readdirplus,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_readdirplusargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_readdirres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readdirplusargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readdirres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
},
|
|
|
|
[NFS3PROC_FSSTAT] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_fsstat,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_fsstatres,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_fsstatres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+2*6+1,
|
|
|
|
},
|
|
|
|
[NFS3PROC_FSINFO] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_fsinfo,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_fsinfores,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_fsinfores),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+12,
|
|
|
|
},
|
|
|
|
[NFS3PROC_PATHCONF] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_pathconf,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_pathconfres,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_pathconfres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+6,
|
|
|
|
},
|
|
|
|
[NFS3PROC_COMMIT] = {
|
2017-05-08 23:35:49 +08:00
|
|
|
.pc_func = nfsd3_proc_commit,
|
2017-05-09 01:01:48 +08:00
|
|
|
.pc_decode = nfs3svc_decode_commitargs,
|
2017-05-09 01:42:02 +08:00
|
|
|
.pc_encode = nfs3svc_encode_commitres,
|
2017-05-09 00:48:24 +08:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 17:33:34 +08:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_commitargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_commitres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+WC+2,
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2017-05-09 05:40:27 +08:00
|
|
|
static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
|
2017-05-12 22:21:37 +08:00
|
|
|
const struct svc_version nfsd_version3 = {
|
|
|
|
.vs_vers = 3,
|
|
|
|
.vs_nproc = 22,
|
|
|
|
.vs_proc = nfsd_procedures3,
|
|
|
|
.vs_dispatch = nfsd_dispatch,
|
|
|
|
.vs_count = nfsd_count3,
|
|
|
|
.vs_xdrsize = NFS3_SVC_XDRSIZE,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|