Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Fix nestio's behavior on error.



details:   https://anonhg.NetBSD.org/src/rev/053b2578c362
branches:  trunk
changeset: 759977:053b2578c362
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Wed Dec 22 14:05:50 2010 +0000

description:
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.

diffstat:

 sys/kern/vfs_bio.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r b39e8f92df40 -r 053b2578c362 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Wed Dec 22 12:38:42 2010 +0000
+++ b/sys/kern/vfs_bio.c        Wed Dec 22 14:05:50 2010 +0000
@@ -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



Home | Main Index | Thread Index | Old Index