nfsd4: cl_count is unused
[safe/jmp/linux-2.6] / fs / nfs / callback_xdr.c
index 6ae3278..db30c0b 100644 (file)
@@ -24,6 +24,7 @@
 #define CB_OP_SEQUENCE_RES_MAXSZ       (CB_OP_HDR_RES_MAXSZ + \
                                        4 + 1 + 3)
 #define CB_OP_RECALLANY_RES_MAXSZ      (CB_OP_HDR_RES_MAXSZ)
+#define CB_OP_RECALLSLOT_RES_MAXSZ     (CB_OP_HDR_RES_MAXSZ)
 #endif /* CONFIG_NFS_V4_1 */
 
 #define NFSDBG_FACILITY NFSDBG_CALLBACK
@@ -218,10 +219,10 @@ out:
 
 #if defined(CONFIG_NFS_V4_1)
 
-static unsigned decode_sessionid(struct xdr_stream *xdr,
+static __be32 decode_sessionid(struct xdr_stream *xdr,
                                 struct nfs4_sessionid *sid)
 {
-       uint32_t *p;
+       __be32 *p;
        int len = NFS4_MAX_SESSIONID_LEN;
 
        p = read_buf(xdr, len);
@@ -232,12 +233,12 @@ static unsigned decode_sessionid(struct xdr_stream *xdr,
        return 0;
 }
 
-static unsigned decode_rc_list(struct xdr_stream *xdr,
+static __be32 decode_rc_list(struct xdr_stream *xdr,
                               struct referring_call_list *rc_list)
 {
-       uint32_t *p;
+       __be32 *p;
        int i;
-       unsigned status;
+       __be32 status;
 
        status = decode_sessionid(xdr, &rc_list->rcl_sessionid);
        if (status)
@@ -270,13 +271,13 @@ out:
        return status;
 }
 
-static unsigned decode_cb_sequence_args(struct svc_rqst *rqstp,
+static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
                                        struct xdr_stream *xdr,
                                        struct cb_sequenceargs *args)
 {
-       uint32_t *p;
+       __be32 *p;
        int i;
-       unsigned status;
+       __be32 status;
 
        status = decode_sessionid(xdr, &args->csa_sessionid);
        if (status)
@@ -330,11 +331,11 @@ out_free:
        goto out;
 }
 
-static unsigned decode_recallany_args(struct svc_rqst *rqstp,
+static __be32 decode_recallany_args(struct svc_rqst *rqstp,
                                      struct xdr_stream *xdr,
                                      struct cb_recallanyargs *args)
 {
-       uint32_t *p;
+       __be32 *p;
 
        args->craa_addr = svc_addr(rqstp);
        p = read_buf(xdr, 4);
@@ -349,6 +350,20 @@ static unsigned decode_recallany_args(struct svc_rqst *rqstp,
        return 0;
 }
 
+static __be32 decode_recallslot_args(struct svc_rqst *rqstp,
+                                       struct xdr_stream *xdr,
+                                       struct cb_recallslotargs *args)
+{
+       __be32 *p;
+
+       args->crsa_addr = svc_addr(rqstp);
+       p = read_buf(xdr, 4);
+       if (unlikely(p == NULL))
+               return htonl(NFS4ERR_BADXDR);
+       args->crsa_target_max_slots = ntohl(*p++);
+       return 0;
+}
+
 #endif /* CONFIG_NFS_V4_1 */
 
 static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
@@ -502,10 +517,10 @@ out:
 
 #if defined(CONFIG_NFS_V4_1)
 
-static unsigned encode_sessionid(struct xdr_stream *xdr,
+static __be32 encode_sessionid(struct xdr_stream *xdr,
                                 const struct nfs4_sessionid *sid)
 {
-       uint32_t *p;
+       __be32 *p;
        int len = NFS4_MAX_SESSIONID_LEN;
 
        p = xdr_reserve_space(xdr, len);
@@ -516,11 +531,11 @@ static unsigned encode_sessionid(struct xdr_stream *xdr,
        return 0;
 }
 
-static unsigned encode_cb_sequence_res(struct svc_rqst *rqstp,
+static __be32 encode_cb_sequence_res(struct svc_rqst *rqstp,
                                       struct xdr_stream *xdr,
                                       const struct cb_sequenceres *res)
 {
-       uint32_t *p;
+       __be32 *p;
        unsigned status = res->csr_status;
 
        if (unlikely(status != 0))
@@ -557,6 +572,7 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
        case OP_CB_RECALL:
        case OP_CB_SEQUENCE:
        case OP_CB_RECALL_ANY:
+       case OP_CB_RECALL_SLOT:
                *op = &callback_ops[op_nr];
                break;
 
@@ -565,7 +581,6 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
        case OP_CB_NOTIFY:
        case OP_CB_PUSH_DELEG:
        case OP_CB_RECALLABLE_OBJ_AVAIL:
-       case OP_CB_RECALL_SLOT:
        case OP_CB_WANTS_CANCELLED:
        case OP_CB_NOTIFY_LOCK:
                return htonl(NFS4ERR_NOTSUPP);
@@ -605,7 +620,7 @@ preprocess_nfs4_op(unsigned int op_nr, struct callback_op **op)
 static __be32 process_op(uint32_t minorversion, int nop,
                struct svc_rqst *rqstp,
                struct xdr_stream *xdr_in, void *argp,
-               struct xdr_stream *xdr_out, void *resp)
+               struct xdr_stream *xdr_out, void *resp, int* drc_status)
 {
        struct callback_op *op = &callback_ops[0];
        unsigned int op_nr;
@@ -625,16 +640,29 @@ static __be32 process_op(uint32_t minorversion, int nop,
                                preprocess_nfs4_op(op_nr, &op);
        if (status == htonl(NFS4ERR_OP_ILLEGAL))
                op_nr = OP_CB_ILLEGAL;
+       if (status)
+               goto encode_hdr;
+
+       if (*drc_status) {
+               status = *drc_status;
+               goto encode_hdr;
+       }
 
        maxlen = xdr_out->end - xdr_out->p;
        if (maxlen > 0 && maxlen < PAGE_SIZE) {
-               if (likely(status == 0 && op->decode_args != NULL))
-                       status = op->decode_args(rqstp, xdr_in, argp);
-               if (likely(status == 0 && op->process_op != NULL))
+               status = op->decode_args(rqstp, xdr_in, argp);
+               if (likely(status == 0))
                        status = op->process_op(argp, resp);
        } else
                status = htonl(NFS4ERR_RESOURCE);
 
+       /* Only set by OP_CB_SEQUENCE processing */
+       if (status == htonl(NFS4ERR_RETRY_UNCACHED_REP)) {
+               *drc_status = status;
+               status = 0;
+       }
+
+encode_hdr:
        res = encode_op_hdr(xdr_out, op_nr, status);
        if (unlikely(res))
                return res;
@@ -653,7 +681,7 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r
        struct cb_compound_hdr_res hdr_res = { NULL };
        struct xdr_stream xdr_in, xdr_out;
        __be32 *p;
-       __be32 status;
+       __be32 status, drc_status = 0;
        unsigned int nops = 0;
 
        dprintk("%s: start\n", __func__);
@@ -673,8 +701,8 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r
                return rpc_system_err;
 
        while (status == 0 && nops != hdr_arg.nops) {
-               status = process_op(hdr_arg.minorversion, nops,
-                                   rqstp, &xdr_in, argp, &xdr_out, resp);
+               status = process_op(hdr_arg.minorversion, nops, rqstp,
+                                   &xdr_in, argp, &xdr_out, resp, &drc_status);
                nops++;
        }
 
@@ -721,6 +749,11 @@ static struct callback_op callback_ops[] = {
                .decode_args = (callback_decode_arg_t)decode_recallany_args,
                .res_maxsize = CB_OP_RECALLANY_RES_MAXSZ,
        },
+       [OP_CB_RECALL_SLOT] = {
+               .process_op = (callback_process_op_t)nfs4_callback_recallslot,
+               .decode_args = (callback_decode_arg_t)decode_recallslot_args,
+               .res_maxsize = CB_OP_RECALLSLOT_RES_MAXSZ,
+       },
 #endif /* CONFIG_NFS_V4_1 */
 };