Subject: i_ino is needed?
To: None <tech-kern@netbsd.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-kern
Date: 11/24/2002 19:06:55
--NextPart-20021124175514-0617500
Content-Type: Text/Plain; charset=us-ascii

hi.

is there any reason that i_ino is a member of struct inode?
i'll commit attached patch if no one objects.
thanks.

YAMAMOTO Takashi

--NextPart-20021124175514-0617500
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="i_ino.diff"

Index: ext2fs/ext2fs_lookup.c
===================================================================
RCS file: /cvs/NetBSD/syssrc/sys/ufs/ext2fs/ext2fs_lookup.c,v
retrieving revision 1.21
diff -u -p -r1.21 ext2fs_lookup.c
--- ext2fs/ext2fs_lookup.c	2002/09/27 15:38:02	1.21
+++ ext2fs/ext2fs_lookup.c	2002/11/24 08:50:30
@@ -292,6 +292,7 @@ ext2fs_lookup(v)
 	struct ucred *cred = cnp->cn_cred;
 	int flags = cnp->cn_flags;
 	int nameiop = cnp->cn_nameiop;
+	ino_t foundino;
 
 	int	dirblksize = VTOI(ap->a_dvp)->i_e2fs->e2fs_bsize;
 
@@ -450,7 +451,7 @@ searchloop:
 				 * reclen in ndp->ni_ufs area, and release
 				 * directory buffer.
 				 */
-				dp->i_ino = fs2h32(ep->e2d_ino);
+				foundino = fs2h32(ep->e2d_ino);
 				dp->i_reclen = fs2h16(ep->e2d_reclen);
 				brelse(bp);
 				goto found;
@@ -580,12 +581,12 @@ found:
 			dp->i_count = 0;
 		else
 			dp->i_count = dp->i_offset - prevoff;
-		if (dp->i_number == dp->i_ino) {
+		if (dp->i_number == foundino) {
 			VREF(vdp);
 			*vpp = vdp;
 			return (0);
 		}
-		if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0)
+		if ((error = VFS_VGET(vdp->v_mount, foundino, &tdp)) != 0)
 			return (error);
 		/*
 		 * If directory is "sticky", then user must own
@@ -623,9 +624,9 @@ found:
 		 * Careful about locking second inode.
 		 * This can only occur if the target is ".".
 		 */
-		if (dp->i_number == dp->i_ino)
+		if (dp->i_number == foundino)
 			return (EISDIR);
-		error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
+		error = VFS_VGET(vdp->v_mount, foundino, &tdp);
 		if (error)
 			return (error);
 		*vpp = tdp;
@@ -660,7 +661,7 @@ found:
 	if (flags & ISDOTDOT) {
 		VOP_UNLOCK(pdp, 0);	/* race to get the inode */
 		cnp->cn_flags |= PDIRUNLOCK;
-		error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
+		error = VFS_VGET(vdp->v_mount, foundino, &tdp);
 		if (error) {
 			if (vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY) == 0)
 				cnp->cn_flags &= ~PDIRUNLOCK;
@@ -674,11 +675,11 @@ found:
 			cnp->cn_flags &= ~PDIRUNLOCK;
 		}
 		*vpp = tdp;
