Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Always call brelse() on error. Otherwise a possible...



details:   https://anonhg.NetBSD.org/src/rev/7dd25806a015
branches:  trunk
changeset: 783570:7dd25806a015
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Dec 29 21:56:04 2012 +0000

description:
Always call brelse() on error. Otherwise a possible error from bread() will
cause the buffer to stay lock and we end up blocking forever in
VOP_CLOSE->spec_close->vinvalbuf->bbysy since the buffer is marked busy
but there is no I/O pending.
This caused my laptop to hang on boot_findwedge because:
    findroot: unable to read block 358331527 of dev dk0 (22)

diffstat:

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

diffs (35 lines):

diff -r 05dddbc981fb -r 7dd25806a015 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Sat Dec 29 20:08:23 2012 +0000
+++ b/sys/kern/vfs_bio.c        Sat Dec 29 21:56:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_bio.c,v 1.240 2012/12/20 08:03:43 hannken Exp $    */
+/*     $NetBSD: vfs_bio.c,v 1.241 2012/12/29 21:56:04 christos 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.240 2012/12/20 08:03:43 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.241 2012/12/29 21:56:04 christos Exp $");
 
 #include "opt_bufcache.h"
 
@@ -727,12 +727,11 @@
 
        /* Wait for the read to complete, and return result. */
        error = biowait(bp);
-       if (error == 0 && (flags & B_MODIFY) != 0) {
+       if (error == 0 && (flags & B_MODIFY) != 0)
                error = fscow_run(bp, true);
-               if (error) {
-                       brelse(bp, 0);
-                       *bpp = NULL;
-               }
+       if (error) {
+               brelse(bp, 0);
+               *bpp = NULL;
        }
 
        return error;



Home | Main Index | Thread Index | Old Index