Slight inefficiency in fs/buffer.c::__block_prepare_write() ?
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 =====
buffer.c renamed from fs/buffer.c +2 -1
@@ -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; }