PERFORCE change 165427 for review
Aditya Sarawgi
truncs at FreeBSD.org
Mon Jun 29 18:59:09 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=165427
Change 165427 by truncs at aditya on 2009/06/29 18:58:19
Included a GPL'd function ie get_group_desc2 included from ext2_linux_ialloc but I will soon be migrating to NetBSD's scheme
for group descriptors.
Currently touch foobar works fine but something like mkdir barfoo gives a panic.
Affected files ...
.. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#20 edit
Differences ...
==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#20 (text+ko) ====
@@ -56,6 +56,7 @@
#endif
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 ino_t ext2_hashalloc(struct inode *, int, long, int,
daddr_t (*)(struct inode *, int, daddr_t,
int));
@@ -63,7 +64,6 @@
#ifdef notyet
static daddr_t ext2_mapsearch(struct m_ext2fs *, char *, daddr_t);
#endif
-static void mark_buffer_dirty2(struct buf *);
/*
* Linux calls this functions at the following locations:
@@ -388,12 +388,15 @@
* else obtain it using ino_to_cg. The preferred inode is always the next
* inode.
*/
+ uprintf("a\n");
if((mode & IFMT) == IFDIR)
cg = ext2_dirpref(fs);
else
cg = ino_to_cg(fs, pip->i_number);
ipref = cg * fs->e2fs->e2fs_ipg + 1;
+ uprintf("b\n");
ino = ext2_hashalloc(pip, cg, (long)ipref, mode, ext2_nodealloccg);
+ uprintf("c\n");
if (ino == 0)
goto noinodes;
@@ -734,23 +737,26 @@
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 = (struct ext2_gd *) fs->e2fs_group_desc[cg]->b_data;
+ gdp = get_group_desc2(fs, cg, NULL);
+ uprintf("2\n");
if (gdp->ext2bgd_nifree == 0)
return (0);
- lock_super(DEVVP(ip));
+/* lock_super(DEVVP(ip)); */
error = bread(ip->i_devvp, fsbtodb(fs,
gdp->ext2bgd_i_bitmap),
(int)fs->e2fs_bsize, NOCRED, &bp);
if (error) {
brelse(bp);
- unlock_super(DEVVP(ip));
+/* unlock_super(DEVVP(ip)); */
+ uprintf("3\n");
return (0);
}
ibp = (char *)bp->b_data;
@@ -792,8 +798,12 @@
if ((mode & IFMT) == IFDIR) {
gdp->ext2bgd_ndirs++;
}
- mark_buffer_dirty2(bp);
- unlock_super(DEVVP(ip));
+/* mark_buffer_dirty2(bh); */
+/* mark_buffer_dirty2(bp); */
+
+/* unlock_super(DEVVP(ip)); */
+ uprintf("4\n");
+ bdwrite(bp);
return (cg * fs->e2fs->e2fs_ipg + ipref +1);
}
@@ -843,12 +853,35 @@
/* NOTREACHED */
}
#endif
-void mark_buffer_dirty2(struct buf *bh)
-{
- int s;
+
+/*
+ * 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);
- s = splbio();
- bh->b_flags |= B_DIRTY;
- splx(s);
+ 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;
}
+
More information about the p4-projects
mailing list