Slight inefficiency in fs/buffer.c::__block_prepare_write() ?

From: Oleg Drokin (green@linuxhacker.ru)
Date: Fri Jun 14 2002 - 12:27:43 EST


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;
                 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:32 EST