It is really rude to clear all the buffer state bits on an access
beyond end-of-device. It can panic filesystems which have internal
state bits, for example. Just clear the dirty flag instead, and leave
the others intact.
--- linux-2.4-ext3push/drivers/block/ll_rw_blk.c.=K0000=.orig 2003-03-25 10:59:15.000000000 +0000
+++ linux-2.4-ext3push/drivers/block/ll_rw_blk.c 2003-03-25 10:59:15.000000000 +0000
@@ -1129,7 +1129,7 @@ void generic_make_request (int rw, struc
if (maxsector < count || maxsector - count < sector) {
/* Yecch */
- bh->b_state &= (1 << BH_Lock) | (1 << BH_Mapped);
+ bh->b_state &= ~(1 << BH_Dirty);
/* This may well happen - the kernel calls bread()
without checking the size of the device, e.g.,
@@ -1140,7 +1140,6 @@ void generic_make_request (int rw, struc
kdevname(bh->b_rdev), rw,
(sector + count)>>1, minorsize);
- /* Yecch again */
bh->b_end_io(bh, 0);
return;
}