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