From owner-p4-projects@FreeBSD.ORG Mon Jun 29 18:59:09 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 248511065674; Mon, 29 Jun 2009 18:59:08 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ADF851065670 for ; Mon, 29 Jun 2009 18:59:07 +0000 (UTC) (envelope-from truncs@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 9B6278FC0C for ; Mon, 29 Jun 2009 18:59:07 +0000 (UTC) (envelope-from truncs@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5TIx7Ne066186 for ; Mon, 29 Jun 2009 18:59:07 GMT (envelope-from truncs@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5TIx7dr066184 for perforce@freebsd.org; Mon, 29 Jun 2009 18:59:07 GMT (envelope-from truncs@FreeBSD.org) Date: Mon, 29 Jun 2009 18:59:07 GMT Message-Id: <200906291859.n5TIx7dr066184@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to truncs@FreeBSD.org using -f From: Aditya Sarawgi To: Perforce Change Reviews Cc: Subject: PERFORCE change 165427 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jun 2009 18:59:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=165427 Change 165427 by truncs@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; } +