OSDN Git Service

[PATCH] block: fix negative bias of ios_in_flight (CONFIG_BLK_STATS) because of unbal...
authorSteffen Maier <smaier@users.sourceforge.net>
Thu, 14 Sep 2006 14:58:24 +0000 (16:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Sep 2006 21:10:27 +0000 (23:10 +0200)
commit55cf1ddbffe17586bdb585647e53c44c92e900b1
treee32a5b2e09a5307eccb81aa5d91cd91fdc4c4b78
parent9a65068e1eadd7254704def8b6fee8432107a61d
[PATCH] block: fix negative bias of ios_in_flight (CONFIG_BLK_STATS) because of unbalanced I/O accounting

Fix for unbalanced I/O accounting, that caused ios_in_flight
(CONFIG_BLK_STATS) to become and stay negative, as suggested by Jens
Axboe.

An added boolean field "io_account" in struct request is assumed to be
initialized to false on new requests. On starting I/O accounting, true is
assigned to the field. On ending I/O accounting, accounting is only
executed if the field has already been assigned true previously. Thus,
this fixes unbalanced cases where requests such as non-data get enqueued
without starting to account (ide_do_drive_cmd?) but the end of accounting
gets executed on finishing the same requests (ide_end_drive_cmd,
end_that_request_last, req_finished_io).

The precondition of io_account being initialized to false is ensured by

1) ide_init_drive_taskfile / ide_init_drive_cmd memset'ing the whole
request to zero, for requests that were potentially accounted unbalanced,
and

2) get_request assigning zero to io_account on allocating a request from
the free list cache (or slab cache initially), for the majority of
requests such as those involving data.

Jens preferred this to other discussed solutions and it should fix all
those unbalanced cases at once without touching each of them individually.

For more details, please see previous posts of this thread
http://www.uwsg.iu.edu/hypermail/linux/kernel/0608.2/0776.html.

I tested the patch with 2.4.24 and 2.4.33.3 successfully on an UP ia32
machine with one /dev/hda.

Signed-off-by: Steffen Maier <smaier@users.sourceforge.net>
drivers/block/ll_rw_blk.c
include/linux/blkdev.h