Re: lockdep: bdev->bd_mutex deadlock

From: Arjan van de Ven
Date: Tue Jul 11 2006 - 07:13:12 EST


On Fri, 2006-07-07 at 11:43 -0400, Peter Jones wrote:
> <4> [<c05ebd9d>] mutex_lock+0x21/0x24
> <4> [<c04c4acf>] blkdev_ioctl+0x5dd/0x732
> <4> [<c046323b>] block_ioctl+0x16/0x1b


From: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
Subject: lockdep: annotate the BLKPG_DEL_PARTITION ioctl

The delete partition IOCTL takes the bd_mutex for both the disk and the partition;
these have an obvious hierarchical relationship and this patch annotates this
relationship for lockdep.

Signed-off-by: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
Index: linux-2.6.18-rc1/block/ioctl.c
===================================================================
--- linux-2.6.18-rc1.orig/block/ioctl.c
+++ linux-2.6.18-rc1/block/ioctl.c
@@ -72,7 +72,7 @@ static int blkpg_ioctl(struct block_devi
bdevp = bdget_disk(disk, part);
if (!bdevp)
return -ENOMEM;
- mutex_lock(&bdevp->bd_mutex);
+ mutex_lock_nested(&bdevp->bd_mutex, BD_MUTEX_PARTITION);
if (bdevp->bd_openers) {
mutex_unlock(&bdevp->bd_mutex);
bdput(bdevp);
@@ -82,7 +82,7 @@ static int blkpg_ioctl(struct block_devi
fsync_bdev(bdevp);
invalidate_bdev(bdevp, 0);

- mutex_lock(&bdev->bd_mutex);
+ mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_WHOLE);
delete_partition(disk, part);
mutex_unlock(&bdev->bd_mutex);
mutex_unlock(&bdevp->bd_mutex);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/