summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2016-01-27 21:23:01 +0000
committermckusick <mckusick@FreeBSD.org>2016-01-27 21:23:01 +0000
commit0b10a802f877a41beb1b823c21a6a4b241ed8e28 (patch)
treef2447333b6b707e0c4a1f5b56e89972d313c010e /sys/ufs
parent36b5b4fdf85dc4c5f943d37989db0d537856cdd7 (diff)
downloadFreeBSD-src-0b10a802f877a41beb1b823c21a6a4b241ed8e28.zip
FreeBSD-src-0b10a802f877a41beb1b823c21a6a4b241ed8e28.tar.gz
The bread() function was inconsistent about whether it would return
a buffer pointer in the event of an error (for some errors it would return a buffer pointer and for other errors it would not return a buffer pointer). The cluster_read() function was similarly inconsistent. Clients of these functions were inconsistent in handling errors. Some would assume that no buffer was returned after an error and would thus lose buffers under certain error conditions. Others would assume that brelse() should always be called after an error and would thus panic the system under certain error conditions. To correct both of these problems with minimal code churn, bread() and cluster_write() now always free the buffer when returning an error thus ensuring that buffers will never be lost. The brelse() routine checks for being passed a NULL buffer pointer and silently returns to avoid panics. Thus both approaches to handling error returns from bread() and cluster_read() will work correctly. Future code should be written assuming that bread() and cluster_read() will never return a buffer with an error, so should not attempt to brelse() the buffer when an error is returned. Reviewed by: kib
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_inode.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index 1647080..b41e04b 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -113,10 +113,8 @@ loop:
fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
(int) fs->fs_bsize, 0, 0, 0, NOCRED, flags, &bp);
if (error != 0) {
- if (error != EBUSY) {
- brelse(bp);
+ if (error != EBUSY)
return (error);
- }
KASSERT((IS_SNAPSHOT(ip)), ("EBUSY from non-snapshot"));
/*
* Wait for our inode block to become available.
OpenPOWER on IntegriCloud