aboutsummaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2016-01-27 21:23:01 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2016-01-27 21:23:01 +0000
commitd2a28cb08088a0b837d4ba4eb5896cb96e42c295 (patch)
treef2447333b6b707e0c4a1f5b56e89972d313c010e /sys/ufs
parent2b198fe92f4aebe14640c7c1256bb222d5fdbb2d (diff)
downloadsrc-d2a28cb08088a0b837d4ba4eb5896cb96e42c295.tar.gz
src-d2a28cb08088a0b837d4ba4eb5896cb96e42c295.zip
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
Notes
Notes: svn path=/head/; revision=294954
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 1647080371e9..b41e04b05ad6 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.