Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys/ufs/lfs Pull up revisions 1.50, 1.52-1.53 (requested...
details: https://anonhg.NetBSD.org/src/rev/e68c30eeefb0
branches: netbsd-1-5
changeset: 490630:e68c30eeefb0
user: he <he%NetBSD.org@localhost>
date: Sat Feb 03 21:54:29 2001 +0000
description:
Pull up revisions 1.50,1.52-1.53 (requested by perseant):
o Close up accounting holes in LFS' accounting of immediately-
available-space, number of clean segments, and amount of dirty
space taken up by metadata (PR#11468, PR#11470, PR#11534).
o Don't clean the same segment twice.
o Fix locking and reference leaks in lfs_markv, on error (PR#11547).
diffstat:
sys/ufs/lfs/lfs_syscalls.c | 52 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 43 insertions(+), 9 deletions(-)
diffs (180 lines):
diff -r f63b9f60f7ce -r e68c30eeefb0 sys/ufs/lfs/lfs_syscalls.c
--- a/sys/ufs/lfs/lfs_syscalls.c Sat Feb 03 21:52:44 2001 +0000
+++ b/sys/ufs/lfs/lfs_syscalls.c Sat Feb 03 21:54:29 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_syscalls.c,v 1.41.4.5 2000/11/01 03:53:38 tv Exp $ */
+/* $NetBSD: lfs_syscalls.c,v 1.41.4.6 2001/02/03 21:54:29 he Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -175,13 +175,14 @@
return (error);
if ((mntp = vfs_getvfs(&fsid)) == NULL)
- return (EINVAL);
+ return (ENOENT);
fs = VFSTOUFS(mntp)->um_lfs;
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
+
maxino = (dbtofsb(fs, VTOI(fs->lfs_ivnode)->i_ffs_blocks) -
fs->lfs_cleansz - fs->lfs_segtabsz) * fs->lfs_ifpb;
@@ -191,6 +192,9 @@
if (error)
goto err1;
+ if ((error = vfs_busy(mntp, LK_NOWAIT, NULL)) != 0)
+ return (error);
+
/*
* This seglock is just to prevent the fact that we might have to sleep
* from allowing the possibility that our blocks might become
@@ -357,15 +361,15 @@
if (blkp->bi_lbn == LFS_UNUSED_LBN) {
/* XXX need to make sure that the inode gets written in this case */
/* XXX but only write the inode if it's the right one */
- if (blkp->bi_inode != LFS_IFILE_INUM) {
- LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
- if(ifp->if_daddr == blkp->bi_daddr
+ if (blkp->bi_inode != LFS_IFILE_INUM) {
+ LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
+ if(ifp->if_daddr == blkp->bi_daddr
|| blkp->bi_daddr == LFS_FORCE_WRITE)
{
LFS_SET_UINO(ip, IN_CLEANING);
}
- brelse(bp);
- }
+ brelse(bp);
+ }
continue;
}
@@ -472,6 +476,7 @@
}
#endif
+ vfs_unbusy(mntp);
if(error)
return (error);
else if(do_again)
@@ -481,7 +486,13 @@
err2:
printf("lfs_markv err2\n");
+ if(lfs_fastvget_unlock) {
+ VOP_UNLOCK(vp, 0);
+ --numlocked;
+ }
lfs_vunref(vp);
+ --numrefed;
+
/* Free up fakebuffers -- have to take these from the LOCKED list */
again:
s = splbio();
@@ -494,6 +505,8 @@
splx(s);
goto again;
}
+ if(bp->b_flags & B_DELWRI)
+ fs->lfs_avail += btodb(bp->b_bcount);
bremfree(bp);
splx(s);
brelse(bp);
@@ -504,6 +517,12 @@
free(start, M_SEGMENT);
lfs_segunlock(fs);
vfs_unbusy(mntp);
+#ifdef DEBUG_LFS
+ if(numlocked != 0 || numrefed != 0) {
+ panic("lfs_markv: numlocked=%d numrefed=%d", numlocked, numrefed);
+ }
+#endif
+
return (error);
err1:
@@ -558,15 +577,18 @@
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
return (error);
if ((mntp = vfs_getvfs(&fsid)) == NULL)
- return (EINVAL);
+ return (ENOENT);
ump = VFSTOUFS(mntp);
+ if ((error = vfs_busy(mntp, LK_NOWAIT, NULL)) != 0)
+ return (error);
origcnt = cnt = SCARG(uap, blkcnt);
start = malloc(cnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK);
error = copyin(SCARG(uap, blkiov), start, cnt * sizeof(BLOCK_INFO));
if (error) {
free(start, M_SEGMENT);
+ vfs_unbusy(mntp);
return (error);
}
@@ -584,6 +606,7 @@
printf("lfs_bmapv: attempt to clean current segment? (#%d)\n",
datosn(fs, fs->lfs_curseg));
free(start,M_SEGMENT);
+ vfs_unbusy(mntp);
return (EBUSY);
}
#endif /* DEBUG */
@@ -600,6 +623,7 @@
printf("lfs_bmapv: attempt to clean pending segment? (#%d)\n",
datosn(fs, fs->lfs_pending[j]));
free(start,M_SEGMENT);
+ vfs_unbusy(mntp);
return (EBUSY);
}
}
@@ -736,6 +760,7 @@
copyout(start, SCARG(uap, blkiov), origcnt * sizeof(BLOCK_INFO));
free(start, M_SEGMENT);
+ vfs_unbusy(mntp);
return 0;
}
@@ -772,18 +797,26 @@
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
return (error);
if ((mntp = vfs_getvfs(&fsid)) == NULL)
- return (EINVAL);
+ return (ENOENT);
fs = VFSTOUFS(mntp)->um_lfs;
if (datosn(fs, fs->lfs_curseg) == SCARG(uap, segment))
return (EBUSY);
+ if ((error = vfs_busy(mntp, LK_NOWAIT, NULL)) != 0)
+ return (error);
LFS_SEGENTRY(sup, fs, SCARG(uap, segment), bp);
if (sup->su_flags & SEGUSE_ACTIVE) {
brelse(bp);
+ vfs_unbusy(mntp);
return (EBUSY);
}
+ if (!(sup->su_flags & SEGUSE_DIRTY)) {
+ brelse(bp);
+ vfs_unbusy(mntp);
+ return (EALREADY);
+ }
fs->lfs_avail += fsbtodb(fs, fs->lfs_ssize);
if (sup->su_flags & SEGUSE_SUPERBLOCK)
@@ -805,6 +838,7 @@
cip->avail = fs->lfs_avail - fs->lfs_ravail;
(void) VOP_BWRITE(bp);
wakeup(&fs->lfs_avail);
+ vfs_unbusy(mntp);
return (0);
}
Home |
Main Index |
Thread Index |
Old Index