public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] seq_file - please review
@ 2003-09-03 12:55 Vladimir Kondratiev
  0 siblings, 0 replies; only message in thread
From: Vladimir Kondratiev @ 2003-09-03 12:55 UTC (permalink / raw)
  To: linux-kernel

Hello,
Could anyone review the following patch? It was generated for 2.4.21, but applies to 2.6 as well.
Below find problem description and patch itself. It is filled into 2.6's bugzilla, see
http://bugme.osdl.org/show_bug.cgi?id=952
So far the only input is that it is worth to push "Again:" label after kmalloc to save redundant if().
P.S. I do not subscribed to the list, thus please in your reply CC me 
(vladimir.kondratiev@intel.com)

seq_file's (fs/seq_file.c) implementation for read() do not allow more than one
page to be returned for one system call. This differs from old read_proc_t one:
old implementation used to loop until there is more data to provide. 
This mean, programs that used to work fine with old implementation, will not
work with seq_file. I mean programs that do read(large_buffer) once. Strictly
say, correct action would be for program to loop while read()>0, but:
- 1. unfortunately, programs like 'xlogmaster' and 'mc' falls into this category;
- 2. by filling large buffer, we reduce number of syscalls
- 3. data returned by one syscall produced (or may be produced) atomically w.r.t
process context stuff, i.e. it is not the same to do one read() and multiple.


--- linux-2.4.21/fs/seq_file.c	2003-06-13 17:51:37.000000000 +0300
+++ linux/fs/seq_file.c	2003-07-10 10:47:53.000000000 +0300
@@ -55,6 +55,7 @@
 		return -EPIPE;
 
 	down(&m->sem);
+Again:
 	/* grab buffer if we didn't have one */
 	if (!m->buf) {
 		m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
@@ -123,11 +124,14 @@
 		goto Efault;
 	copied += n;
 	m->count -= n;
+	size -= n;
+	buf += n;
 	if (m->count)
 		m->from = n;
 	else
 		pos++;
 	m->index = pos;
+	goto Again;
 Done:
 	if (!copied)
 		copied = err;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-03 12:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-03 12:55 [PATCH] seq_file - please review Vladimir Kondratiev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox