PERFORCE change 165438 for review

Aditya Sarawgi truncs at FreeBSD.org
Mon Jun 29 20:28:47 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=165438

Change 165438 by truncs at aditya on 2009/06/29 20:28:02

	Freeing an inode implementation.

Affected files ...

.. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#22 edit

Differences ...

==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#22 (text+ko) ====

@@ -517,7 +517,11 @@
 {
 	struct m_ext2fs *fs;
 	struct inode *pip;
-	mode_t save_i_mode;
+	struct buf *bp;
+	struct ext2_gd * gdp = NULL;
+	int error, cg;
+	char * ibp;
+/*	mode_t save_i_mode; */
 
 	pip = VTOI(pvp);
 	fs = pip->i_e2fs;
@@ -534,10 +538,35 @@
 	   really like to know what the rationale behind this
 	   'set i_mode to zero to denote an unused inode' is
 	 */
-	save_i_mode = pip->i_mode;
+/*	save_i_mode = pip->i_mode;
 	pip->i_mode = mode;
 	ext2_free_inode(pip);	
-	pip->i_mode = save_i_mode;
+	pip->i_mode = save_i_mode; */
+	cg = ino_to_cg(fs, ino);
+	gdp = get_group_desc2(fs, cg, NULL);
+	error = bread(pip->i_devvp,
+		fsbtodb(fs, gdp->ext2bgd_i_bitmap),
+		(int)fs->e2fs_bsize, NOCRED, &bp);
+	if (error) {
+		brelse(bp);
+		return (0);
+	}
+	ibp = (char *)bp->b_data;
+	ino = (ino - 1) % fs->e2fs->e2fs_ipg;
+	if (isclr(ibp, ino)) {
+		printf("ino = %llu, fs = %s\n",
+			 (unsigned long long)ino, fs->e2fs_fsmnt);
+		if (fs->e2fs_ronly == 0)
+			panic("ifree: freeing free inode");
+	}
+	clrbit(ibp, ino);
+	fs->e2fs->e2fs_ficount++;
+	gdp->ext2bgd_nifree++;
+	if ((mode & IFMT) == IFDIR) {
+		gdp->ext2bgd_ndirs--;
+	}
+	fs->e2fs_fmod = 1;
+	bdwrite(bp);
 	return (0);
 }
 


More information about the p4-projects mailing list