diff options
author | Jens Axboe <axboe@suse.de> | 2005-11-01 09:26:16 +0100 |
---|---|---|
committer | Jens Axboe <axboe@suse.de> | 2005-11-01 09:26:16 +0100 |
commit | a362357b6cd62643d4dda3b152639303d78473da (patch) | |
tree | fe4ce823e638ded151edcb142f28a240860f0d33 /drivers/block/ll_rw_blk.c | |
parent | d72d904a5367ad4ca3f2c9a2ce8c3a68f0b28bf0 (diff) | |
download | op-kernel-dev-a362357b6cd62643d4dda3b152639303d78473da.zip op-kernel-dev-a362357b6cd62643d4dda3b152639303d78473da.tar.gz |
[BLOCK] Unify the seperate read/write io stat fields into arrays
Instead of having ->read_sectors and ->write_sectors, combine the two
into ->sectors[2] and similar for the other fields. This saves a branch
several places in the io path, since we don't have to care for what the
actual io direction is. On my x86-64 box, that's 200 bytes less text in
just the core (not counting the various drivers).
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'drivers/block/ll_rw_blk.c')
-rw-r--r-- | drivers/block/ll_rw_blk.c | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c index 1b27288..2747741 100644 --- a/drivers/block/ll_rw_blk.c +++ b/drivers/block/ll_rw_blk.c @@ -2388,10 +2388,7 @@ static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io) return; if (!new_io) { - if (rw == READ) - __disk_stat_inc(rq->rq_disk, read_merges); - else - __disk_stat_inc(rq->rq_disk, write_merges); + __disk_stat_inc(rq->rq_disk, merges[rw]); } else { disk_round_stats(rq->rq_disk); rq->rq_disk->in_flight++; @@ -2787,17 +2784,11 @@ static inline void blk_partition_remap(struct bio *bio) if (bdev != bdev->bd_contains) { struct hd_struct *p = bdev->bd_part; + const int rw = bio_data_dir(bio); + + p->sectors[rw] += bio_sectors(bio); + p->ios[rw]++; - switch (bio_data_dir(bio)) { - case READ: - p->read_sectors += bio_sectors(bio); - p->reads++; - break; - case WRITE: - p->write_sectors += bio_sectors(bio); - p->writes++; - break; - } bio->bi_sector += p->start_sect; bio->bi_bdev = bdev->bd_contains; } @@ -3045,10 +3036,9 @@ static int __end_that_request_first(struct request *req, int uptodate, } if (blk_fs_request(req) && req->rq_disk) { - if (rq_data_dir(req) == READ) - __disk_stat_add(req->rq_disk, read_sectors, nr_bytes >> 9); - else - __disk_stat_add(req->rq_disk, write_sectors, nr_bytes >> 9); + const int rw = rq_data_dir(req); + + __disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9); } total_bytes = bio_nbytes = 0; @@ -3179,16 +3169,10 @@ void end_that_request_last(struct request *req) if (disk && blk_fs_request(req)) { unsigned long duration = jiffies - req->start_time; - switch (rq_data_dir(req)) { - case WRITE: - __disk_stat_inc(disk, writes); - __disk_stat_add(disk, write_ticks, duration); - break; - case READ: - __disk_stat_inc(disk, reads); - __disk_stat_add(disk, read_ticks, duration); - break; - } + const int rw = rq_data_dir(req); + + __disk_stat_inc(disk, ios[rw]); + __disk_stat_add(disk, ticks[rw], duration); disk_round_stats(disk); disk->in_flight--; } |