From owner-p4-projects@FreeBSD.ORG Wed Jul 15 14:35:23 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 727B01065670; Wed, 15 Jul 2009 14:35:23 +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 286F2106566B for ; Wed, 15 Jul 2009 14:35:23 +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 161FA8FC08 for ; Wed, 15 Jul 2009 14:35:23 +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 n6FEZM9l090752 for ; Wed, 15 Jul 2009 14:35:22 GMT (envelope-from truncs@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n6FEZMPt090750 for perforce@freebsd.org; Wed, 15 Jul 2009 14:35:22 GMT (envelope-from truncs@FreeBSD.org) Date: Wed, 15 Jul 2009 14:35:22 GMT Message-Id: <200907151435.n6FEZMPt090750@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 166133 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: Wed, 15 Jul 2009 14:35:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=166133 Change 166133 by truncs@aditya on 2009/07/15 14:35:02 Introduced buffers to sync metadata which will end the metadata corruption problem. But bdwrite() gives rise to panic saying that brelse: free buffer onto another queue??? on umounting. I'm not able to figure out the problem here so using a simple function which just makes the buffer dirty by setting the dirty flag. Affected files ... .. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#30 edit Differences ... ==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#30 (text+ko) ==== @@ -60,7 +60,7 @@ int)); static daddr_t ext2_nodealloccg(struct inode *, int, daddr_t, int); static daddr_t ext2_mapsearch(struct m_ext2fs *, char *, daddr_t); - +static void mark_buffer_dirty2(struct buf *bh); /* * Allocate a block in the file system. * @@ -457,13 +457,14 @@ { 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, NULL); + 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); @@ -487,7 +488,7 @@ clrbit(bbp, bno); fs->e2fs->e2fs_fbcount++; gdp->ext2bgd_nbfree++; - + mark_buffer_dirty2(bh); fs->e2fs_fmod = 1; bdwrite(bp); } @@ -506,6 +507,7 @@ struct m_ext2fs *fs; struct inode *pip; struct buf *bp; + struct buf *bh; struct ext2_gd * gdp = NULL; int error, cg; char * ibp; @@ -530,7 +532,7 @@ ext2_free_inode(pip); pip->i_mode = save_i_mode; */ cg = ino_to_cg(fs, ino); - gdp = get_group_desc2(fs, cg, NULL); + gdp = get_group_desc2(fs, cg, &bh); error = bread(pip->i_devvp, fsbtodb(fs, gdp->ext2bgd_i_bitmap), (int)fs->e2fs_bsize, NOCRED, &bp); @@ -552,6 +554,7 @@ if ((mode & IFMT) == IFDIR) { gdp->ext2bgd_ndirs--; } + mark_buffer_dirty2(bh); fs->e2fs_fmod = 1; bdwrite(bp); return (0); @@ -663,12 +666,13 @@ 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, NULL); + gdp = get_group_desc2(fs, cg, &bh); if (gdp->ext2bgd_nbfree == 0) return (0); error = bread(ip->i_devvp, fsbtodb(fs, @@ -731,6 +735,7 @@ setbit(bbp, (daddr_t)bno); fs->e2fs->e2fs_fbcount--; gdp->ext2bgd_nbfree--; + mark_buffer_dirty2(bh); fs->e2fs_fmod = 1; bdwrite(bp); return (cg * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + bno); @@ -747,7 +752,7 @@ struct m_ext2fs *fs; char *ibp; struct buf *bp; -/* struct buf *bh;*/ + struct buf *bh; struct ext2_gd *gdp = NULL; int error, start, len, loc, map, i; uprintf("1\n"); @@ -755,17 +760,18 @@ if (ipref == -1) ipref = 0; fs = ip->i_e2fs; - gdp = get_group_desc2(fs, cg, NULL); + gdp = get_group_desc2(fs, cg, &bh); uprintf("2\n"); if (gdp->ext2bgd_nifree == 0) return (0); -/* lock_super(DEVVP(ip)); */ + lock_super(DEVVP(ip)); + uprintf("%d\n", gdp->ext2bgd_nifree); 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); } @@ -802,18 +808,20 @@ /* NOTREACHED */ gotit: setbit(ibp, ipref); + gdp->ext2bgd_nifree--; +/* bwrite(bh);*/ + mark_buffer_dirty2(bh); fs->e2fs->e2fs_ficount--; - gdp->ext2bgd_nifree--; fs->e2fs_fmod = 1; if ((mode & IFMT) == IFDIR) { gdp->ext2bgd_ndirs++; } /* mark_buffer_dirty2(bh); */ /* mark_buffer_dirty2(bp); */ - -/* unlock_super(DEVVP(ip)); */ uprintf("4\n"); bdwrite(bp); + uprintf("%d\n", gdp->ext2bgd_nifree); + unlock_super(DEVVP(ip)); return (cg * fs->e2fs->e2fs_ipg + ipref +1); } @@ -906,3 +914,11 @@ return 0; } +void mark_buffer_dirty2(struct buf *bh) +{ + int s; + + s = splbio(); + bh->b_flags |= B_DIRTY; + splx(s); +}