block: use bd{grab,put}() instead of open-coding
authorIlya Dryomov <idryomov@gmail.com>
Fri, 20 Nov 2015 21:18:43 +0000 (22:18 +0100)
committerJens Axboe <axboe@fb.com>
Wed, 13 Jan 2016 17:24:27 +0000 (10:24 -0700)
- bd_acquire() and bd_forget() open-code bdgrab() and bdput()
- raw driver uses igrab() but never checks its return value and always
  holds another ref from bind_set() while calling it, so it's
  equivalent to bdgrab()

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/char/raw.c
fs/block_dev.c

index 60316fbaf2957d1bbbee14c67072920170954170..9b9809b709a55f19f8fc2e5187a26eb47df7f807 100644 (file)
@@ -71,7 +71,7 @@ static int raw_open(struct inode *inode, struct file *filp)
        err = -ENODEV;
        if (!bdev)
                goto out;
-       igrab(bdev->bd_inode);
+       bdgrab(bdev);
        err = blkdev_get(bdev, filp->f_mode | FMODE_EXCL, raw_open);
        if (err)
                goto out;
index aa1a45985889432887da932a368e2d808721e086..8b02c90ced87769d1934c137df9d7e232d3efd26 100644 (file)
@@ -696,7 +696,7 @@ static struct block_device *bd_acquire(struct inode *inode)
        spin_lock(&bdev_lock);
        bdev = inode->i_bdev;
        if (bdev) {
-               ihold(bdev->bd_inode);
+               bdgrab(bdev);
                spin_unlock(&bdev_lock);
                return bdev;
        }
@@ -712,7 +712,7 @@ static struct block_device *bd_acquire(struct inode *inode)
                         * So, we can access it via ->i_mapping always
                         * without igrab().
                         */
-                       ihold(bdev->bd_inode);
+                       bdgrab(bdev);
                        inode->i_bdev = bdev;
                        inode->i_mapping = bdev->bd_inode->i_mapping;
                        list_add(&inode->i_devices, &bdev->bd_inodes);
@@ -735,7 +735,7 @@ void bd_forget(struct inode *inode)
        spin_unlock(&bdev_lock);
 
        if (bdev)
-               iput(bdev->bd_inode);
+               bdput(bdev);
 }
 
 /**