PERFORCE change 166731 for review
Aditya Sarawgi
truncs at FreeBSD.org
Wed Jul 29 13:14:10 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166731
Change 166731 by truncs at aditya on 2009/07/29 13:13:28
Rearranging functions to make it consistent with NetBSD's src.
Suggested by: Pedro Giffuni
Affected files ...
.. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#34 edit
.. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_vfsops.c#16 edit
Differences ...
==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#34 (text+ko) ====
@@ -393,6 +393,31 @@
}
/*
+ * Find a cylinder to place a directory.
+ *
+ * The policy implemented by this algorithm is to select from
+ * among those cylinder groups with above the average number of
+ * free inodes, the one with the smallest number of directories.
+ */
+static u_long
+ext2_dirpref(struct m_ext2fs *fs)
+{
+ int cg, maxspace, mincg, avgifree;
+ avgifree = fs->e2fs->e2fs_ficount / fs->e2fs_gcount;
+ maxspace = 0;
+ mincg = -1;
+ for (cg = 0; cg < fs->e2fs_gcount; cg++) {
+ if ( fs->e2fs_gd[cg].ext2bgd_nifree >= avgifree) {
+ if (mincg == -1 || fs->e2fs_gd[cg].ext2bgd_nbfree > maxspace) {
+ mincg = cg;
+ maxspace = fs->e2fs_gd[cg].ext2bgd_nbfree;
+ }
+ }
+ }
+ return mincg;
+}
+
+/*
* Select the desired position for the next block in a file.
*
* we try to mimic what Remy does in inode_getblk/block_getblk
@@ -439,143 +464,6 @@
}
/*
- * Free a block or fragment.
- *
- * pass on to the Linux code
- */
-void
-ext2_blkfree(ip, bno, size)
- struct inode *ip;
- int32_t bno;
- long size;
-{
- struct m_ext2fs *fs;
- struct buf *bp;
- int cg, error;
- char *bbp;
-
- fs = ip->i_e2fs;
- cg = dtog(fs, bno);
- 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, fs->e2fs_gd[cg].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++;
- fs->e2fs_gd[cg].ext2bgd_nbfree++;
- fs->e2fs_fmod = 1;
- bdwrite(bp);
-}
-
-/*
- * Free an inode.
- *
- * the maintenance of the actual bitmaps is again up to the linux code
- */
-int
-ext2_vfree(pvp, ino, mode)
- struct vnode *pvp;
- ino_t ino;
- int mode;
-{
- struct m_ext2fs *fs;
- struct inode *pip;
- struct buf *bp;
- int error, cg;
- char * ibp;
-/* mode_t save_i_mode; */
-
- pip = VTOI(pvp);
- fs = pip->i_e2fs;
- if ((u_int)ino > fs->e2fs_ipg * fs->e2fs_gcount)
- panic("ext2_vfree: range: devvp = %p, ino = %d, fs = %s",
- pip->i_devvp, ino, fs->e2fs_fsmnt);
-
- cg = ino_to_cg(fs, ino);
- error = bread(pip->i_devvp,
- fsbtodb(fs, fs->e2fs_gd[cg].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++;
- fs->e2fs_gd[cg].ext2bgd_nifree++;
- if ((mode & IFMT) == IFDIR) {
- fs->e2fs_gd[cg].ext2bgd_ndirs--;
- }
- fs->e2fs_fmod = 1;
- bdwrite(bp);
- return (0);
-}
-
-/*
- * Fserr prints the name of a file system with an error diagnostic.
- *
- * The form of the error message is:
- * fs: error message
- */
-static void
-ext2_fserr(fs, uid, cp)
- struct m_ext2fs *fs;
- u_int uid;
- char *cp;
-{
-
- log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->e2fs_fsmnt, cp);
-}
-
-/*
- * Find a cylinder to place a directory.
- *
- * The policy implemented by this algorithm is to select from
- * among those cylinder groups with above the average number of
- * free inodes, the one with the smallest number of directories.
- */
-static u_long
-ext2_dirpref(struct m_ext2fs *fs)
-{
- int cg, maxspace, mincg, avgifree;
- avgifree = fs->e2fs->e2fs_ficount / fs->e2fs_gcount;
- maxspace = 0;
- mincg = -1;
- for (cg = 0; cg < fs->e2fs_gcount; cg++) {
- if ( fs->e2fs_gd[cg].ext2bgd_nifree >= avgifree) {
- if (mincg == -1 || fs->e2fs_gd[cg].ext2bgd_nbfree > maxspace) {
- mincg = cg;
- maxspace = fs->e2fs_gd[cg].ext2bgd_nbfree;
- }
- }
- }
- return mincg;
-}
-
-/*
* Implement the cylinder overflow algorithm.
*
* The policy implemented by this algorithm is:
@@ -708,6 +596,7 @@
bdwrite(bp);
return (cg * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + bno);
}
+
/*
* Determine whether an inode can be allocated.
*
@@ -781,6 +670,102 @@
}
/*
+ * Free a block or fragment.
+ *
+ * pass on to the Linux code
+ */
+void
+ext2_blkfree(ip, bno, size)
+ struct inode *ip;
+ int32_t bno;
+ long size;
+{
+ struct m_ext2fs *fs;
+ struct buf *bp;
+ int cg, error;
+ char *bbp;
+
+ fs = ip->i_e2fs;
+ cg = dtog(fs, bno);
+ 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, fs->e2fs_gd[cg].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++;
+ fs->e2fs_gd[cg].ext2bgd_nbfree++;
+ fs->e2fs_fmod = 1;
+ bdwrite(bp);
+}
+
+/*
+ * Free an inode.
+ *
+ * the maintenance of the actual bitmaps is again up to the linux code
+ */
+int
+ext2_vfree(pvp, ino, mode)
+ struct vnode *pvp;
+ ino_t ino;
+ int mode;
+{
+ struct m_ext2fs *fs;
+ struct inode *pip;
+ struct buf *bp;
+ int error, cg;
+ char * ibp;
+/* mode_t save_i_mode; */
+
+ pip = VTOI(pvp);
+ fs = pip->i_e2fs;
+ if ((u_int)ino > fs->e2fs_ipg * fs->e2fs_gcount)
+ panic("ext2_vfree: range: devvp = %p, ino = %d, fs = %s",
+ pip->i_devvp, ino, fs->e2fs_fsmnt);
+
+ cg = ino_to_cg(fs, ino);
+ error = bread(pip->i_devvp,
+ fsbtodb(fs, fs->e2fs_gd[cg].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++;
+ fs->e2fs_gd[cg].ext2bgd_nifree++;
+ if ((mode & IFMT) == IFDIR) {
+ fs->e2fs_gd[cg].ext2bgd_ndirs--;
+ }
+ fs->e2fs_fmod = 1;
+ bdwrite(bp);
+ return (0);
+}
+
+/*
* Find a block in the specified cylinder group.
*
* It is a panic if a request is made to find a block if none are
@@ -825,6 +810,22 @@
/* NOTREACHED */
}
+/*
+ * Fserr prints the name of a file system with an error diagnostic.
+ *
+ * The form of the error message is:
+ * fs: error message
+ */
+static void
+ext2_fserr(fs, uid, cp)
+ struct m_ext2fs *fs;
+ u_int uid;
+ char *cp;
+{
+
+ log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->e2fs_fsmnt, cp);
+}
+
int
cg_has_sb(int i)
{
@@ -839,5 +840,3 @@
return 1;
return 0;
}
-
-
==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_vfsops.c#16 (text+ko) ====
More information about the p4-projects
mailing list