Skip to contentSkip to conversation

2.6.28 /proc/diskstats

PATCH In review Daniel Collins 6 participants 10 messages Apr 12, 2009 – Apr 22, 2009 Block layer

lore
Share & tools
lore
#0 lore raw

Hi

Since 2.6.28, fd0 isn't visible in /proc/diskstats from boot, only after access/mount. It is visible in /sys/block/ from boot, so there are no issues detecting it. This may also affect other devices such as hda but I haven't tested this yet, my test system and QEMU both only have ram0-ram15 from boot. I have tested 2.6.30-rc1 and found the same behavior. Is this a bug or a deliberate change?

Thanks

#1 lore raw
Quoted 9 lines · On Sun, 12 Apr 2009 02:00:08 +0100 Daniel Collins…

Hi

Since 2.6.28, fd0 isn't visible in /proc/diskstats from boot, only after access/mount. It is visible in /sys/block/ from boot, so there are no issues detecting it. This may also affect other devices such as hda but I haven't tested this yet, my test system and QEMU both only have ram0-ram15 from boot. I have tested 2.6.30-rc1 and found the same behavior. Is this a bug or a deliberate change?

Tejun touched it last :)

#2 lore raw
In reply to Daniel Collins

Reposting since I don't think anyone will see it ~150 messages down, sorry if this is the wrong way to draw attention to a bug.

Quoted 5 lines · Daniel Collins

Hi

Since 2.6.28, fd0 isn't visible in /proc/diskstats from boot, only after access/mount. It is visible in /sys/block/ from boot, so there are no issues detecting it. This may also affect other devices such as hda but I haven't tested this yet, my test system and QEMU both only have ram0-ram15 from boot. I have tested 2.6.30-rc1 and found the same behavior. Is this a bug or a deliberate change?

Thanks

#3 lore raw
In reply to Daniel Collins

I've stepped through the commits in linux-2.6, the first revision with this behavior is 074a7aca7afa6f230104e8e65eba3420263714a5

Quoted 5 lines · Daniel Collins

Hi

Since 2.6.28, fd0 isn't visible in /proc/diskstats from boot, only after access/mount. It is visible in /sys/block/ from boot, so there are no issues detecting it. This may also affect other devices such as hda but I haven't tested this yet, my test system and QEMU both only have ram0-ram15 from boot. I have tested 2.6.30-rc1 and found the same behavior. Is this a bug or a deliberate change?

Thanks

#4 lore raw
Quoted 2 lines · Daniel Collins

I've stepped through the commits in linux-2.6, the first revision with this behavior is 074a7aca7afa6f230104e8e65eba3420263714a5

It would be a good idea to:
1) mention the subject of said path as no-one remember all these SHA-1 anyway (but include the SHA-1 for reference.
2) copy the author of said patch.

The relevant patch is: "block: move stats from disk to part0"

I have copied Tejun and JEns.

The rest of the mail kept for reference.

Sam

Quoted 17 lines
Quoted 10 lines · Daniel Collins

Hi

Since 2.6.28, fd0 isn't visible in /proc/diskstats from boot, only after access/mount. It is visible in /sys/block/ from boot, so there are no issues detecting it. This may also affect other devices such as hda but I haven't tested this yet, my test system and QEMU both only have ram0-ram15 from boot. I have tested 2.6.30-rc1 and found the same behavior. Is this a bug or a deliberate change?

Thanks

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#5 lore raw
In reply to Daniel Collins
Quoted 8 lines · Daniel Collins

Hi

Since 2.6.28, fd0 isn't visible in /proc/diskstats from boot, only after access/mount. It is visible in /sys/block/ from boot, so there are no issues detecting it. This may also affect other devices such as hda but I haven't tested this yet, my test system and QEMU both only have ram0-ram15 from boot. I have tested 2.6.30-rc1 and found the same behavior. Is this a bug or a deliberate change?

