PERFORCE change 166326 for review
Aditya Sarawgi
truncs at FreeBSD.org
Mon Jul 20 19:16:54 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166326
Change 166326 by truncs at aditya on 2009/07/20 19:15:56
Use the new group descriptors implementation and remove unused functions.
Affected files ...
.. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#31 edit
Differences ...
==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#31 (text+ko) ====
@@ -54,7 +54,6 @@
static daddr_t ext2_alloccg(struct inode *, int, daddr_t, int);
static u_long ext2_dirpref(struct m_ext2fs *);
static void ext2_fserr(struct m_ext2fs *, u_int, char *);
-static struct ext2_gd * get_group_desc2(struct m_ext2fs *, int, struct buf **);
static u_long ext2_hashalloc(struct inode *, int, long, int,
daddr_t (*)(struct inode *, int, daddr_t,
int));
@@ -457,14 +456,11 @@
{
struct m_ext2fs *fs;
struct buf *bp;
- struct buf *bh;
- struct ext2_gd *gdp = NULL;
int cg, error;
char *bbp;
fs = ip->i_e2fs;
cg = dtog(fs, bno);
- gdp = get_group_desc2(fs, cg, &bh);
if ((u_int)bno >= fs->e2fs->e2fs_bcount) {
printf("bad block %lld, ino %llu\n", (long long)bno,
(unsigned long long)ip->i_number);
@@ -472,7 +468,7 @@
return;
}
error = bread(ip->i_devvp,
- fsbtodb(fs, gdp->ext2bgd_b_bitmap),
+ fsbtodb(fs, fs->e2fs_gd[cg].ext2bgd_b_bitmap),
(int)fs->e2fs_bsize, NOCRED, &bp);
if (error) {
brelse(bp);
@@ -487,8 +483,7 @@
}
clrbit(bbp, bno);
fs->e2fs->e2fs_fbcount++;
- gdp->ext2bgd_nbfree++;
- mark_buffer_dirty2(bh);
+ fs->e2fs_gd[cg].ext2bgd_nbfree++;
fs->e2fs_fmod = 1;
bdwrite(bp);
}
@@ -507,8 +502,6 @@
struct m_ext2fs *fs;
struct inode *pip;
struct buf *bp;
- struct buf *bh;
- struct ext2_gd * gdp = NULL;
int error, cg;
char * ibp;
/* mode_t save_i_mode; */
@@ -519,22 +512,9 @@
panic("ext2_vfree: range: devvp = %p, ino = %d, fs = %s",
pip->i_devvp, ino, fs->e2fs_fsmnt);
-/* ext2_debug("ext2_vfree (%d, %d) called\n", pip->i_number, mode);
- */
-
- /* we need to make sure that ext2_free_inode can adjust the
- used_dir_counts in the group summary information - I'd
- 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;
- pip->i_mode = mode;
- ext2_free_inode(pip);
- pip->i_mode = save_i_mode; */
cg = ino_to_cg(fs, ino);
- gdp = get_group_desc2(fs, cg, &bh);
error = bread(pip->i_devvp,
- fsbtodb(fs, gdp->ext2bgd_i_bitmap),
+ fsbtodb(fs, fs->e2fs_gd[cg].ext2bgd_i_bitmap),
(int)fs->e2fs_bsize, NOCRED, &bp);
if (error) {
brelse(bp);
@@ -550,11 +530,10 @@
}
clrbit(ibp, ino);
fs->e2fs->e2fs_ficount++;
- gdp->ext2bgd_nifree++;
+ fs->e2fs_gd[cg].ext2bgd_nifree++;
if ((mode & IFMT) == IFDIR) {
- gdp->ext2bgd_ndirs--;
+ fs->e2fs_gd[cg].ext2bgd_ndirs--;
}
- mark_buffer_dirty2(bh);
fs->e2fs_fmod = 1;
bdwrite(bp);
return (0);
@@ -587,16 +566,14 @@
ext2_dirpref(struct m_ext2fs *fs)
{
int cg, maxspace, mincg, avgifree;
- struct ext2_gd *gdp = NULL;
avgifree = fs->e2fs->e2fs_ficount / fs->e2fs_gcount;
maxspace = 0;
mincg = -1;
for (cg = 0; cg < fs->e2fs_gcount; cg++) {
- gdp = get_group_desc2(fs, cg, NULL);
- if ( gdp->ext2bgd_nifree >= avgifree) {
- if (mincg == -1 || gdp->ext2bgd_nbfree > maxspace) {
+ if ( fs->e2fs_gd[cg].ext2bgd_nifree >= avgifree) {
+ if (mincg == -1 || fs->e2fs_gd[cg].ext2bgd_nbfree > maxspace) {
mincg = cg;
- maxspace = gdp->ext2bgd_nbfree;
+ maxspace = fs->e2fs_gd[cg].ext2bgd_nbfree;
}
}
}
@@ -666,17 +643,14 @@
struct m_ext2fs *fs;
char *bbp;
struct buf *bp;
- struct buf *bh;
- struct ext2_gd *gdp = NULL;
/* XXX ondisk32 */
int error, bno, start, end, loc;
fs = ip->i_e2fs;
- gdp = get_group_desc2(fs, cg, &bh);
- if (gdp->ext2bgd_nbfree == 0)
+ if (fs->e2fs_gd[cg].ext2bgd_nbfree == 0)
return (0);
error = bread(ip->i_devvp, fsbtodb(fs,
- gdp->ext2bgd_b_bitmap),
+ fs->e2fs_gd[cg].ext2bgd_b_bitmap),
(int)fs->e2fs_bsize, NOCRED, &bp);
if (error) {
brelse(bp);
@@ -734,8 +708,7 @@
#endif
setbit(bbp, (daddr_t)bno);
fs->e2fs->e2fs_fbcount--;
- gdp->ext2bgd_nbfree--;
- mark_buffer_dirty2(bh);
+ fs->e2fs_gd[cg].ext2bgd_nbfree--;
fs->e2fs_fmod = 1;
bdwrite(bp);
return (cg * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + bno);
@@ -752,22 +725,18 @@
struct m_ext2fs *fs;
char *ibp;
struct buf *bp;
- struct buf *bh;
- struct ext2_gd *gdp = NULL;
int error, start, len, loc, map, i;
uprintf("1\n");
ipref--; /* to avoid a lot of (ipref -1) */
if (ipref == -1)
ipref = 0;
fs = ip->i_e2fs;
- gdp = get_group_desc2(fs, cg, &bh);
uprintf("2\n");
- if (gdp->ext2bgd_nifree == 0)
+ if (fs->e2fs_gd[cg].ext2bgd_nifree == 0)
return (0);
lock_super(DEVVP(ip));
- uprintf("%d\n", gdp->ext2bgd_nifree);
error = bread(ip->i_devvp, fsbtodb(fs,
- gdp->ext2bgd_i_bitmap),
+ fs->e2fs_gd[cg].ext2bgd_i_bitmap),
(int)fs->e2fs_bsize, NOCRED, &bp);
if (error) {
brelse(bp);
@@ -808,19 +777,15 @@
/* NOTREACHED */
gotit:
setbit(ibp, ipref);
- gdp->ext2bgd_nifree--;
-/* bwrite(bh);*/
- mark_buffer_dirty2(bh);
+ fs->e2fs_gd[cg].ext2bgd_nifree--;
fs->e2fs->e2fs_ficount--;
fs->e2fs_fmod = 1;
if ((mode & IFMT) == IFDIR) {
- gdp->ext2bgd_ndirs++;
+ fs->e2fs_gd[cg].ext2bgd_ndirs++;
}
-/* mark_buffer_dirty2(bh); */
-/* mark_buffer_dirty2(bp); */
uprintf("4\n");
bdwrite(bp);
- uprintf("%d\n", gdp->ext2bgd_nifree);
+ uprintf("%d\n", fs->e2fs_gd[cg].ext2bgd_nifree);
unlock_super(DEVVP(ip));
return (cg * fs->e2fs->e2fs_ipg + ipref +1);
}
@@ -870,35 +835,6 @@
/* NOTREACHED */
}
-/*
- * This function is taken from ext2_linux_ialloc.c and is under GPL. NetBSD has e2fs_gd which contains all the group desc and is
- * intialized at the time of mounting.
- */
-struct ext2_gd * get_group_desc2(struct m_ext2fs * fs, int cg, struct buf ** bh) {
-
- unsigned long group_desc;
- unsigned long desc;
- struct ext2_gd * gdp;
-
- if (cg >= fs->e2fs_gcount)
- panic ("get_group_desc: "
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %d",
- cg, fs->e2fs_gcount);
-
- group_desc = cg / EXT2_DESC_PER_BLOCK(fs);
- desc = cg % EXT2_DESC_PER_BLOCK(fs);
- if (!fs->e2fs_group_desc[group_desc])
- panic ( "get_group_desc:"
- "Group descriptor not loaded - "
- "block_group = %d, group_desc = %lu, desc = %lu",
- cg, group_desc, desc);
- gdp = (struct ext2_gd *)
- fs->e2fs_group_desc[group_desc]->b_data;
- if (bh)
- *bh = fs->e2fs_group_desc[group_desc];
- return gdp + desc;
-}
int
cg_has_sb(int i)
{
@@ -914,11 +850,4 @@
return 0;
}
-void mark_buffer_dirty2(struct buf *bh)
-{
- int s;
- s = splbio();
- bh->b_flags |= B_DIRTY;
- splx(s);
-}
More information about the p4-projects
mailing list