forked from luck/tmp_suning_uos_patched
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>
This commit is contained in:
parent
fa9156ae59
commit
cddae808ae
|
@ -390,7 +390,7 @@ char *disk_name(struct gendisk *hd, int partno, char *buf);
|
||||||
#define ADDPART_FLAG_RAID 1
|
#define ADDPART_FLAG_RAID 1
|
||||||
#define ADDPART_FLAG_WHOLEDISK 2
|
#define ADDPART_FLAG_WHOLEDISK 2
|
||||||
void __delete_partition(struct percpu_ref *ref);
|
void __delete_partition(struct percpu_ref *ref);
|
||||||
void delete_partition(struct gendisk *disk, int partno);
|
void delete_partition(struct gendisk *disk, struct hd_struct *part);
|
||||||
int bdev_add_partition(struct block_device *bdev, int partno,
|
int bdev_add_partition(struct block_device *bdev, int partno,
|
||||||
sector_t start, sector_t length);
|
sector_t start, sector_t length);
|
||||||
int bdev_del_partition(struct block_device *bdev, int partno);
|
int bdev_del_partition(struct block_device *bdev, int partno);
|
||||||
|
|
|
@ -897,7 +897,7 @@ void del_gendisk(struct gendisk *disk)
|
||||||
while ((part = disk_part_iter_next(&piter))) {
|
while ((part = disk_part_iter_next(&piter))) {
|
||||||
invalidate_partition(disk, part->partno);
|
invalidate_partition(disk, part->partno);
|
||||||
bdev_unhash_inode(part_devt(part));
|
bdev_unhash_inode(part_devt(part));
|
||||||
delete_partition(disk, part->partno);
|
delete_partition(disk, part);
|
||||||
}
|
}
|
||||||
disk_part_iter_exit(&piter);
|
disk_part_iter_exit(&piter);
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Must be called either with bd_mutex held, before a disk can be opened or
|
||||||
* after all disk users are gone.
|
* 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 =
|
struct disk_part_tbl *ptbl =
|
||||||
rcu_dereference_protected(disk->part_tbl, 1);
|
rcu_dereference_protected(disk->part_tbl, 1);
|
||||||
struct hd_struct *part;
|
|
||||||
|
|
||||||
if (partno >= ptbl->len)
|
rcu_assign_pointer(ptbl->part[part->partno], NULL);
|
||||||
return;
|
|
||||||
|
|
||||||
part = rcu_dereference_protected(ptbl->part[partno], 1);
|
|
||||||
if (!part)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rcu_assign_pointer(ptbl->part[partno], NULL);
|
|
||||||
rcu_assign_pointer(ptbl->last_lookup, NULL);
|
rcu_assign_pointer(ptbl->last_lookup, NULL);
|
||||||
kobject_put(part->holder_dir);
|
kobject_put(part->holder_dir);
|
||||||
device_del(part_to_dev(part));
|
device_del(part_to_dev(part));
|
||||||
|
@ -520,10 +512,10 @@ int bdev_del_partition(struct block_device *bdev, int partno)
|
||||||
if (!part)
|
if (!part)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
|
ret = -ENOMEM;
|
||||||
bdevp = bdget(part_devt(part));
|
bdevp = bdget(part_devt(part));
|
||||||
disk_put_part(part);
|
|
||||||
if (!bdevp)
|
if (!bdevp)
|
||||||
return -ENOMEM;
|
goto out_put_part;
|
||||||
|
|
||||||
mutex_lock(&bdevp->bd_mutex);
|
mutex_lock(&bdevp->bd_mutex);
|
||||||
|
|
||||||
|
@ -535,13 +527,15 @@ int bdev_del_partition(struct block_device *bdev, int partno)
|
||||||
invalidate_bdev(bdevp);
|
invalidate_bdev(bdevp);
|
||||||
|
|
||||||
mutex_lock_nested(&bdev->bd_mutex, 1);
|
mutex_lock_nested(&bdev->bd_mutex, 1);
|
||||||
delete_partition(bdev->bd_disk, partno);
|
delete_partition(bdev->bd_disk, part);
|
||||||
mutex_unlock(&bdev->bd_mutex);
|
mutex_unlock(&bdev->bd_mutex);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out_unlock:
|
out_unlock:
|
||||||
mutex_unlock(&bdevp->bd_mutex);
|
mutex_unlock(&bdevp->bd_mutex);
|
||||||
bdput(bdevp);
|
bdput(bdevp);
|
||||||
|
out_put_part:
|
||||||
|
disk_put_part(part);
|
||||||
return ret;
|
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);
|
disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
|
||||||
while ((part = disk_part_iter_next(&piter)))
|
while ((part = disk_part_iter_next(&piter)))
|
||||||
delete_partition(disk, part->partno);
|
delete_partition(disk, part);
|
||||||
disk_part_iter_exit(&piter);
|
disk_part_iter_exit(&piter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user