public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: linux-kernel@vger.kernel.org
Subject: Slight inefficiency in fs/buffer.c::__block_prepare_write() ?
Date: Fri, 14 Jun 2002 21:27:43 +0400	[thread overview]
Message-ID: <20020614212743.A8884@linuxhacker.ru> (raw)

Hello!

   It seems there is slight inefficiency in __block_prepare_write() function
   in fs/buffer.c
   It seems ennecessary READ request might be scheduled when all useful info
   in page was rewritten anyway.
   Offending code is this:
                if (!buffer_uptodate(bh) &&
                     (block_start < from || block_end > to)) {
                        ll_rw_block(READ, 1, &bh);
                        *wait_bh++=bh;
                }

   Suppose we have a 4k page with underlying buffer of 4k size (for simplicity)
   filled with 500 bytes.
   Now if we write 550 bytes to that page right from the start, 
   READ request would be scheduled, though it is totally pointless.
   Such a code exists both in 2.4 and 2.5 kernels.

   Am I overlooking something or is patch like below needed?

Bye,
    Oleg

===== buffer.c 1.66 vs edited =====
--- 1.66/fs/buffer.c	Sun May 12 04:26:20 2002
+++ edited/buffer.c	Fri Jun 14 21:16:32 2002
@@ -1591,7 +1591,8 @@
 			continue; 
 		}
 		if (!buffer_uptodate(bh) &&
-		     (block_start < from || block_end > to)) {
+		     (block_start < from || block_end > to) &&
+		     !(from == block_start && to > inode -> i_size)) {
 			ll_rw_block(READ, 1, &bh);
 			*wait_bh++=bh;
 		}

                 reply	other threads:[~2002-06-14 17:27 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=20020614212743.A8884@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --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