struct nlm_args *argp = &req->a_args;
struct nlm_res *resp = &req->a_res;
struct file *filp = argp->lock.fl.fl_file;
- struct rpc_message msg;
+ struct rpc_message msg = {
+ .rpc_argp = argp,
+ .rpc_resp = resp,
+ };
int status;
- dprintk("lockd: call procedure %s on %s\n",
- nlm_procname(proc), host->h_name);
+ dprintk("lockd: call procedure %d on %s\n",
+ (int)proc, host->h_name);
- msg.rpc_proc = proc;
- msg.rpc_argp = argp;
- msg.rpc_resp = resp;
if (filp)
msg.rpc_cred = nfs_file_cred(filp);
- else
- msg.rpc_cred = NULL;
do {
if (host->h_reclaiming && !argp->reclaim) {
/* If we have no RPC client yet, create one. */
if ((clnt = nlm_bind_host(host)) == NULL)
return -ENOLCK;
+ msg.rpc_proc = &clnt->cl_procinfo[proc];
/* Perform the RPC call. If an error occurs, try again */
if ((status = rpc_call_sync(clnt, &msg, 0)) < 0) {
{
struct nlm_host *host = req->a_host;
struct rpc_clnt *clnt;
- struct nlm_args *argp = &req->a_args;
- struct nlm_res *resp = &req->a_res;
- struct rpc_message msg;
+ struct rpc_message msg = {
+ .rpc_argp = &req->a_args,
+ .rpc_resp = &req->a_res,
+ };
int status;
- dprintk("lockd: call procedure %s on %s (async)\n",
- nlm_procname(proc), host->h_name);
+ dprintk("lockd: call procedure %d on %s (async)\n",
+ (int)proc, host->h_name);
/* If we have no RPC client yet, create one. */
if ((clnt = nlm_bind_host(host)) == NULL)
return -ENOLCK;
+ msg.rpc_proc = &clnt->cl_procinfo[proc];
/* 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);
return status;
struct nlm_args *argp = &req->a_args;
struct nlm_res *resp = &req->a_res;
struct file *file = argp->lock.fl.fl_file;
- struct rpc_message msg;
+ struct rpc_message msg = {
+ .rpc_argp = argp,
+ .rpc_resp = resp,
+ };
int status;
- dprintk("lockd: call procedure %s on %s (async)\n",
- nlm_procname(proc), host->h_name);
+ dprintk("lockd: call procedure %d on %s (async)\n",
+ (int)proc, host->h_name);
/* If we have no RPC client yet, create one. */
if ((clnt = nlm_bind_host(host)) == NULL)
return -ENOLCK;
+ msg.rpc_proc = &clnt->cl_procinfo[proc];
/* bootstrap and kick off the async RPC call */
- msg.rpc_proc = proc;
- msg.rpc_argp = argp;
- msg.rpc_resp =resp;
if (file)
msg.rpc_cred = nfs_file_cred(file);
- else
- msg.rpc_cred = NULL;
/* Increment host refcount */
nlm_get_host(host);
status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req);
/*
* XDR functions for NSM.
*/
-static int
-xdr_error(struct rpc_rqst *rqstp, u32 *p, void *dummy)
-{
- return -EACCES;
-}
static int
xdr_encode_mon(struct rpc_rqst *rqstp, u32 *p, struct nsm_args *argp)
#endif
static struct rpc_procinfo nsm_procedures[] = {
- {
- .p_procname = "sm_null",
- .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",
+[SM_MON] = {
+ .p_proc = SM_MON,
.p_encode = (kxdrproc_t) xdr_encode_mon,
.p_decode = (kxdrproc_t) xdr_decode_stat_res,
.p_bufsiz = MAX(SM_mon_sz, SM_monres_sz) << 2,
},
- {
- .p_procname = "sm_unmon",
+[SM_UNMON] = {
+ .p_proc = SM_UNMON,
.p_encode = (kxdrproc_t) xdr_encode_mon,
.p_decode = (kxdrproc_t) xdr_decode_stat,
.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 = {
#define nlmclt_decode_norep NULL
#define PROC(proc, argtype, restype) \
- { .p_procname = "nlm_" #proc, \
- .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \
- .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \
- .p_bufsiz = MAX(NLM_##argtype##_sz, NLM_##restype##_sz) << 2 \
- }
+[NLMPROC_##proc] = { \
+ .p_proc = NLMPROC_##proc, \
+ .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \
+ .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \
+ .p_bufsiz = MAX(NLM_##argtype##_sz, NLM_##restype##_sz) << 2 \
+ }
static struct rpc_procinfo nlm_procedures[] = {
- PROC(null, void, void),
- PROC(test, testargs, testres),
- PROC(lock, lockargs, res),
- PROC(canc, cancargs, res),
- PROC(unlock, unlockargs, res),
- PROC(granted, testargs, res),
- PROC(test_msg, testargs, norep),
- PROC(lock_msg, lockargs, norep),
- PROC(canc_msg, cancargs, norep),
- PROC(unlock_msg, unlockargs, norep),
- PROC(granted_msg, testargs, norep),
- PROC(test_res, testres, norep),
- PROC(lock_res, res, norep),
- PROC(canc_res, res, norep),
- PROC(unlock_res, res, norep),
- PROC(granted_res, res, norep),
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
+ PROC(TEST, testargs, testres),
+ PROC(LOCK, lockargs, res),
+ PROC(CANCEL, cancargs, res),
+ PROC(UNLOCK, unlockargs, res),
+ PROC(GRANTED, testargs, res),
+ PROC(TEST_MSG, testargs, norep),
+ PROC(LOCK_MSG, lockargs, norep),
+ PROC(CANCEL_MSG, cancargs, norep),
+ PROC(UNLOCK_MSG, unlockargs, norep),
+ PROC(GRANTED_MSG, testargs, norep),
+ PROC(TEST_RES, testres, norep),
+ PROC(LOCK_RES, res, norep),
+ PROC(CANCEL_RES, res, norep),
+ PROC(UNLOCK_RES, res, norep),
+ PROC(GRANTED_RES, res, norep),
#ifdef NLMCLNT_SUPPORT_SHARES
- PROC(share, shareargs, shareres),
- PROC(unshare, shareargs, shareres),
- PROC(nm_lock, lockargs, res),
- PROC(free_all, notify, void),
-#else
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
+ PROC(SHARE, shareargs, shareres),
+ PROC(UNSHARE, shareargs, shareres),
+ PROC(NM_LOCK, lockargs, res),
+ PROC(FREE_ALL, notify, void),
#endif
};
.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
-
#define nlm4clt_decode_norep NULL
#define PROC(proc, argtype, restype) \
- { .p_procname = "nlm4_" #proc, \
- .p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \
- .p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \
- .p_bufsiz = MAX(NLM4_##argtype##_sz, NLM4_##restype##_sz) << 2 \
- }
+[NLMPROC_##proc] = { \
+ .p_proc = NLMPROC_##proc, \
+ .p_encode = (kxdrproc_t) nlm4clt_encode_##argtype, \
+ .p_decode = (kxdrproc_t) nlm4clt_decode_##restype, \
+ .p_bufsiz = MAX(NLM4_##argtype##_sz, NLM4_##restype##_sz) << 2 \
+ }
static struct rpc_procinfo nlm4_procedures[] = {
- PROC(null, void, void),
- PROC(test, testargs, testres),
- PROC(lock, lockargs, res),
- PROC(canc, cancargs, res),
- PROC(unlock, unlockargs, res),
- PROC(granted, testargs, res),
- PROC(test_msg, testargs, norep),
- PROC(lock_msg, lockargs, norep),
- PROC(canc_msg, cancargs, norep),
- PROC(unlock_msg, unlockargs, norep),
- PROC(granted_msg, testargs, norep),
- PROC(test_res, testres, norep),
- PROC(lock_res, res, norep),
- PROC(canc_res, res, norep),
- PROC(unlock_res, res, norep),
- PROC(granted_res, res, norep),
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
+ PROC(TEST, testargs, testres),
+ PROC(LOCK, lockargs, res),
+ PROC(CANCEL, cancargs, res),
+ PROC(UNLOCK, unlockargs, res),
+ PROC(GRANTED, testargs, res),
+ PROC(TEST_MSG, testargs, norep),
+ PROC(LOCK_MSG, lockargs, norep),
+ PROC(CANCEL_MSG, cancargs, norep),
+ PROC(UNLOCK_MSG, unlockargs, norep),
+ PROC(GRANTED_MSG, testargs, norep),
+ PROC(TEST_RES, testres, norep),
+ PROC(LOCK_RES, res, norep),
+ PROC(CANCEL_RES, res, norep),
+ PROC(UNLOCK_RES, res, norep),
+ PROC(GRANTED_RES, res, norep),
#ifdef NLMCLNT_SUPPORT_SHARES
- PROC(share, shareargs, shareres),
- PROC(unshare, shareargs, shareres),
- PROC(nm_lock, lockargs, res),
- PROC(free_all, notify, void),
-#else
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
- PROC(undef, void, void),
+ PROC(SHARE, shareargs, shareres),
+ PROC(UNSHARE, shareargs, shareres),
+ PROC(NM_LOCK, lockargs, res),
+ PROC(FREE_ALL, notify, void),
#endif
};
#define MNT_dirpath_sz (1 + 256)
#define MNT_fhstatus_sz (1 + 8)
-static struct rpc_procinfo mnt_procedures[2] = {
- { .p_procname = "mnt_null",
- .p_encode = (kxdrproc_t) xdr_error,
- .p_decode = (kxdrproc_t) xdr_error,
- },
- { .p_procname = "mnt_mount",
+static struct rpc_procinfo mnt_procedures[] = {
+[MNTPROC_MNT] = {
+ .p_proc = MNTPROC_MNT,
.p_encode = (kxdrproc_t) xdr_encode_dirpath,
.p_decode = (kxdrproc_t) xdr_decode_fhstatus,
.p_bufsiz = MNT_dirpath_sz << 2,
},
};
-static struct rpc_procinfo mnt3_procedures[2] = {
- { .p_procname = "mnt3_null",
- .p_encode = (kxdrproc_t) xdr_error,
- .p_decode = (kxdrproc_t) xdr_error,
- },
- { .p_procname = "mnt3_mount",
+static struct rpc_procinfo mnt3_procedures[] = {
+[MOUNTPROC3_MNT] = {
+ .p_proc = MOUNTPROC3_MNT,
.p_encode = (kxdrproc_t) xdr_encode_dirpath,
.p_decode = (kxdrproc_t) xdr_decode_fhstatus3,
.p_bufsiz = MNT_dirpath_sz << 2,
#endif
#define PROC(proc, argtype, restype, timer) \
- { .p_procname = "nfs_" #proc, \
- .p_encode = (kxdrproc_t) nfs_xdr_##argtype, \
- .p_decode = (kxdrproc_t) nfs_xdr_##restype, \
- .p_bufsiz = MAX(NFS_##argtype##_sz,NFS_##restype##_sz) << 2, \
- .p_timer = timer \
- }
-static struct rpc_procinfo nfs_procedures[18] = {
- PROC(null, enc_void, dec_void, 0),
- PROC(getattr, fhandle, attrstat, 1),
- PROC(setattr, sattrargs, attrstat, 0),
- PROC(root, enc_void, dec_void, 0),
- PROC(lookup, diropargs, diropres, 2),
- PROC(readlink, readlinkargs, readlinkres, 3),
- PROC(read, readargs, readres, 3),
- PROC(writecache, enc_void, dec_void, 0),
- PROC(write, writeargs, writeres, 4),
- PROC(create, createargs, diropres, 0),
- PROC(remove, diropargs, stat, 0),
- PROC(rename, renameargs, stat, 0),
- PROC(link, linkargs, stat, 0),
- PROC(symlink, symlinkargs, stat, 0),
- PROC(mkdir, createargs, diropres, 0),
- PROC(rmdir, diropargs, stat, 0),
- PROC(readdir, readdirargs, readdirres, 3),
- PROC(statfs, fhandle, statfsres, 0),
+[NFSPROC_##proc] = { \
+ .p_proc = NFSPROC_##proc, \
+ .p_encode = (kxdrproc_t) nfs_xdr_##argtype, \
+ .p_decode = (kxdrproc_t) nfs_xdr_##restype, \
+ .p_bufsiz = MAX(NFS_##argtype##_sz,NFS_##restype##_sz) << 2, \
+ .p_timer = timer \
+ }
+struct rpc_procinfo nfs_procedures[] = {
+ PROC(GETATTR, fhandle, attrstat, 1),
+ PROC(SETATTR, sattrargs, attrstat, 0),
+ PROC(LOOKUP, diropargs, diropres, 2),
+ PROC(READLINK, readlinkargs, readlinkres, 3),
+ PROC(READ, readargs, readres, 3),
+ PROC(WRITE, writeargs, writeres, 4),
+ PROC(CREATE, createargs, diropres, 0),
+ PROC(REMOVE, diropargs, stat, 0),
+ PROC(RENAME, renameargs, stat, 0),
+ PROC(LINK, linkargs, stat, 0),
+ PROC(SYMLINK, symlinkargs, stat, 0),
+ PROC(MKDIR, createargs, diropres, 0),
+ PROC(RMDIR, diropargs, stat, 0),
+ PROC(READDIR, readdirargs, readdirres, 3),
+ PROC(STATFS, fhandle, statfsres, 0),
};
struct rpc_version nfs_version2 = {
#define NFSDBG_FACILITY NFSDBG_PROC
+extern struct rpc_procinfo nfs3_procedures[];
+
/* A wrapper to handle the EJUKEBOX error message */
static int
nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
nfs3_rpc_call_wrapper(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
{
struct rpc_message msg = {
- .rpc_proc = proc,
+ .rpc_proc = &nfs3_procedures[proc],
.rpc_argp = argp,
.rpc_resp = resp,
};
.fattr = &fattr,
};
struct rpc_message msg = {
- .rpc_proc = NFS3PROC_ACCESS,
+ .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS],
.rpc_argp = &arg,
.rpc_resp = &res,
.rpc_cred = cred
.count = count,
};
struct rpc_message msg = {
- .rpc_proc = NFS3PROC_READ,
+ .rpc_proc = &nfs3_procedures[NFS3PROC_READ],
.rpc_argp = &arg,
.rpc_resp = &res,
.rpc_cred = cred
.verf = verf,
};
struct rpc_message msg = {
- .rpc_proc = NFS3PROC_WRITE,
+ .rpc_proc = &nfs3_procedures[NFS3PROC_WRITE],
.rpc_argp = &arg,
.rpc_resp = &res,
.rpc_cred = cred
.len = name->len
};
struct rpc_message msg = {
- .rpc_proc = NFS3PROC_REMOVE,
+ .rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE],
.rpc_argp = &arg,
.rpc_resp = &dir_attr,
};
arg->name = name->name;
arg->len = name->len;
res->valid = 0;
- msg->rpc_proc = NFS3PROC_REMOVE;
+ msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
msg->rpc_argp = arg;
msg->rpc_resp = res;
return 0;
.plus = plus
};
struct rpc_message msg = {
- .rpc_proc = NFS3PROC_READDIR,
+ .rpc_proc = &nfs3_procedures[NFS3PROC_READDIR],
.rpc_argp = &arg,
.rpc_resp = &res,
.rpc_cred = cred
lock_kernel();
if (plus)
- msg.rpc_proc = NFS3PROC_READDIRPLUS;
+ msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS];
dprintk("NFS call readdir%s %d\n",
plus? "plus" : "", (unsigned int) cookie);
struct inode *inode = data->inode;
struct nfs_page *req;
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);
data->u.v3.args.fh = NFS_FH(inode);
/* Release requests */
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);
}
struct nfs_page *req;
int stable;
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 (!NFS_I(inode)->ncommit)
/* Release requests */
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);
}
struct rpc_task *task = &data->task;
struct inode *inode = data->inode;
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.offset = start;
/* Release requests */
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);
}
#define NFS3_pathconf_sz
#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_diropargs_sz NFS3_fh_sz+NFS3_filename_sz
#define NFS3_accessargs_sz NFS3_fh_sz+1
#define NFS3_readdirargs_sz NFS3_fh_sz+2
#define NFS3_commitargs_sz NFS3_fh_sz+3
-#define NFS3_dec_void_sz 0
#define NFS3_attrstat_sz 1+NFS3_fattr_sz
#define NFS3_wccstat_sz 1+NFS3_wcc_data_sz
#define NFS3_lookupres_sz 1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz)
/*
* 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
/*
* 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.
#endif
#define PROC(proc, argtype, restype, timer) \
- { .p_procname = "nfs3_" #proc, \
- .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
- .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
- .p_bufsiz = MAX(NFS3_##argtype##_sz,NFS3_##restype##_sz) << 2, \
- .p_timer = timer \
- }
-
-static struct rpc_procinfo nfs3_procedures[22] = {
- PROC(null, enc_void, dec_void, 0),
- PROC(getattr, fhandle, attrstat, 1),
- PROC(setattr, sattrargs, wccstat, 0),
- PROC(lookup, diropargs, lookupres, 2),
- PROC(access, accessargs, accessres, 1),
- PROC(readlink, readlinkargs, readlinkres, 3),
- PROC(read, readargs, readres, 3),
- PROC(write, writeargs, writeres, 4),
- PROC(create, createargs, createres, 0),
- PROC(mkdir, mkdirargs, createres, 0),
- PROC(symlink, symlinkargs, createres, 0),
- PROC(mknod, mknodargs, createres, 0),
- PROC(remove, diropargs, wccstat, 0),
- PROC(rmdir, diropargs, wccstat, 0),
- PROC(rename, renameargs, renameres, 0),
- PROC(link, linkargs, linkres, 0),
- PROC(readdir, readdirargs, readdirres, 3),
- PROC(readdirplus, readdirargs, readdirres, 3),
- PROC(fsstat, fhandle, fsstatres, 0),
- PROC(fsinfo, fhandle, fsinfores, 0),
- PROC(pathconf, fhandle, pathconfres, 0),
- PROC(commit, commitargs, commitres, 5),
+[NFS3PROC_##proc] = { \
+ .p_proc = NFS3PROC_##proc, \
+ .p_encode = (kxdrproc_t) nfs3_xdr_##argtype, \
+ .p_decode = (kxdrproc_t) nfs3_xdr_##restype, \
+ .p_bufsiz = MAX(NFS3_##argtype##_sz,NFS3_##restype##_sz) << 2, \
+ .p_timer = timer \
+ }
+
+struct rpc_procinfo nfs3_procedures[] = {
+ PROC(GETATTR, fhandle, attrstat, 1),
+ PROC(SETATTR, sattrargs, wccstat, 0),
+ PROC(LOOKUP, diropargs, lookupres, 2),
+ PROC(ACCESS, accessargs, accessres, 1),
+ PROC(READLINK, readlinkargs, readlinkres, 3),
+ PROC(READ, readargs, readres, 3),
+ PROC(WRITE, writeargs, writeres, 4),
+ PROC(CREATE, createargs, createres, 0),
+ PROC(MKDIR, mkdirargs, createres, 0),
+ PROC(SYMLINK, symlinkargs, createres, 0),
+ PROC(MKNOD, mknodargs, createres, 0),
+ PROC(REMOVE, diropargs, wccstat, 0),
+ PROC(RMDIR, diropargs, wccstat, 0),
+ PROC(RENAME, renameargs, renameres, 0),
+ PROC(LINK, linkargs, linkres, 0),
+ PROC(READDIR, readdirargs, readdirres, 3),
+ PROC(READDIRPLUS, readdirargs, readdirres, 3),
+ PROC(FSSTAT, fhandle, fsstatres, 0),
+ PROC(FSINFO, fhandle, fsinfores, 0),
+ PROC(PATHCONF, fhandle, pathconfres, 0),
+ PROC(COMMIT, commitargs, commitres, 5),
};
struct rpc_version nfs_version3 = {
#define OPNUM(cp) cp->ops[cp->req_nops].opnum
extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus);
+extern struct rpc_procinfo nfs4_procedures[];
static nfs4_stateid zero_stateid =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
{
int status;
struct rpc_message msg = {
- .rpc_proc = NFSPROC4_COMPOUND,
+ .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp,
.rpc_resp = cp,
.rpc_cred = cred,
nfs4_setup_remove(cp, name, &up->cinfo);
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_resp = cp;
return 0;
struct rpc_task *task = &data->task;
struct nfs4_compound *cp = &data->u.v4.compound;
struct rpc_message msg = {
- .rpc_proc = NFSPROC4_COMPOUND,
+ .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp,
.rpc_resp = cp,
.rpc_cred = data->cred,
struct rpc_task *task = &data->task;
struct nfs4_compound *cp = &data->u.v4.compound;
struct rpc_message msg = {
- .rpc_proc = NFSPROC4_COMPOUND,
+ .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp,
.rpc_resp = cp,
.rpc_cred = data->cred,
struct rpc_task *task = &data->task;
struct nfs4_compound *cp = &data->u.v4.compound;
struct rpc_message msg = {
- .rpc_proc = NFSPROC4_COMPOUND,
+ .rpc_proc = &nfs4_procedures[NFSPROC4_COMPOUND],
.rpc_argp = cp,
.rpc_resp = cp,
.rpc_cred = data->cred,
struct renew_desc *rp;
struct rpc_task *task;
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);
if (!rp)
nfs4_setup_compound(cp, rp->ops, server, "renew");
nfs4_setup_renew(cp);
- msg.rpc_proc = NFSPROC4_COMPOUND;
msg.rpc_argp = cp;
msg.rpc_resp = cp;
- msg.rpc_cred = NULL;
rpc_init_task(task, server->client, renew_done, RPC_TASK_ASYNC);
rpc_call_setup(task, &msg, 0);
task->tk_calldata = rp;
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_dec_compound_sz 1024 /* XXX: large enough? */
ENCODE_TAIL;
}
+/* FIXME: this sucks */
static int
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
*/
DECODE_TAIL;
}
+/* FIXME: this sucks */
static int
decode_compound(struct nfs4_compound *cp, struct rpc_rqst *req)
{
* 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
*/
#endif
#define PROC(proc, argtype, restype) \
- { "nfs4_" #proc, \
- (kxdrproc_t) nfs4_xdr_##argtype, \
- (kxdrproc_t) nfs4_xdr_##restype, \
- MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \
- 0 \
+[NFSPROC4_##proc] = { \
+ .p_proc = NFSPROC4_##proc, \
+ .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
+ .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
+ .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \
}
-static struct rpc_procinfo nfs4_procedures[] = {
- PROC(null, enc_void, dec_void),
- PROC(compound, enc_compound, dec_compound)
+struct rpc_procinfo nfs4_procedures[] = {
+ PROC(COMPOUND, enc_compound, dec_compound)
};
struct rpc_version nfs_version4 = {
#define NFSDBG_FACILITY NFSDBG_PROC
+extern struct rpc_procinfo nfs_procedures[];
+
/*
* Bare-bones access to getattr: this is for nfs_read_super.
*/
.count = count
};
struct rpc_message msg = {
- .rpc_proc = NFSPROC_READ,
+ .rpc_proc = &nfs_procedures[NFSPROC_READ],
.rpc_argp = &arg,
.rpc_resp = &res,
.rpc_cred = cred
.count = count
};
struct rpc_message msg = {
- .rpc_proc = NFSPROC_WRITE,
+ .rpc_proc = &nfs_procedures[NFSPROC_WRITE],
.rpc_argp = &arg,
.rpc_resp = &res,
.rpc_cred = cred
.len = name->len
};
struct rpc_message msg = {
- .rpc_proc = NFSPROC_REMOVE,
+ .rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
.rpc_argp = &arg,
.rpc_resp = NULL,
.rpc_cred = NULL
arg->fh = NFS_FH(dir->d_inode);
arg->name = name->name;
arg->len = name->len;
- msg->rpc_proc = NFSPROC_REMOVE;
+ msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
msg->rpc_argp = arg;
return 0;
}
.pages = &page
};
struct rpc_message msg = {
- .rpc_proc = NFSPROC_READDIR,
+ .rpc_proc = &nfs_procedures[NFSPROC_READDIR],
.rpc_argp = &arg,
.rpc_resp = NULL,
.rpc_cred = cred
struct inode *inode = data->inode;
struct nfs_page *req;
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);
data->u.v3.args.fh = NFS_FH(inode);
/* Release requests */
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);
}
struct inode *inode = data->inode;
struct nfs_page *req;
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 */
/* Release requests */
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);
}
{
struct nfs_unlinkdata *data = (struct nfs_unlinkdata *)task->tk_calldata;
struct dentry *dir = data->dir;
- struct rpc_message msg;
+ struct rpc_message msg = {
+ .rpc_cred = data->cred,
+ };
int status = -ENOENT;
if (!data->name.len)
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);
if (status < 0)
goto out_err;
# define ifdebug(flag) if (0)
#endif
-#ifdef LOCKD_DEBUG
-char * nlm_procname(u32);
-#endif
-
#endif /* __KERNEL__ */
/*
* Procedure information
*/
struct rpc_procinfo {
- char * p_procname; /* procedure name */
+ u32 p_proc; /* RPC procedure number */
kxdrproc_t p_encode; /* XDR encode function */
kxdrproc_t p_decode; /* XDR decode function */
unsigned int p_bufsiz; /* req. buffer size */
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_PEERADDR(clnt) (&(clnt)->cl_xprt->addr)
int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
{
struct rpc_message msg = {
- .rpc_proc = proc,
+ .rpc_proc = &clnt->cl_procinfo[proc],
.rpc_argp = argp,
.rpc_resp = resp,
.rpc_cred = NULL
/*
* This is the actual RPC procedure call info.
*/
+struct rpc_procinfo;
struct rpc_message {
- __u32 rpc_proc; /* Procedure number */
+ struct rpc_procinfo * rpc_proc; /* Procedure information */
void * rpc_argp; /* Arguments */
void * rpc_resp; /* Result */
struct rpc_cred * rpc_cred; /* Credentials */
{
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,
- 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"));
/* Increment call count */
- rpcproc_count(clnt, task->tk_msg.rpc_proc)++;
+ task->tk_msg.rpc_proc->p_count++;
clnt->cl_stats->rpccnt++;
task->tk_action = call_reserve;
}
static void
call_allocate(struct rpc_task *task)
{
- struct rpc_clnt *clnt = task->tk_client;
unsigned int bufsiz;
dprintk("RPC: %4d call_allocate (status %d)\n",
/* FIXME: compute buffer requirements more exactly using
* 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)
return;
memset(task->tk_buffer, 0, bufsiz);
/* 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))) {
printk(KERN_INFO "RPC: call_header failed, exit EIO\n");
rpc_exit(task, -EIO);
static void
call_transmit(struct rpc_task *task)
{
- struct rpc_clnt *clnt = task->tk_client;
-
dprintk("RPC: %4d call_transmit (status %d)\n",
task->tk_pid, task->tk_status);
if (task->tk_status < 0)
return;
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;
rpc_wake_up_task(task);
}
{
struct rpc_clnt *clnt = task->tk_client;
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;
dprintk("RPC: %4d call_decode (status %d)\n",
*p++ = htonl(RPC_VERSION); /* RPC version */
*p++ = htonl(clnt->cl_prog); /* program number */
*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);
}
#define PMAP_UNSET 2
#define PMAP_GETPORT 3
+static struct rpc_procinfo pmap_procedures[];
static struct rpc_clnt * pmap_create(char *, struct sockaddr_in *, int);
static void pmap_getport_done(struct rpc_task *);
extern struct rpc_program pmap_program;
struct rpc_portmap *map = &clnt->cl_pmap;
struct sockaddr_in *sap = &clnt->cl_xprt->addr;
struct rpc_message msg = {
- .rpc_proc = PMAP_GETPORT,
+ .rpc_proc = &pmap_procedures[PMAP_GETPORT],
.rpc_argp = map,
.rpc_resp = &clnt->cl_port,
.rpc_cred = NULL
/*
* XDR encode/decode functions for PMAP
*/
-static int
-xdr_error(struct rpc_rqst *req, u32 *p, void *dummy)
-{
- return -EIO;
-}
-
static int
xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct rpc_portmap *map)
{
return 0;
}
-static struct rpc_procinfo pmap_procedures[4] = {
- { .p_procname = "pmap_null",
- .p_encode = (kxdrproc_t) xdr_error,
- .p_decode = (kxdrproc_t) xdr_error,
- .p_bufsiz = 0,
- .p_count = 0,
- },
- { .p_procname = "pmap_set",
+static struct rpc_procinfo pmap_procedures[] = {
+[PMAP_SET] = {
+ .p_proc = PMAP_SET,
.p_encode = (kxdrproc_t) xdr_encode_mapping,
.p_decode = (kxdrproc_t) xdr_decode_bool,
.p_bufsiz = 4,
.p_count = 1,
},
- { .p_procname = "pmap_unset",
+[PMAP_UNSET] = {
+ .p_proc = PMAP_UNSET,
.p_encode = (kxdrproc_t) xdr_encode_mapping,
.p_decode = (kxdrproc_t) xdr_decode_bool,
.p_bufsiz = 4,
.p_count = 1,
},
- { .p_procname = "pmap_get",
+[PMAP_GETPORT] = {
+ .p_proc = PMAP_GETPORT,
.p_encode = (kxdrproc_t) xdr_encode_mapping,
.p_decode = (kxdrproc_t) xdr_decode_port,
.p_bufsiz = 4,
"-rpcwait -action- --exit--\n");
alltask_for_each(t, le, &all_tasks)
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_rqstp, t->tk_timeout,
t->tk_rpcwait ? rpc_qname(t->tk_rpcwait) : " <NULL> ",
__xprt_put_cong(xprt, req);
if (!req->rq_nresend) {
unsigned timer =
- rpcproc_timer(clnt, task->tk_msg.rpc_proc);
+ task->tk_msg.rpc_proc->p_timer;
if (timer)
rpc_update_rtt(&clnt->cl_rtt, timer,
(long)jiffies - req->rq_xtime);
/* Set the task's receive timeout value */
if (!xprt->nocong) {
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;
if (task->tk_timeout > req->rq_timeout.to_maxval)
task->tk_timeout = req->rq_timeout.to_maxval;