diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2007-05-13 05:52:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-13 12:44:05 -0400 |
commit | 705962ccc9d21a08b74b6b6e1d3cf10f98968a67 (patch) | |
tree | c9c534aa1be76b790b0d8a4415fd7d46f920c77c /drivers/block | |
parent | 39403865d2e4590802553370a56c9ab93131e4ee (diff) |
fix deadlock in loop.c
... doh
Jeremy Fitzhardinge noted that the recent loop.c cleanups worked, but
cause lockdep to complain.
Ouch. OK, the deadlock is real and yes, I'm an idiot. Speaking of which,
we probably want to s/lock/pin/ in drivers/base/map.c to avoid such
brainos again. And yes, this stuff needs clear documentation. Will try
to put one together once I get some sleep...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/loop.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index e2fc4b6734cf..5526eadb6592 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1399,6 +1399,11 @@ static struct loop_device *loop_init_one(int i) | |||
1399 | struct loop_device *lo; | 1399 | struct loop_device *lo; |
1400 | struct gendisk *disk; | 1400 | struct gendisk *disk; |
1401 | 1401 | ||
1402 | list_for_each_entry(lo, &loop_devices, lo_list) { | ||
1403 | if (lo->lo_number == i) | ||
1404 | return lo; | ||
1405 | } | ||
1406 | |||
1402 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); | 1407 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); |
1403 | if (!lo) | 1408 | if (!lo) |
1404 | goto out; | 1409 | goto out; |
@@ -1443,17 +1448,13 @@ static void loop_del_one(struct loop_device *lo) | |||
1443 | kfree(lo); | 1448 | kfree(lo); |
1444 | } | 1449 | } |
1445 | 1450 | ||
1446 | static int loop_lock(dev_t dev, void *data) | ||
1447 | { | ||
1448 | mutex_lock(&loop_devices_mutex); | ||
1449 | return 0; | ||
1450 | } | ||
1451 | |||
1452 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) | 1451 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) |
1453 | { | 1452 | { |
1454 | struct loop_device *lo = loop_init_one(dev & MINORMASK); | 1453 | struct loop_device *lo; |
1455 | struct kobject *kobj; | 1454 | struct kobject *kobj; |
1456 | 1455 | ||
1456 | mutex_lock(&loop_devices_mutex); | ||
1457 | lo = loop_init_one(dev & MINORMASK); | ||
1457 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); | 1458 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); |
1458 | mutex_unlock(&loop_devices_mutex); | 1459 | mutex_unlock(&loop_devices_mutex); |
1459 | 1460 | ||
@@ -1466,7 +1467,7 @@ static int __init loop_init(void) | |||
1466 | if (register_blkdev(LOOP_MAJOR, "loop")) | 1467 | if (register_blkdev(LOOP_MAJOR, "loop")) |
1467 | return -EIO; | 1468 | return -EIO; |
1468 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, | 1469 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, |
1469 | THIS_MODULE, loop_probe, loop_lock, NULL); | 1470 | THIS_MODULE, loop_probe, NULL, NULL); |
1470 | 1471 | ||
1471 | if (max_loop) { | 1472 | if (max_loop) { |
1472 | printk(KERN_INFO "loop: the max_loop option is obsolete " | 1473 | printk(KERN_INFO "loop: the max_loop option is obsolete " |