Skip to content

Commit

Permalink
block: move bdput() to the callers of __blkdev_get
Browse files Browse the repository at this point in the history
This will allow for a more symmetric calling convention going forward.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Dec 1, 2020
1 parent 5b56b6e commit 63d9932
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ static int __blkdev_get(struct block_device *bdev, struct gendisk *disk,
if (!(disk->flags & GENHD_FL_UP) ||
!bdev->bd_part || !bdev->bd_part->nr_sects) {
__blkdev_put(whole, mode, 1);
bdput(whole);
ret = -ENXIO;
goto out_clear;
}
Expand Down Expand Up @@ -1744,9 +1745,10 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
disk->fops->release(disk, mode);
}
mutex_unlock(&bdev->bd_mutex);
bdput(bdev);
if (victim)
if (victim) {
__blkdev_put(victim, mode, 1);
bdput(victim);
}
}

void blkdev_put(struct block_device *bdev, fmode_t mode)
Expand Down Expand Up @@ -1796,6 +1798,7 @@ void blkdev_put(struct block_device *bdev, fmode_t mode)
mutex_unlock(&bdev->bd_mutex);

__blkdev_put(bdev, mode, 0);
bdput(bdev);
put_disk_and_module(disk);
}
EXPORT_SYMBOL(blkdev_put);
Expand Down

0 comments on commit 63d9932

Please sign in to comment.