diff options
author | Christoph Hellwig <hch@lst.de> | 2020-04-14 09:28:54 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-04-20 11:32:59 -0600 |
commit | cddae808aeb77e5c29d22a8e0dfbdaed413f9e04 (patch) | |
tree | cca16ea68b8e11226b5def4cac2d49f5e565af70 /block/partitions | |
parent | fa9156ae597c244df4e12891dc8329f649970d9a (diff) |
block: pass a hd_struct to delete_partition
All callers have the hd_struct at hand, so pass it instead of performing
another lookup.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/partitions')
-rw-r--r-- | block/partitions/core.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c index 7e2f40875166..6dc534b502a9 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -296,20 +296,12 @@ void __delete_partition(struct percpu_ref *ref) * Must be called either with bd_mutex held, before a disk can be opened or * after all disk users are gone. */ -void delete_partition(struct gendisk *disk, int partno) +void delete_partition(struct gendisk *disk, struct hd_struct *part) { struct disk_part_tbl *ptbl = rcu_dereference_protected(disk->part_tbl, 1); - struct hd_struct *part; - - if (partno >= ptbl->len) - return; - part = rcu_dereference_protected(ptbl->part[partno], 1); - if (!part) - return; - - rcu_assign_pointer(ptbl->part[partno], NULL); + rcu_assign_pointer(ptbl->part[part->partno], NULL); rcu_assign_pointer(ptbl->last_lookup, NULL); kobject_put(part->holder_dir); device_del(part_to_dev(part)); @@ -520,10 +512,10 @@ int bdev_del_partition(struct block_device *bdev, int partno) if (!part) return -ENXIO; + ret = -ENOMEM; bdevp = bdget(part_devt(part)); - disk_put_part(part); if (!bdevp) - return -ENOMEM; + goto out_put_part; mutex_lock(&bdevp->bd_mutex); @@ -535,13 +527,15 @@ int bdev_del_partition(struct block_device *bdev, int partno) invalidate_bdev(bdevp); mutex_lock_nested(&bdev->bd_mutex, 1); - delete_partition(bdev->bd_disk, partno); + delete_partition(bdev->bd_disk, part); mutex_unlock(&bdev->bd_mutex); ret = 0; out_unlock: mutex_unlock(&bdevp->bd_mutex); bdput(bdevp); +out_put_part: + disk_put_part(part); return ret; } @@ -617,7 +611,7 @@ int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev) disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY); while ((part = disk_part_iter_next(&piter))) - delete_partition(disk, part->partno); + delete_partition(disk, part); disk_part_iter_exit(&piter); return 0; |