diff options
Diffstat (limited to 'drivers/md/kcopyd.c')
-rw-r--r-- | drivers/md/kcopyd.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c index 8b3515f394a6..9dcb2c8a3853 100644 --- a/drivers/md/kcopyd.c +++ b/drivers/md/kcopyd.c | |||
@@ -227,8 +227,7 @@ static int jobs_init(void) | |||
227 | if (!_job_cache) | 227 | if (!_job_cache) |
228 | return -ENOMEM; | 228 | return -ENOMEM; |
229 | 229 | ||
230 | _job_pool = mempool_create(MIN_JOBS, mempool_alloc_slab, | 230 | _job_pool = mempool_create_slab_pool(MIN_JOBS, _job_cache); |
231 | mempool_free_slab, _job_cache); | ||
232 | if (!_job_pool) { | 231 | if (!_job_pool) { |
233 | kmem_cache_destroy(_job_cache); | 232 | kmem_cache_destroy(_job_cache); |
234 | return -ENOMEM; | 233 | return -ENOMEM; |
@@ -590,51 +589,51 @@ static void client_del(struct kcopyd_client *kc) | |||
590 | up(&_client_lock); | 589 | up(&_client_lock); |
591 | } | 590 | } |
592 | 591 | ||
593 | static DECLARE_MUTEX(kcopyd_init_lock); | 592 | static DEFINE_MUTEX(kcopyd_init_lock); |
594 | static int kcopyd_clients = 0; | 593 | static int kcopyd_clients = 0; |
595 | 594 | ||
596 | static int kcopyd_init(void) | 595 | static int kcopyd_init(void) |
597 | { | 596 | { |
598 | int r; | 597 | int r; |
599 | 598 | ||
600 | down(&kcopyd_init_lock); | 599 | mutex_lock(&kcopyd_init_lock); |
601 | 600 | ||
602 | if (kcopyd_clients) { | 601 | if (kcopyd_clients) { |
603 | /* Already initialized. */ | 602 | /* Already initialized. */ |
604 | kcopyd_clients++; | 603 | kcopyd_clients++; |
605 | up(&kcopyd_init_lock); | 604 | mutex_unlock(&kcopyd_init_lock); |
606 | return 0; | 605 | return 0; |
607 | } | 606 | } |
608 | 607 | ||
609 | r = jobs_init(); | 608 | r = jobs_init(); |
610 | if (r) { | 609 | if (r) { |
611 | up(&kcopyd_init_lock); | 610 | mutex_unlock(&kcopyd_init_lock); |
612 | return r; | 611 | return r; |
613 | } | 612 | } |
614 | 613 | ||
615 | _kcopyd_wq = create_singlethread_workqueue("kcopyd"); | 614 | _kcopyd_wq = create_singlethread_workqueue("kcopyd"); |
616 | if (!_kcopyd_wq) { | 615 | if (!_kcopyd_wq) { |
617 | jobs_exit(); | 616 | jobs_exit(); |
618 | up(&kcopyd_init_lock); | 617 | mutex_unlock(&kcopyd_init_lock); |
619 | return -ENOMEM; | 618 | return -ENOMEM; |
620 | } | 619 | } |
621 | 620 | ||
622 | kcopyd_clients++; | 621 | kcopyd_clients++; |
623 | INIT_WORK(&_kcopyd_work, do_work, NULL); | 622 | INIT_WORK(&_kcopyd_work, do_work, NULL); |
624 | up(&kcopyd_init_lock); | 623 | mutex_unlock(&kcopyd_init_lock); |
625 | return 0; | 624 | return 0; |
626 | } | 625 | } |
627 | 626 | ||
628 | static void kcopyd_exit(void) | 627 | static void kcopyd_exit(void) |
629 | { | 628 | { |
630 | down(&kcopyd_init_lock); | 629 | mutex_lock(&kcopyd_init_lock); |
631 | kcopyd_clients--; | 630 | kcopyd_clients--; |
632 | if (!kcopyd_clients) { | 631 | if (!kcopyd_clients) { |
633 | jobs_exit(); | 632 | jobs_exit(); |
634 | destroy_workqueue(_kcopyd_wq); | 633 | destroy_workqueue(_kcopyd_wq); |
635 | _kcopyd_wq = NULL; | 634 | _kcopyd_wq = NULL; |
636 | } | 635 | } |
637 | up(&kcopyd_init_lock); | 636 | mutex_unlock(&kcopyd_init_lock); |
638 | } | 637 | } |
639 | 638 | ||
640 | int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) | 639 | int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) |