All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Scanlan <tscanlan@sosaith.org>
To: linux-scsi@vger.kernel.org
Subject: sd/usb deadlock
Date: Sun, 19 Feb 2006 22:14:26 -0500	[thread overview]
Message-ID: <43F93412.6070700@sosaith.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

Not sure if I should report this or ask around elsewhere... This was
also sent to drew@colorado.edu, as he was first in sd.c.


sd_open in drivers/scsi/sd.c  seems to have a deadlock.  It was noticed
when plugging and unplugging lots of usb disks in random order on a slow
machine.  The hotplug scripts were running fdisk -l on the devices and
trying to mount the disks as they were getting (un)plugged.  I saw this
in version 2.4.21, but the code is the same at least up to 2.4.30.

revalidate_scsidisk marks the disk as busy, then we hit an sd_open and
got stuck in a loop waiting for the disk to become not busy.  The change
is to fail on open if the disk is busy.  Requiring a mount retry is
better behavior than hanging the kernel.

The diff is attached... I'm not sure the process to getting it in a
release... pointers would be helpful.  If there is a reason this
shouldn't be used let me know, as I'm not much of a kernel hacker.


[-- Attachment #2: sd.c.diff --]
[-- Type: text/plain, Size: 451 bytes --]

--- sd.c	2006-02-10 12:22:41.000000000 -0500
+++ sd.c~	2006-02-08 16:27:31.000000000 -0500
@@ -466,10 +466,15 @@
 	 * is being re-read.
 	 */
 
- 	if  (rscsi_disks[target].device->busy) {
-		printk("device %d was busy, can't open it, try again soon.\n", target);
- 		return -ENXIO;
- 	}
+
+	while (rscsi_disks[target].device->busy) {
+		barrier();
+		cpu_relax();
+	}
+
 	/*
 	 * The following code can sleep.
 	 * Module unloading must be prevented


                 reply	other threads:[~2006-02-20  3:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=43F93412.6070700@sosaith.org \
    --to=tscanlan@sosaith.org \
    --cc=linux-scsi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.