Commit 63d9932c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: move bdput() to the callers of __blkdev_get

This will allow for a more symmetric calling convention going forward.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 5b56b6ed
...@@ -1462,6 +1462,7 @@ static int __blkdev_get(struct block_device *bdev, struct gendisk *disk, ...@@ -1462,6 +1462,7 @@ static int __blkdev_get(struct block_device *bdev, struct gendisk *disk,
if (!(disk->flags & GENHD_FL_UP) || if (!(disk->flags & GENHD_FL_UP) ||
!bdev->bd_part || !bdev->bd_part->nr_sects) { !bdev->bd_part || !bdev->bd_part->nr_sects) {
__blkdev_put(whole, mode, 1); __blkdev_put(whole, mode, 1);
bdput(whole);
ret = -ENXIO; ret = -ENXIO;
goto out_clear; goto out_clear;
} }
...@@ -1744,9 +1745,10 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) ...@@ -1744,9 +1745,10 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
disk->fops->release(disk, mode); disk->fops->release(disk, mode);
} }
mutex_unlock(&bdev->bd_mutex); mutex_unlock(&bdev->bd_mutex);
bdput(bdev); if (victim) {
if (victim)
__blkdev_put(victim, mode, 1); __blkdev_put(victim, mode, 1);
bdput(victim);
}
} }
void blkdev_put(struct block_device *bdev, fmode_t mode) void blkdev_put(struct block_device *bdev, fmode_t mode)
...@@ -1796,6 +1798,7 @@ void blkdev_put(struct block_device *bdev, fmode_t mode) ...@@ -1796,6 +1798,7 @@ void blkdev_put(struct block_device *bdev, fmode_t mode)
mutex_unlock(&bdev->bd_mutex); mutex_unlock(&bdev->bd_mutex);
__blkdev_put(bdev, mode, 0); __blkdev_put(bdev, mode, 0);
bdput(bdev);
put_disk_and_module(disk); put_disk_and_module(disk);
} }
EXPORT_SYMBOL(blkdev_put); EXPORT_SYMBOL(blkdev_put);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment