Skip to content

Commit 524f9ff

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: reduce part_stat_lock() scope
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>
1 parent b2d76ad commit 524f9ff

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎block/blk-core.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,9 +1437,9 @@ void blk_account_io_done(struct request *req, u64 now)
14371437
update_io_ticks(part, jiffies, true);
14381438
part_stat_inc(part, ios[sgrp]);
14391439
part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
1440+
part_stat_unlock();
14401441

14411442
hd_struct_put(part);
1442-
part_stat_unlock();
14431443
}
14441444
}
14451445

@@ -1448,8 +1448,9 @@ void blk_account_io_start(struct request *rq)
14481448
if (!blk_do_io_stat(rq))
14491449
return;
14501450

1451-
part_stat_lock();
14521451
rq->part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));
1452+
1453+
part_stat_lock();
14531454
update_io_ticks(rq->part, jiffies, false);
14541455
part_stat_unlock();
14551456
}

‎block/blk-merge.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,9 @@ static void blk_account_io_merge_request(struct request *req)
674674
if (blk_do_io_stat(req)) {
675675
part_stat_lock();
676676
part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
677-
hd_struct_put(req->part);
678677
part_stat_unlock();
678+
679+
hd_struct_put(req->part);
679680
}
680681
}
681682

0 commit comments

Comments
 (0)