summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-09-21 09:19:47 +0200
committerJens Axboe <axboe@kernel.dk>2020-09-23 10:43:19 -0600
commit478162821dfb4396c53f07ad82dc32cd0f525cea (patch)
treed38bf0eac97e98602d997aea28c3bbda5374d5d0
parent9301fe734384990ef9a2463cb7aeb3b00bf5dad5 (diff)
downloadlinux-478162821dfb4396c53f07ad82dc32cd0f525cea.tar.gz
linux-478162821dfb4396c53f07ad82dc32cd0f525cea.tar.bz2
linux-478162821dfb4396c53f07ad82dc32cd0f525cea.zip
block: cleanup blkdev_bszset
Use blkdev_get_by_dev instead of bdgrab + blkdev_get. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/ioctl.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/block/ioctl.c b/block/ioctl.c
index ae74d0409afa..06262c28f0c6 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -478,15 +478,14 @@ static int blkdev_bszset(struct block_device *bdev, fmode_t mode,
if (get_user(n, argp))
return -EFAULT;
- if (!(mode & FMODE_EXCL)) {
- bdgrab(bdev);
- if (blkdev_get(bdev, mode | FMODE_EXCL, &bdev) < 0)
- return -EBUSY;
- }
+ if (mode & FMODE_EXCL)
+ return set_blocksize(bdev, n);
+ if (IS_ERR(blkdev_get_by_dev(bdev->bd_dev, mode | FMODE_EXCL, &bdev)))
+ return -EBUSY;
ret = set_blocksize(bdev, n);
- if (!(mode & FMODE_EXCL))
- blkdev_put(bdev, mode | FMODE_EXCL);
+ blkdev_put(bdev, mode | FMODE_EXCL);
+
return ret;
}