Commit 7b9edd50 authored by Trond Myklebust's avatar Trond Myklebust Committed by Linus Torvalds

[PATCH] cleanup: switch to passing *(struct rpc_procinfo) in rpc_message.

The "procedure number" has been used for 2 purposes in the kernel
client RPC implementation:

  1) As a number to pass to the server in the RPC header.

  2) As an index into the "procedure array" of type 'struct
     rpc_procinfo', from which the RPC layer can find the XDR
     encode/decode functions, buffer size, and all the other static
     data that it needs to construct the on-wire RPC message.

This works fine for NFSv2, v3 and for the NLM locking code for which
there is a one-to-one mapping between NFS file operations, and RPC
procedures.
For NFSv4 on the other hand, the mapping is many-to-one, since there
is only one RPC procedure number: NFSPROC4_COMPOUND.

For efficiency purposes, we want to have a one-to-one mapping between
NFS file operations and the corresponding XDR encode/decode routines,
but currently this is not possible because of (2). The result is the
mess that is 'struct nfs4_op' and encode/decode_compound.

In the process eliminating (2), we might as well change to passing a
pointer to the appropriate procedure array entry instead of an
index. This change can be made transparent

The appended patch therefore does the following:

   - Substitute a pointer to the rpc_procinfo instead of the RPC
     procedure number in the struct rpc_message.
   - Make the RPC procedure number an entry in the struct
     rpc_procinfo.
   - Clean out the largely unused (except in some obscure lockd
     debugging code) p_name field. The latter was just a stringified
     version of the RPC procedure name, so for those lockd cases, we
     can use the RPC procedure number instead.
