Date: Sat, 4 Jul 2009 17:53:09 GMT From: Aditya Sarawgi <truncs@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 165601 for review Message-ID: <200907041753.n64Hr9YH010515@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165601 Change 165601 by truncs@aditya on 2009/07/04 17:53:04 New implementation of blkfree. Affected files ... .. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#28 edit Differences ... ==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#28 (text+ko) ==== @@ -456,12 +456,40 @@ long size; { struct m_ext2fs *fs; + struct buf *bp; + struct ext2_gd *gdp = NULL; + int cg, error; + char *bbp; fs = ip->i_e2fs; - /* - * call Linux code with mount *, block number, count - */ - ext2_free_blocks(ITOV(ip)->v_mount, bno, size / fs->e2fs_fsize); + cg = dtog(fs, bno); + gdp = get_group_desc2(fs, cg, NULL); + if ((u_int)bno >= fs->e2fs->e2fs_bcount) { + printf("bad block %lld, ino %llu\n", (long long)bno, + (unsigned long long)ip->i_number); + ext2_fserr(fs, ip->i_uid, "bad block"); + return; + } + error = bread(ip->i_devvp, + fsbtodb(fs, gdp->ext2bgd_b_bitmap), + (int)fs->e2fs_bsize, NOCRED, &bp); + if (error) { + brelse(bp); + return; + } + bbp = (char *)bp->b_data; + bno = dtogd(fs, bno); + if (isclr(bbp, bno)) { + printf("block = %lld, fs = %s\n", + (long long)bno, fs->e2fs_fsmnt); + panic("blkfree: freeing free block"); + } + clrbit(bbp, bno); + fs->e2fs->e2fs_fbcount++; + gdp->ext2bgd_nbfree++; + + fs->e2fs_fmod = 1; + bdwrite(bp); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907041753.n64Hr9YH010515>