Fix nestio's behavior on error.

The mbp->b_resid is used to track if all the nested buffers have been issued
and reported back. When the last buffer calls in, mbp->b_resid becomes zero
and biodone(mbp) is called. This is fine as long as there are no errors.

If a read-error does occure in one of the nested buffers, the mbp->b_error is
set and on its call to biodone(mbp), with mbp->b_resid is zero, physio()
panics since it asserts that IF an error is set on a buffer, there should be a
residual amount of data left to transfered.

The patch fixes this case by setting mbp->b_resid back to mbp->b_bcount on
mbp->b_error just before biodone(mbp).

This behaviour is consistent with normal buffer issueing. It either succeeds
or doesn't succeed.
This commit is contained in:
reinoud 2010-12-22 14:05:50 +00:00
parent 0b639144a8
commit 766116b74d
1 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_bio.c,v 1.225 2010/12/12 10:30:09 hannken Exp $ */
/* $NetBSD: vfs_bio.c,v 1.226 2010/12/22 14:05:50 reinoud Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -123,7 +123,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.225 2010/12/12 10:30:09 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.226 2010/12/22 14:05:50 reinoud Exp $");
#include "opt_bufcache.h"
@ -2000,6 +2000,8 @@ nestiobuf_done(buf_t *mbp, int donebytes, int error)
if (error)
mbp->b_error = error;
if (mbp->b_resid == 0) {
if (mbp->b_error)
mbp->b_resid = mbp->b_bcount;
mutex_exit(mbp->b_objlock);
biodone(mbp);
} else