From: Peter Zijlstra Date: Fri, 8 Dec 2006 10:36:14 +0000 (-0800) Subject: [PATCH] new bd_mutex lockdep annotation X-Git-Tag: v2.6.20-rc1~34^2~388 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35a6027f1ab6594068cb8bca7705e4567753946b;p=linux-2.6 [PATCH] new bd_mutex lockdep annotation Use the gendisk partition number to set a lock class. Signed-off-by: Peter Zijlstra Cc: Neil Brown Cc: Ingo Molnar Acked-by: Arjan van de Ven Cc: Jason Baron Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/block_dev.c b/fs/block_dev.c index 36c38f48a4..528cf053ce 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -355,10 +355,14 @@ static int bdev_set(struct inode *inode, void *data) static LIST_HEAD(all_bdevs); +static struct lock_class_key bdev_part_lock_key; + struct block_device *bdget(dev_t dev) { struct block_device *bdev; struct inode *inode; + struct gendisk *disk; + int part = 0; inode = iget5_locked(bd_mnt->mnt_sb, hash(dev), bdev_test, bdev_set, &dev); @@ -384,6 +388,11 @@ struct block_device *bdget(dev_t dev) list_add(&bdev->bd_list, &all_bdevs); spin_unlock(&bdev_lock); unlock_new_inode(inode); + mutex_init(&bdev->bd_mutex); + disk = get_gendisk(dev, &part); + if (part) + lockdep_set_class(&bdev->bd_mutex, &bdev_part_lock_key); + put_disk(disk); } return bdev; }