[PATCH] new bd_mutex lockdep annotation

Use the gendisk partition number to set a lock class.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Peter Zijlstra 2006-12-08 02:36:14 -08:00 committed by Linus Torvalds
parent 2e7b651df1
commit 35a6027f1a
1 changed files with 9 additions and 0 deletions

View File

@ -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;
}