Merge git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-drm-fsl-dcu.git] / net / sunrpc / svc.c
index 2807fa0eab40bd7644386410a125dc52d1369893..b00511d39b6526b2026220644c5b6c9eb2a6bdef 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/sunrpc/clnt.h>
 
 #define RPCDBG_FACILITY        RPCDBG_SVCDSP
-#define RPC_PARANOIA 1
 
 /*
  * Mode for mapping cpus to pools.
@@ -308,7 +307,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
 
        serv->sv_nrpools = npools;
        serv->sv_pools =
-               kcalloc(sizeof(struct svc_pool), serv->sv_nrpools,
+               kcalloc(serv->sv_nrpools, sizeof(struct svc_pool),
                        GFP_KERNEL);
        if (!serv->sv_pools) {
                kfree(serv);
@@ -387,7 +386,7 @@ svc_destroy(struct svc_serv *serv)
                svsk = list_entry(serv->sv_tempsocks.next,
                                  struct svc_sock,
                                  sk_list);
-               svc_delete_socket(svsk);
+               svc_close_socket(svsk);
        }
        if (serv->sv_shutdown)
                serv->sv_shutdown(serv);
@@ -396,9 +395,9 @@ svc_destroy(struct svc_serv *serv)
                svsk = list_entry(serv->sv_permsocks.next,
                                  struct svc_sock,
                                  sk_list);
-               svc_delete_socket(svsk);
+               svc_close_socket(svsk);
        }
-       
+
        cache_clean_deferred(serv);
 
        /* Unregister service with the portmapper */
@@ -416,7 +415,7 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size)
 {
        int pages;
        int arghi;
-       
+
        pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply.
                                       * We assume one is at most one page
                                       */
@@ -515,7 +514,7 @@ choose_pool(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
        if (pool != NULL)
                return pool;
 
-       return &serv->sv_pools[(*state)++ % serv->sv_nrpools];
+       return &serv->sv_pools[(*state)++ % serv->sv_nrpools];
 }
 
 /*
@@ -531,13 +530,13 @@ choose_victim(struct svc_serv *serv, struct svc_pool *pool, unsigned int *state)
                spin_lock_bh(&pool->sp_lock);
        } else {
                /* choose a pool in round-robin fashion */
-               for (i = 0; i < serv->sv_nrpools; i++) {
-                       pool = &serv->sv_pools[--(*state) % serv->sv_nrpools];
+               for (i = 0; i < serv->sv_nrpools; i++) {
+                       pool = &serv->sv_pools[--(*state) % serv->sv_nrpools];
                        spin_lock_bh(&pool->sp_lock);
-                       if (!list_empty(&pool->sp_all_threads))
-                               goto found_pool;
+                       if (!list_empty(&pool->sp_all_threads))
+                               goto found_pool;
                        spin_unlock_bh(&pool->sp_lock);
-               }
+               }
                return NULL;
        }
 
@@ -552,7 +551,7 @@ found_pool:
                rqstp = list_entry(pool->sp_all_threads.next, struct svc_rqst, rq_all);
                list_del_init(&rqstp->rq_all);
                task = rqstp->rq_task;
-       }
+       }
        spin_unlock_bh(&pool->sp_lock);
 
        return task;
@@ -637,7 +636,7 @@ svc_exit_thread(struct svc_rqst *rqstp)
 
 /*
  * Register an RPC service with the local portmapper.
- * To unregister a service, call this routine with 
+ * To unregister a service, call this routine with
  * proto and port == 0.
  */
 int
@@ -710,7 +709,7 @@ svc_process(struct svc_rqst *rqstp)
                goto err_short_len;
 
        /* setup response xdr_buf.
-        * Initially it has just one page 
+        * Initially it has just one page
         */
        rqstp->rq_resused = 1;
        resv->iov_base = page_address(rqstp->rq_respages[0]);
@@ -812,7 +811,7 @@ svc_process(struct svc_rqst *rqstp)
        memset(rqstp->rq_argp, 0, procp->pc_argsize);
        memset(rqstp->rq_resp, 0, procp->pc_ressize);
 
-       /* un-reserve some of the out-queue now that we have a 
+       /* un-reserve some of the out-queue now that we have a
         * better idea of reply size
         */
        if (procp->pc_xdrressize)
@@ -828,6 +827,11 @@ svc_process(struct svc_rqst *rqstp)
                *statp = procp->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp);
 
                /* Encode reply */
+               if (*statp == rpc_drop_reply) {
+                       if (procp->pc_release)
+                               procp->pc_release(rqstp, NULL, rqstp->rq_resp);
+                       goto dropit;
+               }
                if (*statp == rpc_success && (xdr = procp->pc_encode)
                 && !xdr(rqstp, resv->iov_base+resv->iov_len, rqstp->rq_resp)) {
                        dprintk("svc: failed to encode reply\n");
@@ -867,15 +871,15 @@ svc_process(struct svc_rqst *rqstp)
        return 0;
 
 err_short_len:
-#ifdef RPC_PARANOIA
-       printk("svc: short len %Zd, dropping request\n", argv->iov_len);
-#endif
+       if (net_ratelimit())
+               printk("svc: short len %Zd, dropping request\n", argv->iov_len);
+
        goto dropit;                    /* drop request */
 
 err_bad_dir:
-#ifdef RPC_PARANOIA
-       printk("svc: bad direction %d, dropping request\n", dir);
-#endif
+       if (net_ratelimit())
+               printk("svc: bad direction %d, dropping request\n", dir);
+
        serv->sv_stats->rpcbadfmt++;
        goto dropit;                    /* drop request */
 
@@ -904,9 +908,10 @@ err_bad_prog:
        goto sendit;
 
 err_bad_vers:
-#ifdef RPC_PARANOIA
-       printk("svc: unknown version (%d)\n", vers);
-#endif
+       if (net_ratelimit())
+               printk("svc: unknown version (%d for prog %d, %s)\n",
+                      vers, prog, progp->pg_name);
+
        serv->sv_stats->rpcbadfmt++;
        svc_putnl(resv, RPC_PROG_MISMATCH);
        svc_putnl(resv, progp->pg_lovers);
@@ -914,17 +919,17 @@ err_bad_vers:
        goto sendit;
 
 err_bad_proc:
-#ifdef RPC_PARANOIA
-       printk("svc: unknown procedure (%d)\n", proc);
-#endif
+       if (net_ratelimit())
+               printk("svc: unknown procedure (%d)\n", proc);
+
        serv->sv_stats->rpcbadfmt++;
        svc_putnl(resv, RPC_PROC_UNAVAIL);
        goto sendit;
 
 err_garbage:
-#ifdef RPC_PARANOIA
-       printk("svc: failed to decode args\n");
-#endif
+       if (net_ratelimit())
+               printk("svc: failed to decode args\n");
+
        rpc_stat = rpc_garbage_args;
 err_bad:
        serv->sv_stats->rpcbadfmt++;