-	} else if (dp->i_number == dp->i_ino) {
+	} else if (dp->i_number == foundino) {
 		VREF(vdp);	/* we want ourself, ie "." */
 		*vpp = vdp;
 	} else {
-		if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0)
+		if ((error = VFS_VGET(vdp->v_mount, foundino, &tdp)) != 0)
 			return (error);
 		if (!lockparent || !(flags & ISLASTCN)) {
 			VOP_UNLOCK(pdp, 0);
Index: ufs/inode.h
===================================================================
RCS file: /cvs/NetBSD/syssrc/sys/ufs/ufs/inode.h,v
retrieving revision 1.29
diff -u -p -r1.29 inode.h
--- ufs/inode.h	2002/07/06 01:30:16	1.29
+++ ufs/inode.h	2002/11/24 08:50:30
@@ -100,7 +100,6 @@ struct inode {
 	doff_t	  i_endoff;	/* End of useful stuff in directory. */
 	doff_t	  i_diroff;	/* Offset in dir, where we found last entry. */
 	doff_t	  i_offset;	/* Offset of free space in directory. */
-	ino_t	  i_ino;	/* Inode number of found directory. */
 	u_int32_t i_reclen;	/* Size of found directory entry. */
 	int       i_ffs_effnlink;  /* i_nlink when I/O completes */
 	/*
Index: ufs/ufs_lookup.c
===================================================================
RCS file: /cvs/NetBSD/syssrc/sys/ufs/ufs/ufs_lookup.c,v
retrieving revision 1.40
diff -u -p -r1.40 ufs_lookup.c
--- ufs/ufs_lookup.c	2002/09/28 20:11:09	1.40
+++ ufs/ufs_lookup.c	2002/11/24 08:50:30
@@ -136,6 +136,7 @@ ufs_lookup(v)
 	int nameiop = cnp->cn_nameiop;
 	const int needswap = UFS_MPNEEDSWAP(ap->a_dvp->v_mount);
 	int dirblksiz = DIRBLKSIZ;
+	ino_t foundino;
 	if (UFS_MPISAPPLEUFS(ap->a_dvp->v_mount)) {
 		dirblksiz = APPLEUFS_DIRBLKSIZ;
 	}
@@ -343,7 +345,7 @@ searchloop:
 					numdirpasses--;
 					goto notfound;
 				}
-				dp->i_ino = ufs_rw32(ep->d_ino, needswap);
+				foundino = ufs_rw32(ep->d_ino, needswap);
 				dp->i_reclen = ufs_rw16(ep->d_reclen, needswap);
 				goto found;
 			}
@@ -486,14 +488,14 @@ found:
 			dp->i_count = 0;
 		else
 			dp->i_count = dp->i_offset - prevoff;
-		if (dp->i_number == dp->i_ino) {
+		if (dp->i_number == foundino) {
 			VREF(vdp);
 			*vpp = vdp;
 			return (0);
 		}
 		if (flags & ISDOTDOT)
 			VOP_UNLOCK(vdp, 0); /* race to get the inode */
-		error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
+		error = VFS_VGET(vdp->v_mount, foundino, &tdp);
 		if (flags & ISDOTDOT)
 			vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
 		if (error)
@@ -533,11 +535,11 @@ found:
 		 * Careful about locking second inode.
 		 * This can only occur if the target is ".".
 		 */
-		if (dp->i_number == dp->i_ino)
+		if (dp->i_number == foundino)
 			return (EISDIR);
 		if (flags & ISDOTDOT)
 			VOP_UNLOCK(vdp, 0); /* race to get the inode */
-		error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
+		error = VFS_VGET(vdp->v_mount, foundino, &tdp);
 		if (flags & ISDOTDOT)
 			vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
 		if (error)
@@ -574,7 +576,7 @@ found:
 	if (flags & ISDOTDOT) {
 		VOP_UNLOCK(pdp, 0);	/* race to get the inode */
 		cnp->cn_flags |= PDIRUNLOCK;
-		error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
+		error = VFS_VGET(vdp->v_mount, foundino, &tdp);
 		if (error) {
 			if (vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY) == 0)
 				cnp->cn_flags &= ~PDIRUNLOCK;
@@ -588,11 +590,11 @@ found:
 			cnp->cn_flags &= ~PDIRUNLOCK;
 		}
 		*vpp = tdp;
-	} else if (dp->i_number == dp->i_ino) {
+	} else if (dp->i_number == foundino) {
 		VREF(vdp);	/* we want ourself, ie "." */
 		*vpp = vdp;
 	} else {
-		error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp);
+		error = VFS_VGET(vdp->v_mount, foundino, &tdp);
 		if (error)
 			return (error);
 		if (!lockparent || !(flags & ISLASTCN)) {

--NextPart-20021124175514-0617500--