Subject: kern/1448: Undefined behaviour of bread in case of error
To: None <gnats-bugs@gnats.netbsd.org>
From: Wolfgang Solfrank <ws@charles.tools.de>
List: netbsd-bugs
Date: 09/10/1995 16:49:33
>Number:         1448
>Category:       kern
>Synopsis:       Undefined behaviour of bread in case of error
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 11 21:20:06 1995
>Last-Modified:
>Originator:     Wolfgang Solfrank
>Organization:
>Release:        NetBSD-current as of 09 Sep 95
>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.
>Audit-Trail:
>Unformatted: