PERFORCE change 165601 for review

Aditya Sarawgi truncs at FreeBSD.org
Sat Jul 4 17:53:10 UTC 2009


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

Change 165601 by truncs at aditya on 2009/07/04 17:53:04

	New implementation of blkfree. 

Affected files ...

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

Differences ...

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

@@ -456,12 +456,40 @@
 	long size;
 {
 	struct m_ext2fs *fs;
+	struct buf *bp;
+	struct ext2_gd *gdp = NULL;
+	int cg, error;
+	char *bbp;
 
 	fs = ip->i_e2fs;
-	/*
-	 *	call Linux code with mount *, block number, count
-	 */
-	ext2_free_blocks(ITOV(ip)->v_mount, bno, size / fs->e2fs_fsize);
+	cg = dtog(fs, bno);
+	gdp = get_group_desc2(fs, cg, NULL);
+	if ((u_int)bno >= fs->e2fs->e2fs_bcount) {
+                printf("bad block %lld, ino %llu\n", (long long)bno,
+                    (unsigned long long)ip->i_number);
+                ext2_fserr(fs, ip->i_uid, "bad block");
+                return;
+        }
+        error = bread(ip->i_devvp,
+                fsbtodb(fs, gdp->ext2bgd_b_bitmap),
+                (int)fs->e2fs_bsize, NOCRED, &bp);
+        if (error) {
+                brelse(bp);
+                return;
+        }
+        bbp = (char *)bp->b_data;
+        bno = dtogd(fs, bno);
+        if (isclr(bbp, bno)) {
+                printf("block = %lld, fs = %s\n",
+                     (long long)bno, fs->e2fs_fsmnt);
+                panic("blkfree: freeing free block");
+        }
+        clrbit(bbp, bno);
+        fs->e2fs->e2fs_fbcount++;
+        gdp->ext2bgd_nbfree++;
+
+        fs->e2fs_fmod = 1;
+        bdwrite(bp);
 }
 
 /*


More information about the p4-projects mailing list