diff options
author | Kirk McKusick <mckusick@FreeBSD.org> | 2003-02-22 00:19:26 +0000 |
---|---|---|
committer | Kirk McKusick <mckusick@FreeBSD.org> | 2003-02-22 00:19:26 +0000 |
commit | d60682c2397f0ed3f390ec1a100c013475ac199d (patch) | |
tree | 910ade0004b73f315e224a338a5a590ad65fac25 /sys | |
parent | 60bf07bd333caf9545f3f624bfe7a6f6bcd16923 (diff) | |
download | src-d60682c2397f0ed3f390ec1a100c013475ac199d.tar.gz src-d60682c2397f0ed3f390ec1a100c013475ac199d.zip |
This patch fixes a bug in the logical block calculation macros so
that they convert to 64-bit values before shifting rather than
afterwards. Once fixed, they can be used rather than inline expanded.
Sponsored by: DARPA & NAI Labs.
Notes
Notes:
svn path=/head/; revision=111238
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ffs/ffs_snapshot.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/fs.h | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 7fe373d7bcaf..6c6fe5eba002 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -254,7 +254,7 @@ restart: * Allocate all cylinder group blocks. */ for (cg = 0; cg < fs->fs_ncg; cg++) { - error = UFS_BALLOC(vp, (off_t)(cgtod(fs, cg)) << fs->fs_fshift, + error = UFS_BALLOC(vp, lfragtosize(fs, cgtod(fs, cg)), fs->fs_bsize, KERNCRED, 0, &nbp); if (error) goto out; @@ -272,7 +272,7 @@ restart: MALLOC(fs->fs_active, int *, len, M_DEVBUF, M_WAITOK); bzero(fs->fs_active, len); for (cg = 0; cg < fs->fs_ncg; cg++) { - error = UFS_BALLOC(vp, (off_t)(cgtod(fs, cg)) << fs->fs_fshift, + error = UFS_BALLOC(vp, lfragtosize(fs, cgtod(fs, cg)), fs->fs_bsize, KERNCRED, 0, &nbp); if (error) goto out; @@ -328,7 +328,7 @@ restart: if ((ACTIVECGNUM(fs, cg) & ACTIVECGOFF(cg)) != 0) continue; redo++; - error = UFS_BALLOC(vp, (off_t)(cgtod(fs, cg)) << fs->fs_fshift, + error = UFS_BALLOC(vp, lfragtosize(fs, cgtod(fs, cg)), fs->fs_bsize, KERNCRED, 0, &nbp); if (error) goto out1; diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h index a441693c6875..3aaa375d4fd9 100644 --- a/sys/ufs/ffs/fs.h +++ b/sys/ufs/ffs/fs.h @@ -496,7 +496,7 @@ struct cg { * Cylinder group macros to locate things in cylinder groups. * They calc filesystem addresses of cylinder group data structures. */ -#define cgbase(fs, c) ((ufs2_daddr_t)((fs)->fs_fpg * (c))) +#define cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c)) #define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ #define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ #define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ @@ -541,9 +541,9 @@ struct cg { #define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ ((loc) & (fs)->fs_qfmask) #define lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \ - ((off_t)(frag) << (fs)->fs_fshift) + (((off_t)(frag)) << (fs)->fs_fshift) #define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \ - ((off_t)(blk) << (fs)->fs_bshift) + (((off_t)(blk)) << (fs)->fs_bshift) /* Use this only when `blk' is known to be small, e.g., < NDADDR. */ #define smalllblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \ ((blk) << (fs)->fs_bshift) @@ -571,7 +571,7 @@ struct cg { #define freespace(fs, percentreserved) \ (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \ (fs)->fs_cstotal.cs_nffree - \ - ((off_t)((fs)->fs_dsize) * (percentreserved) / 100)) + (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100)) /* * Determining the size of a file block in the filesystem. |