summaryrefslogtreecommitdiff
path: root/block/partitions
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-05-25 08:13:01 +0200
committerJens Axboe <axboe@kernel.dk>2021-06-01 07:47:14 -0600
commit0e0ccdecb3cff95a350b4364e7ebbaa754d0e47d (patch)
treee824664c86b6b1dc7799c5fd007f1d5615cbc7f0 /block/partitions
parentc97d93c31e5734a16bfe663085ec91b8c9fb20f9 (diff)
block: remove bdget_disk
Just opencode the xa_load in the callers, as none of them actually needs a reference to the bdev. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20210525061301.2242282-9-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/partitions')
-rw-r--r--block/partitions/core.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 4fde8e0dd7cd..186d4fbd9f09 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -326,6 +326,8 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
const char *dname;
int err;
+ lockdep_assert_held(&disk->open_mutex);
+
if (partno >= disk_max_parts(disk))
return ERR_PTR(-EINVAL);
@@ -467,14 +469,13 @@ int bdev_add_partition(struct block_device *bdev, int partno,
int bdev_del_partition(struct block_device *bdev, int partno)
{
- struct block_device *part;
- int ret;
-
- part = bdget_disk(bdev->bd_disk, partno);
- if (!part)
- return -ENXIO;
+ struct block_device *part = NULL;
+ int ret = -ENXIO;
mutex_lock(&bdev->bd_disk->open_mutex);
+ part = xa_load(&bdev->bd_disk->part_tbl, partno);
+ if (!part)
+ goto out_unlock;
ret = -EBUSY;
if (part->bd_openers)
@@ -484,21 +485,20 @@ int bdev_del_partition(struct block_device *bdev, int partno)
ret = 0;
out_unlock:
mutex_unlock(&bdev->bd_disk->open_mutex);
- bdput(part);
return ret;
}
int bdev_resize_partition(struct block_device *bdev, int partno,
sector_t start, sector_t length)
{
- struct block_device *part;
- int ret = 0;
+ struct block_device *part = NULL;
+ int ret = -ENXIO;
- part = bdget_disk(bdev->bd_disk, partno);
+ mutex_lock(&bdev->bd_disk->open_mutex);
+ part = xa_load(&bdev->bd_disk->part_tbl, partno);
if (!part)
- return -ENXIO;
+ goto out_unlock;
- mutex_lock(&bdev->bd_disk->open_mutex);
ret = -EINVAL;
if (start != part->bd_start_sect)
goto out_unlock;
@@ -512,7 +512,6 @@ int bdev_resize_partition(struct block_device *bdev, int partno,
ret = 0;
out_unlock:
mutex_unlock(&bdev->bd_disk->open_mutex);
- bdput(part);
return ret;
}