aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/loop.c
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2006-06-25 08:48:59 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:20 -0400
commitc7b2eff059fcc2d1b7085ee3d84b79fd657a537b (patch)
tree72d357c3975f27b5c8e5cfd77464e7823a9d6b1d /drivers/block/loop.c
parent2f72100c01dd31d769097c58874e8ab1e70b2518 (diff)
[PATCH] kthread: update loop.c to use kthread
Update loop.c to use a kthread instead of a deprecated kernel_thread for loop devices. [akpm@osdl.org: don't change the thread's name] Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r--drivers/block/loop.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 3c74ea729fc7..9dc294a74953 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -74,6 +74,7 @@
74#include <linux/completion.h> 74#include <linux/completion.h>
75#include <linux/highmem.h> 75#include <linux/highmem.h>
76#include <linux/gfp.h> 76#include <linux/gfp.h>
77#include <linux/kthread.h>
77 78
78#include <asm/uaccess.h> 79#include <asm/uaccess.h>
79 80
@@ -578,8 +579,6 @@ static int loop_thread(void *data)
578 struct loop_device *lo = data; 579 struct loop_device *lo = data;
579 struct bio *bio; 580 struct bio *bio;
580 581
581 daemonize("loop%d", lo->lo_number);
582
583 /* 582 /*
584 * loop can be used in an encrypted device, 583 * loop can be used in an encrypted device,
585 * hence, it mustn't be stopped at all 584 * hence, it mustn't be stopped at all
@@ -592,11 +591,6 @@ static int loop_thread(void *data)
592 lo->lo_state = Lo_bound; 591 lo->lo_state = Lo_bound;
593 lo->lo_pending = 1; 592 lo->lo_pending = 1;
594 593
595 /*
596 * complete it, we are running
597 */
598 complete(&lo->lo_done);
599
600 for (;;) { 594 for (;;) {
601 int pending; 595 int pending;
602 596
@@ -629,7 +623,6 @@ static int loop_thread(void *data)
629 break; 623 break;
630 } 624 }
631 625
632 complete(&lo->lo_done);
633 return 0; 626 return 0;
634} 627}
635 628
@@ -746,6 +739,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
746 unsigned lo_blocksize; 739 unsigned lo_blocksize;
747 int lo_flags = 0; 740 int lo_flags = 0;
748 int error; 741 int error;
742 struct task_struct *tsk;
749 loff_t size; 743 loff_t size;
750 744
751 /* This is safe, since we have a reference from open(). */ 745 /* This is safe, since we have a reference from open(). */
@@ -839,10 +833,11 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
839 833
840 set_blocksize(bdev, lo_blocksize); 834 set_blocksize(bdev, lo_blocksize);
841 835
842 error = kernel_thread(loop_thread, lo, CLONE_KERNEL); 836 tsk = kthread_run(loop_thread, lo, "loop%d", lo->lo_number);
843 if (error < 0) 837 if (IS_ERR(tsk)) {
838 error = PTR_ERR(tsk);
844 goto out_putf; 839 goto out_putf;
845 wait_for_completion(&lo->lo_done); 840 }
846 return 0; 841 return 0;
847 842
848 out_putf: 843 out_putf:
@@ -898,6 +893,9 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
898 if (lo->lo_state != Lo_bound) 893 if (lo->lo_state != Lo_bound)
899 return -ENXIO; 894 return -ENXIO;
900 895
896 if (!lo->lo_thread)
897 return -EINVAL;
898
901 if (lo->lo_refcnt > 1) /* we needed one fd for the ioctl */ 899 if (lo->lo_refcnt > 1) /* we needed one fd for the ioctl */
902 return -EBUSY; 900 return -EBUSY;
903 901
@@ -911,7 +909,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
911 complete(&lo->lo_bh_done); 909 complete(&lo->lo_bh_done);
912 spin_unlock_irq(&lo->lo_lock); 910 spin_unlock_irq(&lo->lo_lock);
913 911
914 wait_for_completion(&lo->lo_done); 912 kthread_stop(lo->lo_thread);
915 913
916 lo->lo_backing_file = NULL; 914 lo->lo_backing_file = NULL;
917 915
@@ -924,6 +922,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
924 lo->lo_sizelimit = 0; 922 lo->lo_sizelimit = 0;
925 lo->lo_encrypt_key_size = 0; 923 lo->lo_encrypt_key_size = 0;
926 lo->lo_flags = 0; 924 lo->lo_flags = 0;
925 lo->lo_thread = NULL;
927 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE); 926 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
928 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE); 927 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
929 memset(lo->lo_file_name, 0, LO_NAME_SIZE); 928 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
@@ -1288,7 +1287,6 @@ static int __init loop_init(void)
1288 if (!lo->lo_queue) 1287 if (!lo->lo_queue)
1289 goto out_mem4; 1288 goto out_mem4;
1290 mutex_init(&lo->lo_ctl_mutex); 1289 mutex_init(&lo->lo_ctl_mutex);
1291 init_completion(&lo->lo_done);
1292 init_completion(&lo->lo_bh_done); 1290 init_completion(&lo->lo_bh_done);
1293 lo->lo_number = i; 1291 lo->lo_number = i;
1294 spin_lock_init(&lo->lo_lock); 1292 spin_lock_init(&lo->lo_lock);