* [PATCH] loop: potential kernel hang waiting for kthread
@ 2006-03-25 1:49 Herbert Poetzl
2006-03-25 11:20 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Herbert Poetzl @ 2006-03-25 1:49 UTC (permalink / raw)
To: Andrew Morton, Linux Kernel ML
Hi Andrew! Folks!
just stumbled over the following issue with loop_set_fd()
calling kernel_thread(loop_thread), ignoring the return
value, even if it is an error, then doing wait_for_completion()
on the device, which, in beforementioned error case, would
wait forever (keeping a process stuck in 'D' state)
I can imagine at least three other solutions, but this
one seemed quite organic to me, YMMV ...
best,
Herbert
Signed-off-by: Herbert Poetzl <herbert@13thfloor.at>
---
--- linux/drivers/block/loop.c 2006-03-24 03:37:07 +0100
+++ linux/drivers/block/loop.c 2006-03-25 02:30:37 +0100
@@ -747,6 +747,7 @@ static int loop_set_fd(struct loop_devic
int lo_flags = 0;
int error;
loff_t size;
+ pid_t pid;
/* This is safe, since we have a reference from open(). */
__module_get(THIS_MODULE);
@@ -839,10 +840,14 @@ static int loop_set_fd(struct loop_devic
set_blocksize(bdev, lo_blocksize);
- kernel_thread(loop_thread, lo, CLONE_KERNEL);
+ pid = kernel_thread(loop_thread, lo, CLONE_KERNEL);
+ if (pid < 0)
+ goto out_err;
wait_for_completion(&lo->lo_done);
return 0;
+ out_err:
+ error = (int)pid;
out_putf:
fput(file);
out:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] loop: potential kernel hang waiting for kthread
2006-03-25 1:49 [PATCH] loop: potential kernel hang waiting for kthread Herbert Poetzl
@ 2006-03-25 11:20 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2006-03-25 11:20 UTC (permalink / raw)
To: Andrew Morton, Linux Kernel ML
On Sat, Mar 25, 2006 at 02:49:32AM +0100, Herbert Poetzl wrote:
>
> Hi Andrew! Folks!
>
> just stumbled over the following issue with loop_set_fd()
> calling kernel_thread(loop_thread), ignoring the return
> value, even if it is an error, then doing wait_for_completion()
> on the device, which, in beforementioned error case, would
> wait forever (keeping a process stuck in 'D' state)
>
> I can imagine at least three other solutions, but this
> one seemed quite organic to me, YMMV ...
Best thing would be to switch it to the kthread_ API.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-03-25 11:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-25 1:49 [PATCH] loop: potential kernel hang waiting for kthread Herbert Poetzl
2006-03-25 11:20 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®