Skip to contentSkip to conversation

Enhanced partition statistics: procfs

PATCH In review Jerome Marchand 2 participants 5 messages Dec 13, 2007 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 7/8 Enhanced partition statistics: procfs

Reports enhanced partition statistics in /proc/diskstats.

---
 genhd.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
block/genhd.c +21 -6
diff -urNp -X linux-2.6/Documentation/dontdiff linux-2.6.orig/block/genhd.c linux-2.6/block/genhd.c
@@ -655,12 +655,27 @@ static int diskstats_show(struct seq_fil
 	for (n = 0; n < gp->minors - 1; n++) {
 		struct hd_struct *hd = gp->part[n];
 
-		if (hd && hd->nr_sects)
-			seq_printf(s, "%4d %4d %s %u %u %u %u\n",
-				gp->major, n + gp->first_minor + 1,
-				disk_name(gp, n + 1, buf),
-				hd->ios[0], hd->sectors[0],
-				hd->ios[1], hd->sectors[1]);
+		if (!hd || !hd->nr_sects) continue;
+
+		preempt_disable();
+		part_round_stats(hd);
+		preempt_enable();
+		seq_printf(s, "%4d %4d %s %lu %lu %llu "
+			   "%u %lu %lu %llu %u %u %u %u\n",
+			   gp->major, n + gp->first_minor + 1,
+			   disk_name(gp, n + 1, buf),
+			   part_stat_read(hd, ios[0]),
+			   part_stat_read(hd, merges[0]),
+			   (unsigned long long)part_stat_read(hd, sectors[0]),
+			   jiffies_to_msecs(part_stat_read(hd, ticks[0])),
+			   part_stat_read(hd, ios[1]),
+			   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,
+			   jiffies_to_msecs(part_stat_read(hd, io_ticks)),
+			   jiffies_to_msecs(part_stat_read(hd, time_in_queue))
+			);
 	}
  
 	return 0;
#1 lore raw
Quoted 10 lines · On Thu, 13 Dec 2007 17:18:04 +0100 Jerome Marchand wrote:

Reports enhanced partition statistics in /proc/diskstats.

---
 genhd.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff -urNp -X linux-2.6/Documentation/dontdiff linux-2.6.orig/block/genhd.c linux-2.6/block/genhd.c

block/genhd.c static int diskstats_show(struct seq_fil · line 658

Quoted 10 lines
block/genhd.c +1 -6
@@ -655,12 +655,27 @@ static int diskstats_show(struct seq_fil
 	for (n = 0; n < gp->minors - 1; n++) {
 		struct hd_struct *hd = gp->part[n];
 
-		if (hd && hd->nr_sects)
-			seq_printf(s, "%4d %4d %s %u %u %u %u\n",
-				gp->major, n + gp->first_minor + 1,
-				disk_name(gp, n + 1, buf),
-				hd->ios[0], hd->sectors[0],
-				hd->ios[1], hd->sectors[1]);
+		if (!hd || !hd->nr_sects) continue;

Don't put if () and following statement on same line.

Quoted 15 lines
block/genhd.c +15 -0
+
+		preempt_disable();
+		part_round_stats(hd);
+		preempt_enable();
+		seq_printf(s, "%4d %4d %s %lu %lu %llu "
+			   "%u %lu %lu %llu %u %u %u %u\n",
+			   gp->major, n + gp->first_minor + 1,
+			   disk_name(gp, n + 1, buf),
+			   part_stat_read(hd, ios[0]),
+			   part_stat_read(hd, merges[0]),
+			   (unsigned long long)part_stat_read(hd, sectors[0]),
+			   jiffies_to_msecs(part_stat_read(hd, ticks[0])),
+			   part_stat_read(hd, ios[1]),
+			   part_stat_read(hd, merges[1]),
+			   (unsigned long long)part_stat_read(hd, sectors[1]),

block/genhd.c static int diskstats_show(struct seq_fil

Quoted 10 lines
block/genhd.c +5 -1
+			   jiffies_to_msecs(part_stat_read(hd, ticks[1])),
+			   hd->in_flight,
+			   jiffies_to_msecs(part_stat_read(hd, io_ticks)),
+			   jiffies_to_msecs(part_stat_read(hd, time_in_queue))
+			);
 	}
 
 	return 0;
 
--

The format of the /proc file is not changed except to add data at the end of each line. Is that correct?

---
~Randy

#2 lore raw
Quoted 4 lines · Randy Dunlap

The format of the /proc file is not changed except to add data at the end of each line. Is that correct?

No. The line concerning partitions will display different data. The new format match the current format concerning disks.

Current partition format:
major minor name reads_issued sectors_read writes_issued sectors_written

New partition format (current disk format):
major minor name reads_issued reads_merged sector_read ms_reading writes_completed writes_merged sectors_written ms_writing I/Os_running ms_I/O weighted_ms_I/O

Jérôme

#3 lore raw
Quoted 6 lines · On Thu, 13 Dec 2007 18:36:45 +0100 Jerome Marchand wrote:
Quoted 4 lines · Randy Dunlap

The format of the /proc file is not changed except to add data at the end of each line. Is that correct?

Quoted 8 lines

No. The line concerning partitions will display different data. The new format match the current format concerning disks.

Current partition format:
major minor name reads_issued sectors_read writes_issued sectors_written

New partition format (current disk format):
major minor name reads_issued reads_merged sector_read ms_reading writes_completed writes_merged sectors_written ms_writing I/Os_running ms_I/O weighted_ms_I/O

I would have expected the /proc file contents to represent a user interface that we shouldn't change, other than by adding to the end of each line.

---
~Randy

#4 lore raw
Quoted 12 lines · Randy Dunlap
Quoted 10 lines · On Thu, 13 Dec 2007 18:36:45 +0100 Jerome Marchand wrote:
Quoted 3 lines · Randy Dunlap

The format of the /proc file is not changed except to add data at the end of each line. Is that correct?

No. The line concerning partitions will display different data. The new format match the current format concerning disks.

Current partition format:
major minor name reads_issued sectors_read writes_issued sectors_written

Quoted 8 lines
Quoted 2 lines

New partition format (current disk format):
major minor name reads_issued reads_merged sector_read ms_reading writes_completed writes_merged sectors_written ms_writing I/Os_running ms_I/O weighted_ms_I/O

I would have expected the /proc file contents to represent a user interface that we shouldn't change, other than by adding to the end of each line.

I could eventually keep the old data and add the new ones at the end of the line, but it will leads to a less coherent interface. Moreover all the users of /proc/diskstats I know about use the number of field to make the distinction between current disk and partitions format. They all will be confused if we add new fields.

Jérôme