Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6
[powerpc.git] / fs / nfsd / nfs4callback.c
index f6ca9fb..864090e 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/inet.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
+#include <linux/sched.h>
 #include <linux/sunrpc/xdr.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/clnt.h>
@@ -85,8 +86,8 @@ enum nfs_cb_opnum4 {
 /*
 * Generic encode routines from fs/nfs/nfs4xdr.c
 */
-static inline u32 *
-xdr_writemem(u32 *p, const void *ptr, int nbytes)
+static inline __be32 *
+xdr_writemem(__be32 *p, const void *ptr, int nbytes)
 {
        int tmp = XDR_QUADLEN(nbytes);
        if (!tmp)
@@ -205,7 +206,7 @@ nfs_cb_stat_to_errno(int stat)
 static int
 encode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr)
 {
-       u32 * p;
+       __be32 * p;
 
        RESERVE_SPACE(16);
        WRITE32(0);            /* tag length is always 0 */
@@ -218,7 +219,7 @@ encode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr)
 static int
 encode_cb_recall(struct xdr_stream *xdr, struct nfs4_cb_recall *cb_rec)
 {
-       u32 *p;
+       __be32 *p;
        int len = cb_rec->cbr_fhlen;
 
        RESERVE_SPACE(12+sizeof(cb_rec->cbr_stateid) + len);
@@ -231,7 +232,7 @@ encode_cb_recall(struct xdr_stream *xdr, struct nfs4_cb_recall *cb_rec)
 }
 
 static int
-nfs4_xdr_enc_cb_null(struct rpc_rqst *req, u32 *p)
+nfs4_xdr_enc_cb_null(struct rpc_rqst *req, __be32 *p)
 {
        struct xdr_stream xdrs, *xdr = &xdrs;
 
@@ -241,7 +242,7 @@ nfs4_xdr_enc_cb_null(struct rpc_rqst *req, u32 *p)
 }
 
 static int
-nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, u32 *p, struct nfs4_cb_recall *args)
+nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, __be32 *p, struct nfs4_cb_recall *args)
 {
        struct xdr_stream xdr;
        struct nfs4_cb_compound_hdr hdr = {
@@ -257,7 +258,7 @@ nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, u32 *p, struct nfs4_cb_recall *args
 
 static int
 decode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr){
-        u32 *p;
+        __be32 *p;
 
         READ_BUF(8);
         READ32(hdr->status);
@@ -272,7 +273,7 @@ decode_cb_compound_hdr(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr)
 static int
 decode_cb_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
 {
-       u32 *p;
+       __be32 *p;
        u32 op;
        int32_t nfserr;
 
@@ -291,13 +292,13 @@ decode_cb_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
 }
 
 static int
-nfs4_xdr_dec_cb_null(struct rpc_rqst *req, u32 *p)
+nfs4_xdr_dec_cb_null(struct rpc_rqst *req, __be32 *p)
 {
        return 0;
 }
 
 static int
-nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, u32 *p)
+nfs4_xdr_dec_cb_recall(struct rpc_rqst *rqstp, __be32 *p)
 {
        struct xdr_stream xdr;
        struct nfs4_cb_compound_hdr hdr;
@@ -315,16 +316,13 @@ out:
 /*
  * RPC procedure tables
  */
-#ifndef MAX
-# define MAX(a, b)      (((a) > (b))? (a) : (b))
-#endif
-
 #define PROC(proc, call, argtype, restype)                              \
 [NFSPROC4_CLNT_##proc] = {                                             \
         .p_proc   = NFSPROC4_CB_##call,                                        \
         .p_encode = (kxdrproc_t) nfs4_xdr_##argtype,                    \
         .p_decode = (kxdrproc_t) nfs4_xdr_##restype,                    \
-        .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2,  \
+        .p_arglen = NFS4_##argtype##_sz,                                \
+        .p_replen = NFS4_##restype##_sz,                                \
         .p_statidx = NFSPROC4_CB_##call,                               \
        .p_name   = #proc,                                              \
 }
@@ -387,7 +385,6 @@ nfsd4_probe_callback(struct nfs4_client *clp)
                .address        = (struct sockaddr *)&addr,
                .addrsize       = sizeof(addr),
                .timeout        = &timeparms,
-               .servername     = clp->cl_name.data,
                .program        = program,
                .version        = nfs_cb_version[1]->number,
                .authflavor     = RPC_AUTH_UNIX,        /* XXX: need AUTH_GSS... */
@@ -397,6 +394,7 @@ nfsd4_probe_callback(struct nfs4_client *clp)
                .rpc_proc       = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL],
                .rpc_argp       = clp,
        };
+       char clientname[16];
        int status;
 
        if (atomic_read(&cb->cb_set))
@@ -419,9 +417,14 @@ nfsd4_probe_callback(struct nfs4_client *clp)
        memset(program->stats, 0, sizeof(cb->cb_stat));
        program->stats->program = program;
 
+       /* Just here to make some printk's more useful: */
+       snprintf(clientname, sizeof(clientname),
+               "%u.%u.%u.%u", NIPQUAD(addr.sin_addr));
+       args.servername = clientname;
+
        /* Create RPC client */
        cb->cb_client = rpc_create(&args);
-       if (!cb->cb_client) {
+       if (IS_ERR(cb->cb_client)) {
                dprintk("NFSD: couldn't create callback client\n");
                goto out_err;
        }
@@ -448,10 +451,10 @@ nfsd4_probe_callback(struct nfs4_client *clp)
 out_rpciod:
        atomic_dec(&clp->cl_count);
        rpciod_down();
-       cb->cb_client = NULL;
 out_clnt:
        rpc_shutdown_client(cb->cb_client);
 out_err:
+       cb->cb_client = NULL;
        dprintk("NFSD: warning: no callback path to client %.*s\n",
                (int)clp->cl_name.len, clp->cl_name.data);
 }
@@ -461,7 +464,7 @@ nfs4_cb_null(struct rpc_task *task, void *dummy)
 {
        struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp;
        struct nfs4_callback *cb = &clp->cl_callback;
-       u32 addr = htonl(cb->cb_addr);
+       __be32 addr = htonl(cb->cb_addr);
 
        dprintk("NFSD: nfs4_cb_null task->tk_status %d\n", task->tk_status);