Hmm... the reason why fd device is skipped before the first open is because diskstats_show() skips zero sized devices and open is when the floppy driver sets the capacity. I think the original code also skipped zero sized device. It could be that the original code triggered revalidation while the current one doesn't. I'll dig deeper.

Thanks.

Signature · 1 line
tejun
#6 lore raw

/proc/diskstats used to show stats for all disks whether they're zero-sized or not and their non-zero partitions. Commit 074a7aca7afa6f230104e8e65eba3420263714a5 accidentally changed the behavior such that it doesn't print out zero sized disks. This patch implements DISK_PITER_INCL_EMPTY_PART0 flag to partition iterator and uses it in diskstats_show() such that empty part0 is shown in /proc/diskstats.

Reported and bisectd by Dianel Collins.

---
It was my bad. I missed that diskstats showed empty disks too. This fixes the problem.

 block/genhd.c         |   12 ++++++++----
 include/linux/genhd.h |    1 +
 2 files changed, 9 insertions(+), 4 deletions(-)
block/genhd.c +8 -4
index a9ec910..1a4916e 100644
@@ -98,7 +98,7 @@ void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
 
 	if (flags & DISK_PITER_REVERSE)
 		piter->idx = ptbl->len - 1;
-	else if (flags & DISK_PITER_INCL_PART0)
+	else if (flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0))
 		piter->idx = 0;
 	else
 		piter->idx = 1;
@@ -134,7 +134,8 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
 	/* determine iteration parameters */
 	if (piter->flags & DISK_PITER_REVERSE) {
 		inc = -1;
-		if (piter->flags & DISK_PITER_INCL_PART0)
+		if (piter->flags & (DISK_PITER_INCL_PART0 |
+				    DISK_PITER_INCL_EMPTY_PART0))
 			end = -1;
 		else
 			end = 0;
@@ -150,7 +151,10 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
 		part = rcu_dereference(ptbl->part[piter->idx]);
 		if (!part)
 			continue;
-		if (!(piter->flags & DISK_PITER_INCL_EMPTY) && !part->nr_sects)
+		if (!part->nr_sects &&
+		    !(piter->flags & DISK_PITER_INCL_EMPTY) &&
+		    !(piter->flags & DISK_PITER_INCL_EMPTY_PART0 &&
+		      piter->idx == 0))
 			continue;
 
 		get_device(part_to_dev(part));
@@ -1011,7 +1015,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
 				"\n\n");
 	*/
  
