[PATCH RESEND v2 06/26] md: let procfs own the seq_file of /proc/mdstat
From: Christian Brauner
Date: Wed Nov 04 2026 - 15:47:03 EST
Declare the seq_operations and let procfs open and free the seq_file.
->proc_open() only records the event count for ->proc_poll() now.
Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
drivers/md/md.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 03e35386a802..64abf1743e41 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9167,18 +9167,13 @@ static const struct seq_operations md_seq_ops = {
.show = md_seq_show,
};
+/* procfs opens the seq_file */
static int md_seq_open(struct inode *inode, struct file *file)
{
- struct seq_file *seq;
- int error;
-
- error = seq_open(file, &md_seq_ops);
- if (error)
- return error;
+ struct seq_file *seq = file->private_data;
- seq = file->private_data;
seq->poll_event = atomic_read(&md_event_count);
- return error;
+ return 0;
}
static int md_unloading;
@@ -9200,10 +9195,8 @@ static __poll_t mdstat_poll(struct file *filp, poll_table *wait)
}
static const struct proc_ops mdstat_proc_ops = {
+ .proc_seq_ops = &md_seq_ops,
.proc_open = md_seq_open,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
- .proc_release = seq_release,
.proc_poll = mdstat_poll,
};
--
2.53.0