Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/sys/ufs/lfs Pull up src/sys/ufs/lfs: lfs_alloc.c 1.19->...
details: https://anonhg.NetBSD.org/src/rev/0bdbfcbffbff
branches: netbsd-1-4
changeset: 468300:0bdbfcbffbff
user: perseant <perseant%NetBSD.org@localhost>
date: Fri Apr 16 23:10:07 1999 +0000
description:
Pull up src/sys/ufs/lfs: lfs_alloc.c 1.19->1.21.
This fixes another locking problem, this time a lock on ufs_hashlock in
lfs_vfree. The lock could be held by a process calling getnewvnode, and
then attempted again by lfs_vfree. This works around that, not attempting
to get the lock if curproc already holds it.
diffstat:
sys/ufs/lfs/lfs_alloc.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (39 lines):
diff -r 51264416273a -r 0bdbfcbffbff sys/ufs/lfs/lfs_alloc.c
--- a/sys/ufs/lfs/lfs_alloc.c Fri Apr 16 23:09:48 1999 +0000
+++ b/sys/ufs/lfs/lfs_alloc.c Fri Apr 16 23:10:07 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_alloc.c,v 1.18.2.1 1999/04/13 21:33:55 perseant Exp $ */
+/* $NetBSD: lfs_alloc.c,v 1.18.2.2 1999/04/16 23:10:07 perseant Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -292,15 +292,18 @@
struct lfs *fs;
ufs_daddr_t old_iaddr;
ino_t ino;
+ int already_locked;
/* Get the inode number and file system. */
ip = VTOI(ap->a_pvp);
fs = ip->i_lfs;
ino = ip->i_number;
+ /* If we already hold ufs_hashlock, don't panic, just do it anyway */
+ already_locked = lockstatus(&ufs_hashlock) && ufs_hashlock.lk_lockholder == curproc->p_pid;
while(WRITEINPROG(ap->a_pvp)
|| fs->lfs_seglock
- || lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0))
+ || (!already_locked && lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0)))
{
if (WRITEINPROG(ap->a_pvp)) {
tsleep(ap->a_pvp, (PRIBIO+1), "lfs_vfree", 0);
@@ -357,7 +360,8 @@
sup->su_nbytes -= DINODE_SIZE;
(void) VOP_BWRITE(bp);
}
- lockmgr(&ufs_hashlock, LK_RELEASE, 0);
+ if(!already_locked)
+ lockmgr(&ufs_hashlock, LK_RELEASE, 0);
/* Set superblock modified bit and decrement file count. */
fs->lfs_fmod = 1;
Home |
Main Index |
Thread Index |
Old Index