diff options
Diffstat (limited to 'block/blk-core.c')
-rw-r--r-- | block/blk-core.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index a0dc2e72fcbb..d6128d9ad601 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -60,7 +60,9 @@ static void drive_stat_acct(struct request *rq, int new_io) | |||
60 | if (!blk_fs_request(rq) || !rq->rq_disk) | 60 | if (!blk_fs_request(rq) || !rq->rq_disk) |
61 | return; | 61 | return; |
62 | 62 | ||
63 | part = disk_map_sector(rq->rq_disk, rq->sector); | 63 | rcu_read_lock(); |
64 | |||
65 | part = disk_map_sector_rcu(rq->rq_disk, rq->sector); | ||
64 | if (!new_io) | 66 | if (!new_io) |
65 | __all_stat_inc(rq->rq_disk, part, merges[rw], rq->sector); | 67 | __all_stat_inc(rq->rq_disk, part, merges[rw], rq->sector); |
66 | else { | 68 | else { |
@@ -71,6 +73,8 @@ static void drive_stat_acct(struct request *rq, int new_io) | |||
71 | part->in_flight++; | 73 | part->in_flight++; |
72 | } | 74 | } |
73 | } | 75 | } |
76 | |||
77 | rcu_read_unlock(); | ||
74 | } | 78 | } |
75 | 79 | ||
76 | void blk_queue_congestion_threshold(struct request_queue *q) | 80 | void blk_queue_congestion_threshold(struct request_queue *q) |
@@ -1557,12 +1561,14 @@ static int __end_that_request_first(struct request *req, int error, | |||
1557 | } | 1561 | } |
1558 | 1562 | ||
1559 | if (blk_fs_request(req) && req->rq_disk) { | 1563 | if (blk_fs_request(req) && req->rq_disk) { |
1560 | struct hd_struct *part = | ||
1561 | disk_map_sector(req->rq_disk, req->sector); | ||
1562 | const int rw = rq_data_dir(req); | 1564 | const int rw = rq_data_dir(req); |
1565 | struct hd_struct *part; | ||
1563 | 1566 | ||
1567 | rcu_read_lock(); | ||
1568 | part = disk_map_sector_rcu(req->rq_disk, req->sector); | ||
1564 | all_stat_add(req->rq_disk, part, sectors[rw], | 1569 | all_stat_add(req->rq_disk, part, sectors[rw], |
1565 | nr_bytes >> 9, req->sector); | 1570 | nr_bytes >> 9, req->sector); |
1571 | rcu_read_unlock(); | ||
1566 | } | 1572 | } |
1567 | 1573 | ||
1568 | total_bytes = bio_nbytes = 0; | 1574 | total_bytes = bio_nbytes = 0; |
@@ -1746,7 +1752,11 @@ static void end_that_request_last(struct request *req, int error) | |||
1746 | if (disk && blk_fs_request(req) && req != &req->q->bar_rq) { | 1752 | if (disk && blk_fs_request(req) && req != &req->q->bar_rq) { |
1747 | unsigned long duration = jiffies - req->start_time; | 1753 | unsigned long duration = jiffies - req->start_time; |
1748 | const int rw = rq_data_dir(req); | 1754 | const int rw = rq_data_dir(req); |
1749 | struct hd_struct *part = disk_map_sector(disk, req->sector); | 1755 | struct hd_struct *part; |
1756 | |||
1757 | rcu_read_lock(); | ||
1758 | |||
1759 | part = disk_map_sector_rcu(disk, req->sector); | ||
1750 | 1760 | ||
1751 | __all_stat_inc(disk, part, ios[rw], req->sector); | 1761 | __all_stat_inc(disk, part, ios[rw], req->sector); |
1752 | __all_stat_add(disk, part, ticks[rw], duration, req->sector); | 1762 | __all_stat_add(disk, part, ticks[rw], duration, req->sector); |
@@ -1756,6 +1766,8 @@ static void end_that_request_last(struct request *req, int error) | |||
1756 | part_round_stats(part); | 1766 | part_round_stats(part); |
1757 | part->in_flight--; | 1767 | part->in_flight--; |
1758 | } | 1768 | } |
1769 | |||
1770 | rcu_read_unlock(); | ||
1759 | } | 1771 | } |
1760 | 1772 | ||
1761 | if (req->end_io) | 1773 | if (req->end_io) |