-	disk_part_iter_init(&piter, gp, DISK_PITER_INCL_PART0);
+	disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
 	while ((hd = disk_part_iter_next(&piter))) {
 		cpu = part_stat_lock();
 		part_round_stats(cpu, hd);
include/linux/genhd.h +1 -0
index 634c530..a1a28ca 100644
@@ -214,6 +214,7 @@ static inline void disk_put_part(struct hd_struct *part)
 #define DISK_PITER_REVERSE	(1 << 0) /* iterate in the reverse direction */
 #define DISK_PITER_INCL_EMPTY	(1 << 1) /* include 0-sized parts */
 #define DISK_PITER_INCL_PART0	(1 << 2) /* include partition 0 */
+#define DISK_PITER_INCL_EMPTY_PART0 (1 << 3) /* include empty partition 0 */
 
 struct disk_part_iter {
 	struct gendisk		*disk;
#7 lore raw

PATCH 1/1 block: include empty disks in /proc/diskstats

In reply to Tejun Heo

/proc/diskstats used to show stats for all disks whether they're zero-sized or not and their non-zero partitions. Commit 074a7aca7afa6f230104e8e65eba3420263714a5 accidentally changed the behavior such that it doesn't print out zero sized disks. This patch implements DISK_PITER_INCL_EMPTY_PART0 flag to partition iterator and uses it in diskstats_show() such that empty part0 is shown in /proc/diskstats.

Reported and bisectd by Dianel Collins.

---
It was my bad. I missed that diskstats showed empty disks too. This fixes the problem.

(Oops, forgot to write SUBJECT, resending...)

 block/genhd.c         |   12 ++++++++----
 include/linux/genhd.h |    1 +
 2 files changed, 9 insertions(+), 4 deletions(-)
block/genhd.c +8 -4
index a9ec910..1a4916e 100644
@@ -98,7 +98,7 @@ void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
 
 	if (flags & DISK_PITER_REVERSE)
 		piter->idx = ptbl->len - 1;
-	else if (flags & DISK_PITER_INCL_PART0)
+	else if (flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0))
 		piter->idx = 0;
 	else
 		piter->idx = 1;
@@ -134,7 +134,8 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
 	/* determine iteration parameters */
 	if (piter->flags & DISK_PITER_REVERSE) {
 		inc = -1;
-		if (piter->flags & DISK_PITER_INCL_PART0)
+		if (piter->flags & (DISK_PITER_INCL_PART0 |
+				    DISK_PITER_INCL_EMPTY_PART0))
 			end = -1;
 		else
 			end = 0;
@@ -150,7 +151,10 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
 		part = rcu_dereference(ptbl->part[piter->idx]);
 		if (!part)
 			continue;
-		if (!(piter->flags & DISK_PITER_INCL_EMPTY) && !part->nr_sects)
+		if (!part->nr_sects &&
+		    !(piter->flags & DISK_PITER_INCL_EMPTY) &&
+		    !(piter->flags & DISK_PITER_INCL_EMPTY_PART0 &&
+		      piter->idx == 0))
 			continue;
 
 		get_device(part_to_dev(part));
@@ -1011,7 +1015,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
 				"\n\n");
 	*/
  
-	disk_part_iter_init(&piter, gp, DISK_PITER_INCL_PART0);
+	disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
 	while ((hd = disk_part_iter_next(&piter))) {
 		cpu = part_stat_lock();
 		part_round_stats(cpu, hd);
include/linux/genhd.h +1 -0
index 634c530..a1a28ca 100644
@@ -214,6 +214,7 @@ static inline void disk_put_part(struct hd_struct *part)
 #define DISK_PITER_REVERSE	(1 << 0) /* iterate in the reverse direction */
 #define DISK_PITER_INCL_EMPTY	(1 << 1) /* include 0-sized parts */
 #define DISK_PITER_INCL_PART0	(1 << 2) /* include partition 0 */
+#define DISK_PITER_INCL_EMPTY_PART0 (1 << 3) /* include empty partition 0 */
 
 struct disk_part_iter {
 	struct gendisk		*disk;
#8 lore raw

Re: [stable] [PATCH] block: include empty disks in /proc/diskstats

Quoted 8 lines · * Tejun Heo ([email protected]) wrote:

/proc/diskstats used to show stats for all disks whether they're zero-sized or not and their non-zero partitions. Commit 074a7aca7afa6f230104e8e65eba3420263714a5 accidentally changed the behavior such that it doesn't print out zero sized disks. This patch implements DISK_PITER_INCL_EMPTY_PART0 flag to partition iterator and uses it in diskstats_show() such that empty part0 is shown in /proc/diskstats.

Quoted 4 lines

Reported and bisectd by Dianel Collins.

looks like this isn't upstream yet.

thanks,
-chris

#9 lore raw

Re: [stable] [PATCH] block: include empty disks in /proc/diskstats

Quoted 9 lines · Chris Wright
Quoted 8 lines · * Tejun Heo ([email protected]) wrote:

/proc/diskstats used to show stats for all disks whether they're zero-sized or not and their non-zero partitions. Commit 074a7aca7afa6f230104e8e65eba3420263714a5 accidentally changed the behavior such that it doesn't print out zero sized disks. This patch implements DISK_PITER_INCL_EMPTY_PART0 flag to partition iterator and uses it in diskstats_show() such that empty part0 is shown in /proc/diskstats.

Quoted 6 lines
Quoted 4 lines

Reported and bisectd by Dianel Collins.

looks like this isn't upstream yet.

It'll go upstream today or tomorrow.

Signature · 1 line
Jens Axboe