diff options
author | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> | 2020-05-27 08:24:17 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-05-27 14:21:23 +0300 |
commit | 8ab1d40a646e753adb6814642432a093d93dbf47 (patch) | |
tree | f70e9ee9cc1ea5823cba3865f380a597ef5db3ca /block | |
parent | b5af37ab3a2b143e278340d2c6fa5790d53817e7 (diff) | |
download | linux-8ab1d40a646e753adb6814642432a093d93dbf47.tar.xz |
block: remove rcu_read_lock() from part_stat_lock()
The RCU lock is required only in disk_map_sector_rcu() to lookup the
partition. After that request holds reference to related hd_struct.
Replace get_cpu() with preempt_disable() - returned cpu index is unused.
[hch: rebased]
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/genhd.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/block/genhd.c b/block/genhd.c index 3e7df0a3e6bb..1a7659327664 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -321,11 +321,12 @@ struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector) struct hd_struct *part; int i; + rcu_read_lock(); ptbl = rcu_dereference(disk->part_tbl); part = rcu_dereference(ptbl->last_lookup); if (part && sector_in_part(part, sector) && hd_struct_try_get(part)) - return part; + goto out_unlock; for (i = 1; i < ptbl->len; i++) { part = rcu_dereference(ptbl->part[i]); @@ -339,10 +340,14 @@ struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector) if (!hd_struct_try_get(part)) break; rcu_assign_pointer(ptbl->last_lookup, part); - return part; + goto out_unlock; } } - return &disk->part0; + + part = &disk->part0; +out_unlock: + rcu_read_unlock(); + return part; } /** |