summaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-07-22 18:44:26 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-07-22 18:44:26 +0000
commit0ce330d43c73814da55f95ceec87f811685c0922 (patch)
tree1a99637cf65912fc2c353952c2545c6f30457640 /sys/ufs
parentcb4a81c1a7c71ab43ec154018edc2d555cdfe3d0 (diff)
Use cgbase() instead of doing arithmetic on fs_fpg, for the former does
proper casts to ensure the result is not truncated. From FreeBSD via NetBSD. ok thib@
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_alloc.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 9290dc02328..a921c3c2c73 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.83 2008/04/10 19:39:37 thib Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.84 2008/07/22 18:44:25 miod Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */
/*
@@ -1051,7 +1051,7 @@ ffs1_blkpref(struct inode *ip, daddr64_t lbn, int indx, int32_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 (cgbase(fs, cg) + fs->fs_frag);
}
/*
* Find a cylinder with greater than average number of
@@ -1067,12 +1067,12 @@ ffs1_blkpref(struct inode *ip, daddr64_t lbn, int indx, int32_t *bap)
for (cg = startcg; cg < fs->fs_ncg; cg++)
if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
fs->fs_cgrotor = cg;
- return (fs->fs_fpg * cg + fs->fs_frag);
+ return (cgbase(fs, cg) + fs->fs_frag);
}
for (cg = 0; cg <= startcg; cg++)
if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) {
fs->fs_cgrotor = cg;
- return (fs->fs_fpg * cg + fs->fs_frag);
+ return (cgbase(fs, cg) + fs->fs_frag);
}
return (0);
}
@@ -1095,7 +1095,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 ((int64_t)fs->fs_fpg * cg + fs->fs_frag);
+ return (cgbase(fs, cg) + fs->fs_frag);
}
/*
@@ -1113,13 +1113,11 @@ 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 ((int64_t)fs->fs_fpg * cg +
- fs->fs_frag);
+ return (cgbase(fs, cg) + fs->fs_frag);
for (cg = 0; cg < startcg; cg++)
if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree)
- return ((int64_t)fs->fs_fpg * cg +
- fs->fs_frag);
+ return (cgbase(fs, cg) + fs->fs_frag);
return (0);
}