From: thib Date: Fri, 8 Aug 2008 16:17:38 +0000 (+0000) Subject: use cgbase() instead of doing arthmetic on fs_fpg when calculating X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=00d1f8ca813f338a78da6b7055fef422faafa3b2;p=openbsd use cgbase() instead of doing arthmetic on fs_fpg when calculating block# too ensure proper casting. From FreeBSD; ok miod@, pedro@, blambert@ --- diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index c1b5ef5dcf4..b241b75af6c 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.85 2008/08/02 08:34:36 otto Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.86 2008/08/08 16:17:38 thib Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -1346,7 +1346,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr64_t bpref, int size) if (frags != allocsiz) cgp->cg_frsum[allocsiz - frags]++; - blkno = (daddr64_t)cg * fs->fs_fpg + bno; + blkno = cgbase(fs, cg) + bno; if (DOINGSOFTDEP(ITOV(ip))) softdep_setup_blkmapdep(bp, fs, blkno); bdwrite(bp); @@ -1407,7 +1407,7 @@ gotit: } fs->fs_fmod = 1; - blkno = (daddr64_t)cgp->cg_cgx * fs->fs_fpg + bno; + blkno = cgbase(fs, cgp->cg_cgx) + bno; if (DOINGSOFTDEP(ITOV(ip))) softdep_setup_blkmapdep(bp, fs, blkno); @@ -1509,7 +1509,7 @@ ffs_clusteralloc(struct inode *ip, int cg, daddr64_t bpref, int len) if (!ffs_isblock(fs, cg_blksfree(cgp), got - run + i)) panic("ffs_clusteralloc: map mismatch"); #endif - bno = cg * fs->fs_fpg + blkstofrags(fs, got - run + 1); + bno = cgbase(fs, cg) + blkstofrags(fs, got - run + 1); #ifdef DIAGNOSTIC if (dtog(fs, bno) != cg) panic("ffs_clusteralloc: allocated out of group");