NetBSD Problem Report #1448

From gnats  Mon Sep 11 21:09:31 1995
Received: from mail.Germany.EU.net (mail.Germany.EU.net [192.76.144.65]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id VAA00584 for <gnats-bugs@gnats.netbsd.org>; Mon, 11 Sep 1995 21:09:30 -0400
Message-Id: <199509101449.QAA02325@charles.tools.de>
Date: Sun, 10 Sep 1995 16:49:33 +0200
From: Wolfgang Solfrank <ws@charles.tools.de>
Reply-To: ws@charles.tools.de
To: gnats-bugs@gnats.netbsd.org
Subject: Undefined behaviour of bread in case of error
X-Send-Pr-Version: 3.2

>Number:         1448
>Category:       kern
>Synopsis:       Undefined behaviour of bread in case of error
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bouyer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 11 21:20:06 +0000 1995
>Closed-Date:    Wed Feb 10 13:14:20 +0000 1999
>Last-Modified:  Wed Feb 10 13:16:13 +0000 1999
>Originator:     Wolfgang Solfrank
>Release:        NetBSD-current as of 09 Sep 95
>Organization:
>Environment:

System: NetBSD charles.tools.de 1.0A NetBSD 1.0A (charles) #129: Sat Sep 9 21:28:49 MET DST 1995 ws@kurt:/files/NetBSD/kernel/NetBSD/sys/arch/i386/compile/charles i386


>Description:

The expected behaviour of bread in case of error is unclear. There are
conflicting uses even in ffs, even in one single source file, e.g. in
sys/ufs/ffs/ffs_vfsops.c.

In e.g. ffs_reload the code reads:

	if (error = bread(..., &bp))
		return (error);

without further manipulation of the buffer pointed to by bp.

At some other point, e.g. ffs_vget, it reads:

	if (error = bread(..., &bp)) {
		...
		brelse(bp);
		return (error);
	}

So it's unclear, whether bread should return the buffer B_BUSY or not.
The current implementation does indeed the former.

>How-To-Repeat:

Be unlucky and get an I/O error in one of the places similar to the first
example above. After that you are unable to unmount the filesystem in question
(or to do a standard reboot).

>Fix:

My personal preference is for bread to not return the buffer in case of error.
But that's a matter of taste (mainly).

Anyway, the error cases of bread usages in all filesystems need some
reworking.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->bouyer 
Responsible-Changed-By: bouyer 
Responsible-Changed-When: Thu Dec 3 11:12:46 PST 1998 
Responsible-Changed-Why:  
Sounds like this needs to be handled, and for bwrite as wee, probably. 
I'll take care of this ASAP. 
State-Changed-From-To: open->closed 
State-Changed-By: bouyer 
State-Changed-When: Wed Feb 10 05:14:20 PST 1999 
State-Changed-Why:  
I audited the FS sources and fixed all the place where a buffer would not be 
bresle()'d after an error I think ... 
Unlocking the buffer in bread itself after an error would break in a place 
or two (especially the clustering code). 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.