diff -uNr linux-2.4.18.o/fs/reiserfs/inode.c linux-2.4.18/fs/reiserfs/inode.c --- linux-2.4.18.o/fs/reiserfs/inode.c Wed Feb 27 11:46:52 2002 +++ linux-2.4.18/fs/reiserfs/inode.c Wed Feb 27 11:40:30 2002 @@ -1901,14 +1901,21 @@ static inline void submit_bh_for_writepage(struct buffer_head **bhp, int nr) { struct buffer_head *bh ; int i; + + /* lock them all first so the end_io handler doesn't unlock the page + ** too early + */ for(i = 0 ; i < nr ; i++) { bh = bhp[i] ; lock_buffer(bh) ; set_buffer_async_io(bh) ; + } + for(i = 0 ; i < nr ; i++) { /* submit_bh doesn't care if the buffer is dirty, but nobody ** later on in the call chain will be cleaning it. So, we ** clean the buffer here, it still gets written either way. */ + bh = bhp[i] ; clear_bit(BH_Dirty, &bh->b_state) ; set_bit(BH_Uptodate, &bh->b_state) ; submit_bh(WRITE, bh) ; .