parent b29cd7df
...@@ -241,19 +241,17 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc) ...@@ -241,19 +241,17 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc)
struct nlm_args *argp = &req->a_args; struct nlm_args *argp = &req->a_args;
struct nlm_res *resp = &req->a_res; struct nlm_res *resp = &req->a_res;
struct file *filp = argp->lock.fl.fl_file; struct file *filp = argp->lock.fl.fl_file;
struct rpc_message msg; struct rpc_message msg = {
.rpc_argp = argp,
.rpc_resp = resp,
};
int status; int status;
dprintk("lockd: call procedure %s on %s\n", dprintk("lockd: call procedure %d on %s\n",
nlm_procname(proc), host->h_name); (int)proc, host->h_name);
msg.rpc_proc = proc;
msg.rpc_argp = argp;
msg.rpc_resp = resp;
if (filp) if (filp)
msg.rpc_cred = nfs_file_cred(filp); msg.rpc_cred = nfs_file_cred(filp);
else
msg.rpc_cred = NULL;
do { do {
if (host->h_reclaiming && !argp->reclaim) { if (host->h_reclaiming && !argp->reclaim) {
...@@ -264,6 +262,7 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc) ...@@ -264,6 +262,7 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc)
/* If we have no RPC client yet, create one. */ /* If we have no RPC client yet, create one. */
if ((clnt = nlm_bind_host(host)) == NULL) if ((clnt = nlm_bind_host(host)) == NULL)
return -ENOLCK; return -ENOLCK;
msg.rpc_proc = &clnt->cl_procinfo[proc];
/* Perform the RPC call. If an error occurs, try again */ /* Perform the RPC call. If an error occurs, try again */
if ((status = rpc_call_sync(clnt, &msg, 0)) < 0) { if ((status = rpc_call_sync(clnt, &msg, 0)) < 0) {
...@@ -321,23 +320,21 @@ nlmsvc_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback) ...@@ -321,23 +320,21 @@ nlmsvc_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback)
{ {
struct nlm_host *host = req->a_host; struct nlm_host *host = req->a_host;
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
struct nlm_args *argp = &req->a_args; struct rpc_message msg = {
struct nlm_res *resp = &req->a_res; .rpc_argp = &req->a_args,
struct rpc_message msg; .rpc_resp = &req->a_res,
};
int status; int status;
dprintk("lockd: call procedure %s on %s (async)\n", dprintk("lockd: call procedure %d on %s (async)\n",
nlm_procname(proc), host->h_name); (int)proc, host->h_name);
/* If we have no RPC client yet, create one. */ /* If we have no RPC client yet, create one. */
if ((clnt = nlm_bind_host(host)) == NULL) if ((clnt = nlm_bind_host(host)) == NULL)
return -ENOLCK; return -ENOLCK;
msg.rpc_proc = &clnt->cl_procinfo[proc];
/* bootstrap and kick off the async RPC call */ /* bootstrap and kick off the async RPC call */
msg.rpc_proc = proc;
msg.rpc_argp = argp;
msg.rpc_resp =resp;
msg.rpc_cred = NULL;
status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req); status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req);
return status; return status;
...@@ -351,24 +348,23 @@ nlmclnt_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback) ...@@ -351,24 +348,23 @@ nlmclnt_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback)
struct nlm_args *argp = &req->a_args; struct nlm_args *argp = &req->a_args;
struct nlm_res *resp = &req->a_res; struct nlm_res *resp = &req->a_res;
struct file *file = argp->lock.fl.fl_file; struct file *file = argp->lock.fl.fl_file;
struct rpc_message msg; struct rpc_message msg = {
.rpc_argp = argp,
.rpc_resp = resp,
};
int status; int status;
dprintk("lockd: call procedure %s on %s (async)\n", dprintk("lockd: call procedure %d on %s (async)\n",
nlm_procname(proc), host->h_name); (int)proc, host->h_name);
/* If we have no RPC client yet, create one. */ /* If we have no RPC client yet, create one. */
if ((clnt = nlm_bind_host(host)) == NULL) if ((clnt = nlm_bind_host(host)) == NULL)
return -ENOLCK; return -ENOLCK;
msg.rpc_proc = &clnt->cl_procinfo[proc];
/* bootstrap and kick off the async RPC call */ /* bootstrap and kick off the async RPC call */
msg.rpc_proc = proc;
msg.rpc_argp = argp;
msg.rpc_resp =resp;
if (file) if (file)
msg.rpc_cred = nfs_file_cred(file); msg.rpc_cred = nfs_file_cred(file);
else
msg.rpc_cred = NULL;
/* Increment host refcount */ /* Increment host refcount */
nlm_get_host(host); nlm_get_host(host);
status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req); status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req);
......
...@@ -134,11 +134,6 @@ nsm_create(void) ...@@ -134,11 +134,6 @@ nsm_create(void)
/* /*
* XDR functions for NSM. * XDR functions for NSM.
*/ */
static int
xdr_error(struct rpc_rqst *rqstp, u32 *p, void *dummy)
{
return -EACCES;
}
static int static int
xdr_encode_mon(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp) xdr_encode_mon(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp)
...@@ -206,43 +201,18 @@ xdr_decode_stat(struct rpc_rqst *rqstp, u32 *p, struct nsm_res *resp) ...@@ -206,43 +201,18 @@ xdr_decode_stat(struct rpc_rqst *rqstp, u32 *p, struct nsm_res *resp)
#endif #endif
static struct rpc_procinfo nsm_procedures[] = { static struct rpc_procinfo nsm_procedures[] = {
{ [SM_MON] = {
.p_procname = "sm_null", .p_proc = SM_MON,
.p_encode = (kxdrproc_t) xdr_error,
.p_decode = (kxdrproc_t) xdr_error,
},
{
.p_procname = "sm_stat",
.p_encode = (kxdrproc_t) xdr_error,
.p_decode = (kxdrproc_t) xdr_error,
},
{
.p_procname = "sm_mon",
.p_encode = (kxdrproc_t) xdr_encode_mon, .p_encode = (kxdrproc_t) xdr_encode_mon,
.p_decode = (kxdrproc_t) xdr_decode_stat_res, .p_decode = (kxdrproc_t) xdr_decode_stat_res,
.p_bufsiz = MAX(SM_mon_sz, SM_monres_sz) << 2, .p_bufsiz = MAX(SM_mon_sz, SM_monres_sz) << 2,
}, },
{ [SM_UNMON] = {
.p_procname = "sm_unmon", .p_proc = SM_UNMON,
.p_encode = (kxdrproc_t) xdr_encode_mon, .p_encode = (kxdrproc_t) xdr_encode_mon,
.p_decode = (kxdrproc_t) xdr_decode_stat, .p_decode = (kxdrproc_t) xdr_decode_stat,
.p_bufsiz = MAX(SM_mon_id_sz, SM_unmonres_sz) << 2, .p_bufsiz = MAX(SM_mon_id_sz, SM_unmonres_sz) << 2,
}, },
{
.p_procname = "sm_unmon_all",
.p_encode = (kxdrproc_t) xdr_error,
.p_decode = (kxdrproc_t) xdr_error,
},
{
.p_procname = "sm_simu_crash",
.p_encode = (kxdrproc_t) xdr_error,
.p_decode = (kxdrproc_t) xdr_error,
},
{
.p_procname = "sm_notify",
.p_encode = (kxdrproc_t) xdr_error,
.p_decode = (kxdrproc_t) xdr_error,
},
}; };
static struct rpc_version nsm_version1 = { static struct rpc_version nsm_version1 = {
......
...@@ -544,43 +544,34 @@ nlmclt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) ...@@ -544,43 +544,34 @@ nlmclt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
#define nlmclt_decode_norep NULL #define nlmclt_decode_norep NULL
#define PROC(proc, argtype, restype) \ #define PROC(proc, argtype, restype) \
{ .p_procname = "nlm_" #proc, \ [NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
.p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \ .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \
.p_decode = (kxdrproc_t) nlmclt_decode_##restype, \ .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \
.p_bufsiz = MAX(NLM_##argtype##_sz, NLM_##restype##_sz) << 2 \ .p_bufsiz = MAX(NLM_##argtype##_sz, NLM_##restype##_sz) << 2 \
} }
static struct rpc_procinfo nlm_procedures[] = { static struct rpc_procinfo nlm_procedures[] = {
PROC(null, void, void), PROC(TEST, testargs, testres),
PROC(test, testargs, testres), PROC(LOCK, lockargs, res),
PROC(lock, lockargs, res), PROC(CANCEL, cancargs, res),
PROC(canc, cancargs, res), PROC(UNLOCK, unlockargs, res),
PROC(unlock, unlockargs, res), PROC(GRANTED, testargs, res),
PROC(granted, testargs, res), PROC(TEST_MSG, testargs, norep),
PROC(test_msg, testargs, norep), PROC(LOCK_MSG, lockargs, norep),
PROC(lock_msg, lockargs, norep), PROC(CANCEL_MSG, cancargs, norep),
PROC(canc_msg, cancargs, norep), PROC(UNLOCK_MSG, unlockargs, norep),
PROC(unlock_msg, unlockargs, norep), PROC(GRANTED_MSG, testargs, norep),
PROC(granted_msg, testargs, norep), PROC(TEST_RES, testres, norep),
PROC(test_res, testres, norep), PROC(LOCK_RES, res, norep),
PROC(lock_res, res, norep), PROC(CANCEL_RES, res, norep),
PROC(canc_res, res, norep), PROC(UNLOCK_RES, res, norep),
PROC(unlock_res, res, norep), PROC(GRANTED_RES, res, norep),
PROC(granted_res, res, norep),
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
#ifdef NLMCLNT_SUPPORT_SHARES #ifdef NLMCLNT_SUPPORT_SHARES
PROC(share, shareargs, shareres), PROC(SHARE, shareargs, shareres),
PROC(unshare, shareargs, shareres), PROC(UNSHARE, shareargs, shareres),
PROC(nm_lock, lockargs, res), PROC(NM_LOCK, lockargs, res),
PROC(free_all, notify, void), PROC(FREE_ALL, notify, void),
#else
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
#endif #endif
}; };
...@@ -618,13 +609,3 @@ struct rpc_program nlm_program = { ...@@ -618,13 +609,3 @@ struct rpc_program nlm_program = {
.stats = &nlm_stats, .stats = &nlm_stats,
}; };
#ifdef LOCKD_DEBUG
char *
nlm_procname(u32 proc)
{
if (proc < sizeof(nlm_procedures)/sizeof(nlm_procedures[0]))
return nlm_procedures[proc].p_procname;
return "unknown";
}
#endif
...@@ -547,43 +547,34 @@ nlm4clt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) ...@@ -547,43 +547,34 @@ nlm4clt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
#define nlm4clt_decode_norep NULL #define nlm4clt_decode_norep NULL
#define PROC(proc, argtype, restype) \ #define PROC(proc, argtype, restype) \
{ .p_procname = "nlm4_" #proc, \ [NLMPROC_##proc] = { \
.p_proc = NLMPROC_##proc, \
.p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \ .p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \
.p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \ .p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \
.p_bufsiz = MAX(NLM4_##argtype##_sz, NLM4_##restype##_sz) << 2 \ .p_bufsiz = MAX(NLM4_##argtype##_sz, NLM4_##restype##_sz) << 2 \
} }
static struct rpc_procinfo nlm4_procedures[] = { static struct rpc_procinfo nlm4_procedures[] = {
PROC(null, void, void), PROC(TEST, testargs, testres),
PROC(test, testargs, testres), PROC(LOCK, lockargs, res),
PROC(lock, lockargs, res), PROC(CANCEL, cancargs, res),
PROC(canc, cancargs, res), PROC(UNLOCK, unlockargs, res),
PROC(unlock, unlockargs, res), PROC(GRANTED, testargs, res),
PROC(granted, testargs, res), PROC(TEST_MSG, testargs, norep),
PROC(test_msg, testargs, norep), PROC(LOCK_MSG, lockargs, norep),
PROC(lock_msg, lockargs, norep), PROC(CANCEL_MSG, cancargs, norep),
PROC(canc_msg, cancargs, norep), PROC(UNLOCK_MSG, unlockargs, norep),
PROC(unlock_msg, unlockargs, norep), PROC(GRANTED_MSG, testargs, norep),
PROC(granted_msg, testargs, norep), PROC(TEST_RES, testres, norep),
PROC(test_res, testres, norep), PROC(LOCK_RES, res, norep),
PROC(lock_res, res, norep), PROC(CANCEL_RES, res, norep),
PROC(canc_res, res, norep), PROC(UNLOCK_RES, res, norep),
PROC(unlock_res, res, norep), PROC(GRANTED_RES, res, norep),
PROC(granted_res, res, norep),
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
#ifdef NLMCLNT_SUPPORT_SHARES #ifdef NLMCLNT_SUPPORT_SHARES
PROC(share, shareargs, shareres), PROC(SHARE, shareargs, shareres),
PROC(unshare, shareargs, shareres), PROC(UNSHARE, shareargs, shareres),
PROC(nm_lock, lockargs, res), PROC(NM_LOCK, lockargs, res),
PROC(free_all, notify, void), PROC(FREE_ALL, notify, void),
#else
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
PROC(undef, void, void),
#endif #endif
}; };
......
...@@ -140,24 +140,18 @@ xdr_decode_fhstatus3(struct rpc_rqst *req, u32 *p, struct mnt_fhstatus *res) ...@@ -140,24 +140,18 @@ xdr_decode_fhstatus3(struct rpc_rqst *req, u32 *p, struct mnt_fhstatus *res)
#define MNT_dirpath_sz (1 + 256) #define MNT_dirpath_sz (1 + 256)
#define MNT_fhstatus_sz (1 + 8) #define MNT_fhstatus_sz (1 + 8)
static struct rpc_procinfo mnt_procedures[2] = { static struct rpc_procinfo mnt_procedures[] = {
{ .p_procname = "mnt_null", [MNTPROC_MNT] = {
.p_encode = (kxdrproc_t) xdr_error, .p_proc = MNTPROC_MNT,
.p_decode = (kxdrproc_t) xdr_error,
},
{ .p_procname = "mnt_mount",
.p_encode = (kxdrproc_t) xdr_encode_dirpath, .p_encode = (kxdrproc_t) xdr_encode_dirpath,
.p_decode = (kxdrproc_t) xdr_decode_fhstatus, .p_decode = (kxdrproc_t) xdr_decode_fhstatus,
.p_bufsiz = MNT_dirpath_sz << 2, .p_bufsiz = MNT_dirpath_sz << 2,
}, },
}; };
static struct rpc_procinfo mnt3_procedures[2] = { static struct rpc_procinfo mnt3_procedures[] = {
{ .p_procname = "mnt3_null", [MOUNTPROC3_MNT] = {
.p_encode = (kxdrproc_t) xdr_error, .p_proc = MOUNTPROC3_MNT,
.p_decode = (kxdrproc_t) xdr_error,
},
{ .p_procname = "mnt3_mount",
.p_encode = (kxdrproc_t) xdr_encode_dirpath, .p_encode = (kxdrproc_t) xdr_encode_dirpath,
.p_decode = (kxdrproc_t) xdr_decode_fhstatus3, .p_decode = (kxdrproc_t) xdr_decode_fhstatus3,
.p_bufsiz = MNT_dirpath_sz << 2, .p_bufsiz = MNT_dirpath_sz << 2,
......
...@@ -663,31 +663,29 @@ nfs_stat_to_errno(int stat) ...@@ -663,31 +663,29 @@ nfs_stat_to_errno(int stat)
#endif #endif
#define PROC(proc, argtype, restype, timer) \ #define PROC(proc, argtype, restype, timer) \
{ .p_procname = "nfs_" #proc, \ [NFSPROC_##proc] = { \
.p_proc = NFSPROC_##proc, \
.p_encode = (kxdrproc_t) nfs_xdr_##argtype, \ .p_encode = (kxdrproc_t) nfs_xdr_##argtype, \
.p_decode = (kxdrproc_t) nfs_xdr_##restype, \ .p_decode = (kxdrproc_t) nfs_xdr_##restype, \
.p_bufsiz = MAX(NFS_##argtype##_sz,NFS_##restype##_sz) << 2, \ .p_bufsiz = MAX(NFS_##argtype##_sz,NFS_##restype##_sz) << 2, \
.p_timer = timer \ .p_timer = timer \
} }
static struct rpc_procinfo nfs_procedures[18] = { struct rpc_procinfo nfs_procedures[] = {
PROC(null, enc_void, dec_void, 0), PROC(GETATTR, fhandle, attrstat, 1),
PROC(getattr, fhandle, attrstat, 1), PROC(SETATTR, sattrargs, attrstat, 0),
PROC(setattr, sattrargs, attrstat, 0), PROC(LOOKUP, diropargs, diropres, 2),
PROC(root, enc_void, dec_void, 0), PROC(READLINK, readlinkargs, readlinkres, 3),
PROC(lookup, diropargs, diropres, 2), PROC(READ, readargs, readres, 3),
PROC(readlink, readlinkargs, readlinkres, 3), PROC(WRITE, writeargs, writeres, 4),
PROC(read, readargs, readres, 3), PROC(CREATE, createargs, diropres, 0),
PROC(writecache, enc_void, dec_void, 0), PROC(REMOVE, diropargs, stat, 0),
PROC(write, writeargs, writeres, 4), PROC(RENAME, renameargs, stat, 0),
PROC(create, createargs, diropres, 0), PROC(LINK, linkargs, stat, 0),
PROC(remove, diropargs, stat, 0), PROC(SYMLINK, symlinkargs, stat, 0),
PROC(rename, renameargs, stat, 0), PROC(MKDIR, createargs, diropres, 0),
PROC(link, linkargs, stat, 0), PROC(RMDIR, diropargs, stat, 0),
PROC(symlink, symlinkargs, stat, 0), PROC(READDIR, readdirargs, readdirres, 3),
PROC(mkdir, createargs, diropres, 0), PROC(STATFS, fhandle, statfsres, 0),
PROC(rmdir, diropargs, stat, 0),
PROC(readdir, readdirargs, readdirres, 3),
PROC(statfs, fhandle, statfsres, 0),
}; };
struct rpc_version nfs_version2 = { struct rpc_version nfs_version2 = {
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#define NFSDBG_FACILITY NFSDBG_PROC #define NFSDBG_FACILITY NFSDBG_PROC
extern struct rpc_procinfo nfs3_procedures[];
/* A wrapper to handle the EJUKEBOX error message */ /* A wrapper to handle the EJUKEBOX error message */
static int static int
nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
...@@ -42,7 +44,7 @@ static inline int ...@@ -42,7 +44,7 @@ static inline int
nfs3_rpc_call_wrapper(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags) nfs3_rpc_call_wrapper(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
{ {
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = proc, .rpc_proc = &nfs3_procedures[proc],
.rpc_argp = argp, .rpc_argp = argp,
.rpc_resp = resp, .rpc_resp = resp,
}; };
...@@ -156,7 +158,7 @@ nfs3_proc_access(struct inode *inode, struct rpc_cred *cred, int mode) ...@@ -156,7 +158,7 @@ nfs3_proc_access(struct inode *inode, struct rpc_cred *cred, int mode)
.fattr = &fattr, .fattr = &fattr,
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFS3PROC_ACCESS, .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred .rpc_cred = cred
...@@ -227,7 +229,7 @@ nfs3_proc_read(struct inode *inode, struct rpc_cred *cred, ...@@ -227,7 +229,7 @@ nfs3_proc_read(struct inode *inode, struct rpc_cred *cred,
.count = count, .count = count,
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFS3PROC_READ, .rpc_proc = &nfs3_procedures[NFS3PROC_READ],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred .rpc_cred = cred
...@@ -262,7 +264,7 @@ nfs3_proc_write(struct inode *inode, struct rpc_cred *cred, ...@@ -262,7 +264,7 @@ nfs3_proc_write(struct inode *inode, struct rpc_cred *cred,
.verf = verf, .verf = verf,
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFS3PROC_WRITE, .rpc_proc = &nfs3_procedures[NFS3PROC_WRITE],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred .rpc_cred = cred
...@@ -369,7 +371,7 @@ nfs3_proc_remove(struct inode *dir, struct qstr *name) ...@@ -369,7 +371,7 @@ nfs3_proc_remove(struct inode *dir, struct qstr *name)
.len = name->len .len = name->len
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFS3PROC_REMOVE, .rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &dir_attr, .rpc_resp = &dir_attr,
}; };
...@@ -397,7 +399,7 @@ nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr ...@@ -397,7 +399,7 @@ nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr
arg->name = name->name; arg->name = name->name;
arg->len = name->len; arg->len = name->len;
res->valid = 0; res->valid = 0;
msg->rpc_proc = NFS3PROC_REMOVE; msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
msg->rpc_argp = arg; msg->rpc_argp = arg;
msg->rpc_resp = res; msg->rpc_resp = res;
return 0; return 0;
...@@ -580,7 +582,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, ...@@ -580,7 +582,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
.plus = plus .plus = plus
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFS3PROC_READDIR, .rpc_proc = &nfs3_procedures[NFS3PROC_READDIR],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred .rpc_cred = cred
...@@ -590,7 +592,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, ...@@ -590,7 +592,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
lock_kernel(); lock_kernel();
if (plus) if (plus)
msg.rpc_proc = NFS3PROC_READDIRPLUS; msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS];
dprintk("NFS call readdir%s %d\n", dprintk("NFS call readdir%s %d\n",
plus? "plus" : "", (unsigned int) cookie); plus? "plus" : "", (unsigned int) cookie);
...@@ -697,7 +699,12 @@ nfs3_proc_read_setup(struct nfs_read_data *data, unsigned int count) ...@@ -697,7 +699,12 @@ nfs3_proc_read_setup(struct nfs_read_data *data, unsigned int count)
struct inode *inode = data->inode; struct inode *inode = data->inode;
struct nfs_page *req; struct nfs_page *req;
int flags; int flags;
struct rpc_message msg; struct rpc_message msg = {
.rpc_proc = &nfs3_procedures[NFS3PROC_READ],
.rpc_argp = &data->u.v3.args,
.rpc_resp = &data->u.v3.res,
.rpc_cred = data->cred,
};
req = nfs_list_entry(data->pages.next); req = nfs_list_entry(data->pages.next);
data->u.v3.args.fh = NFS_FH(inode); data->u.v3.args.fh = NFS_FH(inode);
...@@ -718,10 +725,6 @@ nfs3_proc_read_setup(struct nfs_read_data *data, unsigned int count) ...@@ -718,10 +725,6 @@ nfs3_proc_read_setup(struct nfs_read_data *data, unsigned int count)
/* Release requests */ /* Release requests */
task->tk_release = nfs_readdata_release; task->tk_release = nfs_readdata_release;
msg.rpc_proc = NFS3PROC_READ;
msg.rpc_argp = &data->u.v3.args;
msg.rpc_resp = &data->u.v3.res;
msg.rpc_cred = data->cred;
rpc_call_setup(&data->task, &msg, 0); rpc_call_setup(&data->task, &msg, 0);
} }
...@@ -744,7 +747,12 @@ nfs3_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how) ...@@ -744,7 +747,12 @@ nfs3_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how)
struct nfs_page *req; struct nfs_page *req;
int stable; int stable;
int flags; int flags;
struct rpc_message msg; struct rpc_message msg = {
.rpc_proc = &nfs3_procedures[NFS3PROC_WRITE],
.rpc_argp = &data->u.v3.args,
.rpc_resp = &data->u.v3.res,
.rpc_cred = data->cred,
};
if (how & FLUSH_STABLE) { if (how & FLUSH_STABLE) {
if (!NFS_I(inode)->ncommit) if (!NFS_I(inode)->ncommit)
...@@ -774,10 +782,6 @@ nfs3_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how) ...@@ -774,10 +782,6 @@ nfs3_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how)
/* Release requests */ /* Release requests */
task->tk_release = nfs_writedata_release; task->tk_release = nfs_writedata_release;
msg.rpc_proc = NFS3PROC_WRITE;
msg.rpc_argp = &data->u.v3.args;
msg.rpc_resp = &data->u.v3.res;
msg.rpc_cred = data->cred;
rpc_call_setup(&data->task, &msg, 0); rpc_call_setup(&data->task, &msg, 0);
} }
...@@ -795,7 +799,12 @@ nfs3_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how) ...@@ -795,7 +799,12 @@ nfs3_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how)
struct rpc_task *task = &data->task; struct rpc_task *task = &data->task;
struct inode *inode = data->inode; struct inode *inode = data->inode;
int flags; int flags;
struct rpc_message msg; struct rpc_message msg = {
.rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT],
.rpc_argp = &data->u.v3.args,
.rpc_resp = &data->u.v3.res,
.rpc_cred = data->cred,
};
data->u.v3.args.fh = NFS_FH(data->inode); data->u.v3.args.fh = NFS_FH(data->inode);
data->u.v3.args.offset = start; data->u.v3.args.offset = start;
...@@ -813,10 +822,6 @@ nfs3_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how) ...@@ -813,10 +822,6 @@ nfs3_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how)
/* Release requests */ /* Release requests */
task->tk_release = nfs_commit_release; task->tk_release = nfs_commit_release;
msg.rpc_proc = NFS3PROC_COMMIT;
msg.rpc_argp = &data->u.v3.args;
msg.rpc_resp = &data->u.v3.res;
msg.rpc_cred = data->cred;
rpc_call_setup(&data->task, &msg, 0); rpc_call_setup(&data->task, &msg, 0);
} }
......
...@@ -48,7 +48,6 @@ extern int nfs_stat_to_errno(int); ...@@ -48,7 +48,6 @@ extern int nfs_stat_to_errno(int);
#define NFS3_pathconf_sz #define NFS3_pathconf_sz
#define NFS3_entry_sz NFS3_filename_sz+3 #define NFS3_entry_sz NFS3_filename_sz+3
#define NFS3_enc_void_sz 0
#define NFS3_sattrargs_sz NFS3_fh_sz+NFS3_sattr_sz+3 #define NFS3_sattrargs_sz NFS3_fh_sz+NFS3_sattr_sz+3
#define NFS3_diropargs_sz NFS3_fh_sz+NFS3_filename_sz #define NFS3_diropargs_sz NFS3_fh_sz+NFS3_filename_sz
#define NFS3_accessargs_sz NFS3_fh_sz+1 #define NFS3_accessargs_sz NFS3_fh_sz+1
...@@ -64,7 +63,6 @@ extern int nfs_stat_to_errno(int); ...@@ -64,7 +63,6 @@ extern int nfs_stat_to_errno(int);
#define NFS3_readdirargs_sz NFS3_fh_sz+2 #define NFS3_readdirargs_sz NFS3_fh_sz+2
#define NFS3_commitargs_sz NFS3_fh_sz+3 #define NFS3_commitargs_sz NFS3_fh_sz+3
#define NFS3_dec_void_sz 0
#define NFS3_attrstat_sz 1+NFS3_fattr_sz #define NFS3_attrstat_sz 1+NFS3_fattr_sz
#define NFS3_wccstat_sz 1+NFS3_wcc_data_sz #define NFS3_wccstat_sz 1+NFS3_wcc_data_sz
#define NFS3_lookupres_sz 1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz) #define NFS3_lookupres_sz 1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz)
...@@ -268,15 +266,6 @@ xdr_decode_wcc_data(u32 *p, struct nfs_fattr *fattr) ...@@ -268,15 +266,6 @@ xdr_decode_wcc_data(u32 *p, struct nfs_fattr *fattr)
/* /*
* NFS encode functions * NFS encode functions
*/ */
/*
* Encode void argument
*/
static int
nfs3_xdr_enc_void(struct rpc_rqst *req, u32 *p, void *dummy)
{
req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
return 0;
}
/* /*
* Encode file handle argument * Encode file handle argument
...@@ -652,14 +641,6 @@ nfs3_xdr_commitargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args) ...@@ -652,14 +641,6 @@ nfs3_xdr_commitargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args)
/* /*
* NFS XDR decode functions * NFS XDR decode functions
*/ */
/*
* Decode void reply
*/
static int
nfs3_xdr_dec_void(struct rpc_rqst *req, u32 *p, void *dummy)
{
return 0;
}
/* /*
* Decode attrstat reply. * Decode attrstat reply.
...@@ -1004,36 +985,36 @@ nfs3_xdr_commitres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res) ...@@ -1004,36 +985,36 @@ nfs3_xdr_commitres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res)
#endif #endif
#define PROC(proc, argtype, restype, timer) \ #define PROC(proc, argtype, restype, timer) \
{ .p_procname = "nfs3_" #proc, \ [NFS3PROC_##proc] = { \
.p_proc = NFS3PROC_##proc, \
.p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \ .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
.p_decode = (kxdrproc_t) nfs3_xdr_##restype, \ .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
.p_bufsiz = MAX(NFS3_##argtype##_sz,NFS3_##restype##_sz) << 2, \ .p_bufsiz = MAX(NFS3_##argtype##_sz,NFS3_##restype##_sz) << 2, \
.p_timer = timer \ .p_timer = timer \
} }
static struct rpc_procinfo nfs3_procedures[22] = { struct rpc_procinfo nfs3_procedures[] = {
PROC(null, enc_void, dec_void, 0), PROC(GETATTR, fhandle, attrstat, 1),
PROC(getattr, fhandle, attrstat, 1), PROC(SETATTR, sattrargs, wccstat, 0),
PROC(setattr, sattrargs, wccstat, 0), PROC(LOOKUP, diropargs, lookupres, 2),
PROC(lookup, diropargs, lookupres, 2), PROC(ACCESS, accessargs, accessres, 1),
PROC(access, accessargs, accessres, 1), PROC(READLINK, readlinkargs, readlinkres, 3),
PROC(readlink, readlinkargs, readlinkres, 3), PROC(READ, readargs, readres, 3),
PROC(read, readargs, readres, 3), PROC(WRITE, writeargs, writeres, 4),
PROC(write, writeargs, writeres, 4), PROC(CREATE, createargs, createres, 0),
PROC(create, createargs, createres, 0), PROC(MKDIR, mkdirargs, createres, 0),
PROC(mkdir, mkdirargs, createres, 0), PROC(SYMLINK, symlinkargs, createres, 0),
PROC(symlink, symlinkargs, createres, 0), PROC(MKNOD, mknodargs, createres, 0),
PROC(mknod, mknodargs, createres, 0), PROC(REMOVE, diropargs, wccstat, 0),
PROC(remove, diropargs, wccstat, 0), PROC(RMDIR, diropargs, wccstat, 0),
PROC(rmdir, diropargs, wccstat, 0), PROC(RENAME, renameargs, renameres, 0),
PROC(rename, renameargs, renameres, 0), PROC(LINK, linkargs, linkres, 0),
PROC(link, linkargs, linkres, 0), PROC(READDIR, readdirargs, readdirres, 3),
PROC(readdir, readdirargs, readdirres, 3), PROC(READDIRPLUS, readdirargs, readdirres, 3),
PROC(readdirplus, readdirargs, readdirres, 3), PROC(FSSTAT, fhandle, fsstatres, 0),
PROC(fsstat, fhandle, fsstatres, 0), PROC(FSINFO, fhandle, fsinfores, 0),
PROC(fsinfo, fhandle, fsinfores, 0), PROC(PATHCONF, fhandle, pathconfres, 0),
PROC(pathconf, fhandle, pathconfres, 0), PROC(COMMIT, commitargs, commitres, 5),
PROC(commit, commitargs, commitres, 5),
}; };
struct rpc_version nfs_version3 = { struct rpc_version nfs_version3 = {
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#define OPNUM(cp) cp->ops[cp->req_nops].opnum #define OPNUM(cp) cp->ops[cp->req_nops].opnum
extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus);
extern struct rpc_procinfo nfs4_procedures[];
static nfs4_stateid zero_stateid = static nfs4_stateid zero_stateid =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
...@@ -642,7 +643,7 @@ nfs4_call_compound(struct nfs4_compound *cp, struct rpc_cred *cred, int flags) ...@@ -642,7 +643,7 @@ nfs4_call_compound(struct nfs4_compound *cp, struct rpc_cred *cred, int flags)
{ {
int status; int status;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC4_COMPOUND, .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp, .rpc_argp = cp,
.rpc_resp = cp, .rpc_resp = cp,
.rpc_cred = cred, .rpc_cred = cred,
...@@ -1106,7 +1107,7 @@ nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr ...@@ -1106,7 +1107,7 @@ nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr
nfs4_setup_remove(cp, name, &up->cinfo); nfs4_setup_remove(cp, name, &up->cinfo);
nfs4_setup_getattr(cp, &up->attrs, bmres); nfs4_setup_getattr(cp, &up->attrs, bmres);
msg->rpc_proc = NFSPROC4_COMPOUND; msg->rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND];
msg->rpc_argp = cp; msg->rpc_argp = cp;
msg->rpc_resp = cp; msg->rpc_resp = cp;
return 0; return 0;
...@@ -1367,7 +1368,7 @@ nfs4_proc_read_setup(struct nfs_read_data *data, unsigned int count) ...@@ -1367,7 +1368,7 @@ nfs4_proc_read_setup(struct nfs_read_data *data, unsigned int count)
struct rpc_task *task = &data->task; struct rpc_task *task = &data->task;
struct nfs4_compound *cp = &data->u.v4.compound; struct nfs4_compound *cp = &data->u.v4.compound;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC4_COMPOUND, .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp, .rpc_argp = cp,
.rpc_resp = cp, .rpc_resp = cp,
.rpc_cred = data->cred, .rpc_cred = data->cred,
...@@ -1411,7 +1412,7 @@ nfs4_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how) ...@@ -1411,7 +1412,7 @@ nfs4_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how)
struct rpc_task *task = &data->task; struct rpc_task *task = &data->task;
struct nfs4_compound *cp = &data->u.v4.compound; struct nfs4_compound *cp = &data->u.v4.compound;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC4_COMPOUND, .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp, .rpc_argp = cp,
.rpc_resp = cp, .rpc_resp = cp,
.rpc_cred = data->cred, .rpc_cred = data->cred,
...@@ -1462,7 +1463,7 @@ nfs4_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how) ...@@ -1462,7 +1463,7 @@ nfs4_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how)
struct rpc_task *task = &data->task; struct rpc_task *task = &data->task;
struct nfs4_compound *cp = &data->u.v4.compound; struct nfs4_compound *cp = &data->u.v4.compound;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC4_COMPOUND, .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp, .rpc_argp = cp,
.rpc_resp = cp, .rpc_resp = cp,
.rpc_cred = data->cred, .rpc_cred = data->cred,
...@@ -1516,7 +1517,9 @@ nfs4_proc_renew(struct nfs_server *server) ...@@ -1516,7 +1517,9 @@ nfs4_proc_renew(struct nfs_server *server)
struct renew_desc *rp; struct renew_desc *rp;
struct rpc_task *task; struct rpc_task *task;
struct nfs4_compound *cp; struct nfs4_compound *cp;
struct rpc_message msg; struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
};
rp = (struct renew_desc *) kmalloc(sizeof(*rp), GFP_KERNEL); rp = (struct renew_desc *) kmalloc(sizeof(*rp), GFP_KERNEL);
if (!rp) if (!rp)
...@@ -1527,10 +1530,8 @@ nfs4_proc_renew(struct nfs_server *server) ...@@ -1527,10 +1530,8 @@ nfs4_proc_renew(struct nfs_server *server)
nfs4_setup_compound(cp, rp->ops, server, "renew"); nfs4_setup_compound(cp, rp->ops, server, "renew");
nfs4_setup_renew(cp); nfs4_setup_renew(cp);
msg.rpc_proc = NFSPROC4_COMPOUND;
msg.rpc_argp = cp; msg.rpc_argp = cp;
msg.rpc_resp = cp; msg.rpc_resp = cp;
msg.rpc_cred = NULL;
rpc_init_task(task, server->client, renew_done, RPC_TASK_ASYNC); rpc_init_task(task, server->client, renew_done, RPC_TASK_ASYNC);
rpc_call_setup(task, &msg, 0); rpc_call_setup(task, &msg, 0);
task->tk_calldata = rp; task->tk_calldata = rp;
......
...@@ -66,8 +66,6 @@ ...@@ -66,8 +66,6 @@
extern int nfs_stat_to_errno(int); extern int nfs_stat_to_errno(int);
#define NFS4_enc_void_sz 0
#define NFS4_dec_void_sz 0
#define NFS4_enc_compound_sz 1024 /* XXX: large enough? */ #define NFS4_enc_compound_sz 1024 /* XXX: large enough? */
#define NFS4_dec_compound_sz 1024 /* XXX: large enough? */ #define NFS4_dec_compound_sz 1024 /* XXX: large enough? */
...@@ -722,6 +720,7 @@ encode_write(struct nfs4_compound *cp, struct nfs4_write *write, struct rpc_rqst ...@@ -722,6 +720,7 @@ encode_write(struct nfs4_compound *cp, struct nfs4_write *write, struct rpc_rqst
ENCODE_TAIL; ENCODE_TAIL;
} }
/* FIXME: this sucks */
static int static int
encode_compound(struct nfs4_compound *cp, struct rpc_rqst *req) encode_compound(struct nfs4_compound *cp, struct rpc_rqst *req)
{ {
...@@ -825,16 +824,6 @@ encode_compound(struct nfs4_compound *cp, struct rpc_rqst *req) ...@@ -825,16 +824,6 @@ encode_compound(struct nfs4_compound *cp, struct rpc_rqst *req)
*/ */
/*
* Encode void argument
*/
static int
nfs4_xdr_enc_void(struct rpc_rqst *req, u32 *p, void *dummy)
{
req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
return 0;
}
/* /*
* Encode COMPOUND argument * Encode COMPOUND argument
*/ */
...@@ -1546,6 +1535,7 @@ decode_write(struct nfs4_compound *cp, int nfserr, struct nfs4_write *write) ...@@ -1546,6 +1535,7 @@ decode_write(struct nfs4_compound *cp, int nfserr, struct nfs4_write *write)
DECODE_TAIL; DECODE_TAIL;
} }
/* FIXME: this sucks */
static int static int
decode_compound(struct nfs4_compound *cp, struct rpc_rqst *req) decode_compound(struct nfs4_compound *cp, struct rpc_rqst *req)
{ {
...@@ -1679,15 +1669,6 @@ decode_compound(struct nfs4_compound *cp, struct rpc_rqst *req) ...@@ -1679,15 +1669,6 @@ decode_compound(struct nfs4_compound *cp, struct rpc_rqst *req)
* END OF "GENERIC" DECODE ROUTINES. * END OF "GENERIC" DECODE ROUTINES.
*/ */
/*
* Decode void reply
*/
static int
nfs4_xdr_dec_void(struct rpc_rqst *req, u32 *p, void *dummy)
{
return 0;
}
/* /*
* Decode COMPOUND response * Decode COMPOUND response
*/ */
...@@ -1753,16 +1734,15 @@ nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus) ...@@ -1753,16 +1734,15 @@ nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus)
#endif #endif
#define PROC(proc, argtype, restype) \ #define PROC(proc, argtype, restype) \
{ "nfs4_" #proc, \ [NFSPROC4_##proc] = { \
(kxdrproc_t) nfs4_xdr_##argtype, \ .p_proc = NFSPROC4_##proc, \
(kxdrproc_t) nfs4_xdr_##restype, \ .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \ .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
0 \ .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \
} }
static struct rpc_procinfo nfs4_procedures[] = { struct rpc_procinfo nfs4_procedures[] = {
PROC(null, enc_void, dec_void), PROC(COMPOUND, enc_compound, dec_compound)
PROC(compound, enc_compound, dec_compound)
}; };
struct rpc_version nfs_version4 = { struct rpc_version nfs_version4 = {
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#define NFSDBG_FACILITY NFSDBG_PROC #define NFSDBG_FACILITY NFSDBG_PROC
extern struct rpc_procinfo nfs_procedures[];
/* /*
* Bare-bones access to getattr: this is for nfs_read_super. * Bare-bones access to getattr: this is for nfs_read_super.
*/ */
...@@ -153,7 +155,7 @@ nfs_proc_read(struct inode *inode, struct rpc_cred *cred, ...@@ -153,7 +155,7 @@ nfs_proc_read(struct inode *inode, struct rpc_cred *cred,
.count = count .count = count
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC_READ, .rpc_proc = &nfs_procedures[NFSPROC_READ],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred .rpc_cred = cred
...@@ -190,7 +192,7 @@ nfs_proc_write(struct inode *inode, struct rpc_cred *cred, ...@@ -190,7 +192,7 @@ nfs_proc_write(struct inode *inode, struct rpc_cred *cred,
.count = count .count = count
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC_WRITE, .rpc_proc = &nfs_procedures[NFSPROC_WRITE],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred .rpc_cred = cred
...@@ -282,7 +284,7 @@ nfs_proc_remove(struct inode *dir, struct qstr *name) ...@@ -282,7 +284,7 @@ nfs_proc_remove(struct inode *dir, struct qstr *name)
.len = name->len .len = name->len
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC_REMOVE, .rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = NULL, .rpc_resp = NULL,
.rpc_cred = NULL .rpc_cred = NULL
...@@ -307,7 +309,7 @@ nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr * ...@@ -307,7 +309,7 @@ nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *
arg->fh = NFS_FH(dir->d_inode); arg->fh = NFS_FH(dir->d_inode);
arg->name = name->name; arg->name = name->name;
arg->len = name->len; arg->len = name->len;
msg->rpc_proc = NFSPROC_REMOVE; msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
msg->rpc_argp = arg; msg->rpc_argp = arg;
return 0; return 0;
} }
...@@ -441,7 +443,7 @@ nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, ...@@ -441,7 +443,7 @@ nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
.pages = &page .pages = &page
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = NFSPROC_READDIR, .rpc_proc = &nfs_procedures[NFSPROC_READDIR],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = NULL, .rpc_resp = NULL,
.rpc_cred = cred .rpc_cred = cred
...@@ -532,7 +534,12 @@ nfs_proc_read_setup(struct nfs_read_data *data, unsigned int count) ...@@ -532,7 +534,12 @@ nfs_proc_read_setup(struct nfs_read_data *data, unsigned int count)
struct inode *inode = data->inode; struct inode *inode = data->inode;
struct nfs_page *req; struct nfs_page *req;
int flags; int flags;
struct rpc_message msg; struct rpc_message msg = {
.rpc_proc = &nfs_procedures[NFSPROC_READ],
.rpc_argp = &data->u.v3.args,
.rpc_resp = &data->u.v3.res,
.rpc_cred = data->cred,
};
req = nfs_list_entry(data->pages.next); req = nfs_list_entry(data->pages.next);
data->u.v3.args.fh = NFS_FH(inode); data->u.v3.args.fh = NFS_FH(inode);
...@@ -553,10 +560,6 @@ nfs_proc_read_setup(struct nfs_read_data *data, unsigned int count) ...@@ -553,10 +560,6 @@ nfs_proc_read_setup(struct nfs_read_data *data, unsigned int count)
/* Release requests */ /* Release requests */
task->tk_release = nfs_readdata_release; task->tk_release = nfs_readdata_release;
msg.rpc_proc = NFSPROC_READ;
msg.rpc_argp = &data->u.v3.args;
msg.rpc_resp = &data->u.v3.res;
msg.rpc_cred = data->cred;
rpc_call_setup(&data->task, &msg, 0); rpc_call_setup(&data->task, &msg, 0);
} }
...@@ -575,7 +578,12 @@ nfs_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how) ...@@ -575,7 +578,12 @@ nfs_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how)
struct inode *inode = data->inode; struct inode *inode = data->inode;
struct nfs_page *req; struct nfs_page *req;
int flags; int flags;
struct rpc_message msg; struct rpc_message msg = {
.rpc_proc = &nfs_procedures[NFSPROC_WRITE],
.rpc_argp = &data->u.v3.args,
.rpc_resp = &data->u.v3.res,
.rpc_cred = data->cred,
};
/* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */ /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
...@@ -599,10 +607,6 @@ nfs_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how) ...@@ -599,10 +607,6 @@ nfs_proc_write_setup(struct nfs_write_data *data, unsigned int count, int how)
/* Release requests */ /* Release requests */
task->tk_release = nfs_writedata_release; task->tk_release = nfs_writedata_release;
msg.rpc_proc = NFSPROC_WRITE;
msg.rpc_argp = &data->u.v3.args;
msg.rpc_resp = &data->u.v3.res;
msg.rpc_cred = data->cred;
rpc_call_setup(&data->task, &msg, 0); rpc_call_setup(&data->task, &msg, 0);
} }
......
...@@ -93,14 +93,14 @@ nfs_async_unlink_init(struct rpc_task *task) ...@@ -93,14 +93,14 @@ nfs_async_unlink_init(struct rpc_task *task)
{ {
struct nfs_unlinkdata *data = (struct nfs_unlinkdata *)task->tk_calldata; struct nfs_unlinkdata *data = (struct nfs_unlinkdata *)task->tk_calldata;
struct dentry *dir = data->dir; struct dentry *dir = data->dir;
struct rpc_message msg; struct rpc_message msg = {
.rpc_cred = data->cred,
};
int status = -ENOENT; int status = -ENOENT;
if (!data->name.len) if (!data->name.len)
goto out_err; goto out_err;
memset(&msg, 0, sizeof(msg));
msg.rpc_cred = data->cred;
status = NFS_PROTO(dir->d_inode)->unlink_setup(&msg, dir, &data->name); status = NFS_PROTO(dir->d_inode)->unlink_setup(&msg, dir, &data->name);
if (status < 0) if (status < 0)
goto out_err; goto out_err;
......
...@@ -28,10 +28,6 @@ ...@@ -28,10 +28,6 @@
# define ifdebug(flag) if (0) # define ifdebug(flag) if (0)
#endif #endif
#ifdef LOCKD_DEBUG
char * nlm_procname(u32);
#endif
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
/* /*
......
...@@ -87,7 +87,7 @@ struct rpc_version { ...@@ -87,7 +87,7 @@ struct rpc_version {
* Procedure information * Procedure information
*/ */
struct rpc_procinfo { struct rpc_procinfo {
char * p_procname; /* procedure name */ u32 p_proc; /* RPC procedure number */
kxdrproc_t p_encode; /* XDR encode function */ kxdrproc_t p_encode; /* XDR encode function */
kxdrproc_t p_decode; /* XDR decode function */ kxdrproc_t p_decode; /* XDR decode function */
unsigned int p_bufsiz; /* req. buffer size */ unsigned int p_bufsiz; /* req. buffer size */
...@@ -95,13 +95,6 @@ struct rpc_procinfo { ...@@ -95,13 +95,6 @@ struct rpc_procinfo {
unsigned int p_timer; /* Which RTT timer to use */ unsigned int p_timer; /* Which RTT timer to use */
}; };
#define rpcproc_bufsiz(clnt, proc) ((clnt)->cl_procinfo[proc].p_bufsiz)
#define rpcproc_encode(clnt, proc) ((clnt)->cl_procinfo[proc].p_encode)
#define rpcproc_decode(clnt, proc) ((clnt)->cl_procinfo[proc].p_decode)
#define rpcproc_name(clnt, proc) ((clnt)->cl_procinfo[proc].p_procname)
#define rpcproc_count(clnt, proc) ((clnt)->cl_procinfo[proc].p_count)
#define rpcproc_timer(clnt, proc) ((clnt)->cl_procinfo[proc].p_timer)
#define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt)) #define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt))
#define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr) #define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr)
...@@ -131,7 +124,7 @@ static __inline__ ...@@ -131,7 +124,7 @@ static __inline__
int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags) int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
{ {
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = proc, .rpc_proc = &clnt->cl_procinfo[proc],
.rpc_argp = argp, .rpc_argp = argp,
.rpc_resp = resp, .rpc_resp = resp,
.rpc_cred = NULL .rpc_cred = NULL
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
/* /*
* This is the actual RPC procedure call info. * This is the actual RPC procedure call info.
*/ */
struct rpc_procinfo;
struct rpc_message { struct rpc_message {
__u32 rpc_proc; /* Procedure number */ struct rpc_procinfo * rpc_proc; /* Procedure information */
void * rpc_argp; /* Arguments */ void * rpc_argp; /* Arguments */
void * rpc_resp; /* Result */ void * rpc_resp; /* Result */
struct rpc_cred * rpc_cred; /* Credentials */ struct rpc_cred * rpc_cred; /* Credentials */
......
...@@ -379,20 +379,12 @@ call_start(struct rpc_task *task) ...@@ -379,20 +379,12 @@ call_start(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client; struct rpc_clnt *clnt = task->tk_client;
if (task->tk_msg.rpc_proc > clnt->cl_maxproc) {
printk(KERN_ERR "%s (vers %d): bad procedure number %d\n",
clnt->cl_protname, clnt->cl_vers,
task->tk_msg.rpc_proc);
rpc_exit(task, -EIO);
return;
}
dprintk("RPC: %4d call_start %s%d proc %d (%s)\n", task->tk_pid, dprintk("RPC: %4d call_start %s%d proc %d (%s)\n", task->tk_pid,
clnt->cl_protname, clnt->cl_vers, task->tk_msg.rpc_proc, clnt->cl_protname, clnt->cl_vers, task->tk_msg.rpc_proc->p_proc,
(RPC_IS_ASYNC(task) ? "async" : "sync")); (RPC_IS_ASYNC(task) ? "async" : "sync"));
/* Increment call count */ /* Increment call count */
rpcproc_count(clnt, task->tk_msg.rpc_proc)++; task->tk_msg.rpc_proc->p_count++;
clnt->cl_stats->rpccnt++; clnt->cl_stats->rpccnt++;
task->tk_action = call_reserve; task->tk_action = call_reserve;
} }
...@@ -474,7 +466,6 @@ call_reserveresult(struct rpc_task *task) ...@@ -474,7 +466,6 @@ call_reserveresult(struct rpc_task *task)
static void static void
call_allocate(struct rpc_task *task) call_allocate(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client;
unsigned int bufsiz; unsigned int bufsiz;
dprintk("RPC: %4d call_allocate (status %d)\n", dprintk("RPC: %4d call_allocate (status %d)\n",
...@@ -485,7 +476,7 @@ call_allocate(struct rpc_task *task) ...@@ -485,7 +476,7 @@ call_allocate(struct rpc_task *task)
/* FIXME: compute buffer requirements more exactly using /* FIXME: compute buffer requirements more exactly using
* auth->au_wslack */ * auth->au_wslack */
bufsiz = rpcproc_bufsiz(clnt, task->tk_msg.rpc_proc) + RPC_SLACK_SPACE; bufsiz = task->tk_msg.rpc_proc->p_bufsiz + RPC_SLACK_SPACE;
if (rpc_malloc(task, bufsiz << 1) != NULL) if (rpc_malloc(task, bufsiz << 1) != NULL)
return; return;
...@@ -538,7 +529,7 @@ call_encode(struct rpc_task *task) ...@@ -538,7 +529,7 @@ call_encode(struct rpc_task *task)
memset(task->tk_buffer, 0, bufsiz); memset(task->tk_buffer, 0, bufsiz);
/* Encode header and provided arguments */ /* Encode header and provided arguments */
encode = rpcproc_encode(clnt, task->tk_msg.rpc_proc); encode = task->tk_msg.rpc_proc->p_encode;
if (!(p = call_header(task))) { if (!(p = call_header(task))) {
printk(KERN_INFO "RPC: call_header failed, exit EIO\n"); printk(KERN_INFO "RPC: call_header failed, exit EIO\n");
rpc_exit(task, -EIO); rpc_exit(task, -EIO);
...@@ -620,8 +611,6 @@ child_connect_status(struct rpc_task *task) ...@@ -620,8 +611,6 @@ child_connect_status(struct rpc_task *task)
static void static void
call_transmit(struct rpc_task *task) call_transmit(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client;
dprintk("RPC: %4d call_transmit (status %d)\n", dprintk("RPC: %4d call_transmit (status %d)\n",
task->tk_pid, task->tk_status); task->tk_pid, task->tk_status);
...@@ -629,7 +618,7 @@ call_transmit(struct rpc_task *task) ...@@ -629,7 +618,7 @@ call_transmit(struct rpc_task *task)
if (task->tk_status < 0) if (task->tk_status < 0)
return; return;
xprt_transmit(task); xprt_transmit(task);
if (!rpcproc_decode(clnt, task->tk_msg.rpc_proc) && task->tk_status >= 0) { if (!task->tk_msg.rpc_proc->p_decode && task->tk_status >= 0) {
task->tk_action = NULL; task->tk_action = NULL;
rpc_wake_up_task(task); rpc_wake_up_task(task);
} }
...@@ -732,7 +721,7 @@ call_decode(struct rpc_task *task) ...@@ -732,7 +721,7 @@ call_decode(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client; struct rpc_clnt *clnt = task->tk_client;
struct rpc_rqst *req = task->tk_rqstp; struct rpc_rqst *req = task->tk_rqstp;
kxdrproc_t decode = rpcproc_decode(clnt, task->tk_msg.rpc_proc); kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode;
u32 *p; u32 *p;
dprintk("RPC: %4d call_decode (status %d)\n", dprintk("RPC: %4d call_decode (status %d)\n",
...@@ -832,7 +821,7 @@ call_header(struct rpc_task *task) ...@@ -832,7 +821,7 @@ call_header(struct rpc_task *task)
*p++ = htonl(RPC_VERSION); /* RPC version */ *p++ = htonl(RPC_VERSION); /* RPC version */
*p++ = htonl(clnt->cl_prog); /* program number */ *p++ = htonl(clnt->cl_prog); /* program number */
*p++ = htonl(clnt->cl_vers); /* program version */ *p++ = htonl(clnt->cl_vers); /* program version */
*p++ = htonl(task->tk_msg.rpc_proc); /* procedure */ *p++ = htonl(task->tk_msg.rpc_proc->p_proc); /* procedure */
return rpcauth_marshcred(task, p); return rpcauth_marshcred(task, p);
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define PMAP_UNSET 2 #define PMAP_UNSET 2
#define PMAP_GETPORT 3 #define PMAP_GETPORT 3
static struct rpc_procinfo pmap_procedures[];
static struct rpc_clnt * pmap_create(char *, struct sockaddr_in *, int); static struct rpc_clnt * pmap_create(char *, struct sockaddr_in *, int);
static void pmap_getport_done(struct rpc_task *); static void pmap_getport_done(struct rpc_task *);
extern struct rpc_program pmap_program; extern struct rpc_program pmap_program;
...@@ -43,7 +44,7 @@ rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt) ...@@ -43,7 +44,7 @@ rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt)
struct rpc_portmap *map = &clnt->cl_pmap; struct rpc_portmap *map = &clnt->cl_pmap;
struct sockaddr_in *sap = &clnt->cl_xprt->addr; struct sockaddr_in *sap = &clnt->cl_xprt->addr;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = PMAP_GETPORT, .rpc_proc = &pmap_procedures[PMAP_GETPORT],
.rpc_argp = map, .rpc_argp = map,
.rpc_resp = &clnt->cl_port, .rpc_resp = &clnt->cl_port,
.rpc_cred = NULL .rpc_cred = NULL
...@@ -218,12 +219,6 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto) ...@@ -218,12 +219,6 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto)
/* /*
* XDR encode/decode functions for PMAP * XDR encode/decode functions for PMAP
*/ */
static int
xdr_error(struct rpc_rqst *req, u32 *p, void *dummy)
{
return -EIO;
}
static int static int
xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct rpc_portmap *map) xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct rpc_portmap *map)
{ {
...@@ -252,26 +247,23 @@ xdr_decode_bool(struct rpc_rqst *req, u32 *p, unsigned int *boolp) ...@@ -252,26 +247,23 @@ xdr_decode_bool(struct rpc_rqst *req, u32 *p, unsigned int *boolp)
return 0; return 0;
} }
static struct rpc_procinfo pmap_procedures[4] = { static struct rpc_procinfo pmap_procedures[] = {
{ .p_procname = "pmap_null", [PMAP_SET] = {
.p_encode = (kxdrproc_t) xdr_error, .p_proc = PMAP_SET,
.p_decode = (kxdrproc_t) xdr_error,
.p_bufsiz = 0,
.p_count = 0,
},
{ .p_procname = "pmap_set",
.p_encode = (kxdrproc_t) xdr_encode_mapping, .p_encode = (kxdrproc_t) xdr_encode_mapping,
.p_decode = (kxdrproc_t) xdr_decode_bool, .p_decode = (kxdrproc_t) xdr_decode_bool,
.p_bufsiz = 4, .p_bufsiz = 4,
.p_count = 1, .p_count = 1,
}, },
{ .p_procname = "pmap_unset", [PMAP_UNSET] = {
.p_proc = PMAP_UNSET,
.p_encode = (kxdrproc_t) xdr_encode_mapping, .p_encode = (kxdrproc_t) xdr_encode_mapping,
.p_decode = (kxdrproc_t) xdr_decode_bool, .p_decode = (kxdrproc_t) xdr_decode_bool,
.p_bufsiz = 4, .p_bufsiz = 4,
.p_count = 1, .p_count = 1,
}, },
{ .p_procname = "pmap_get", [PMAP_GETPORT] = {
.p_proc = PMAP_GETPORT,
.p_encode = (kxdrproc_t) xdr_encode_mapping, .p_encode = (kxdrproc_t) xdr_encode_mapping,
.p_decode = (kxdrproc_t) xdr_decode_port, .p_decode = (kxdrproc_t) xdr_decode_port,
.p_bufsiz = 4, .p_bufsiz = 4,
......
...@@ -1123,7 +1123,8 @@ void rpc_show_tasks(void) ...@@ -1123,7 +1123,8 @@ void rpc_show_tasks(void)
"-rpcwait -action- --exit--\n"); "-rpcwait -action- --exit--\n");
alltask_for_each(t, le, &all_tasks) alltask_for_each(t, le, &all_tasks)
printk("%05d %04d %04x %06d %8p %6d %8p %08ld %8s %8p %8p\n", printk("%05d %04d %04x %06d %8p %6d %8p %08ld %8s %8p %8p\n",
t->tk_pid, t->tk_msg.rpc_proc, t->tk_flags, t->tk_status, t->tk_pid, t->tk_msg.rpc_proc->p_proc,
t->tk_flags, t->tk_status,
t->tk_client, t->tk_client->cl_prog, t->tk_client, t->tk_client->cl_prog,
t->tk_rqstp, t->tk_timeout, t->tk_rqstp, t->tk_timeout,
t->tk_rpcwait ? rpc_qname(t->tk_rpcwait) : " <NULL> ", t->tk_rpcwait ? rpc_qname(t->tk_rpcwait) : " <NULL> ",
......
...@@ -585,7 +585,7 @@ xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied) ...@@ -585,7 +585,7 @@ xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied)
__xprt_put_cong(xprt, req); __xprt_put_cong(xprt, req);
if (!req->rq_nresend) { if (!req->rq_nresend) {
unsigned timer = unsigned timer =
rpcproc_timer(clnt, task->tk_msg.rpc_proc); task->tk_msg.rpc_proc->p_timer;
if (timer) if (timer)
rpc_update_rtt(&clnt->cl_rtt, timer, rpc_update_rtt(&clnt->cl_rtt, timer,
(long)jiffies - req->rq_xtime); (long)jiffies - req->rq_xtime);
...@@ -1223,7 +1223,7 @@ do_xprt_transmit(struct rpc_task *task) ...@@ -1223,7 +1223,7 @@ do_xprt_transmit(struct rpc_task *task)
/* Set the task's receive timeout value */ /* Set the task's receive timeout value */
if (!xprt->nocong) { if (!xprt->nocong) {
task->tk_timeout = rpc_calc_rto(&clnt->cl_rtt, task->tk_timeout = rpc_calc_rto(&clnt->cl_rtt,
rpcproc_timer(clnt, task->tk_msg.rpc_proc)); task->tk_msg.rpc_proc->p_timer);
req->rq_ntimeo = 0; req->rq_ntimeo = 0;
if (task->tk_timeout > req->rq_timeout.to_maxval) if (task->tk_timeout > req->rq_timeout.to_maxval)
task->tk_timeout = req->rq_timeout.to_maxval; task->tk_timeout = req->rq_timeout.to_maxval;
......
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