mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Poetzl <herbert@13thfloor.at>
To: Andrew Morton <akpm@osdl.org>,
	Linux Kernel ML <linux-kernel@vger.kernel.org>
Subject: [PATCH] loop: potential kernel hang waiting for kthread
Date: Sat, 25 Mar 2006 02:49:32 +0100	[thread overview]
Message-ID: <20060325014932.GA16485@MAIL.13thfloor.at> (raw)


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:

             reply	other threads:[~2006-03-25  1:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-25  1:49 Herbert Poetzl [this message]
2006-03-25 11:20 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060325014932.GA16485@MAIL.13thfloor.at \
    --to=herbert@13thfloor.at \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®