Skip to content

Commit

Permalink
Revert "[BLOCK] Fix oops on removal of SD/MMC card"
Browse files Browse the repository at this point in the history
This reverts commit 56cf650.

Both Erik Mouw and Andrew Vasquez independently pinpointed this commit
as causing problems, where the slab cache for a driver is never released
(most obviously causing problems when immediately re-loading that
driver, resulting in a "kmem_cache_create: duplicate cache <xyz>"
message, but it can also cause other trouble).

James Bottomley dug into it, and reports:

  "OK, here's the scoop.  The problem patch adds a get of driverfs_dev in
   add_disk(), but doesn't put it again until disk_release() (which occurs
   on final put_disk() of the gendisk).

   However, in SCSI, the driverfs_dev is the sdev_gendev.  That means
   there's a reference held on sdev_gendev  until final disk put.
   Unfortunately, we use the driver model driver_remove to trigger
   del_gendisk (which removes the gendisk from visibility and decrements
   the refcount), so we've introduced an unbreakable deadlock in the
   reference counting with this.

   I suggest simply reversing this patch at the moment.  If Russell and
   Jens can tell me what they're trying to do I'll see if there's another
   way to do it."

so hereby the patch gets reverted, waiting for a better fix.

Cc: Jens Axboe <[email protected]>
Cc: Russell King <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Erik Mouw <[email protected]>
Cc: Andrew Vasquez <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Linus Torvalds committed May 12, 2006
1 parent d8c3291 commit 1a2acc9
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ static int exact_lock(dev_t dev, void *data)
*/
void add_disk(struct gendisk *disk)
{
get_device(disk->driverfs_dev);
disk->flags |= GENHD_FL_UP;
blk_register_region(MKDEV(disk->major, disk->first_minor),
disk->minors, NULL, exact_match, exact_lock, disk);
Expand Down Expand Up @@ -428,7 +427,6 @@ static struct attribute * default_attrs[] = {
static void disk_release(struct kobject * kobj)
{
struct gendisk *disk = to_disk(kobj);
put_device(disk->driverfs_dev);
kfree(disk->random);
kfree(disk->part);
free_disk_stats(disk);
Expand Down

0 comments on commit 1a2acc9

Please sign in to comment.