diff options
author | Ming Lei <tom.leiming@gmail.com> | 2015-07-16 11:16:45 +0800 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-07-17 08:41:53 -0600 |
commit | 6c71013ecb7e2bddbed9f5b95e7aed22c491daa9 (patch) | |
tree | 773a3ebe4289815e677ce2b357c665cba5292c0e /block | |
parent | b54e5ed8f285d62c0d242c4ef9da90937994db02 (diff) | |
download | linux-6c71013ecb7e2bddbed9f5b95e7aed22c491daa9.tar.gz linux-6c71013ecb7e2bddbed9f5b95e7aed22c491daa9.tar.bz2 linux-6c71013ecb7e2bddbed9f5b95e7aed22c491daa9.zip |
block: partition: convert percpu ref
Percpu refcount is the perfect match for partition's case,
and the conversion is quite straight.
With the convertion, one pair of atomic inc/dec can be saved
for accounting block I/O, which is run in hot path of block I/O.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/genhd.c | 6 | ||||
-rw-r--r-- | block/partition-generic.c | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/block/genhd.c b/block/genhd.c index 85df45292dba..0c706f33a599 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1284,7 +1284,11 @@ struct gendisk *alloc_disk_node(int minors, int node_id) * converted to make use of bd_mutex and sequence counters. */ seqcount_init(&disk->part0.nr_sects_seq); - hd_ref_init(&disk->part0); + if (hd_ref_init(&disk->part0)) { + hd_free_part(&disk->part0); + kfree(disk); + return NULL; + } disk->minors = minors; rand_initialize_disk(disk); diff --git a/block/partition-generic.c b/block/partition-generic.c index eca0d02a607c..e7711133284e 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -232,8 +232,9 @@ static void delete_partition_rcu_cb(struct rcu_head *head) put_device(part_to_dev(part)); } -void __delete_partition(struct hd_struct *part) +void __delete_partition(struct percpu_ref *ref) { + struct hd_struct *part = container_of(ref, struct hd_struct, ref); call_rcu(&part->rcu_head, delete_partition_rcu_cb); } @@ -254,7 +255,7 @@ void delete_partition(struct gendisk *disk, int partno) kobject_put(part->holder_dir); device_del(part_to_dev(part)); - hd_struct_put(part); + hd_struct_kill(part); } static ssize_t whole_disk_show(struct device *dev, @@ -355,8 +356,8 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, if (!dev_get_uevent_suppress(ddev)) kobject_uevent(&pdev->kobj, KOBJ_ADD); - hd_ref_init(p); - return p; + if (!hd_ref_init(p)) + return p; out_free_info: free_part_info(p); |