fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / md / kcopyd.c
index fc009cb..b46f6c5 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/atomic.h>
 
 #include <linux/blkdev.h>
-#include <linux/config.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/list.h>
@@ -22,6 +21,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/workqueue.h>
+#include <linux/mutex.h>
 
 #include "kcopyd.h"
 
@@ -203,7 +203,7 @@ struct kcopyd_job {
 /* FIXME: this should scale with the number of pages */
 #define MIN_JOBS 512
 
-static kmem_cache_t *_job_cache;
+static struct kmem_cache *_job_cache;
 static mempool_t *_job_pool;
 
 /*
@@ -230,8 +230,7 @@ static int jobs_init(void)
        if (!_job_cache)
                return -ENOMEM;
 
-       _job_pool = mempool_create(MIN_JOBS, mempool_alloc_slab,
-                                  mempool_free_slab, _job_cache);
+       _job_pool = mempool_create_slab_pool(MIN_JOBS, _job_cache);
        if (!_job_pool) {
                kmem_cache_destroy(_job_cache);
                return -ENOMEM;
@@ -314,7 +313,7 @@ static void complete_io(unsigned long error, void *context)
 
        if (error) {
                if (job->rw == WRITE)
-                       job->write_err &= error;
+                       job->write_err |= error;
                else
                        job->read_err = 1;
 
@@ -418,7 +417,7 @@ static int process_jobs(struct list_head *jobs, int (*fn) (struct kcopyd_job *))
 /*
  * kcopyd does this every time it's woken up.
  */
-static void do_work(void *ignored)
+static void do_work(struct work_struct *ignored)
 {
        /*
         * The order that these are called is *very* important.
@@ -460,7 +459,7 @@ static void segment_complete(int read_err,
                job->read_err = 1;
 
        if (write_err)
-               job->write_err &= write_err;
+               job->write_err |= write_err;
 
        /*
         * Only dispatch more work if there hasn't been an error.
@@ -582,68 +581,68 @@ int kcopyd_cancel(struct kcopyd_job *job, int block)
 /*-----------------------------------------------------------------
  * Unit setup
  *---------------------------------------------------------------*/
-static DECLARE_MUTEX(_client_lock);
+static DEFINE_MUTEX(_client_lock);
 static LIST_HEAD(_clients);
 
 static void client_add(struct kcopyd_client *kc)
 {
-       down(&_client_lock);
+       mutex_lock(&_client_lock);
        list_add(&kc->list, &_clients);
-       up(&_client_lock);
+       mutex_unlock(&_client_lock);
 }
 
 static void client_del(struct kcopyd_client *kc)
 {
-       down(&_client_lock);
+       mutex_lock(&_client_lock);
        list_del(&kc->list);
-       up(&_client_lock);
+       mutex_unlock(&_client_lock);
 }
 
-static DECLARE_MUTEX(kcopyd_init_lock);
+static DEFINE_MUTEX(kcopyd_init_lock);
 static int kcopyd_clients = 0;
 
 static int kcopyd_init(void)
 {
        int r;
 
-       down(&kcopyd_init_lock);
+       mutex_lock(&kcopyd_init_lock);
 
        if (kcopyd_clients) {
                /* Already initialized. */
                kcopyd_clients++;
-               up(&kcopyd_init_lock);
+               mutex_unlock(&kcopyd_init_lock);
                return 0;
        }
 
        r = jobs_init();
        if (r) {
-               up(&kcopyd_init_lock);
+               mutex_unlock(&kcopyd_init_lock);
                return r;
        }
 
        _kcopyd_wq = create_singlethread_workqueue("kcopyd");
        if (!_kcopyd_wq) {
                jobs_exit();
-               up(&kcopyd_init_lock);
+               mutex_unlock(&kcopyd_init_lock);
                return -ENOMEM;
        }
 
        kcopyd_clients++;
-       INIT_WORK(&_kcopyd_work, do_work, NULL);
-       up(&kcopyd_init_lock);
+       INIT_WORK(&_kcopyd_work, do_work);
+       mutex_unlock(&kcopyd_init_lock);
        return 0;
 }
 
 static void kcopyd_exit(void)
 {
-       down(&kcopyd_init_lock);
+       mutex_lock(&kcopyd_init_lock);
        kcopyd_clients--;
        if (!kcopyd_clients) {
                jobs_exit();
                destroy_workqueue(_kcopyd_wq);
                _kcopyd_wq = NULL;
        }
-       up(&kcopyd_init_lock);
+       mutex_unlock(&kcopyd_init_lock);
 }
 
 int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result)