linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH (resend)] seq_file: reset iterator to first record for zero offset
@ 2016-12-19 11:38 Miklos Szeredi
  2017-11-08 13:10 ` [(resend)] " Szabolcs Nagy
  0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2016-12-19 11:38 UTC (permalink / raw)
  To: Al Viro; +Cc: Tomasz Majchrzak, linux-kernel, linux-fsdevel

Al,

Can you please take (or NACK) this patch please?

Thanks,
Miklos

---
From: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Date: Tue, 29 Nov 2016 15:18:20 +0100

If kernfs file is empty on a first read, successive read operations
using the same file descriptor will return no data, even when data is
available. Default kernfs 'seq_next' implementation advances iterator
position even when next object is not there. Kernfs 'seq_start' for
following requests will not return iterator as position is already on
the second object.

This defect doesn't allow to monitor badblocks sysfs files from MD raid.
They are initially empty but if data appears at some stage, userspace is
not able to read it.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/seq_file.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -190,6 +190,13 @@ ssize_t seq_read(struct file *file, char
 	 */
 	m->version = file->f_version;
 
+	/*
+	 * if request is to read from zero offset, reset iterator to first
+	 * record as it might have been already advanced by previous requests
+	 */
+	if (*ppos == 0)
+		m->index = 0;
+
 	/* Don't assume *ppos is where we left it */
 	if (unlikely(*ppos != m->read_pos)) {
 		while ((err = traverse(m, *ppos)) == -EAGAIN)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-15 10:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-19 11:38 [PATCH (resend)] seq_file: reset iterator to first record for zero offset Miklos Szeredi
2017-11-08 13:10 ` [(resend)] " Szabolcs Nagy
2017-11-10  1:14   ` [musl] " Rich Felker
2017-11-15 10:34     ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).