From: Peter Zijlstra Date: Tue, 20 Feb 2007 21:58:18 +0000 (-0800) Subject: [PATCH] lockdep: annotate BLKPG_DEL_PARTITION X-Git-Tag: v2.6.21-rc1~8 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=6d740cd5b18bc8128e70f98cfde8c74ebd21cea1;p=linux-2.6-omap-h63xx.git [PATCH] lockdep: annotate BLKPG_DEL_PARTITION >============================================= >[ INFO: possible recursive locking detected ] >2.6.19-1.2909.fc7 #1 >--------------------------------------------- >anaconda/587 is trying to acquire lock: > (&bdev->bd_mutex){--..}, at: [] mutex_lock+0x21/0x24 > >but task is already holding lock: > (&bdev->bd_mutex){--..}, at: [] mutex_lock+0x21/0x24 > >other info that might help us debug this: >1 lock held by anaconda/587: > #0: (&bdev->bd_mutex){--..}, at: [] mutex_lock+0x21/0x24 > >stack backtrace: > [] show_trace_log_lvl+0x1a/0x2f > [] show_trace+0x12/0x14 > [] dump_stack+0x16/0x18 > [] __lock_acquire+0x116/0xa09 > [] lock_acquire+0x56/0x6f > [] __mutex_lock_slowpath+0xe5/0x24a > [] mutex_lock+0x21/0x24 > [] blkdev_ioctl+0x600/0x76d > [] block_ioctl+0x1b/0x1f > [] do_ioctl+0x22/0x68 > [] vfs_ioctl+0x252/0x265 > [] sys_ioctl+0x49/0x63 > [] syscall_call+0x7/0xb Annotate BLKPG_DEL_PARTITION's bd_mutex locking and add a little comment clarifying the bd_mutex locking, because I confused myself and initially thought the lock order was wrong too. Signed-off-by: Peter Zijlstra Cc: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/block/ioctl.c b/block/ioctl.c index e3f5eb9882c..e06dbe9bc85 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -82,7 +82,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user fsync_bdev(bdevp); invalidate_bdev(bdevp, 0); - mutex_lock(&bdev->bd_mutex); + mutex_lock_nested(&bdev->bd_mutex, 1); delete_partition(disk, part); mutex_unlock(&bdev->bd_mutex); mutex_unlock(&bdevp->bd_mutex); diff --git a/fs/block_dev.c b/fs/block_dev.c index 0c59b703e9d..575076c018f 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1101,6 +1101,13 @@ static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags, int for_part); static int __blkdev_put(struct block_device *bdev, int for_part); +/* + * bd_mutex locking: + * + * mutex_lock(part->bd_mutex) + * mutex_lock_nested(whole->bd_mutex, 1) + */ + static int do_open(struct block_device *bdev, struct file *file, int for_part) { struct module *owner = NULL;