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>
#include <linux/completion.h>
#include <linux/highmem.h>
#include <linux/gfp.h>
#include <linux/completion.h>
#include <linux/highmem.h>
#include <linux/gfp.h>
+#include <linux/kthread.h>
struct loop_device *lo = data;
struct bio *bio;
struct loop_device *lo = data;
struct bio *bio;
- daemonize("loop%d", lo->lo_number);
-
/*
* loop can be used in an encrypted device,
* hence, it mustn't be stopped at all
/*
* loop can be used in an encrypted device,
* hence, it mustn't be stopped at all
lo->lo_state = Lo_bound;
lo->lo_pending = 1;
lo->lo_state = Lo_bound;
lo->lo_pending = 1;
- /*
- * complete it, we are running
- */
- complete(&lo->lo_done);
-
- complete(&lo->lo_done);
unsigned lo_blocksize;
int lo_flags = 0;
int error;
unsigned lo_blocksize;
int lo_flags = 0;
int error;
+ struct task_struct *tsk;
loff_t size;
/* This is safe, since we have a reference from open(). */
loff_t size;
/* This is safe, since we have a reference from open(). */
set_blocksize(bdev, lo_blocksize);
set_blocksize(bdev, lo_blocksize);
- error = kernel_thread(loop_thread, lo, CLONE_KERNEL);
- if (error < 0)
+ tsk = kthread_run(loop_thread, lo, "loop%d", lo->lo_number);
+ if (IS_ERR(tsk)) {
+ error = PTR_ERR(tsk);
- wait_for_completion(&lo->lo_done);
if (lo->lo_state != Lo_bound)
return -ENXIO;
if (lo->lo_state != Lo_bound)
return -ENXIO;
+ if (!lo->lo_thread)
+ return -EINVAL;
+
if (lo->lo_refcnt > 1) /* we needed one fd for the ioctl */
return -EBUSY;
if (lo->lo_refcnt > 1) /* we needed one fd for the ioctl */
return -EBUSY;
complete(&lo->lo_bh_done);
spin_unlock_irq(&lo->lo_lock);
complete(&lo->lo_bh_done);
spin_unlock_irq(&lo->lo_lock);
- wait_for_completion(&lo->lo_done);
+ kthread_stop(lo->lo_thread);
lo->lo_backing_file = NULL;
lo->lo_backing_file = NULL;
lo->lo_sizelimit = 0;
lo->lo_encrypt_key_size = 0;
lo->lo_flags = 0;
lo->lo_sizelimit = 0;
lo->lo_encrypt_key_size = 0;
lo->lo_flags = 0;
memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
memset(lo->lo_file_name, 0, LO_NAME_SIZE);
memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
memset(lo->lo_file_name, 0, LO_NAME_SIZE);
if (!lo->lo_queue)
goto out_mem4;
mutex_init(&lo->lo_ctl_mutex);
if (!lo->lo_queue)
goto out_mem4;
mutex_init(&lo->lo_ctl_mutex);
- init_completion(&lo->lo_done);
init_completion(&lo->lo_bh_done);
lo->lo_number = i;
spin_lock_init(&lo->lo_lock);
init_completion(&lo->lo_bh_done);
lo->lo_number = i;
spin_lock_init(&lo->lo_lock);
struct bio *lo_bio;
struct bio *lo_biotail;
int lo_state;
struct bio *lo_bio;
struct bio *lo_biotail;
int lo_state;
- struct completion lo_done;
+ struct task_struct *lo_thread;
struct completion lo_bh_done;
struct mutex lo_ctl_mutex;
int lo_pending;
struct completion lo_bh_done;
struct mutex lo_ctl_mutex;
int lo_pending;