Skip to content

Commit 2448085

Browse files
Gu Zhengaxboe
authored andcommitted
drbd: use generic io stats accounting functions to simplify io stat accounting
Use generic io stats accounting help functions (generic_{start,end}_io_acct) to simplify io stat accounting. Signed-off-by: Gu Zheng <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent aae4933 commit 2448085

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

drivers/block/drbd/drbd_req.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,15 @@ static bool drbd_may_do_local_read(struct drbd_device *device, sector_t sector,
3636
/* Update disk stats at start of I/O request */
3737
static void _drbd_start_io_acct(struct drbd_device *device, struct drbd_request *req)
3838
{
39-
const int rw = bio_data_dir(req->master_bio);
40-
int cpu;
41-
cpu = part_stat_lock();
42-
part_round_stats(cpu, &device->vdisk->part0);
43-
part_stat_inc(cpu, &device->vdisk->part0, ios[rw]);
44-
part_stat_add(cpu, &device->vdisk->part0, sectors[rw], req->i.size >> 9);
45-
(void) cpu; /* The macro invocations above want the cpu argument, I do not like
46-
the compiler warning about cpu only assigned but never used... */
47-
part_inc_in_flight(&device->vdisk->part0, rw);
48-
part_stat_unlock();
39+
generic_start_io_acct(bio_data_dir(req->master_bio), req->i.size >> 9,
40+
&device->vdisk->part0);
4941
}
5042

5143
/* Update disk stats when completing request upwards */
5244
static void _drbd_end_io_acct(struct drbd_device *device, struct drbd_request *req)
5345
{
54-
int rw = bio_data_dir(req->master_bio);
55-
unsigned long duration = jiffies - req->start_jif;
56-
int cpu;
57-
cpu = part_stat_lock();
58-
part_stat_add(cpu, &device->vdisk->part0, ticks[rw], duration);
59-
part_round_stats(cpu, &device->vdisk->part0);
60-
part_dec_in_flight(&device->vdisk->part0, rw);
61-
part_stat_unlock();
46+
generic_end_io_acct(bio_data_dir(req->master_bio),
47+
&device->vdisk->part0, req->start_jif);
6248
}
6349

6450
static struct drbd_request *drbd_req_new(struct drbd_device *device,

0 commit comments

Comments
 (0)