When buffer write is failed, it is wrong for brelse() to invalidate

portion of the page that was written. Among other problems, this
page might be picked up by pagedaemon, with failed assertion in
vm_pageout_flush() about validity of the page.

Reported and tested by:	pho
Approved by:	re (kensmith)
MFC after:	3 weeks
This commit is contained in:
Konstantin Belousov 2009-07-19 20:25:59 +00:00
parent 8e41399c8f
commit 7ac5806bfb

View File

@ -1330,7 +1330,8 @@ brelse(struct buf *bp)
m = bp->b_pages[i];
}
if ((bp->b_flags & B_NOCACHE) ||
(bp->b_ioflags & BIO_ERROR)) {
(bp->b_ioflags & BIO_ERROR &&
bp->b_iocmd == BIO_READ)) {
int poffset = foff & PAGE_MASK;
int presid = resid > (PAGE_SIZE - poffset) ?
(PAGE_SIZE - poffset) : resid;