Skip to contentSkip to conversation

md: Fix missing unused status line of /proc/mdstat

PATCH Applied Jan Glauber 2 participants 2 messages Mar 17, 2021 – Mar 22, 2021 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md: Fix missing unused status line of /proc/mdstat

Reading /proc/mdstat with a read buffer size that would not fit the unused status line in the first read will skip this line from the output.

So 'dd if=/proc/mdstat bs=64 2>/dev/null' will not print something
like: unused devices: <none>

Don't return NULL immediately in start() for v=2 but call show() once to print the status line also for multiple reads.

Fixes 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface")
---
 drivers/md/md.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/md.c +5 -1
index 21da0c48f6c2..cb19d50fa672 100644
@@ -8153,7 +8153,11 @@ static void *md_seq_start(struct seq_file *seq, loff_t *pos)
 	loff_t l = *pos;
 	struct mddev *mddev;
 
-	if (l >= 0x10000)
+	if (l == 0x10000) {
+		++*pos;
+		return (void *)2;
+	}
+	if (l > 0x10000)
 		return NULL;
 	if (!l--)
 		/* header */
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Jan Glauber

Reading /proc/mdstat with a read buffer size that would not fit the unused status line in the first read will skip this line from the output.

Quoted 8 lines

So 'dd if=/proc/mdstat bs=64 2>/dev/null' will not print something
like: unused devices: <none>

Don't return NULL immediately in start() for v=2 but call show() once to print the status line also for multiple reads.

Fixes 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface")

Applied to md-next. Thanks!
Song