Module Name:    src
Committed By:   reinoud
Date:           Wed Dec 22 14:05:51 UTC 2010

Modified Files:
        src/sys/kern: vfs_bio.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/sys/kern/vfs_bio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.225 src/sys/kern/vfs_bio.c:1.226
--- src/sys/kern/vfs_bio.c:1.225	Sun Dec 12 10:30:09 2010
+++ src/sys/kern/vfs_bio.c	Wed Dec 22 14:05:50 2010
@@ -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 @@
 	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

Reply via email to