[pnfs] [PATCH 5/6] nfsd: tabulate nfs4 xdr encoding functions
Benny Halevy
bhalevy at panasas.com
Wed Jul 2 04:14:42 EDT 2008
In preparation for minorversion 1
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfsd/nfs4xdr.c | 144 ++++++++++++++++++-----------------------------------
1 files changed, 49 insertions(+), 95 deletions(-)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index a40bec5..facd247 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2024,8 +2024,9 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
}
static void
-nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh *fhp)
+nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh **fhpp)
{
+ struct svc_fh *fhp = *fhpp;
unsigned int len;
ENCODE_HEAD;
@@ -2549,6 +2550,50 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w
}
}
+static void
+nfsd4_encode_noop(struct nfsd4_compoundres *resp, __be32 nfserr, void *p)
+{
+}
+
+typedef __be32(* nfsd4_enc)(struct nfsd4_compoundres *, __be32, void *);
+
+static nfsd4_enc nfsd4_enc_ops[] = {
+ [OP_ACCESS] (nfsd4_enc)nfsd4_encode_access,
+ [OP_CLOSE] (nfsd4_enc)nfsd4_encode_close,
+ [OP_COMMIT] (nfsd4_enc)nfsd4_encode_commit,
+ [OP_CREATE] (nfsd4_enc)nfsd4_encode_create,
+ [OP_DELEGRETURN] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_GETATTR] (nfsd4_enc)nfsd4_encode_getattr,
+ [OP_GETFH] (nfsd4_enc)nfsd4_encode_getfh,
+ [OP_LINK] (nfsd4_enc)nfsd4_encode_link,
+ [OP_LOCK] (nfsd4_enc)nfsd4_encode_lock,
+ [OP_LOCKT] (nfsd4_enc)nfsd4_encode_lockt,
+ [OP_LOCKU] (nfsd4_enc)nfsd4_encode_locku,
+ [OP_LOOKUP] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_LOOKUPP] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_NVERIFY] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_OPEN] (nfsd4_enc)nfsd4_encode_open,
+ [OP_OPEN_CONFIRM] (nfsd4_enc)nfsd4_encode_open_confirm,
+ [OP_OPEN_DOWNGRADE] (nfsd4_enc)nfsd4_encode_open_downgrade,
+ [OP_PUTFH] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_PUTROOTFH] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_READ] (nfsd4_enc)nfsd4_encode_read,
+ [OP_READDIR] (nfsd4_enc)nfsd4_encode_readdir,
+ [OP_READLINK] (nfsd4_enc)nfsd4_encode_readlink,
+ [OP_REMOVE] (nfsd4_enc)nfsd4_encode_remove,
+ [OP_RENAME] (nfsd4_enc)nfsd4_encode_rename,
+ [OP_RENEW] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_RESTOREFH] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_SAVEFH] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_SECINFO] (nfsd4_enc)nfsd4_encode_secinfo,
+ [OP_SETATTR] (nfsd4_enc)nfsd4_encode_setattr,
+ [OP_SETCLIENTID] (nfsd4_enc)nfsd4_encode_setclientid,
+ [OP_SETCLIENTID_CONFIRM](nfsd4_enc)nfsd4_encode_noop,
+ [OP_VERIFY] (nfsd4_enc)nfsd4_encode_noop,
+ [OP_WRITE] (nfsd4_enc)nfsd4_encode_write,
+ [OP_RELEASE_LOCKOWNER] (nfsd4_enc)nfsd4_encode_noop,
+};
+
void
nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
{
@@ -2560,100 +2605,9 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
statp = p++; /* to be backfilled at the end */
ADJUST_ARGS();
- switch (op->opnum) {
- case OP_ACCESS:
- nfsd4_encode_access(resp, op->status, &op->u.access);
- break;
- case OP_CLOSE:
- nfsd4_encode_close(resp, op->status, &op->u.close);
- break;
- case OP_COMMIT:
- nfsd4_encode_commit(resp, op->status, &op->u.commit);
- break;
- case OP_CREATE:
- nfsd4_encode_create(resp, op->status, &op->u.create);
- break;
- case OP_DELEGRETURN:
- break;
- case OP_GETATTR:
- op->status = nfsd4_encode_getattr(resp, op->status, &op->u.getattr);
- break;
- case OP_GETFH:
- nfsd4_encode_getfh(resp, op->status, op->u.getfh);
- break;
- case OP_LINK:
- nfsd4_encode_link(resp, op->status, &op->u.link);
- break;
- case OP_LOCK:
- nfsd4_encode_lock(resp, op->status, &op->u.lock);
- break;
- case OP_LOCKT:
- nfsd4_encode_lockt(resp, op->status, &op->u.lockt);
- break;
- case OP_LOCKU:
- nfsd4_encode_locku(resp, op->status, &op->u.locku);
- break;
- case OP_LOOKUP:
- break;
- case OP_LOOKUPP:
- break;
- case OP_NVERIFY:
- break;
- case OP_OPEN:
- nfsd4_encode_open(resp, op->status, &op->u.open);
- break;
- case OP_OPEN_CONFIRM:
- nfsd4_encode_open_confirm(resp, op->status, &op->u.open_confirm);
- break;
- case OP_OPEN_DOWNGRADE:
- nfsd4_encode_open_downgrade(resp, op->status, &op->u.open_downgrade);
- break;
- case OP_PUTFH:
- break;
- case OP_PUTROOTFH:
- break;
- case OP_READ:
- op->status = nfsd4_encode_read(resp, op->status, &op->u.read);
- break;
- case OP_READDIR:
- op->status = nfsd4_encode_readdir(resp, op->status, &op->u.readdir);
- break;
- case OP_READLINK:
- op->status = nfsd4_encode_readlink(resp, op->status, &op->u.readlink);
- break;
- case OP_REMOVE:
- nfsd4_encode_remove(resp, op->status, &op->u.remove);
- break;
- case OP_RENAME:
- nfsd4_encode_rename(resp, op->status, &op->u.rename);
- break;
- case OP_RENEW:
- break;
- case OP_RESTOREFH:
- break;
- case OP_SAVEFH:
- break;
- case OP_SECINFO:
- nfsd4_encode_secinfo(resp, op->status, &op->u.secinfo);
- break;
- case OP_SETATTR:
- nfsd4_encode_setattr(resp, op->status, &op->u.setattr);
- break;
- case OP_SETCLIENTID:
- nfsd4_encode_setclientid(resp, op->status, &op->u.setclientid);
- break;
- case OP_SETCLIENTID_CONFIRM:
- break;
- case OP_VERIFY:
- break;
- case OP_WRITE:
- nfsd4_encode_write(resp, op->status, &op->u.write);
- break;
- case OP_RELEASE_LOCKOWNER:
- break;
- default:
- break;
- }
+ BUG_ON(op->opnum < 0 || op->opnum >= ARRAY_SIZE(nfsd4_enc_ops) ||
+ !nfsd4_enc_ops[op->opnum]);
+ nfsd4_enc_ops[op->opnum](resp, op->status, &op->u);
/*
* Note: We write the status directly, instead of using WRITE32(),
--
1.5.6.GIT
More information about the pNFS
mailing list