summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1997-10-14 18:46:48 +0000
committerphk <phk@FreeBSD.org>1997-10-14 18:46:48 +0000
commit15a4cff98fa6536424b94a22e832812b22fdc0fd (patch)
tree8da8b82beb5af42385e9146956feb328905614ed
parentf239670138341525c55ec5ee2f164d1d9c3a66ad (diff)
downloadFreeBSD-src-15a4cff98fa6536424b94a22e832812b22fdc0fd.zip
FreeBSD-src-15a4cff98fa6536424b94a22e832812b22fdc0fd.tar.gz
I think my previous change may have opened a race conditio.
This patch does the same thing, with no change in semantics.
-rw-r--r--sys/gnu/ext2fs/ext2_alloc.c2
-rw-r--r--sys/gnu/ext2fs/ext2_ihash.c11
-rw-r--r--sys/gnu/ext2fs/inode.h3
-rw-r--r--sys/gnu/fs/ext2fs/ext2_alloc.c2
-rw-r--r--sys/gnu/fs/ext2fs/inode.h3
-rw-r--r--sys/ufs/ffs/ffs_alloc.c5
-rw-r--r--sys/ufs/lfs/lfs_alloc.c4
-rw-r--r--sys/ufs/ufs/inode.h3
-rw-r--r--sys/ufs/ufs/ufs_ihash.c11
-rw-r--r--sys/ufs/ufs/ufs_inode.c7
10 files changed, 28 insertions, 23 deletions
diff --git a/sys/gnu/ext2fs/ext2_alloc.c b/sys/gnu/ext2fs/ext2_alloc.c
index a570ce4..64e9b87 100644
--- a/sys/gnu/ext2fs/ext2_alloc.c
+++ b/sys/gnu/ext2fs/ext2_alloc.c
@@ -538,8 +538,6 @@ ext2_vfree(ap)
int mode;
pip = VTOI(ap->a_pvp);
- /* Remove the inode from its hash chain */
- ufs_ihashrem(pip);
fs = pip->i_e2fs;
if ((u_int)ino >= fs->s_inodes_per_group * fs->s_groups_count)
panic("ifree: range: dev = 0x%x, ino = %d, fs = %s",
diff --git a/sys/gnu/ext2fs/ext2_ihash.c b/sys/gnu/ext2fs/ext2_ihash.c
index 83b29d4..e536e1e 100644
--- a/sys/gnu/ext2fs/ext2_ihash.c
+++ b/sys/gnu/ext2fs/ext2_ihash.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
- * $Id: ufs_ihash.c,v 1.8 1997/02/22 09:47:47 peter Exp $
+ * $Id: ufs_ihash.c,v 1.9 1997/10/12 20:26:21 phk Exp $
*/
#include <sys/param.h>
@@ -131,6 +131,7 @@ ufs_ihashins(ip)
simple_lock(&ufs_ihash_slock);
ipp = INOHASH(ip->i_dev, ip->i_number);
LIST_INSERT_HEAD(ipp, ip, i_hash);
+ ip->i_flags |= IN_HASHED;
simple_unlock(&ufs_ihash_slock);
}
@@ -142,10 +143,12 @@ ufs_ihashrem(ip)
struct inode *ip;
{
simple_lock(&ufs_ihash_slock);
- LIST_REMOVE(ip, i_hash);
+ if (ip->i_flags & IN_HASHED) {
+ LIST_REMOVE(ip, i_hash);
#ifdef DIAGNOSTIC
- ip->i_hash.le_next = NULL;
- ip->i_hash.le_prev = NULL;
+ ip->i_hash.le_next = NULL;
+ ip->i_hash.le_prev = NULL;
#endif
+ }
simple_unlock(&ufs_ihash_slock);
}
diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h
index 4647136..8a7e935 100644
--- a/sys/gnu/ext2fs/inode.h
+++ b/sys/gnu/ext2fs/inode.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)inode.h 8.9 (Berkeley) 5/14/95
- * $Id: inode.h,v 1.15 1997/05/22 07:30:55 phk Exp $
+ * $Id: inode.h,v 1.16 1997/07/13 15:40:31 bde Exp $
*/
#ifndef _UFS_UFS_INODE_H_
@@ -121,6 +121,7 @@ struct inode {
#define IN_RENAME 0x0010 /* Inode is being renamed. */
#define IN_SHLOCK 0x0020 /* File has shared lock. */
#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
+#define IN_HASHED 0x0080 /* Inode is on hash list */
#ifdef KERNEL
/*
diff --git a/sys/gnu/fs/ext2fs/ext2_alloc.c b/sys/gnu/fs/ext2fs/ext2_alloc.c
index a570ce4..64e9b87 100644
--- a/sys/gnu/fs/ext2fs/ext2_alloc.c
+++ b/sys/gnu/fs/ext2fs/ext2_alloc.c
@@ -538,8 +538,6 @@ ext2_vfree(ap)
int mode;
pip = VTOI(ap->a_pvp);
- /* Remove the inode from its hash chain */
- ufs_ihashrem(pip);
fs = pip->i_e2fs;
if ((u_int)ino >= fs->s_inodes_per_group * fs->s_groups_count)
panic("ifree: range: dev = 0x%x, ino = %d, fs = %s",
diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h
index 4647136..8a7e935 100644
--- a/sys/gnu/fs/ext2fs/inode.h
+++ b/sys/gnu/fs/ext2fs/inode.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)inode.h 8.9 (Berkeley) 5/14/95
- * $Id: inode.h,v 1.15 1997/05/22 07:30:55 phk Exp $
+ * $Id: inode.h,v 1.16 1997/07/13 15:40:31 bde Exp $
*/
#ifndef _UFS_UFS_INODE_H_
@@ -121,6 +121,7 @@ struct inode {
#define IN_RENAME 0x0010 /* Inode is being renamed. */
#define IN_SHLOCK 0x0020 /* File has shared lock. */
#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
+#define IN_HASHED 0x0080 /* Inode is on hash list */
#ifdef KERNEL
/*
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 056246a..425bf64 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95
- * $Id: ffs_alloc.c,v 1.37 1997/09/19 11:13:16 phk Exp $
+ * $Id: ffs_alloc.c,v 1.38 1997/10/14 14:22:23 phk Exp $
*/
#include "opt_quota.h"
@@ -48,7 +48,6 @@
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufs_extern.h>
#include <ufs/ffs/fs.h>
#include <ufs/ffs/ffs_extern.h>
@@ -1420,8 +1419,6 @@ ffs_vfree(ap)
int error, cg;
pip = VTOI(ap->a_pvp);
- /* Remove the inode from its hash chain */
- ufs_ihashrem(pip);
fs = pip->i_fs;
if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)
panic("ffs_vfree: range: dev = 0x%x, ino = %d, fs = %s",
diff --git a/sys/ufs/lfs/lfs_alloc.c b/sys/ufs/lfs/lfs_alloc.c
index 19cd4f8..797d0ba 100644
--- a/sys/ufs/lfs/lfs_alloc.c
+++ b/sys/ufs/lfs/lfs_alloc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)lfs_alloc.c 8.7 (Berkeley) 5/14/95
- * $Id: lfs_alloc.c,v 1.15 1997/08/02 14:33:19 bde Exp $
+ * $Id: lfs_alloc.c,v 1.16 1997/10/14 14:22:29 phk Exp $
*/
#include "opt_quota.h"
@@ -223,8 +223,6 @@ lfs_vfree(ap)
/* Get the inode number and file system. */
ip = VTOI(ap->a_pvp);
- /* Remove the inode from its hash chain */
- ufs_ihashrem(ip);
fs = ip->i_lfs;
ino = ip->i_number;
if (ip->i_flag & IN_MODIFIED) {
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index 4647136..8a7e935 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)inode.h 8.9 (Berkeley) 5/14/95
- * $Id: inode.h,v 1.15 1997/05/22 07:30:55 phk Exp $
+ * $Id: inode.h,v 1.16 1997/07/13 15:40:31 bde Exp $
*/
#ifndef _UFS_UFS_INODE_H_
@@ -121,6 +121,7 @@ struct inode {
#define IN_RENAME 0x0010 /* Inode is being renamed. */
#define IN_SHLOCK 0x0020 /* File has shared lock. */
#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
+#define IN_HASHED 0x0080 /* Inode is on hash list */
#ifdef KERNEL
/*
diff --git a/sys/ufs/ufs/ufs_ihash.c b/sys/ufs/ufs/ufs_ihash.c
index 83b29d4..e536e1e 100644
--- a/sys/ufs/ufs/ufs_ihash.c
+++ b/sys/ufs/ufs/ufs_ihash.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
- * $Id: ufs_ihash.c,v 1.8 1997/02/22 09:47:47 peter Exp $
+ * $Id: ufs_ihash.c,v 1.9 1997/10/12 20:26:21 phk Exp $
*/
#include <sys/param.h>
@@ -131,6 +131,7 @@ ufs_ihashins(ip)
simple_lock(&ufs_ihash_slock);
ipp = INOHASH(ip->i_dev, ip->i_number);
LIST_INSERT_HEAD(ipp, ip, i_hash);
+ ip->i_flags |= IN_HASHED;
simple_unlock(&ufs_ihash_slock);
}
@@ -142,10 +143,12 @@ ufs_ihashrem(ip)
struct inode *ip;
{
simple_lock(&ufs_ihash_slock);
- LIST_REMOVE(ip, i_hash);
+ if (ip->i_flags & IN_HASHED) {
+ LIST_REMOVE(ip, i_hash);
#ifdef DIAGNOSTIC
- ip->i_hash.le_next = NULL;
- ip->i_hash.le_prev = NULL;
+ ip->i_hash.le_next = NULL;
+ ip->i_hash.le_prev = NULL;
#endif
+ }
simple_unlock(&ufs_ihash_slock);
}
diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c
index a2ff326..812e86d 100644
--- a/sys/ufs/ufs/ufs_inode.c
+++ b/sys/ufs/ufs/ufs_inode.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_inode.c 8.9 (Berkeley) 5/14/95
- * $Id: ufs_inode.c,v 1.16 1997/10/10 18:18:12 phk Exp $
+ * $Id: ufs_inode.c,v 1.17 1997/10/14 14:22:31 phk Exp $
*/
#include "opt_quota.h"
@@ -124,6 +124,11 @@ ufs_reclaim(ap)
if (prtactive && vp->v_usecount != 0)
vprint("ufs_reclaim: pushing active", vp);
/*
+ * Remove the inode from its hash chain.
+ */
+ ip = VTOI(vp);
+ ufs_ihashrem(ip);
+ /*
* Purge old data structures associated with the inode.
*/
cache_purge(vp);
OpenPOWER on IntegriCloud