Date: Wed, 15 Jul 2009 14:35:22 GMT From: Aditya Sarawgi <truncs@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166133 for review Message-ID: <200907151435.n6FEZMPt090750@repoman.freebsd.org>
index | next in thread | raw e-mail
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); +}help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907151435.n6FEZMPt090750>
