Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30623
b: refs/heads/master
c: 09c0dc6
h: refs/heads/master
i:
  30621: 634db00
  30619: 5b70409
  30615: e81d8c7
  30607: 6775cf9
  30591: 59f050c
v: v3
  • Loading branch information
Linus Torvalds committed Jun 26, 2006
1 parent e1e888e commit 0fd28e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2a2ed2db353d949c06b6ef8b6913f65b39111eab
refs/heads/master: 09c0dc68625c06f5b1e786aad0d5369b592179e6
24 changes: 13 additions & 11 deletions trunk/drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
#include <linux/completion.h>
#include <linux/highmem.h>
#include <linux/gfp.h>
#include <linux/kthread.h>

#include <asm/uaccess.h>

Expand Down Expand Up @@ -579,6 +578,8 @@ static int loop_thread(void *data)
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
Expand All @@ -591,6 +592,11 @@ static int loop_thread(void *data)
lo->lo_state = Lo_bound;
lo->lo_pending = 1;

/*
* complete it, we are running
*/
complete(&lo->lo_done);

for (;;) {
int pending;

Expand Down Expand Up @@ -623,6 +629,7 @@ static int loop_thread(void *data)
break;
}

complete(&lo->lo_done);
return 0;
}

Expand Down Expand Up @@ -739,7 +746,6 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
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(). */
Expand Down Expand Up @@ -833,11 +839,10 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,

set_blocksize(bdev, lo_blocksize);

tsk = kthread_run(loop_thread, lo, "loop%d", lo->lo_number);
if (IS_ERR(tsk)) {
error = PTR_ERR(tsk);
error = kernel_thread(loop_thread, lo, CLONE_KERNEL);
if (error < 0)
goto out_putf;
}
wait_for_completion(&lo->lo_done);
return 0;

out_putf:
Expand Down Expand Up @@ -893,9 +898,6 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
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;

Expand All @@ -909,7 +911,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
complete(&lo->lo_bh_done);
spin_unlock_irq(&lo->lo_lock);

kthread_stop(lo->lo_thread);
wait_for_completion(&lo->lo_done);

lo->lo_backing_file = NULL;

Expand All @@ -922,7 +924,6 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
lo->lo_sizelimit = 0;
lo->lo_encrypt_key_size = 0;
lo->lo_flags = 0;
lo->lo_thread = NULL;
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);
Expand Down Expand Up @@ -1287,6 +1288,7 @@ static int __init loop_init(void)
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);
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct loop_device {
struct bio *lo_bio;
struct bio *lo_biotail;
int lo_state;
struct task_struct *lo_thread;
struct completion lo_done;
struct completion lo_bh_done;
struct mutex lo_ctl_mutex;
int lo_pending;
Expand Down

0 comments on commit 0fd28e9

Please sign in to comment.