From: Anton Vorontsov <cbou@mail.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: James.Bottomley@steeleye.com, alan@lxorguk.ukuu.org.uk,
greg@kroah.com, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org
Subject: [PATCH] fix ide-cs hang after device removal 2
Date: Fri, 3 Nov 2006 19:36:59 +0300 [thread overview]
Message-ID: <20061103163659.GA16034@localhost> (raw)
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
Hi!
Andrew, can you please replace
fix-ide-cs-hang-after-device-removal.patch by attached one?
They are exactly same, but -2.patch do not touches SCSI's sd.c.
Todd Blumer found that SCSI do get_device() and must put it back,
thus my assumption that SCSI also affected was wrong.
Thanks,
-- Anton (irc: bd2)
[-- Attachment #2: fix-ide-cs-hang-after-device-removal-2.patch --]
[-- Type: text/plain, Size: 2484 bytes --]
From: Anton Vorontsov <cbou@mail.ru>
I've caught deadlock inside IDE layer using IDE-CS: after accessing to IDE
disk placed in PCMCIA (CF card really), it will never probe again after
pulling it from PCMCIA/CF.
The kernel is stuck at
drivers/ide/ide.c:ide_unregister():604:
602 spin_unlock_irq(&ide_lock);
603 device_unregister(&drive->gendev);
604 wait_for_completion(&drive->gendev_rel_comp);
605 spin_lock_irq(&ide_lock);
ide_unregister() assumes that device_unregister() will call
ide-probe.c:drive_release_dev():
1282 static void drive_release_dev (struct device *dev)
1283 {
.... [...]
1302 complete(&drive->gendev_rel_comp);
1303 }
1311 static void init_gendisk (ide_hwif_t *hwif)
1312 {
....
1323 drive->gendev.release = drive_release_dev;
....
1333 }
But release() function will not called because drive->gendev is still
referenced inside genhd layer.
No need to get_device(driverfs_dev), because it's already gotten by
add_disk(). And no function will call put_device() second time. This is
the source of deadlock[1] in IDE layer.
[1] deadlock in ide_unregister()
at wait_for_completion(&drive->gendev_rel_comp) after
device_unregister(&drive->gendev). That happens by reason of
ide-probe.c:drive_release_dev() not called because of driverfs_dev (which
is drive->gendev) still referenced by add_disk().
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Anton Vorontsov <cbou@mail.ru>
---
fs/partitions/check.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 6fb4b61..8371adf 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -378,7 +378,7 @@ static char *make_block_name(struct gend
static int disk_sysfs_symlinks(struct gendisk *disk)
{
- struct device *target = get_device(disk->driverfs_dev);
+ struct device *target = disk->driverfs_dev;
int err;
char *disk_name = NULL;
@@ -414,9 +414,8 @@ err_out_dev_link:
sysfs_remove_link(&disk->kobj, "device");
err_out_disk_name:
kfree(disk_name);
-err_out:
- put_device(target);
}
+err_out:
return err;
}
_
reply other threads:[~2006-11-03 15:34 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=20061103163659.GA16034@localhost \
--to=cbou@mail.ru \
--cc=James.Bottomley@steeleye.com \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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