From owner-p4-projects@FreeBSD.ORG Sun Oct 18 20:10:40 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 38FD310656DB; Sun, 18 Oct 2009 20:10:40 +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 F08CF10656CB for ; Sun, 18 Oct 2009 20:10:39 +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 DD49F8FC18 for ; Sun, 18 Oct 2009 20:10:39 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n9IKAdhA036634 for ; Sun, 18 Oct 2009 20:10:39 GMT (envelope-from truncs@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n9IKAddL036632 for perforce@freebsd.org; Sun, 18 Oct 2009 20:10:39 GMT (envelope-from truncs@FreeBSD.org) Date: Sun, 18 Oct 2009 20:10:39 GMT Message-Id: <200910182010.n9IKAddL036632@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 Precedence: bulk Cc: Subject: PERFORCE change 169581 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2009 20:10:40 -0000 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 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. */