diff options
-rw-r--r-- | fs/block_dev.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 36c38f48a4ed..528cf053ce96 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -355,10 +355,14 @@ static int bdev_set(struct inode *inode, void *data) | |||
355 | 355 | ||
356 | static LIST_HEAD(all_bdevs); | 356 | static LIST_HEAD(all_bdevs); |
357 | 357 | ||
358 | static struct lock_class_key bdev_part_lock_key; | ||
359 | |||
358 | struct block_device *bdget(dev_t dev) | 360 | struct block_device *bdget(dev_t dev) |
359 | { | 361 | { |
360 | struct block_device *bdev; | 362 | struct block_device *bdev; |
361 | struct inode *inode; | 363 | struct inode *inode; |
364 | struct gendisk *disk; | ||
365 | int part = 0; | ||
362 | 366 | ||
363 | inode = iget5_locked(bd_mnt->mnt_sb, hash(dev), | 367 | inode = iget5_locked(bd_mnt->mnt_sb, hash(dev), |
364 | bdev_test, bdev_set, &dev); | 368 | bdev_test, bdev_set, &dev); |
@@ -384,6 +388,11 @@ struct block_device *bdget(dev_t dev) | |||
384 | list_add(&bdev->bd_list, &all_bdevs); | 388 | list_add(&bdev->bd_list, &all_bdevs); |
385 | spin_unlock(&bdev_lock); | 389 | spin_unlock(&bdev_lock); |
386 | unlock_new_inode(inode); | 390 | unlock_new_inode(inode); |
391 | mutex_init(&bdev->bd_mutex); | ||
392 | disk = get_gendisk(dev, &part); | ||
393 | if (part) | ||
394 | lockdep_set_class(&bdev->bd_mutex, &bdev_part_lock_key); | ||
395 | put_disk(disk); | ||
387 | } | 396 | } |
388 | return bdev; | 397 | return bdev; |
389 | } | 398 | } |