Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Change bread() and breadn() to never return a buffer on
details: https://anonhg.NetBSD.org/src/rev/9ac35099542f
branches: trunk
changeset: 783424:9ac35099542f
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Dec 20 08:03:41 2012 +0000
description:
Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.
Welcome to 6.99.16
PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
diffstat:
sys/fs/adosfs/advfsops.c | 8 ++------
sys/fs/adosfs/advnops.c | 6 ++----
sys/fs/cd9660/cd9660_lookup.c | 5 ++---
sys/fs/cd9660/cd9660_vfsops.c | 5 ++---
sys/fs/cd9660/cd9660_vnops.c | 8 +++-----
sys/fs/efs/efs_subr.c | 9 ++-------
sys/fs/efs/efs_vfsops.c | 12 +++++-------
sys/fs/efs/efs_vnops.c | 6 ++----
sys/fs/filecorefs/filecore_bmap.c | 8 ++------
sys/fs/filecorefs/filecore_lookup.c | 5 ++---
sys/fs/filecorefs/filecore_utils.c | 6 ++----
sys/fs/filecorefs/filecore_vfsops.c | 8 ++------
sys/fs/filecorefs/filecore_vnops.c | 11 +++--------
sys/fs/msdosfs/msdosfs_denode.c | 5 ++---
sys/fs/msdosfs/msdosfs_fat.c | 9 ++-------
sys/fs/msdosfs/msdosfs_lookup.c | 14 ++------------
sys/fs/msdosfs/msdosfs_vnops.c | 7 ++-----
sys/fs/nilfs/nilfs_subr.c | 6 ++----
sys/fs/nilfs/nilfs_vfsops.c | 6 ++----
sys/fs/ntfs/ntfs_subr.c | 7 ++-----
sys/kern/vfs_bio.c | 32 +++++++++++++++++++++++++-------
sys/miscfs/specfs/spec_vnops.c | 8 +++-----
sys/sys/param.h | 4 ++--
sys/ufs/ext2fs/ext2fs_alloc.c | 8 ++------
sys/ufs/ext2fs/ext2fs_balloc.c | 8 ++------
sys/ufs/ext2fs/ext2fs_inode.c | 5 ++---
sys/ufs/ext2fs/ext2fs_subr.c | 5 ++---
sys/ufs/ext2fs/ext2fs_vfsops.c | 11 ++++-------
sys/ufs/ffs/ffs_alloc.c | 17 ++++++-----------
sys/ufs/ffs/ffs_balloc.c | 16 ++--------------
sys/ufs/ffs/ffs_inode.c | 5 ++---
sys/ufs/ffs/ffs_snapshot.c | 13 +++++--------
sys/ufs/ffs/ffs_vfsops.c | 11 +++--------
sys/ufs/ffs/ffs_wapbl.c | 9 ++++++---
sys/ufs/lfs/lfs_balloc.c | 5 ++---
sys/ufs/lfs/lfs_syscalls.c | 5 ++---
sys/ufs/lfs/lfs_vfsops.c | 7 ++++---
sys/ufs/ufs/ufs_lookup.c | 5 ++---
38 files changed, 121 insertions(+), 204 deletions(-)
diffs (truncated from 1685 to 300 lines):
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/adosfs/advfsops.c
--- a/sys/fs/adosfs/advfsops.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/adosfs/advfsops.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: advfsops.c,v 1.65 2012/10/03 07:20:50 mlelstv Exp $ */
+/* $NetBSD: advfsops.c,v 1.66 2012/12/20 08:03:41 hannken Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.65 2012/10/03 07:20:50 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.66 2012/12/20 08:03:41 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -233,7 +233,6 @@
bp = NULL;
if ((error = bread(devvp, (daddr_t)BBOFF,
amp->bsize, NOCRED, 0, &bp)) != 0) {
- brelse(bp, 0);
goto fail;
}
amp->dostype = adoswordn(bp, 0);
@@ -411,7 +410,6 @@
if ((error = bread(amp->devvp, an * amp->bsize / DEV_BSIZE,
amp->bsize, NOCRED, 0, &bp)) != 0) {
- brelse(bp, 0);
vput(vp);
return (error);
}
@@ -532,7 +530,6 @@
error = bread(amp->devvp, ap->linkto * amp->bsize / DEV_BSIZE,
amp->bsize, NOCRED, 0, &bp);
if (error) {
- brelse(bp, 0);
vput(vp);
return (error);
}
@@ -612,7 +609,6 @@
bn = amp->rootb;
if ((error = bread(amp->devvp, bn * amp->bsize / DEV_BSIZE, amp->bsize,
NOCRED, 0, &bp)) != 0) {
- brelse(bp, 0);
return (error);
}
blkix = amp->nwords - 49;
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/adosfs/advnops.c
--- a/sys/fs/adosfs/advnops.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/adosfs/advnops.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: advnops.c,v 1.39 2012/03/13 18:40:35 elad Exp $ */
+/* $NetBSD: advnops.c,v 1.40 2012/12/20 08:03:42 hannken Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.39 2012/03/13 18:40:35 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.40 2012/12/20 08:03:42 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -296,7 +296,6 @@
*/
error = bread(sp->a_vp, lbn, amp->bsize, NOCRED, 0, &bp);
if (error) {
- brelse(bp, 0);
goto reterr;
}
if (!IS_FFS(amp)) {
@@ -518,7 +517,6 @@
error = bread(ap->amp->devvp, nb * ap->amp->bsize / DEV_BSIZE,
ap->amp->bsize, NOCRED, 0, &flbp);
if (error) {
- brelse(flbp, 0);
goto reterr;
}
if (adoscksum(flbp, ap->nwords)) {
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/cd9660/cd9660_lookup.c
--- a/sys/fs/cd9660/cd9660_lookup.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/cd9660/cd9660_lookup.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_lookup.c,v 1.22 2012/11/05 17:27:37 dholland Exp $ */
+/* $NetBSD: cd9660_lookup.c,v 1.23 2012/12/20 08:03:42 hannken Exp $ */
/*-
* Copyright (c) 1989, 1993, 1994
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.22 2012/11/05 17:27:37 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.23 2012/12/20 08:03:42 hannken Exp $");
#include <sys/param.h>
#include <sys/namei.h>
@@ -425,7 +425,6 @@
bsize = blksize(imp, ip, lbn);
if ((error = bread(vp, lbn, bsize, NOCRED, 0, &bp)) != 0) {
- brelse(bp, 0);
*bpp = NULL;
return (error);
}
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/cd9660/cd9660_vfsops.c
--- a/sys/fs/cd9660/cd9660_vfsops.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/cd9660/cd9660_vfsops.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_vfsops.c,v 1.75 2012/03/13 18:40:35 elad Exp $ */
+/* $NetBSD: cd9660_vfsops.c,v 1.76 2012/12/20 08:03:42 hannken Exp $ */
/*-
* Copyright (c) 1994
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.75 2012/03/13 18:40:35 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.76 2012/12/20 08:03:42 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -779,7 +779,6 @@
imp->logical_block_size, NOCRED, 0, &bp);
if (error) {
vput(vp);
- brelse(bp, 0);
printf("fhtovp: bread error %d\n",error);
return (error);
}
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/cd9660/cd9660_vnops.c
--- a/sys/fs/cd9660/cd9660_vnops.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/cd9660/cd9660_vnops.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_vnops.c,v 1.41 2012/03/13 18:40:36 elad Exp $ */
+/* $NetBSD: cd9660_vnops.c,v 1.42 2012/12/20 08:03:42 hannken Exp $ */
/*-
* Copyright (c) 1994
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.41 2012/03/13 18:40:36 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.42 2012/12/20 08:03:42 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -266,11 +266,10 @@
} else {
error = bread(vp, lbn, size, NOCRED, 0, &bp);
}
- n = MIN(n, size - bp->b_resid);
if (error) {
- brelse(bp, 0);
return (error);
}
+ n = MIN(n, size - bp->b_resid);
error = uiomove((char *)bp->b_data + on, (int)n, uio);
brelse(bp, 0);
@@ -603,7 +602,6 @@
(imp->im_bshift - DEV_BSHIFT),
imp->logical_block_size, NOCRED, 0, &bp);
if (error) {
- brelse(bp, 0);
return (EINVAL);
}
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/efs/efs_subr.c
--- a/sys/fs/efs/efs_subr.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/efs/efs_subr.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efs_subr.c,v 1.7 2008/05/16 09:21:59 hannken Exp $ */
+/* $NetBSD: efs_subr.c,v 1.8 2012/12/20 08:03:42 hannken Exp $ */
/*
* Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efs_subr.c,v 1.7 2008/05/16 09:21:59 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efs_subr.c,v 1.8 2012/12/20 08:03:42 hannken Exp $");
#include <sys/param.h>
#include <sys/kauth.h>
@@ -165,7 +165,6 @@
err = efs_bread(emp, bboff, l, &bp);
if (err) {
- brelse(bp, 0);
return (err);
}
memcpy(di, ((struct efs_dinode *)bp->b_data) + index, sizeof(*di));
@@ -322,7 +321,6 @@
err = efs_bread(emp, ex->ex_bn + i, NULL, &bp);
if (err) {
printf("efs: warning: invalid extent descriptor\n");
- brelse(bp, 0);
return (err);
}
@@ -482,7 +480,6 @@
err = efs_bread(emp, ex.ex_bn, NULL, &bp);
if (err) {
- brelse(bp, 0);
return;
}
@@ -528,7 +525,6 @@
err = efs_bread(emp, ex.ex_bn + bboff, NULL, &bp);
if (err) {
- brelse(bp, 0);
EFS_DPRINTF(("efs_extent_iterator_init: bsrch read\n"));
return;
}
@@ -603,7 +599,6 @@
if (err) {
EFS_DPRINTF(("efs_extent_iterator_next: "
"efs_bread failed: %d\n", err));
- brelse(bp, 0);
return (err);
}
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/efs/efs_vfsops.c
--- a/sys/fs/efs/efs_vfsops.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/efs/efs_vfsops.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efs_vfsops.c,v 1.23 2012/03/13 18:40:36 elad Exp $ */
+/* $NetBSD: efs_vfsops.c,v 1.24 2012/12/20 08:03:42 hannken Exp $ */
/*
* Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.23 2012/03/13 18:40:36 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.24 2012/12/20 08:03:42 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -83,7 +83,6 @@
if (err) {
EFS_DPRINTF(("superblock read failed\n"));
free(emp, M_EFSMNT);
- brelse(bp, 0);
return (err);
}
memcpy(&emp->em_sb, bp->b_data, sizeof(emp->em_sb));
@@ -118,7 +117,6 @@
skip = true;
} else {
free(emp, M_EFSMNT);
- brelse(rbp, 0);
return (err);
}
}
@@ -134,8 +132,8 @@
return (EIO);
}
}
+ brelse(rbp, 0);
}
- brelse(rbp, 0);
}
/* ensure we can read last block */
@@ -145,11 +143,11 @@
"fsck_efs(8)\n");
if (!(mp->mnt_flag & MNT_FORCE)) {
free(emp, M_EFSMNT);
- brelse(bp, 0);
return (err);
}
+ } else {
+ brelse(bp, 0);
}
- brelse(bp, 0);
mp->mnt_data = emp;
mp->mnt_flag |= MNT_LOCAL;
diff -r be7f3d40f645 -r 9ac35099542f sys/fs/efs/efs_vnops.c
--- a/sys/fs/efs/efs_vnops.c Thu Dec 20 08:03:21 2012 +0000
+++ b/sys/fs/efs/efs_vnops.c Thu Dec 20 08:03:41 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efs_vnops.c,v 1.28 2012/11/05 17:27:37 dholland Exp $ */
+/* $NetBSD: efs_vnops.c,v 1.29 2012/12/20 08:03:42 hannken Exp $ */
/*
* Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
Home |
Main Index |
Thread Index |
Old Index