From: Jerome Marchand <jmarchan@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: axboe@kernel.dk
Subject: [Patch 2/8] Enhanced partition statistics: update partition statitics
Date: Thu, 13 Dec 2007 17:17:35 +0100 [thread overview]
Message-ID: <47615B1F.7030603@redhat.com> (raw)
Updates the enhanced partition statistics in generic block layer besides the disk statistics.
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
block/ll_rw_blk.c | 40 ++++++++++++++++++++++++++++++++++++----
fs/partitions/check.c | 7 +++++++
include/linux/genhd.h | 1 +
3 files changed, 44 insertions(+), 4 deletions(-)
diff -urNp -X linux-2.6/Documentation/dontdiff linux-2.6.orig/block/ll_rw_blk.c linux-2.6/block/ll_rw_blk.c
--- linux-2.6.orig/block/ll_rw_blk.c 2007-12-04 17:37:31.000000000 +0100
+++ linux-2.6/block/ll_rw_blk.c 2007-12-05 12:18:49.000000000 +0100
@@ -2734,10 +2734,15 @@ static void drive_stat_acct(struct reque
return;
if (!new_io) {
- __disk_stat_inc(rq->rq_disk, merges[rw]);
+ __all_stat_inc(rq->rq_disk, merges[rw], rq->sector);
} else {
+ struct hd_struct *part = get_part(rq->rq_disk, rq->sector);
disk_round_stats(rq->rq_disk);
rq->rq_disk->in_flight++;
+ if (part) {
+ part_round_stats(part);
+ part->in_flight++;
+ }
}
}
@@ -2789,6 +2794,21 @@ void disk_round_stats(struct gendisk *di
EXPORT_SYMBOL_GPL(disk_round_stats);
+void part_round_stats(struct hd_struct *part)
+{
+ unsigned long now = jiffies;
+
+ if (now == part->stamp)
+ return;
+
+ if (part->in_flight) {
+ __part_stat_add(part, time_in_queue,
+ part->in_flight * (now - part->stamp));
+ __part_stat_add(part, io_ticks, (now - part->stamp));
+ }
+ part->stamp = now;
+}
+
/*
* queue lock must be held
*/
@@ -2903,8 +2923,14 @@ static int attempt_merge(struct request_
elv_merge_requests(q, req, next);
if (req->rq_disk) {
+ struct hd_struct *part
+ = get_part(req->rq_disk, req->sector);
disk_round_stats(req->rq_disk);
req->rq_disk->in_flight--;
+ if (part) {
+ part_round_stats(part);
+ part->in_flight--;
+ }
}
req->ioprio = ioprio_best(req->ioprio, next->ioprio);
@@ -3447,7 +3473,8 @@ static int __end_that_request_first(stru
if (blk_fs_request(req) && req->rq_disk) {
const int rw = rq_data_dir(req);
- disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9);
+ all_stat_add(req->rq_disk, sectors[rw],
+ nr_bytes >> 9, req->sector);
}
total_bytes = bio_nbytes = 0;
@@ -3676,11 +3703,16 @@ void end_that_request_last(struct reques
if (disk && blk_fs_request(req) && req != &req->q->bar_rq) {
unsigned long duration = jiffies - req->start_time;
const int rw = rq_data_dir(req);
+ struct hd_struct *part = get_part(disk, req->sector);
- __disk_stat_inc(disk, ios[rw]);
- __disk_stat_add(disk, ticks[rw], duration);
+ __all_stat_inc(disk, ios[rw], req->sector);
+ __all_stat_add(disk, ticks[rw], duration, req->sector);
disk_round_stats(disk);
disk->in_flight--;
+ if (part) {
+ part_round_stats(part);
+ part->in_flight--;
+ }
}
if (req->end_io)
req->end_io(req, error);
diff -urNp -X linux-2.6/Documentation/dontdiff linux-2.6.orig/fs/partitions/check.c linux-2.6/fs/partitions/check.c
--- linux-2.6.orig/fs/partitions/check.c 2007-12-04 17:36:20.000000000 +0100
+++ linux-2.6/fs/partitions/check.c 2007-12-05 12:18:49.000000000 +0100
@@ -18,6 +18,7 @@
#include <linux/fs.h>
#include <linux/kmod.h>
#include <linux/ctype.h>
+#include <linux/genhd.h>
#include "check.h"
@@ -321,6 +322,7 @@ extern struct kset block_subsys;
static void part_release(struct kobject *kobj)
{
struct hd_struct * p = container_of(kobj,struct hd_struct,kobj);
+ free_part_stats(p);
kfree(p);
}
@@ -361,6 +363,7 @@ void delete_partition(struct gendisk *di
p->nr_sects = 0;
p->ios[0] = p->ios[1] = 0;
p->sectors[0] = p->sectors[1] = 0;
+ part_stat_set_all(p, 0);
sysfs_remove_link(&p->kobj, "subsystem");
kobject_unregister(p->holder_dir);
kobject_uevent(&p->kobj, KOBJ_REMOVE);
@@ -376,6 +379,10 @@ void add_partition(struct gendisk *disk,
if (!p)
return;
+ if (!init_part_stats(p)) {
+ kfree(p);
+ return;
+ }
p->start_sect = start;
p->nr_sects = len;
p->partno = part;
diff -urNp -X linux-2.6/Documentation/dontdiff linux-2.6.orig/include/linux/genhd.h linux-2.6/include/linux/genhd.h
--- linux-2.6.orig/include/linux/genhd.h 2007-12-05 12:18:33.000000000 +0100
+++ linux-2.6/include/linux/genhd.h 2007-12-05 12:18:49.000000000 +0100
@@ -359,6 +359,7 @@ static inline void free_part_stats(struc
/* drivers/block/ll_rw_blk.c */
extern void disk_round_stats(struct gendisk *disk);
+extern void part_round_stats(struct hd_struct *part);
/* drivers/block/genhd.c */
extern int get_blkdev_list(char *, int);
reply other threads:[~2007-12-13 16:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=47615B1F.7030603@redhat.com \
--to=jmarchan@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
/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