diff options
author | Christoph Hellwig <hch@lst.de> | 2020-04-14 10:28:55 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-04-20 20:32:59 +0300 |
commit | 8da2892e27833c5ee78788a66941e0e96eedad22 (patch) | |
tree | dfb5eb341b7a1f9a717c1db754ec54ae1c9fa208 /block/partitions | |
parent | cddae808aeb77e5c29d22a8e0dfbdaed413f9e04 (diff) | |
download | linux-8da2892e27833c5ee78788a66941e0e96eedad22.tar.xz |
block: cleanup hd_struct freeing
Move hd_ref_init out of line as there it isn't anywhere near a fast path,
and rename the rcu ref freeing callbacks to be more descriptive.
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 | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c index 6dc534b502a9..c5b47627210a 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -274,10 +274,10 @@ struct device_type part_type = { .uevent = part_uevent, }; -static void delete_partition_work_fn(struct work_struct *work) +static void hd_struct_free_work(struct work_struct *work) { - struct hd_struct *part = container_of(to_rcu_work(work), struct hd_struct, - rcu_work); + struct hd_struct *part = + container_of(to_rcu_work(work), struct hd_struct, rcu_work); part->start_sect = 0; part->nr_sects = 0; @@ -285,13 +285,21 @@ static void delete_partition_work_fn(struct work_struct *work) put_device(part_to_dev(part)); } -void __delete_partition(struct percpu_ref *ref) +static void hd_struct_free(struct percpu_ref *ref) { struct hd_struct *part = container_of(ref, struct hd_struct, ref); - INIT_RCU_WORK(&part->rcu_work, delete_partition_work_fn); + + INIT_RCU_WORK(&part->rcu_work, hd_struct_free_work); queue_rcu_work(system_wq, &part->rcu_work); } +int hd_ref_init(struct hd_struct *part) +{ + if (percpu_ref_init(&part->ref, hd_struct_free, 0, GFP_KERNEL)) + return -ENOMEM; + return 0; +} + /* * Must be called either with bd_mutex held, before a disk can be opened or * after all disk users are gone. |