Seperate read and write statistics of in_flight requests
Subsystems (3)
PATCH 1/1 Seperate read and write statistics of in_flight requests
Currently, there is a single in_flight counter measuring the number of requests in the request_queue. But some monitoring tools would like to know how many read requests and write requests are in progress. Split the current in_flight counter into two seperate counters for read and write.
This patch is based on a patch from Mark Landis <[email protected]>
---
Documentation/iostats.txt +10 -7
@@ -26,11 +26,11 @@ Here are examples of these different formats: 2.6 sysfs: - 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160 + 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 0 3376340 23705160 35486 38030 38030 38030 2.6 diskstats: - 3 0 hda 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160 + 3 0 hda 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 0 3376340 23705160 3 1 hda1 35486 38030 38030 38030 On 2.4 you might execute "grep 'hda ' /proc/partitions". On 2.6, you have
@@ -77,12 +77,15 @@ Field 7 -- # of sectors written Field 8 -- # of milliseconds spent writing This is the total number of milliseconds spent by all writes (as measured from __make_request() to end_that_request_last()). -Field 9 -- # of I/Os currently in progress - The only field that should go to zero. Incremented as requests are - given to appropriate struct request_queue and decremented as they finish. -Field 10 -- # of milliseconds spent doing I/Os +Field 9 -- # of read I/Os currently in progress + This field should go to zero. Incremented as read requests are given + to appropriate struct request_queue and decremented as they finish. +Field 10 -- # of write I/Os currently in progress + This field should go to zero. Incremented as write requests are given + to appropriate struct request_queue and decremented as they finish. +Field 11 -- # of milliseconds spent doing I/Os This field is increases so long as field 9 is nonzero. -Field 11 -- weighted # of milliseconds spent doing I/Os +Field 12 -- weighted # of milliseconds spent doing I/Os This field is incremented at each I/O start, I/O completion, I/O merge, or read of these stats by the number of I/Os in progress (field 9) times the number of milliseconds spent doing I/O since the
block/blk-core.c +3 -3
@@ -69,7 +69,7 @@ static void drive_stat_acct(struct request *rq, int new_io)part_stat_inc (cpu, part, merges[rw]); else {part_round_stats (cpu, part); -part_inc_in_flight (part); +part_inc_in_flight (part, rw); }part_stat_unlock ();
@@ -1030,7 +1030,7 @@ static void part_round_stats_single(int cpu, struct hd_struct *part,if (part->in_flight) {__part_stat_add (cpu, part, time_in_queue, - part->in_flight * (now - part->stamp)); +part_in_flight (part) * (now - part->stamp));__part_stat_add (cpu, part, io_ticks, (now - part->stamp)); } part->stamp = now;
@@ -1686,7 +1686,7 @@ static void blk_account_io_done(struct request *req)part_stat_inc (cpu, part, ios[rw]);part_stat_add (cpu, part, ticks[rw], duration);part_round_stats (cpu, part); -part_dec_in_flight (part); +part_dec_in_flight (part, rw);part_stat_unlock (); }
block/blk-merge.c +1 -1
@@ -321,7 +321,7 @@ static void blk_account_io_merge(struct request *req) part =disk_map_sector_rcu (req->rq_disk,blk_rq_pos (req));part_round_stats (cpu, part); -part_dec_in_flight (part); +part_dec_in_flight (part,rq_data_dir (req));part_stat_unlock (); }
block/genhd.c +3 -2
@@ -1042,7 +1042,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)part_round_stats (cpu, hd);part_stat_unlock (); seq_printf(seqf, "%4d %7d %s %lu %lu %llu " - "%u %lu %lu %llu %u %u %u %u\n", + "%u %lu %lu %llu %u %u %u %u %u\n", MAJOR(part_devt(hd)), MINOR(part_devt(hd)), disk_name(gp, hd->partno, buf), part_stat_read(hd, ios[0]),
@@ -1053,7 +1053,8 @@ static int diskstats_show(struct seq_file *seqf, void *v)part_stat_read (hd, merges[1 ]), (unsigned long long )part_stat_read (hd, sectors[1 ]),jiffies_to_msecs (part_stat_read (hd, ticks[1 ])), - hd->in_flight, + hd->in_flight[0 ], + hd->in_flight[1 ],jiffies_to_msecs (part_stat_read (hd, io_ticks)),jiffies_to_msecs (part_stat_read (hd, time_in_queue)) );
drivers/md/dm.c +10 -6
@@ -130,7 +130,7 @@ struct mapped_device {/* * A list of ios that arrived while we were suspended. */ -atomic_t pending; +atomic_t pending[2 ];wait_queue_head_t wait;struct work_struct work;struct bio_list deferred;
@@ -453,13 +453,14 @@ static void start_io_acct(struct dm_io *io) {struct mapped_device *md = io->md;int cpu; +int rw =bio_data_dir (io->bio); io->start_time = jiffies; cpu =part_stat_lock ();part_round_stats (cpu, &dm_disk (md)->part0);part_stat_unlock (); -dm_disk (md)->part0.in_flight =atomic_inc_return (&md->pending); +dm_disk (md)->part0.in_flight[rw] =atomic_inc_return (&md->pending[rw]); }static void end_io_acct (struct dm_io *io)
@@ -479,8 +480,9 @@ static void end_io_acct(struct dm_io *io)* After this is decremented the bio must not be touched if it is * a barrier. */ -dm_disk (md)->part0.in_flight = pending = -atomic_dec_return (&md->pending); +dm_disk (md)->part0.in_flight[rw] = pending = +atomic_dec_return (&md->pending[rw]); + pending +=atomic_read (&md->pending[rw^0x1 ]);/* nudge anyone waiting on suspend queue */ if (!pending)
@@ -1780,7 +1782,8 @@ static struct mapped_device *alloc_dev(int minor)if (!md->disk) goto bad_disk; -atomic_set (&md->pending,0 ); +atomic_set (&md->pending[0 ],0 ); +atomic_set (&md->pending[1 ],0 );init_waitqueue_head (&md->wait);INIT_WORK (&md->work, dm_wq_work);init_waitqueue_head (&md->eventq);
@@ -2083,7 +2086,8 @@ static int dm_wait_for_completion(struct mapped_device *md, int interruptible)break ; }spin_unlock_irqrestore (q->queue_lock, flags); - }else if (!atomic_read (&md->pending)) + }else if (!atomic_read (&md->pending[0 ]) && + !atomic_read (&md->pending[1 ]))break ; if (interruptible == TASK_INTERRUPTIBLE &&
fs/partitions/check.c +3 -2
@@ -238,7 +238,7 @@ ssize_t part_stat_show(struct device *dev, return sprintf(buf, "%8lu %8lu %8llu %8u " "%8lu %8lu %8llu %8u " - "%8u %8u %8u" + "%8u %8u %8u %8u" "\n", part_stat_read(p, ios[READ]), part_stat_read(p, merges[READ]),
@@ -248,7 +248,8 @@ ssize_t part_stat_show(struct device *dev,part_stat_read (p, merges[WRITE ]), (unsigned long long )part_stat_read (p, sectors[WRITE ]),jiffies_to_msecs (part_stat_read (p, ticks[WRITE ])), - p->in_flight, + p->in_flight[0 ], + p->in_flight[1 ],jiffies_to_msecs (part_stat_read (p, io_ticks)), jiffies_to_msecs(part_stat_read(p, time_in_queue))); }
include/linux/genhd.h +12 -7
@@ -98,7 +98,7 @@ struct hd_struct {int make_it_fail;#endif unsigned long stamp; -int in_flight; +int in_flight[2 ];#ifdef CONFIG_SMP struct disk_stats *dkstats;#else
@@ -322,18 +322,23 @@ static inline void free_part_stats(struct hd_struct *part)#define part_stat_sub (cpu, gendiskp, field, subnd) \ part_stat_add(cpu, gendiskp, field, -subnd) -static inline void part_inc_in_flight (struct hd_struct *part) +static inline void part_inc_in_flight (struct hd_struct *part,int rw) { - part->in_flight++; + part->in_flight[rw]++;if (part->partno) -part_to_disk (part)->part0.in_flight++; +part_to_disk (part)->part0.in_flight[rw]++; } -static inline void part_dec_in_flight (struct hd_struct *part) +static inline void part_dec_in_flight (struct hd_struct *part,int rw) { - part->in_flight--; + part->in_flight[rw]--;if (part->partno) -part_to_disk (part)->part0.in_flight--; +part_to_disk (part)->part0.in_flight[rw]--; +} + +static inline int part_in_flight (struct hd_struct *part) +{ +return part->in_flight[0 ] + part->in_flight[1 ]; }/* block/blk-core.c */
Quoted 6 lines · Nikanth Karthikesan
Currently, there is a single
in_flightcounter measuring the number of requests in therequest_queue. But some monitoring tools would like to know how many read requests and write requests are in progress. Split the currentin_flightcounter into two seperate counters for read and write.This patch is based on a patch from Mark Landis <[email protected]>
With fear of stating the obvious, this changes the output format of the exported stat files. This can/will break existing tools.
Signature · 1 line
Jens Axboe
Quoted 11 lines · On Monday 24 August 2009 16:37:36 Jens Axboe wrote:
Quoted 7 lines · Nikanth Karthikesan
Currently, there is a single
in_flightcounter measuring the number of requests in therequest_queue. But some monitoring tools would like to know how many read requests and write requests are in progress. Split the currentin_flightcounter into two seperate counters for read and write.This patch is based on a patch from Mark Landis
<[email protected]>With fear of stating the obvious, this changes the output format of the exported stat files. This can/will break existing tools.
Oh, yes. This version of the patch adds it as a new attribute in the sysfs instead.
Thanks
Nikanth
Currently, there is a single in_flight counter measuring the number of requests in the request_queue. But some monitoring tools would like to know how many read requests and write requests are in progress. Split the current in_flight counter into two seperate counters for read and write.
---
block/blk-core.c +3 -3
@@ -69,7 +69,7 @@ static void drive_stat_acct(struct request *rq, int new_io)part_stat_inc (cpu, part, merges[rw]); else {part_round_stats (cpu, part); -part_inc_in_flight (part); +part_inc_in_flight (part, rw); }part_stat_unlock ();
@@ -1030,7 +1030,7 @@ static void part_round_stats_single(int cpu, struct hd_struct *part,if (part->in_flight) {__part_stat_add (cpu, part, time_in_queue, - part->in_flight * (now - part->stamp)); +part_in_flight (part) * (now - part->stamp));__part_stat_add (cpu, part, io_ticks, (now - part->stamp)); } part->stamp = now;
@@ -1686,7 +1686,7 @@ static void blk_account_io_done(struct request *req)part_stat_inc (cpu, part, ios[rw]);part_stat_add (cpu, part, ticks[rw], duration);part_round_stats (cpu, part); -part_dec_in_flight (part); +part_dec_in_flight (part, rw);part_stat_unlock (); }
block/blk-merge.c +1 -1
@@ -321,7 +321,7 @@ static void blk_account_io_merge(struct request *req) part =disk_map_sector_rcu (req->rq_disk,blk_rq_pos (req));part_round_stats (cpu, part); -part_dec_in_flight (part); +part_dec_in_flight (part,rq_data_dir (req));part_stat_unlock (); }
block/genhd.c +3 -1
@@ -869,6 +869,7 @@ static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); static DEVICE_ATTR(alignment_offset, S_IRUGO, disk_alignment_offset_show, NULL); static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL); static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); +static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL);#ifdef CONFIG_FAIL_MAKE_REQUEST static struct device_attribute dev_attr_fail =__ATTR (make-it-fail,S_IRUGO |S_IWUSR , part_fail_show, part_fail_store);
@@ -888,6 +889,7 @@ static struct attribute *disk_attrs[] = { &dev_attr_alignment_offset.attr, &dev_attr_capability.attr, &dev_attr_stat.attr, + &dev_attr_inflight.attr, #ifdef CONFIG_FAIL_MAKE_REQUEST &dev_attr_fail.attr, #endif
@@ -1053,7 +1055,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)part_stat_read (hd, merges[1 ]), (unsigned long long )part_stat_read (hd, sectors[1 ]),jiffies_to_msecs (part_stat_read (hd, ticks[1 ])), - hd->in_flight, +part_in_flight (hd),jiffies_to_msecs (part_stat_read (hd, io_ticks)),jiffies_to_msecs (part_stat_read (hd, time_in_queue)) );
drivers/md/dm.c +10 -6
@@ -130,7 +130,7 @@ struct mapped_device {/* * A list of ios that arrived while we were suspended. */ -atomic_t pending; +atomic_t pending[2 ];wait_queue_head_t wait;struct work_struct work;struct bio_list deferred;
@@ -453,13 +453,14 @@ static void start_io_acct(struct dm_io *io) {struct mapped_device *md = io->md;int cpu; +int rw =bio_data_dir (io->bio); io->start_time = jiffies; cpu =part_stat_lock ();part_round_stats (cpu, &dm_disk (md)->part0);part_stat_unlock (); -dm_disk (md)->part0.in_flight =atomic_inc_return (&md->pending); +dm_disk (md)->part0.in_flight[rw] =atomic_inc_return (&md->pending[rw]); }static void end_io_acct (struct dm_io *io)
@@ -479,8 +480,9 @@ static void end_io_acct(struct dm_io *io)* After this is decremented the bio must not be touched if it is * a barrier. */ -dm_disk (md)->part0.in_flight = pending = -atomic_dec_return (&md->pending); +dm_disk (md)->part0.in_flight[rw] = pending = +atomic_dec_return (&md->pending[rw]); + pending +=atomic_read (&md->pending[rw^0x1 ]);/* nudge anyone waiting on suspend queue */ if (!pending)
@@ -1780,7 +1782,8 @@ static struct mapped_device *alloc_dev(int minor)if (!md->disk) goto bad_disk; -atomic_set (&md->pending,0 ); +atomic_set (&md->pending[0 ],0 ); +atomic_set (&md->pending[1 ],0 );init_waitqueue_head (&md->wait);INIT_WORK (&md->work, dm_wq_work);init_waitqueue_head (&md->eventq);
@@ -2083,7 +2086,8 @@ static int dm_wait_for_completion(struct mapped_device *md, int interruptible)break ; }spin_unlock_irqrestore (q->queue_lock, flags); - }else if (!atomic_read (&md->pending)) + }else if (!atomic_read (&md->pending[0 ]) && + !atomic_read (&md->pending[1 ]))break ; if (interruptible == TASK_INTERRUPTIBLE &&
fs/partitions/check.c +11 -1
@@ -248,11 +248,19 @@ ssize_t part_stat_show(struct device *dev,part_stat_read (p, merges[WRITE ]), (unsigned long long )part_stat_read (p, sectors[WRITE ]),jiffies_to_msecs (part_stat_read (p, ticks[WRITE ])), - p->in_flight, +part_in_flight (p),jiffies_to_msecs (part_stat_read (p, io_ticks)), jiffies_to_msecs(part_stat_read(p, time_in_queue))); } +ssize_t part_inflight_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct hd_struct *p =dev_to_part (dev); + +return sprintf (buf,"%8u %8u\n" , p->in_flight[0 ], p->in_flight[1 ]); +} +#ifdef CONFIG_FAIL_MAKE_REQUEST ssize_t part_fail_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -281,6 +289,7 @@ static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL); static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); static DEVICE_ATTR(alignment_offset, S_IRUGO, part_alignment_offset_show, NULL); static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); +static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL);#ifdef CONFIG_FAIL_MAKE_REQUEST static struct device_attribute dev_attr_fail =__ATTR (make-it-fail,S_IRUGO |S_IWUSR , part_fail_show, part_fail_store);
@@ -292,6 +301,7 @@ static struct attribute *part_attrs[] = { &dev_attr_size.attr, &dev_attr_alignment_offset.attr, &dev_attr_stat.attr, + &dev_attr_inflight.attr, #ifdef CONFIG_FAIL_MAKE_REQUEST &dev_attr_fail.attr, #endif
include/linux/genhd.h +14 -7
@@ -98,7 +98,7 @@ struct hd_struct {int make_it_fail;#endif unsigned long stamp; -int in_flight; +int in_flight[2 ];#ifdef CONFIG_SMP struct disk_stats *dkstats;#else
@@ -322,18 +322,23 @@ static inline void free_part_stats(struct hd_struct *part)#define part_stat_sub (cpu, gendiskp, field, subnd) \ part_stat_add(cpu, gendiskp, field, -subnd) -static inline void part_inc_in_flight (struct hd_struct *part) +static inline void part_inc_in_flight (struct hd_struct *part,int rw) { - part->in_flight++; + part->in_flight[rw]++;if (part->partno) -part_to_disk (part)->part0.in_flight++; +part_to_disk (part)->part0.in_flight[rw]++; } -static inline void part_dec_in_flight (struct hd_struct *part) +static inline void part_dec_in_flight (struct hd_struct *part,int rw) { - part->in_flight--; + part->in_flight[rw]--;if (part->partno) -part_to_disk (part)->part0.in_flight--; +part_to_disk (part)->part0.in_flight[rw]--; +} + +static inline int part_in_flight (struct hd_struct *part) +{ +return part->in_flight[0 ] + part->in_flight[1 ]; }/* block/blk-core.c */
@@ -546,6 +551,8 @@ extern ssize_t part_size_show(struct device *dev, struct device_attribute *attr, char *buf);extern ssize_t part_stat_show (struct device *dev,struct device_attribute *attr,char *buf); +extern ssize_t part_inflight_show (struct device *dev, +struct device_attribute *attr,char *buf);#ifdef CONFIG_FAIL_MAKE_REQUEST extern ssize_t part_fail_show (struct device *dev,struct device_attribute *attr,char *buf);
PATCH RESEND 1/1 Seperate read and write statistics of in_flight requests
Currently, there is a single in_flight counter measuring the number of requests in the request_queue. But some monitoring tools would like to know how many read requests and write requests are in progress. Split the current in_flight counter into two seperate counters for read and write.
This information is exported as a sysfs attribute, as changing the currently available stat files would break the existing tools.
---
block/blk-core.c +3 -3
@@ -69,7 +69,7 @@ static void drive_stat_acct(struct request *rq, int new_io)part_stat_inc (cpu, part, merges[rw]); else {part_round_stats (cpu, part); -part_inc_in_flight (part); +part_inc_in_flight (part, rw); }part_stat_unlock ();
@@ -1030,7 +1030,7 @@ static void part_round_stats_single(int cpu, struct hd_struct *part,if (part->in_flight) {__part_stat_add (cpu, part, time_in_queue, - part->in_flight * (now - part->stamp)); +part_in_flight (part) * (now - part->stamp));__part_stat_add (cpu, part, io_ticks, (now - part->stamp)); } part->stamp = now;
@@ -1737,7 +1737,7 @@ static void blk_account_io_done(struct request *req)part_stat_inc (cpu, part, ios[rw]);part_stat_add (cpu, part, ticks[rw], duration);part_round_stats (cpu, part); -part_dec_in_flight (part); +part_dec_in_flight (part, rw);part_stat_unlock (); }
block/blk-merge.c +1 -1
@@ -351,7 +351,7 @@ static void blk_account_io_merge(struct request *req) part =disk_map_sector_rcu (req->rq_disk,blk_rq_pos (req));part_round_stats (cpu, part); -part_dec_in_flight (part); +part_dec_in_flight (part,rq_data_dir (req));part_stat_unlock (); }
block/genhd.c +3 -1
@@ -869,6 +869,7 @@ static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); static DEVICE_ATTR(alignment_offset, S_IRUGO, disk_alignment_offset_show, NULL); static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL); static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); +static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL);#ifdef CONFIG_FAIL_MAKE_REQUEST static struct device_attribute dev_attr_fail =__ATTR (make-it-fail,S_IRUGO |S_IWUSR , part_fail_show, part_fail_store);
@@ -888,6 +889,7 @@ static struct attribute *disk_attrs[] = { &dev_attr_alignment_offset.attr, &dev_attr_capability.attr, &dev_attr_stat.attr, + &dev_attr_inflight.attr, #ifdef CONFIG_FAIL_MAKE_REQUEST &dev_attr_fail.attr, #endif
@@ -1053,7 +1055,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)part_stat_read (hd, merges[1 ]), (unsigned long long )part_stat_read (hd, sectors[1 ]),jiffies_to_msecs (part_stat_read (hd, ticks[1 ])), - hd->in_flight, +part_in_flight (hd),jiffies_to_msecs (part_stat_read (hd, io_ticks)),jiffies_to_msecs (part_stat_read (hd, time_in_queue)) );
drivers/md/dm.c +10 -6
@@ -130,7 +130,7 @@ struct mapped_device {/* * A list of ios that arrived while we were suspended. */ -atomic_t pending; +atomic_t pending[2 ];wait_queue_head_t wait;struct work_struct work;struct bio_list deferred;
@@ -453,13 +453,14 @@ static void start_io_acct(struct dm_io *io) {struct mapped_device *md = io->md;int cpu; +int rw =bio_data_dir (io->bio); io->start_time = jiffies; cpu =part_stat_lock ();part_round_stats (cpu, &dm_disk (md)->part0);part_stat_unlock (); -dm_disk (md)->part0.in_flight =atomic_inc_return (&md->pending); +dm_disk (md)->part0.in_flight[rw] =atomic_inc_return (&md->pending[rw]); }static void end_io_acct (struct dm_io *io)
@@ -479,8 +480,9 @@ static void end_io_acct(struct dm_io *io)* After this is decremented the bio must not be touched if it is * a barrier. */ -dm_disk (md)->part0.in_flight = pending = -atomic_dec_return (&md->pending); +dm_disk (md)->part0.in_flight[rw] = pending = +atomic_dec_return (&md->pending[rw]); + pending +=atomic_read (&md->pending[rw^0x1 ]);/* nudge anyone waiting on suspend queue */ if (!pending)
@@ -1780,7 +1782,8 @@ static struct mapped_device *alloc_dev(int minor)if (!md->disk) goto bad_disk; -atomic_set (&md->pending,0 ); +atomic_set (&md->pending[0 ],0 ); +atomic_set (&md->pending[1 ],0 );init_waitqueue_head (&md->wait);INIT_WORK (&md->work, dm_wq_work);init_waitqueue_head (&md->eventq);
@@ -2083,7 +2086,8 @@ static int dm_wait_for_completion(struct mapped_device *md, int interruptible)break ; }spin_unlock_irqrestore (q->queue_lock, flags); - }else if (!atomic_read (&md->pending)) + }else if (!atomic_read (&md->pending[0 ]) && + !atomic_read (&md->pending[1 ]))break ; if (interruptible == TASK_INTERRUPTIBLE &&
fs/partitions/check.c +11 -1
@@ -248,11 +248,19 @@ ssize_t part_stat_show(struct device *dev,part_stat_read (p, merges[WRITE ]), (unsigned long long )part_stat_read (p, sectors[WRITE ]),jiffies_to_msecs (part_stat_read (p, ticks[WRITE ])), - p->in_flight, +part_in_flight (p),jiffies_to_msecs (part_stat_read (p, io_ticks)), jiffies_to_msecs(part_stat_read(p, time_in_queue))); } +ssize_t part_inflight_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct hd_struct *p =dev_to_part (dev); + +return sprintf (buf,"%8u %8u\n" , p->in_flight[0 ], p->in_flight[1 ]); +} +#ifdef CONFIG_FAIL_MAKE_REQUEST ssize_t part_fail_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -281,6 +289,7 @@ static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL); static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); static DEVICE_ATTR(alignment_offset, S_IRUGO, part_alignment_offset_show, NULL); static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); +static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL);#ifdef CONFIG_FAIL_MAKE_REQUEST static struct device_attribute dev_attr_fail =__ATTR (make-it-fail,S_IRUGO |S_IWUSR , part_fail_show, part_fail_store);
@@ -292,6 +301,7 @@ static struct attribute *part_attrs[] = { &dev_attr_size.attr, &dev_attr_alignment_offset.attr, &dev_attr_stat.attr, + &dev_attr_inflight.attr, #ifdef CONFIG_FAIL_MAKE_REQUEST &dev_attr_fail.attr, #endif
include/linux/genhd.h +14 -7
@@ -98,7 +98,7 @@ struct hd_struct {int make_it_fail;#endif unsigned long stamp; -int in_flight; +int in_flight[2 ];#ifdef CONFIG_SMP struct disk_stats *dkstats;#else
@@ -322,18 +322,23 @@ static inline void free_part_stats(struct hd_struct *part)#define part_stat_sub (cpu, gendiskp, field, subnd) \ part_stat_add(cpu, gendiskp, field, -subnd) -static inline void part_inc_in_flight (struct hd_struct *part) +static inline void part_inc_in_flight (struct hd_struct *part,int rw) { - part->in_flight++; + part->in_flight[rw]++;if (part->partno) -part_to_disk (part)->part0.in_flight++; +part_to_disk (part)->part0.in_flight[rw]++; } -static inline void part_dec_in_flight (struct hd_struct *part) +static inline void part_dec_in_flight (struct hd_struct *part,int rw) { - part->in_flight--; + part->in_flight[rw]--;if (part->partno) -part_to_disk (part)->part0.in_flight--; +part_to_disk (part)->part0.in_flight[rw]--; +} + +static inline int part_in_flight (struct hd_struct *part) +{ +return part->in_flight[0 ] + part->in_flight[1 ]; }/* block/blk-core.c */
@@ -546,6 +551,8 @@ extern ssize_t part_size_show(struct device *dev, struct device_attribute *attr, char *buf);extern ssize_t part_stat_show (struct device *dev,struct device_attribute *attr,char *buf); +extern ssize_t part_inflight_show (struct device *dev, +struct device_attribute *attr,char *buf);#ifdef CONFIG_FAIL_MAKE_REQUEST extern ssize_t part_fail_show (struct device *dev,struct device_attribute *attr,char *buf);
Jens Axboe
AppliedQuoted 7 lines · Nikanth Karthikesan
Currently, there is a single
in_flightcounter measuring the number of requests in therequest_queue. But some monitoring tools would like to know how many read requests and write requests are in progress. Split the currentin_flightcounter into two seperate counters for read and write.This information is exported as a sysfs attribute, as changing the currently available stat files would break the existing tools.
Applied, this is better than breaking existing stat exports.
Signature · 1 line
Jens Axboe