summaryrefslogtreecommitdiff
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-17 12:01:26 +0100
committerJens Axboe <axboe@kernel.dk>2020-12-01 14:53:39 -0700
commitec5d451438a2f24c9b9c33c195bc2c39dcd3d3f0 (patch)
tree571340e8aadfe2b604ac5c012b7d52ce5aaeedf8 /fs/block_dev.c
parent013b0e96ae2225a649b48a2f8fc4f87429483cb1 (diff)
block: refactor __blkdev_put
Reorder the code to have one big section for the last close, and to use bdev_is_partition. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Hannes Reinecke <hare@suse.de> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 962fabe8a67b..6016777b6483 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1742,22 +1742,22 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
WARN_ON_ONCE(bdev->bd_holders);
sync_blockdev(bdev);
kill_bdev(bdev);
-
bdev_write_inode(bdev);
- }
- if (bdev->bd_contains == bdev) {
- if (disk->fops->release)
+
+ if (!bdev_is_partition(bdev) && disk->fops->release)
disk->fops->release(disk, mode);
- }
- if (!bdev->bd_openers) {
+
disk_put_part(bdev->bd_part);
bdev->bd_part = NULL;
bdev->bd_disk = NULL;
- if (bdev != bdev->bd_contains)
+ if (bdev_is_partition(bdev))
victim = bdev->bd_contains;
bdev->bd_contains = NULL;
put_disk_and_module(disk);
+ } else {
+ if (!bdev_is_partition(bdev) && disk->fops->release)
+ disk->fops->release(disk, mode);
}
mutex_unlock(&bdev->bd_mutex);
bdput(bdev);