]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/sunrpc/sched.c
[SG] Get rid of __sg_mark_end()
[mv-sheeva.git] / net / sunrpc / sched.c
index 2ac43c41c3a9889664a1c36b5072e1690ce0fea2..c98873f39aec49bc4d4af57f60f34d23a20123c4 100644 (file)
@@ -50,8 +50,6 @@ static RPC_WAITQ(delay_queue, "delayq");
 /*
  * rpciod-related stuff
  */
-static DEFINE_MUTEX(rpciod_mutex);
-static atomic_t rpciod_users = ATOMIC_INIT(0);
 struct workqueue_struct *rpciod_workqueue;
 
 /*
@@ -779,6 +777,7 @@ void *rpc_malloc(struct rpc_task *task, size_t size)
                        task->tk_pid, size, buf);
        return &buf->data;
 }
+EXPORT_SYMBOL_GPL(rpc_malloc);
 
 /**
  * rpc_free - free buffer allocated via rpc_malloc
@@ -804,6 +803,7 @@ void rpc_free(void *buffer)
        else
                kfree(buf);
 }
+EXPORT_SYMBOL_GPL(rpc_free);
 
 /*
  * Creation and deletion of RPC task structures
@@ -847,7 +847,7 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, cons
        task->tk_start = jiffies;
 
        dprintk("RPC:       new task initialized, procpid %u\n",
-                               current->pid);
+                               task_pid_nr(current));
 }
 
 static struct rpc_task *
@@ -961,60 +961,49 @@ void rpc_killall_tasks(struct rpc_clnt *clnt)
        spin_unlock(&clnt->cl_lock);
 }
 
+int rpciod_up(void)
+{
+       return try_module_get(THIS_MODULE) ? 0 : -EINVAL;
+}
+
+void rpciod_down(void)
+{
+       module_put(THIS_MODULE);
+}
+
 /*
- * Start up the rpciod process if it's not already running.
+ * Start up the rpciod workqueue.
  */
-int
-rpciod_up(void)
+static int rpciod_start(void)
 {
        struct workqueue_struct *wq;
-       int error = 0;
-
-       if (atomic_inc_not_zero(&rpciod_users))
-               return 0;
-
-       mutex_lock(&rpciod_mutex);
 
-       /* Guard against races with rpciod_down() */
-       if (rpciod_workqueue != NULL)
-               goto out_ok;
        /*
         * Create the rpciod thread and wait for it to start.
         */
        dprintk("RPC:       creating workqueue rpciod\n");
-       error = -ENOMEM;
        wq = create_workqueue("rpciod");
-       if (wq == NULL)
-               goto out;
-
        rpciod_workqueue = wq;
-       error = 0;
-out_ok:
-       atomic_inc(&rpciod_users);
-out:
-       mutex_unlock(&rpciod_mutex);
-       return error;
+       return rpciod_workqueue != NULL;
 }
 
-void
-rpciod_down(void)
+static void rpciod_stop(void)
 {
-       if (!atomic_dec_and_test(&rpciod_users))
-               return;
+       struct workqueue_struct *wq = NULL;
 
-       mutex_lock(&rpciod_mutex);
+       if (rpciod_workqueue == NULL)
+               return;
        dprintk("RPC:       destroying workqueue rpciod\n");
 
-       if (atomic_read(&rpciod_users) == 0 && rpciod_workqueue != NULL) {
-               destroy_workqueue(rpciod_workqueue);
-               rpciod_workqueue = NULL;
-       }
-       mutex_unlock(&rpciod_mutex);
+       wq = rpciod_workqueue;
+       rpciod_workqueue = NULL;
+       destroy_workqueue(wq);
 }
 
 void
 rpc_destroy_mempool(void)
 {
+       rpciod_stop();
        if (rpc_buffer_mempool)
                mempool_destroy(rpc_buffer_mempool);
        if (rpc_task_mempool)
@@ -1031,13 +1020,13 @@ rpc_init_mempool(void)
        rpc_task_slabp = kmem_cache_create("rpc_tasks",
                                             sizeof(struct rpc_task),
                                             0, SLAB_HWCACHE_ALIGN,
-                                            NULL, NULL);
+                                            NULL);
        if (!rpc_task_slabp)
                goto err_nomem;
        rpc_buffer_slabp = kmem_cache_create("rpc_buffers",
                                             RPC_BUFFER_MAXSIZE,
                                             0, SLAB_HWCACHE_ALIGN,
-                                            NULL, NULL);
+                                            NULL);
        if (!rpc_buffer_slabp)
                goto err_nomem;
        rpc_task_mempool = mempool_create_slab_pool(RPC_TASK_POOLSIZE,
@@ -1048,6 +1037,8 @@ rpc_init_mempool(void)
                                                      rpc_buffer_slabp);
        if (!rpc_buffer_mempool)
                goto err_nomem;
+       if (!rpciod_start())
+               goto err_nomem;
        return 0;
 err_nomem:
        rpc_destroy_mempool();