]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
block: reduce part_stat_lock() scope
authorChristoph Hellwig <hch@lst.de>
Wed, 27 May 2020 05:24:19 +0000 (07:24 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 27 May 2020 11:21:23 +0000 (05:21 -0600)
We only need the stats lock (aka preempt_disable()) for updating the
states, not for looking up or dropping the hd_struct reference.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-merge.c

index bf2f7d4bc0c1c692bf541dccade4fa1ad91d3181..a01fb2b508f0efa042f86085092b51cb08741e7e 100644 (file)
@@ -1437,9 +1437,9 @@ void blk_account_io_done(struct request *req, u64 now)
                update_io_ticks(part, jiffies, true);
                part_stat_inc(part, ios[sgrp]);
                part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
+               part_stat_unlock();
 
                hd_struct_put(part);
-               part_stat_unlock();
        }
 }
 
@@ -1448,8 +1448,9 @@ void blk_account_io_start(struct request *rq)
        if (!blk_do_io_stat(rq))
                return;
 
-       part_stat_lock();
        rq->part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));
+
+       part_stat_lock();
        update_io_ticks(rq->part, jiffies, false);
        part_stat_unlock();
 }
index c3beae5c1be71bbf84bef3b081396a2d7d5f8a42..f0b0bae075a0c8ea98c7158985b8d16fec7e9c4d 100644 (file)
@@ -674,8 +674,9 @@ static void blk_account_io_merge_request(struct request *req)
        if (blk_do_io_stat(req)) {
                part_stat_lock();
                part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
-               hd_struct_put(req->part);
                part_stat_unlock();
+
+               hd_struct_put(req->part);
        }
 }