Date: Sun, 18 Oct 2009 20:10:39 GMT From: Aditya Sarawgi <truncs@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 169581 for review Message-ID: <200910182010.n9IKAddL036632@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=169581 Change 169581 by truncs@aditya on 2009/10/18 20:10:10 Reallocation cleanup. Affected files ... .. //depot/projects/soc2009/soc_ext2fs/src/sys/fs/ext2fs/ext2_alloc.c#12 edit Differences ... ==== //depot/projects/soc2009/soc_ext2fs/src/sys/fs/ext2fs/ext2_alloc.c#12 (text+ko) ==== @@ -159,6 +159,8 @@ #ifdef FANCY_REALLOC #include <sys/sysctl.h> static int doasyncfree = 1; +static int doreallocblks = 1; + #ifdef OPT_DEBUG SYSCTL_INT(_debug, 14, doasyncfree, CTLFLAG_RW, &doasyncfree, 0, ""); #endif /* OPT_DEBUG */ @@ -180,11 +182,11 @@ struct inode *ip; struct vnode *vp; struct buf *sbp, *ebp; + int32_t *bap, *sbap, *ebap = 0; struct ext2mount *ump; struct cluster_save *buflist; struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp; - int32_t *bap, *sbap, *ebap; - int32_t start_lbn, end_lbn, soff, eoff, newblk, blkno; + int32_t start_lbn, end_lbn, soff, eoff, newblk, blkno =0; int i, len, start_lvl, end_lvl, pref, ssize; vp = ap->a_vp; @@ -212,8 +214,8 @@ if (dtog(fs, dbtofsb(fs, buflist->bs_children[0]->b_blkno)) != dtog(fs, dbtofsb(fs, buflist->bs_children[len - 1]->b_blkno))) return (ENOSPC); - if (ufs_getlbns(vp, start_lbn, start_ap, &start_lvl) || - ufs_getlbns(vp, end_lbn, end_ap, &end_lvl)) + if (ext2_getlbns(vp, start_lbn, start_ap, &start_lvl) || + ext2_getlbns(vp, end_lbn, end_ap, &end_lvl)) return (ENOSPC); /* * Get the starting offset and block map for the first block. @@ -234,7 +236,7 @@ * Find the preferred location for the cluster. */ EXT2_LOCK(ump); - pref = ext2_blkpref(ip, start_lbn, soff, sbap); + pref = ext2_blkpref(ip, start_lbn, soff, sbap, blkno); /* * If the block range spans two block maps, get the second map. */ @@ -256,7 +258,7 @@ * Search the block map looking for an allocation of the desired size. */ if ((newblk = (int32_t)ext2_hashalloc(ip, dtog(fs, pref), (long)pref, - len, (u_long (*)())ext2_clusteralloc)) == 0){ + len, ext2_clusteralloc)) == 0){ EXT2_UNLOCK(ump); goto fail; } @@ -271,6 +273,7 @@ for (bap = &sbap[soff], i = 0; i < len; i++, blkno += fs->e2fs_fpb) { if (i == ssize) bap = ebap; + soff = -i; #ifdef DIAGNOSTIC if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap)) panic("ext2_reallocblks: alloc mismatch"); @@ -301,11 +304,12 @@ if (!doasyncfree) ext2_update(vp, 1); } - if (ssize < len) + if (ssize < len) { if (doasyncfree) bdwrite(ebp); else bwrite(ebp); + } /* * Last, free the old blocks and assign the new blocks to the buffers. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910182010.n9IKAddL036632>