mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Divyesh Shah <dpshah@google.com>
To: jens.axboe@oracle.com
Cc: linux-kernel@vger.kernel.org, nauman@google.com, rickyb@google.com
Subject: [PATCH 1/4] block: Re-introduce rq->__nr_sectors to maintain the
Date: Wed, 14 Apr 2010 22:44:31 -0700	[thread overview]
Message-ID: <20100415054348.15836.88264.stgit@austin.mtv.corp.google.com> (raw)
In-Reply-To: <20100415054057.15836.17897.stgit@austin.mtv.corp.google.com>

original size of the request right through completion where it will be useful
for the disk performance histograms.

Signed-off-by: Divyesh Shah <dpshah@google.com>
---

 block/blk-core.c       |    4 ++++
 block/blk-merge.c      |    1 +
 include/linux/blkdev.h |    7 +++++++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index e9a5ae2..f18e7b7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1159,6 +1159,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)
 	struct request *req;
 	int el_ret;
 	unsigned int bytes = bio->bi_size;
+	const unsigned int nr_sectors = bio_sectors(bio);
 	const unsigned short prio = bio_prio(bio);
 	const bool sync = bio_rw_flagged(bio, BIO_RW_SYNCIO);
 	const bool unplug = bio_rw_flagged(bio, BIO_RW_UNPLUG);
@@ -1198,6 +1199,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)
 		req->biotail->bi_next = bio;
 		req->biotail = bio;
 		req->__data_len += bytes;
+		req->__nr_sectors += nr_sectors;
 		req->ioprio = ioprio_best(req->ioprio, prio);
 		if (!blk_rq_cpu_valid(req))
 			req->cpu = bio->bi_comp_cpu;
@@ -1232,6 +1234,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)
 		req->buffer = bio_data(bio);
 		req->__sector = bio->bi_sector;
 		req->__data_len += bytes;
+		req->__nr_sectors += nr_sectors;
 		req->ioprio = ioprio_best(req->ioprio, prio);
 		if (!blk_rq_cpu_valid(req))
 			req->cpu = bio->bi_comp_cpu;
@@ -2350,6 +2353,7 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
 	}
 	rq->__data_len = bio->bi_size;
 	rq->bio = rq->biotail = bio;
+	rq->__nr_sectors = bio_sectors(bio);
 
 	if (bio->bi_bdev)
 		rq->rq_disk = bio->bi_bdev->bd_disk;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 5e7dc99..ee0bb50 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -411,6 +411,7 @@ static int attempt_merge(struct request_queue *q, struct request *req,
 	req->biotail = next->biotail;
 
 	req->__data_len += blk_rq_bytes(next);
+	req->__nr_sectors += blk_rq_size(next);
 
 	elv_merge_requests(q, req, next);
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d483c49..4cc2cdf 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -170,6 +170,7 @@ struct request {
 	/* the following two fields are internal, NEVER access directly */
 	unsigned int __data_len;	/* total data len */
 	sector_t __sector;		/* sector cursor */
+	sector_t __nr_sectors;		/* Total number of sectors */
 
 	struct bio *bio;
 	struct bio *biotail;
@@ -844,6 +845,7 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
 
 /*
  * blk_rq_pos()			: the current sector
+ * blk_rq_size()		: the size of the request in sectors
  * blk_rq_bytes()		: bytes left in the entire request
  * blk_rq_cur_bytes()		: bytes left in the current segment
  * blk_rq_err_bytes()		: bytes left till the next error boundary
@@ -855,6 +857,11 @@ static inline sector_t blk_rq_pos(const struct request *rq)
 	return rq->__sector;
 }
 
+static inline sector_t blk_rq_size(const struct request *rq)
+{
+	return rq->__nr_sectors;
+}
+
 static inline unsigned int blk_rq_bytes(const struct request *rq)
 {
 	return rq->__data_len;


  reply	other threads:[~2010-04-15  5:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-15  5:43 [PATCH 0/4] block: Per-partition block IO performance histograms Divyesh Shah
2010-04-15  5:44 ` Divyesh Shah [this message]
2010-04-15  5:45 ` [PATCH 2/4] block: Add disk performance histograms which can be read Divyesh Shah
2010-04-15  5:45 ` [PATCH 3/4] block: Add seek histograms to the block histograms Divyesh Shah
2010-04-15  5:46 ` [PATCH 4/4] block: Make base bucket for the histograms configurable Divyesh Shah
2010-04-15 10:29 ` [PATCH 0/4] block: Per-partition block IO performance histograms Jens Axboe
2010-04-15 23:49   ` Divyesh Shah
2010-04-15 13:40 ` Jeff Moyer
2010-04-15 23:50   ` Divyesh Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100415054348.15836.88264.stgit@austin.mtv.corp.google.com \
    --to=dpshah@google.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nauman@google.com \
    --cc=rickyb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®