diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-01-22 20:45:01 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-01-22 20:45:01 +0000 |
commit | 1162c7d346f4c8e28e2f334df2a65348c9934e46 (patch) | |
tree | 99b8913543e1364820ed1cd5c8624313c827af7e | |
parent | 4815eb98a731b64bbb840d66bf0326e1c89de844 (diff) |
with a lot of fragments per cylinder group and lots of cylinder
groups, it is possible that fpg * ncg overflows an int. Problem
seen by jared rr spiegel while playing with very small fragments
on a large disk. ok krw@ millert@
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 76eec44843c..c3b1ca09cf4 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.81 2008/01/05 19:49:26 otto Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.82 2008/01/22 20:45:00 otto Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -1082,7 +1082,7 @@ ffs2_blkpref(struct inode *ip, daddr64_t lbn, int indx, int64_t *bap) if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { if (lbn < NDADDR + NINDIR(fs)) { cg = ino_to_cg(fs, ip->i_number); - return (fs->fs_fpg * cg + fs->fs_frag); + return ((int64_t)fs->fs_fpg * cg + fs->fs_frag); } /* @@ -1100,11 +1100,13 @@ ffs2_blkpref(struct inode *ip, daddr64_t lbn, int indx, int64_t *bap) for (cg = startcg; cg < fs->fs_ncg; cg++) if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) - return (fs->fs_fpg * cg + fs->fs_frag); + return ((int64_t)fs->fs_fpg * cg + + fs->fs_frag); for (cg = 0; cg < startcg; cg++) if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) - return (fs->fs_fpg * cg + fs->fs_frag); + return ((int64_t)fs->fs_fpg * cg + + fs->fs_frag); return (0); } @@ -1333,7 +1335,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr64_t bpref, int size) if (frags != allocsiz) cgp->cg_frsum[allocsiz - frags]++; - blkno = cg * fs->fs_fpg + bno; + blkno = (daddr64_t)cg * fs->fs_fpg + bno; if (DOINGSOFTDEP(ITOV(ip))) softdep_setup_blkmapdep(bp, fs, blkno); bdwrite(bp); @@ -1394,7 +1396,7 @@ gotit: } fs->fs_fmod = 1; - blkno = cgp->cg_cgx * fs->fs_fpg + bno; + blkno = (daddr64_t)cgp->cg_cgx * fs->fs_fpg + bno; if (DOINGSOFTDEP(ITOV(ip))) softdep_setup_blkmapdep(bp, fs, blkno); |