public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Kondratiev <vladimir.kondratiev@intel.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] seq_file - please review
Date: Wed, 03 Sep 2003 15:55:41 +0300	[thread overview]
Message-ID: <3F55E4CD.3030301@intel.com> (raw)

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;



                 reply	other threads:[~2003-09-03 12:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F55E4CD.3030301@intel.com \
    --to=vladimir.kondratiev@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox