git: d69d55f78b93 - stable/13 - UFS/FFS: Migrate to modern uintXX_t from u_intXX_t.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Sun, 06 Aug 2023 04:31:24 UTC
The branch stable/13 has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=d69d55f78b93f1b639df61a7470b053614548fbb

commit d69d55f78b93f1b639df61a7470b053614548fbb
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-07-27 22:26:01 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-08-06 04:28:53 +0000

    UFS/FFS: Migrate to modern uintXX_t from u_intXX_t.
    
    As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html
    move to the modern uintXX_t. While here also migrate u_char to uint8_t.
    Where other kernel interfaces allow, migrate u_long to uint64_t.
    
    No functional changes intended.
    
    Sponsored-by: The FreeBSD Foundation
    (cherry picked from commit 831b1ff7913fb0b317a258a43dce5abefee03a31)
---
 sys/ufs/ffs/ffs_alloc.c    | 148 +++++++++++++++++++++++----------------------
 sys/ufs/ffs/ffs_extern.h   |  19 +++---
 sys/ufs/ffs/ffs_inode.c    |  10 +--
 sys/ufs/ffs/ffs_rawread.c  |   4 +-
 sys/ufs/ffs/ffs_snapshot.c |  10 +--
 sys/ufs/ffs/ffs_softdep.c  |  28 ++++-----
 sys/ufs/ffs/ffs_subr.c     |  24 ++++----
 sys/ufs/ffs/ffs_tables.c   |   6 +-
 sys/ufs/ffs/ffs_vfsops.c   |  25 ++++----
 sys/ufs/ffs/ffs_vnops.c    |  33 +++++-----
 sys/ufs/ffs/fs.h           |  78 ++++++++++++------------
 sys/ufs/ffs/softdep.h      |   4 +-
 sys/ufs/ufs/dinode.h       |  38 ++++++------
 sys/ufs/ufs/dir.h          |  28 ++++-----
 sys/ufs/ufs/dirhash.h      |   2 +-
 sys/ufs/ufs/extattr.h      |   2 +-
 sys/ufs/ufs/inode.h        |  20 +++---
 sys/ufs/ufs/quota.h        |  46 +++++++-------
 sys/ufs/ufs/ufs_dirhash.c  |   6 +-
 sys/ufs/ufs/ufs_gjournal.c |   6 +-
 sys/ufs/ufs/ufs_lookup.c   |  19 +++---
 sys/ufs/ufs/ufs_quota.c    |  30 ++++-----
 sys/ufs/ufs/ufs_vfsops.c   |   2 +-
 sys/ufs/ufs/ufs_vnops.c    |  14 ++---
 sys/ufs/ufs/ufsmount.h     |  18 +++---
 25 files changed, 312 insertions(+), 308 deletions(-)

diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index c3e6fa3b093c..36181263876c 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -103,10 +103,11 @@ __FBSDID("$FreeBSD$");
 #include <ufs/ffs/ffs_extern.h>
 #include <ufs/ffs/softdep.h>
 
-typedef ufs2_daddr_t allocfcn_t(struct inode *ip, u_int cg, ufs2_daddr_t bpref,
-				  int size, int rsize);
+typedef ufs2_daddr_t allocfcn_t(struct inode *ip, uint64_t cg,
+				  ufs2_daddr_t bpref, int size, int rsize);
 
-static ufs2_daddr_t ffs_alloccg(struct inode *, u_int, ufs2_daddr_t, int, int);
+static ufs2_daddr_t ffs_alloccg(struct inode *, uint64_t, ufs2_daddr_t, int,
+				  int);
 static ufs2_daddr_t
 	      ffs_alloccgblk(struct inode *, struct buf *, ufs2_daddr_t, int);
 static void	ffs_blkfree_cg(struct ufsmount *, struct fs *,
@@ -115,13 +116,14 @@ static void	ffs_blkfree_cg(struct ufsmount *, struct fs *,
 #ifdef INVARIANTS
 static int	ffs_checkblk(struct inode *, ufs2_daddr_t, long);
 #endif
-static ufs2_daddr_t ffs_clusteralloc(struct inode *, u_int, ufs2_daddr_t, int);
+static ufs2_daddr_t ffs_clusteralloc(struct inode *, uint64_t, ufs2_daddr_t,
+				  int);
 static ino_t	ffs_dirpref(struct inode *);
-static ufs2_daddr_t ffs_fragextend(struct inode *, u_int, ufs2_daddr_t,
+static ufs2_daddr_t ffs_fragextend(struct inode *, uint64_t, ufs2_daddr_t,
 		    int, int);
-static ufs2_daddr_t	ffs_hashalloc
-		(struct inode *, u_int, ufs2_daddr_t, int, int, allocfcn_t *);
-static ufs2_daddr_t ffs_nodealloccg(struct inode *, u_int, ufs2_daddr_t, int,
+static ufs2_daddr_t	ffs_hashalloc(struct inode *, uint64_t, ufs2_daddr_t,
+		    int, int, allocfcn_t *);
+static ufs2_daddr_t ffs_nodealloccg(struct inode *, uint64_t, ufs2_daddr_t, int,
 		    int);
 static ufs1_daddr_t ffs_mapsearch(struct fs *, struct cg *, ufs2_daddr_t, int);
 static int	ffs_reallocblks_ufs1(struct vop_reallocblks_args *);
@@ -159,7 +161,7 @@ ffs_alloc(struct inode *ip,
 	struct fs *fs;
 	struct ufsmount *ump;
 	ufs2_daddr_t bno;
-	u_int cg, reclaimed;
+	uint64_t cg, reclaimed;
 	int64_t delta;
 #ifdef QUOTA
 	int error;
@@ -170,7 +172,7 @@ ffs_alloc(struct inode *ip,
 	fs = ump->um_fs;
 	mtx_assert(UFS_MTX(ump), MA_OWNED);
 #ifdef INVARIANTS
-	if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) {
+	if ((uint64_t)size > fs->fs_bsize || fragoff(fs, size) != 0) {
 		printf("dev = %s, bsize = %ld, size = %d, fs = %s\n",
 		    devtoname(ump->um_dev), (long)fs->fs_bsize, size,
 		    fs->fs_fsmnt);
@@ -263,7 +265,7 @@ ffs_realloccg(struct inode *ip,
 	struct fs *fs;
 	struct buf *bp;
 	struct ufsmount *ump;
-	u_int cg, request, reclaimed;
+	uint64_t cg, request, reclaimed;
 	int error, gbflags;
 	ufs2_daddr_t bno;
 	int64_t delta;
@@ -281,8 +283,8 @@ ffs_realloccg(struct inode *ip,
 #ifdef INVARIANTS
 	if (vp->v_mount->mnt_kern_flag & MNTK_SUSPENDED)
 		panic("ffs_realloccg: allocation on suspended filesystem");
-	if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 ||
-	    (u_int)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) {
+	if ((uint64_t)osize > fs->fs_bsize || fragoff(fs, osize) != 0 ||
+	    (uint64_t)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) {
 		printf(
 		"dev = %s, bsize = %ld, osize = %d, nsize = %d, fs = %s\n",
 		    devtoname(ump->um_dev), (long)fs->fs_bsize, osize,
@@ -1117,7 +1119,7 @@ ffs_valloc(struct vnode *pvp,
 	struct timespec ts;
 	struct ufsmount *ump;
 	ino_t ino, ipref;
-	u_int cg;
+	uint64_t cg;
 	int error, reclaimed;
 
 	*vpp = NULL;
@@ -1173,8 +1175,8 @@ retry:
 		panic("ffs_valloc: dup alloc");
 	}
 	if (DIP(ip, i_blocks) && (fs->fs_flags & FS_UNCLEAN) == 0) {  /* XXX */
-		printf("free inode %s/%lu had %ld blocks\n",
-		    fs->fs_fsmnt, (u_long)ino, (long)DIP(ip, i_blocks));
+		printf("free inode %s/%ju had %ld blocks\n",
+		    fs->fs_fsmnt, (intmax_t)ino, (long)DIP(ip, i_blocks));
 		DIP_SET(ip, i_blocks, 0);
 	}
 	ip->i_flags = 0;
@@ -1242,9 +1244,9 @@ ffs_dirpref(struct inode *pip)
 	struct fs *fs;
 	int cg, prefcg, curcg, dirsize, cgsize;
 	int depth, range, start, end, numdirs, power, numerator, denominator;
-	u_int avgifree, avgbfree, avgndir, curdirsize;
-	u_int minifree, minbfree, maxndir;
-	u_int maxcontigdirs;
+	uint64_t avgifree, avgbfree, avgndir, curdirsize;
+	uint64_t minifree, minbfree, maxndir;
+	uint64_t maxcontigdirs;
 
 	mtx_assert(UFS_MTX(ITOUMP(pip)), MA_OWNED);
 	fs = ITOFS(pip);
@@ -1406,8 +1408,8 @@ ffs_blkpref_ufs1(struct inode *ip,
 	ufs1_daddr_t *bap)
 {
 	struct fs *fs;
-	u_int cg, inocg;
-	u_int avgbfree, startcg;
+	uint64_t cg, inocg;
+	uint64_t avgbfree, startcg;
 	ufs2_daddr_t pref, prevbn;
 
 	KASSERT(indx <= 0 || bap != NULL, ("need non-NULL bap"));
@@ -1518,8 +1520,8 @@ ffs_blkpref_ufs2(struct inode *ip,
 	ufs2_daddr_t *bap)
 {
 	struct fs *fs;
-	u_int cg, inocg;
-	u_int avgbfree, startcg;
+	uint64_t cg, inocg;
+	uint64_t avgbfree, startcg;
 	ufs2_daddr_t pref, prevbn;
 
 	KASSERT(indx <= 0 || bap != NULL, ("need non-NULL bap"));
@@ -1634,7 +1636,7 @@ ffs_blkpref_ufs2(struct inode *ip,
 /*VARARGS5*/
 static ufs2_daddr_t
 ffs_hashalloc(struct inode *ip,
-	u_int cg,
+	uint64_t cg,
 	ufs2_daddr_t pref,
 	int size,	/* Search size for data blocks, mode for inodes */
 	int rsize,	/* Real allocated size. */
@@ -1642,7 +1644,7 @@ ffs_hashalloc(struct inode *ip,
 {
 	struct fs *fs;
 	ufs2_daddr_t result;
-	u_int i, icg = cg;
+	uint64_t i, icg = cg;
 
 	mtx_assert(UFS_MTX(ITOUMP(ip)), MA_OWNED);
 #ifdef INVARIANTS
@@ -1692,7 +1694,7 @@ ffs_hashalloc(struct inode *ip,
  */
 static ufs2_daddr_t
 ffs_fragextend(struct inode *ip,
-	u_int cg,
+	uint64_t cg,
 	ufs2_daddr_t bprev,
 	int osize,
 	int nsize)
@@ -1705,7 +1707,7 @@ ffs_fragextend(struct inode *ip,
 	long bno;
 	int frags, bbase;
 	int i, error;
-	u_int8_t *blksfree;
+	uint8_t *blksfree;
 
 	ump = ITOUMP(ip);
 	fs = ump->um_fs;
@@ -1769,7 +1771,7 @@ fail:
  */
 static ufs2_daddr_t
 ffs_alloccg(struct inode *ip,
-	u_int cg,
+	uint64_t cg,
 	ufs2_daddr_t bpref,
 	int size,
 	int rsize)
@@ -1781,7 +1783,7 @@ ffs_alloccg(struct inode *ip,
 	ufs1_daddr_t bno;
 	ufs2_daddr_t blkno;
 	int i, allocsiz, error, frags;
-	u_int8_t *blksfree;
+	uint8_t *blksfree;
 
 	ump = ITOUMP(ip);
 	fs = ump->um_fs;
@@ -1874,7 +1876,7 @@ ffs_alloccgblk(struct inode *ip,
 	struct ufsmount *ump;
 	ufs1_daddr_t bno;
 	ufs2_daddr_t blkno;
-	u_int8_t *blksfree;
+	uint8_t *blksfree;
 	int i, cgbpref;
 
 	ump = ITOUMP(ip);
@@ -1947,7 +1949,7 @@ gotit:
  */
 static ufs2_daddr_t
 ffs_clusteralloc(struct inode *ip,
-	u_int cg,
+	uint64_t cg,
 	ufs2_daddr_t bpref,
 	int len)
 {
@@ -1957,9 +1959,9 @@ ffs_clusteralloc(struct inode *ip,
 	struct ufsmount *ump;
 	int i, run, bit, map, got, error;
 	ufs2_daddr_t bno;
-	u_char *mapp;
+	uint8_t *mapp;
 	int32_t *lp;
-	u_int8_t *blksfree;
+	uint8_t *blksfree;
 
 	ump = ITOUMP(ip);
 	fs = ump->um_fs;
@@ -2057,8 +2059,8 @@ ffs_clusteralloc(struct inode *ip,
 
 static inline struct buf *
 getinobuf(struct inode *ip,
-	u_int cg,
-	u_int32_t cginoblk,
+	uint64_t cg,
+	uint32_t cginoblk,
 	int gbflags)
 {
 	struct fs *fs;
@@ -2090,7 +2092,7 @@ SYSCTL_INT(_vfs_ffs, OID_AUTO, doasyncinodeinit, CTLFLAG_RWTUN,
  */
 static ufs2_daddr_t
 ffs_nodealloccg(struct inode *ip,
-	u_int cg,
+	uint64_t cg,
 	ufs2_daddr_t ipref,
 	int mode,
 	int unused)
@@ -2099,10 +2101,10 @@ ffs_nodealloccg(struct inode *ip,
 	struct cg *cgp;
 	struct buf *bp, *ibp;
 	struct ufsmount *ump;
-	u_int8_t *inosused, *loc;
+	uint8_t *inosused, *loc;
 	struct ufs2_dinode *dp2;
 	int error, start, len, i;
-	u_int32_t old_initediblk;
+	uint32_t old_initediblk;
 
 	ump = ITOUMP(ip);
 	fs = ump->um_fs;
@@ -2134,8 +2136,8 @@ restart:
 		start = 0;
 		loc = memcchr(&inosused[start], 0xff, len);
 		if (loc == NULL) {
-			printf("cg = %d, irotor = %ld, fs = %s\n",
-			    cg, (long)cgp->cg_irotor, fs->fs_fsmnt);
+			printf("cg = %ju, irotor = %ld, fs = %s\n",
+			    (intmax_t)cg, (long)cgp->cg_irotor, fs->fs_fsmnt);
 			panic("ffs_nodealloccg: map corrupted");
 			/* NOTREACHED */
 		}
@@ -2259,8 +2261,8 @@ ffs_blkfree_cg(struct ufsmount *ump,
 	daddr_t dbn;
 	ufs1_daddr_t fragno, cgbno;
 	int i, blk, frags, bbase, error;
-	u_int cg;
-	u_int8_t *blksfree;
+	uint64_t cg;
+	uint8_t *blksfree;
 	struct cdev *dev;
 
 	cg = dtog(fs, bno);
@@ -2278,7 +2280,7 @@ ffs_blkfree_cg(struct ufsmount *ump,
 	} else
 		return;
 #ifdef INVARIANTS
-	if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0 ||
+	if ((uint64_t)size > fs->fs_bsize || fragoff(fs, size) != 0 ||
 	    fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) {
 		printf("dev=%s, bno = %jd, bsize = %ld, size = %ld, fs = %s\n",
 		    devtoname(dev), (intmax_t)bno, (long)fs->fs_bsize,
@@ -2286,9 +2288,9 @@ ffs_blkfree_cg(struct ufsmount *ump,
 		panic("ffs_blkfree_cg: bad size");
 	}
 #endif
-	if ((u_int)bno >= fs->fs_size) {
-		printf("bad block %jd, ino %lu\n", (intmax_t)bno,
-		    (u_long)inum);
+	if ((uint64_t)bno >= fs->fs_size) {
+		printf("bad block %jd, ino %ju\n", (intmax_t)bno,
+		    (intmax_t)inum);
 		ffs_fserr(fs, inum, "bad block");
 		return;
 	}
@@ -2429,7 +2431,7 @@ struct ffs_blkfree_trim_params {
 static void	ffs_blkfree_trim_completed(struct buf *);
 static void	ffs_blkfree_trim_task(void *ctx, int pending __unused);
 static struct	ffs_blkfree_trim_params *trim_lookup(struct ufsmount *,
-		    struct vnode *, ufs2_daddr_t, long, ino_t, u_long, int);
+		    struct vnode *, ufs2_daddr_t, long, ino_t, uint64_t, int);
 static void	ffs_blkfree_sendtrim(struct ffs_blkfree_trim_params *);
 
 /*
@@ -2482,7 +2484,7 @@ trim_lookup(struct ufsmount *ump,
 	ufs2_daddr_t bno,
 	long size,
 	ino_t inum,
-	u_long key,
+	uint64_t key,
 	int alloctype)
 {
 	struct trimlist_hashhead *tphashhead;
@@ -2571,13 +2573,13 @@ ffs_blkfree_sendtrim(struct ffs_blkfree_trim_params *tp)
 /*
  * Allocate a new key to use to identify a range of blocks.
  */
-u_long
+uint64_t
 ffs_blkrelease_start(struct ufsmount *ump,
 	struct vnode *devvp,
 	ino_t inum)
 {
 	static u_long masterkey;
-	u_long key;
+	uint64_t key;
 
 	if (((ump->um_flags & UM_CANDELETE) == 0) || dotrimcons == 0)
 		return (SINGLETON_KEY);
@@ -2592,7 +2594,7 @@ ffs_blkrelease_start(struct ufsmount *ump,
  * Deallocate a key that has been used to identify a range of blocks.
  */
 void
-ffs_blkrelease_finish(struct ufsmount *ump, u_long key)
+ffs_blkrelease_finish(struct ufsmount *ump, uint64_t key)
 {
 	struct ffs_blkfree_trim_params *tp;
 
@@ -2646,7 +2648,7 @@ ffs_blkfree(struct ufsmount *ump,
 	ino_t inum,
 	enum vtype vtype,
 	struct workhead *dephd,
-	u_long key)
+	uint64_t key)
 {
 	struct ffs_blkfree_trim_params *tp, *ntp;
 	struct trim_blkreq *blkelm;
@@ -2754,15 +2756,15 @@ ffs_checkblk(struct inode *ip,
 	struct buf *bp;
 	ufs1_daddr_t cgbno;
 	int i, error, frags, free;
-	u_int8_t *blksfree;
+	uint8_t *blksfree;
 
 	fs = ITOFS(ip);
-	if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) {
+	if ((uint64_t)size > fs->fs_bsize || fragoff(fs, size) != 0) {
 		printf("bsize = %ld, size = %ld, fs = %s\n",
 		    (long)fs->fs_bsize, size, fs->fs_fsmnt);
 		panic("ffs_checkblk: bad size");
 	}
-	if ((u_int)bno >= fs->fs_size)
+	if ((uint64_t)bno >= fs->fs_size)
 		panic("ffs_checkblk: bad block %jd", (intmax_t)bno);
 	error = ffs_getcg(fs, ITODEVVP(ip), dtog(fs, bno), 0, &bp, &cgp);
 	if (error)
@@ -2818,8 +2820,8 @@ ffs_freefile(struct ufsmount *ump,
 	struct buf *bp;
 	daddr_t dbn;
 	int error;
-	u_int cg;
-	u_int8_t *inosused;
+	uint64_t cg;
+	uint8_t *inosused;
 	struct cdev *dev;
 	ino_t cgino;
 
@@ -2895,8 +2897,8 @@ ffs_checkfreefile(struct fs *fs,
 	struct cg *cgp;
 	struct buf *bp;
 	int ret, error;
-	u_int cg;
-	u_int8_t *inosused;
+	uint64_t cg;
+	uint8_t *inosused;
 
 	cg = ino_to_cg(fs, ino);
 	if ((devvp->v_type != VREG) && (devvp->v_type != VCHR))
@@ -2927,7 +2929,7 @@ ffs_mapsearch(struct fs *fs,
 	ufs1_daddr_t bno;
 	int start, len, loc, i;
 	int blk, field, subfield, pos;
-	u_int8_t *blksfree;
+	uint8_t *blksfree;
 
 	/*
 	 * find the fragment by searching through the free block
@@ -2939,15 +2941,15 @@ ffs_mapsearch(struct fs *fs,
 		start = cgp->cg_frotor / NBBY;
 	blksfree = cg_blksfree(cgp);
 	len = howmany(fs->fs_fpg, NBBY) - start;
-	loc = scanc((u_int)len, (u_char *)&blksfree[start],
+	loc = scanc((uint64_t)len, (uint8_t *)&blksfree[start],
 		fragtbl[fs->fs_frag],
-		(u_char)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
+		(uint8_t)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
 	if (loc == 0) {
 		len = start + 1;
 		start = 0;
-		loc = scanc((u_int)len, (u_char *)&blksfree[0],
+		loc = scanc((uint64_t)len, (uint8_t *)&blksfree[0],
 			fragtbl[fs->fs_frag],
-			(u_char)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
+			(uint8_t)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
 		if (loc == 0) {
 			printf("start = %d, len = %d, fs = %s\n",
 			    start, len, fs->fs_fsmnt);
@@ -2973,7 +2975,7 @@ ffs_mapsearch(struct fs *fs,
 			subfield <<= 1;
 		}
 	}
-	printf("bno = %lu, fs = %s\n", (u_long)bno, fs->fs_fsmnt);
+	printf("bno = %ju, fs = %s\n", (intmax_t)bno, fs->fs_fsmnt);
 	panic("ffs_alloccg: block not in map");
 	return (-1);
 }
@@ -2993,7 +2995,7 @@ ffs_getmntstat(struct vnode *devvp)
 int
 ffs_getcg(struct fs *fs,
 	struct vnode *devvp,
-	u_int cg,
+	uint64_t cg,
 	int flags,
 	struct buf **bpp,
 	struct cg **cgpp)
@@ -3021,11 +3023,11 @@ ffs_getcg(struct fs *fs,
 	    (bp->b_flags & B_CKHASH) != 0 &&
 	    cgp->cg_ckhash != bp->b_ckhash) {
 		sfs = ffs_getmntstat(devvp);
-		printf("UFS %s%s (%s) cylinder checksum failed: cg %u, cgp: "
+		printf("UFS %s%s (%s) cylinder checksum failed: cg %ju, cgp: "
 		    "0x%x != bp: 0x%jx\n",
 		    devvp->v_type == VCHR ? "" : "snapshot of ",
 		    sfs->f_mntfromname, sfs->f_mntonname,
-		    cg, cgp->cg_ckhash, (uintmax_t)bp->b_ckhash);
+		    (intmax_t)cg, cgp->cg_ckhash, (uintmax_t)bp->b_ckhash);
 		bp->b_flags &= ~B_CKHASH;
 		bp->b_flags |= B_INVAL | B_NOCACHE;
 		brelse(bp);
@@ -3037,11 +3039,11 @@ ffs_getcg(struct fs *fs,
 		    devvp->v_type == VCHR ? "" : "snapshot of ",
 		    sfs->f_mntfromname, sfs->f_mntonname);
 		if (!cg_chkmagic(cgp))
-			printf(" cg %u: bad magic number 0x%x should be 0x%x\n",
-			    cg, cgp->cg_magic, CG_MAGIC);
+			printf(" cg %ju: bad magic number 0x%x should be "
+			    "0x%x\n", (intmax_t)cg, cgp->cg_magic, CG_MAGIC);
 		else
-			printf(": wrong cylinder group cg %u != cgx %u\n", cg,
-			    cgp->cg_cgx);
+			printf(": wrong cylinder group cg %ju != cgx %u\n",
+			    (intmax_t)cg, cgp->cg_cgx);
 		bp->b_flags &= ~B_CKHASH;
 		bp->b_flags |= B_INVAL | B_NOCACHE;
 		brelse(bp);
@@ -3219,7 +3221,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
 	struct pwd *pwd;
 	ufs2_daddr_t blkno;
 	long blkcnt, blksize;
-	u_long key;
+	uint64_t key;
 	struct file *fp;
 	cap_rights_t rights;
 	int filetype, error;
diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h
index 1ea473e69f52..fb448abe4e5e 100644
--- a/sys/ufs/ffs/ffs_extern.h
+++ b/sys/ufs/ffs/ffs_extern.h
@@ -62,14 +62,15 @@ int	ffs_balloc_ufs1(struct vnode *a_vp, off_t a_startoffset, int a_size,
 int	ffs_balloc_ufs2(struct vnode *a_vp, off_t a_startoffset, int a_size,
             struct ucred *a_cred, int a_flags, struct buf **a_bpp);
 void	ffs_blkfree(struct ufsmount *, struct fs *, struct vnode *,
-	    ufs2_daddr_t, long, ino_t, enum vtype, struct workhead *, u_long);
+	    ufs2_daddr_t, long, ino_t, enum vtype, struct workhead *,
+	    uint64_t);
 ufs2_daddr_t ffs_blkpref_ufs1(struct inode *, ufs_lbn_t, int, ufs1_daddr_t *);
 ufs2_daddr_t ffs_blkpref_ufs2(struct inode *, ufs_lbn_t, int, ufs2_daddr_t *);
-void	ffs_blkrelease_finish(struct ufsmount *, u_long);
-u_long	ffs_blkrelease_start(struct ufsmount *, struct vnode *, ino_t);
+void	ffs_blkrelease_finish(struct ufsmount *, uint64_t);
+uint64_t ffs_blkrelease_start(struct ufsmount *, struct vnode *, ino_t);
 uint32_t ffs_calc_sbhash(struct fs *);
 int	ffs_checkfreefile(struct fs *, struct vnode *, ino_t);
-void	ffs_clrblock(struct fs *, u_char *, ufs1_daddr_t);
+void	ffs_clrblock(struct fs *, uint8_t *, ufs1_daddr_t);
 void	ffs_clusteracct(struct fs *, struct cg *, ufs1_daddr_t, int);
 void	ffs_bdflush(struct bufobj *, struct buf *);
 int	ffs_copyonwrite(struct vnode *, struct buf *);
@@ -78,12 +79,12 @@ void	ffs_fragacct(struct fs *, int, int32_t [], int);
 int	ffs_freefile(struct ufsmount *, struct fs *, struct vnode *, ino_t,
 	    int, struct workhead *);
 void	ffs_fserr(struct fs *, ino_t, char *);
-int	ffs_getcg(struct fs *, struct vnode *, u_int, int, struct buf **,
+int	ffs_getcg(struct fs *, struct vnode *, uint64_t, int, struct buf **,
 	    struct cg **);
-int	ffs_inotovp(struct mount *, ino_t, u_int64_t, int, struct vnode **,
+int	ffs_inotovp(struct mount *, ino_t, uint64_t, int, struct vnode **,
 	    int);
-int	ffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
-int	ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
+int	ffs_isblock(struct fs *, uint8_t *, ufs1_daddr_t);
+int	ffs_isfreeblock(struct fs *, uint8_t *, ufs1_daddr_t);
 void	ffs_oldfscompat_write(struct fs *, struct ufsmount *);
 int	ffs_own_mount(const struct mount *mp);
 int	ffs_reallocblks(struct vop_reallocblks_args *);
@@ -95,7 +96,7 @@ int	ffs_sbget(void *, struct fs **, off_t, struct malloc_type *,
 int	ffs_sbput(void *, struct fs *, off_t, int (*)(void *, off_t, void *,
 	    int));
 int	ffs_sbupdate(struct ufsmount *, int, int);
-void	ffs_setblock(struct fs *, u_char *, ufs1_daddr_t);
+void	ffs_setblock(struct fs *, uint8_t *, ufs1_daddr_t);
 int	ffs_snapblkfree(struct fs *, struct vnode *, ufs2_daddr_t, long, ino_t,
 	    enum vtype, struct workhead *);
 void	ffs_snapremove(struct vnode *vp);
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index d9d4f3c4a155..f54c1d57152e 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -250,7 +250,7 @@ ffs_truncate(struct vnode *vp,
 	int needextclean, extblocks;
 	int offset, size, level, nblocks;
 	int i, error, allerror, indiroff, waitforupdate;
-	u_long key;
+	uint64_t key;
 	off_t osize;
 
 	ip = VTOI(vp);
@@ -339,7 +339,7 @@ ffs_truncate(struct vnode *vp,
 		if (length != 0)
 			panic("ffs_truncate: partial truncate of symlink");
 #endif
-		bzero(DIP(ip, i_shortlink), (u_int)ip->i_size);
+		bzero(DIP(ip, i_shortlink), (uint64_t)ip->i_size);
 		ip->i_size = 0;
 		DIP_SET(ip, i_size, 0);
 		UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
@@ -501,7 +501,7 @@ ffs_truncate(struct vnode *vp,
 		size = blksize(fs, ip, lbn);
 		if (vp->v_type != VDIR && offset != 0)
 			bzero((char *)bp->b_data + offset,
-			    (u_int)(size - offset));
+			    (uint64_t)(size - offset));
 		/* Kirk's code has reallocbuf(bp, size, 1) here */
 		allocbuf(bp, size);
 		if (bp->b_bufsize == fs->fs_bsize)
@@ -704,7 +704,7 @@ ffs_indirtrunc(struct inode *ip,
 	struct ufsmount *ump;
 	struct vnode *vp;
 	caddr_t copy = NULL;
-	u_long key;
+	uint64_t key;
 	int i, nblocks, error = 0, allerror = 0;
 	ufs2_daddr_t nb, nlbn, last;
 	ufs2_daddr_t blkcount, factor, blocksreleased = 0;
@@ -747,7 +747,7 @@ ffs_indirtrunc(struct inode *ip,
 		bap2 = (ufs2_daddr_t *)bp->b_data;
 	if (lastbn != -1) {
 		copy = malloc(fs->fs_bsize, M_TEMP, M_WAITOK);
-		bcopy((caddr_t)bp->b_data, copy, (u_int)fs->fs_bsize);
+		bcopy((caddr_t)bp->b_data, copy, (uint64_t)fs->fs_bsize);
 		for (i = last + 1; i < NINDIR(fs); i++)
 			if (I_IS_UFS1(ip))
 				bap1[i] = 0;
diff --git a/sys/ufs/ffs/ffs_rawread.c b/sys/ufs/ffs/ffs_rawread.c
index 2c1e6bf2b8d2..3def0784a15e 100644
--- a/sys/ufs/ffs/ffs_rawread.c
+++ b/sys/ufs/ffs/ffs_rawread.c
@@ -192,7 +192,7 @@ ffs_rawread_readahead(struct vnode *vp,
 		      struct buf *bp)
 {
 	int error;
-	u_int iolen;
+	uint64_t iolen;
 	off_t blockno;
 	int blockoff;
 	int bsize;
@@ -264,7 +264,7 @@ ffs_rawread_main(struct vnode *vp,
 {
 	int error, nerror;
 	struct buf *bp, *nbp, *tbp;
-	u_int iolen;
+	uint64_t iolen;
 	caddr_t udata;
 	long resid;
 	off_t offset;
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index 907ccb9558be..b606c64241e3 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -376,7 +376,7 @@ restart:
 	 * touch up the few cylinder groups that changed during
 	 * the suspension period.
 	 */
-	len = roundup2(howmany(fs->fs_ncg, NBBY), sizeof(int));
+	len = roundup2(howmany(fs->fs_ncg, NBBY), sizeof(uint64_t));
 	space = malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
 	UFS_LOCK(ump);
 	fs->fs_active = space;
@@ -467,7 +467,7 @@ restart:
 	 * Grab a copy of the superblock and its summary information.
 	 * We delay writing it until the suspension is released below.
 	 */
-	copy_fs = malloc((u_long)fs->fs_bsize, M_UFSMNT, M_WAITOK);
+	copy_fs = malloc((uint64_t)fs->fs_bsize, M_UFSMNT, M_WAITOK);
 	bcopy(fs, copy_fs, fs->fs_sbsize);
 	copy_fs->fs_si = malloc(sizeof(struct fs_summary_info), M_UFSMNT,
 	    M_ZERO | M_WAITOK);
@@ -480,7 +480,7 @@ restart:
 	size = blkroundup(fs, fs->fs_cssize);
 	if (fs->fs_contigsumsize > 0)
 		size += fs->fs_ncg * sizeof(int32_t);
-	space = malloc((u_long)size, M_UFSMNT, M_WAITOK);
+	space = malloc((uint64_t)size, M_UFSMNT, M_WAITOK);
 	copy_fs->fs_csp = space;
 	bcopy(fs->fs_csp, copy_fs->fs_csp, fs->fs_cssize);
 	space = (char *)space + fs->fs_cssize;
@@ -493,7 +493,7 @@ restart:
 			brelse(bp);
 			goto resumefs;
 		}
-		bcopy(bp->b_data, space, (u_int)len);
+		bcopy(bp->b_data, space, (uint64_t)len);
 		space = (char *)space + len;
 		bp->b_flags |= B_INVAL | B_NOCACHE;
 		brelse(bp);
@@ -829,7 +829,7 @@ resumefs:
 		loc = blkoff(fs, fs->fs_sblockloc);
 		copy_fs->fs_fmod = 0;
 		bpfs = (struct fs *)&nbp->b_data[loc];
-		bcopy((caddr_t)copy_fs, (caddr_t)bpfs, (u_int)fs->fs_sbsize);
+		bcopy((caddr_t)copy_fs, (caddr_t)bpfs, (uint64_t)fs->fs_sbsize);
 		ffs_oldfscompat_write(bpfs, ump);
 		bpfs->fs_ckhash = ffs_calc_sbhash(bpfs);
 		bawrite(nbp);
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 75dd5d7e5a5a..6ac3f92fb330 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -831,7 +831,7 @@ static	void cancel_allocdirect(struct allocdirectlst *,
 	    struct allocdirect *, struct freeblks *);
 static	int check_inode_unwritten(struct inodedep *);
 static	int free_inodedep(struct inodedep *);
-static	void freework_freeblock(struct freework *, u_long);
+static	void freework_freeblock(struct freework *, uint64_t);
 static	void freework_enqueue(struct freework *);
 static	int handle_workitem_freeblocks(struct freeblks *, int);
 static	int handle_complete_freeblocks(struct freeblks *, int);
@@ -846,7 +846,7 @@ static	struct allocindir *newallocindir(struct inode *, int, ufs2_daddr_t,
 	    ufs2_daddr_t, ufs_lbn_t);
 static	void handle_workitem_freefrag(struct freefrag *);
 static	struct freefrag *newfreefrag(struct inode *, ufs2_daddr_t, long,
-	    ufs_lbn_t, u_long);
+	    ufs_lbn_t, uint64_t);
 static	void allocdirect_merge(struct allocdirectlst *,
 	    struct allocdirect *, struct allocdirect *);
 static	struct freefrag *allocindir_merge(struct allocindir *,
@@ -1568,7 +1568,7 @@ worklist_speedup(struct mount *mp)
 static void
 softdep_send_speedup(struct ufsmount *ump,
 	off_t shortage,
-	u_int flags)
+	uint64_t flags)
 {
 	struct buf *bp;
 
@@ -2585,7 +2585,7 @@ softdep_mount(struct vnode *devvp,
 	struct ufsmount *ump;
 	struct cg *cgp;
 	struct buf *bp;
-	u_int cyl, i;
+	uint64_t cyl, i;
 	int error;
 
 	ump = VFSTOUFS(mp);
@@ -2750,8 +2750,8 @@ softdep_unmount(struct mount *mp)
 #ifdef INVARIANTS
 	for (int i = 0; i <= D_LAST; i++) {
 		KASSERT(ums->sd_curdeps[i] == 0,
-		    ("Unmount %s: Dep type %s != 0 (%ld)", ump->um_fs->fs_fsmnt,
-		    TYPENAME(i), ums->sd_curdeps[i]));
+		    ("Unmount %s: Dep type %s != 0 (%jd)", ump->um_fs->fs_fsmnt,
+		    TYPENAME(i), (intmax_t)ums->sd_curdeps[i]));
 		KASSERT(LIST_EMPTY(&ums->sd_alldeps[i]),
 		    ("Unmount %s: Dep type %s not empty (%p)",
 		    ump->um_fs->fs_fsmnt,
@@ -5795,7 +5795,7 @@ newfreefrag(struct inode *ip,
 	ufs2_daddr_t blkno,
 	long size,
 	ufs_lbn_t lbn,
-	u_long key)
+	uint64_t key)
 {
 	struct freefrag *freefrag;
 	struct ufsmount *ump;
@@ -7954,7 +7954,7 @@ free_inodedep(struct inodedep *inodedep)
  * in memory immediately.
  */
 static void
-freework_freeblock(struct freework *freework, u_long key)
+freework_freeblock(struct freework *freework, uint64_t key)
 {
 	struct freeblks *freeblks;
 	struct jnewblk *jnewblk;
@@ -8118,7 +8118,7 @@ handle_workitem_freeblocks(struct freeblks *freeblks, int flags)
 	struct allocindir *aip;
 	struct ufsmount *ump;
 	struct worklist *wk;
-	u_long key;
+	uint64_t key;
 
 	KASSERT(LIST_EMPTY(&freeblks->fb_jblkdephd),
 	    ("handle_workitem_freeblocks: Journal entries not written."));
@@ -8306,7 +8306,7 @@ indir_trunc(struct freework *freework,
 	ufs1_daddr_t *bap1;
 	ufs2_daddr_t nb, nnb, *bap2;
 	ufs_lbn_t lbnadd, nlbn;
-	u_long key;
+	uint64_t key;
 	int nblocks, ufs1fmt, freedblocks;
 	int goingaway, freedeps, needj, level, cnt, i, error;
 
@@ -9924,7 +9924,7 @@ clear_unlinked_inodedep( struct inodedep *inodedep)
 		 * that is in the list.
 		 */
 		if (pino == 0) {
-			bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
+			bcopy((caddr_t)fs, bp->b_data, (uint64_t)fs->fs_sbsize);
 			bpfs = (struct fs *)bp->b_data;
 			ffs_oldfscompat_write(bpfs, ump);
 			softdep_setup_sbupdate(ump, bpfs, bp);
@@ -9956,7 +9956,7 @@ clear_unlinked_inodedep( struct inodedep *inodedep)
 			FREE_LOCK(ump);
 			bp = getblk(ump->um_devvp, btodb(fs->fs_sblockloc),
 			    (int)fs->fs_sbsize, 0, 0, 0);
-			bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
+			bcopy((caddr_t)fs, bp->b_data, (uint64_t)fs->fs_sbsize);
 			bpfs = (struct fs *)bp->b_data;
 			ffs_oldfscompat_write(bpfs, ump);
 			softdep_setup_sbupdate(ump, bpfs, bp);
@@ -14781,11 +14781,11 @@ worklist_print(struct worklist *wk, int verbose)
 
 	if (!verbose) {
 		db_printf("%s: %p state 0x%b\n", TYPENAME(wk->wk_type), wk,
-		    (u_int)wk->wk_state, PRINT_SOFTDEP_FLAGS);
+		    wk->wk_state, PRINT_SOFTDEP_FLAGS);
 		return;
 	}
 	db_printf("worklist: %p type %s state 0x%b next %p\n    ", wk,
-	    TYPENAME(wk->wk_type), (u_int)wk->wk_state, PRINT_SOFTDEP_FLAGS,
+	    TYPENAME(wk->wk_type), wk->wk_state, PRINT_SOFTDEP_FLAGS,
 	    LIST_NEXT(wk, wk_list));
 	db_print_ffs(VFSTOUFS(wk->wk_mp));
 }
diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c
index 813736c9d070..ca90f915c9e4 100644
--- a/sys/ufs/ffs/ffs_subr.c
+++ b/sys/ufs/ffs/ffs_subr.c
@@ -201,7 +201,7 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsblock,
 	blks = howmany(size, fs->fs_fsize);
 	if (fs->fs_contigsumsize > 0)
 		size += fs->fs_ncg * sizeof(int32_t);
-	size += fs->fs_ncg * sizeof(u_int8_t);
+	size += fs->fs_ncg * sizeof(uint8_t);
 	/* When running in libufs or libsa, UFS_MALLOC may fail */
 	if ((fs_si = UFS_MALLOC(sizeof(*fs_si), filltype, M_WAITOK)) == NULL) {
 		UFS_FREE(fs, filltype);
@@ -240,8 +240,8 @@ ffs_sbget(void *devfd, struct fs **fsp, off_t altsblock,
 			*lp++ = fs->fs_contigsumsize;
 		space = (uint8_t *)lp;
 	}
-	size = fs->fs_ncg * sizeof(u_int8_t);
-	fs->fs_contigdirs = (u_int8_t *)space;
+	size = fs->fs_ncg * sizeof(uint8_t);
+	fs->fs_contigdirs = (uint8_t *)space;
 	bzero(fs->fs_contigdirs, size);
 	*fsp = fs;
 	return (0);
@@ -362,8 +362,8 @@ SYSCTL_INT(_vfs_ffs, OID_AUTO, prtsberrmsg, CTLFLAG_RWTUN, &prtmsg, 0,
 static int
 validate_sblock(struct fs *fs, int isaltsblk)
 {
-	u_long i, sectorsize;
-	u_int64_t maxfilesize, sizepb;
+	uint64_t i, sectorsize;
+	uint64_t maxfilesize, sizepb;
 	int error;
 
 	error = 0;
@@ -421,14 +421,14 @@ validate_sblock(struct fs *fs, int isaltsblk)
 	CHK(fs->fs_fpg, <, 3 * fs->fs_frag, %jd);
 	CHK(fs->fs_ncg, <, 1, %jd);
 	CHK(fs->fs_ipg, <, fs->fs_inopb, %jd);
-	CHK((u_int64_t)fs->fs_ipg * fs->fs_ncg, >,
+	CHK((uint64_t)fs->fs_ipg * fs->fs_ncg, >,
 	    (((int64_t)(1)) << 32) - INOPB(fs), %jd);
 	CHK(fs->fs_cstotal.cs_nifree, <, 0, %jd);
-	CHK(fs->fs_cstotal.cs_nifree, >, (u_int64_t)fs->fs_ipg * fs->fs_ncg,
+	CHK(fs->fs_cstotal.cs_nifree, >, (uint64_t)fs->fs_ipg * fs->fs_ncg,
 	    %jd);
 	CHK(fs->fs_cstotal.cs_ndir, <, 0, %jd);
 	CHK(fs->fs_cstotal.cs_ndir, >,
-	    ((u_int64_t)fs->fs_ipg * fs->fs_ncg) - fs->fs_cstotal.cs_nifree,
+	    ((uint64_t)fs->fs_ipg * fs->fs_ncg) - fs->fs_cstotal.cs_nifree,
 	    %jd);
 	CHK(fs->fs_sbsize, >, SBLOCKSIZE, %jd);
 	CHK(fs->fs_sbsize, <, (unsigned)sizeof(struct fs), %jd);
@@ -694,7 +694,7 @@ ffs_isblock(struct fs *fs, unsigned char *cp, ufs1_daddr_t h)
  * check if a block is free
  */
 int
-ffs_isfreeblock(struct fs *fs, u_char *cp, ufs1_daddr_t h)
+ffs_isfreeblock(struct fs *fs, uint8_t *cp, ufs1_daddr_t h)
 {
 
 	switch ((int)fs->fs_frag) {
@@ -719,7 +719,7 @@ ffs_isfreeblock(struct fs *fs, u_char *cp, ufs1_daddr_t h)
  * take a block out of the map
  */
 void
-ffs_clrblock(struct fs *fs, u_char *cp, ufs1_daddr_t h)
+ffs_clrblock(struct fs *fs, uint8_t *cp, ufs1_daddr_t h)
 {
 
 	switch ((int)fs->fs_frag) {
@@ -781,9 +781,9 @@ ffs_clusteracct(struct fs *fs, struct cg *cgp, ufs1_daddr_t blkno, int cnt)
 {
 	int32_t *sump;
 	int32_t *lp;
-	u_char *freemapp, *mapp;
+	uint8_t *freemapp, *mapp;
 	int i, start, end, forw, back, map;
-	u_int bit;
+	uint64_t bit;
 
 	if (fs->fs_contigsumsize <= 0)
 		return;
diff --git a/sys/ufs/ffs/ffs_tables.c b/sys/ufs/ffs/ffs_tables.c
index cb00db256e9b..2a91e292b461 100644
--- a/sys/ufs/ffs/ffs_tables.c
+++ b/sys/ufs/ffs/ffs_tables.c
@@ -62,7 +62,7 @@ int inside[9] = {
  * These tables are used by the scanc instruction on the VAX to
  * quickly find an appropriate fragment.
  */
-static u_char fragtbl124[256] = {
+static uint8_t fragtbl124[256] = {
 	0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
 	0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
 	0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
@@ -97,7 +97,7 @@ static u_char fragtbl124[256] = {
 	0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
 };
 
-static u_char fragtbl8[256] = {
+static uint8_t fragtbl8[256] = {
 	0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
 	0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
 	0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
@@ -135,6 +135,6 @@ static u_char fragtbl8[256] = {
 /*
  * The actual fragtbl array.
  */
-u_char *fragtbl[MAXFRAG + 1] = {
+uint8_t *fragtbl[MAXFRAG + 1] = {
 	0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
 };
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 8e719516b9ce..e77d5e336bf1 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -786,7 +786,7 @@ ffs_reload(struct mount *mp, int flags)
 	struct ufsmount *ump;
 	ufs2_daddr_t sblockloc;
 	int i, blks, error;
-	u_long size;
+	uint64_t size;
 	int32_t *lp;
 
 	ump = VFSTOUFS(mp);
@@ -830,7 +830,7 @@ ffs_reload(struct mount *mp, int flags)
 	newfs->fs_si = fs->fs_si;
 	newfs->fs_ronly = fs->fs_ronly;
 	sblockloc = fs->fs_sblockloc;
-	bcopy(newfs, fs, (u_int)fs->fs_sbsize);
+	bcopy(newfs, fs, (uint64_t)fs->fs_sbsize);
 	brelse(bp);
 	ump->um_maxsymlinklen = fs->fs_maxsymlinklen;
 	ffs_oldfscompat_read(fs, VFSTOUFS(mp), sblockloc);
@@ -851,7 +851,7 @@ ffs_reload(struct mount *mp, int flags)
 	blks = howmany(size, fs->fs_fsize);
 	if (fs->fs_contigsumsize > 0)
 		size += fs->fs_ncg * sizeof(int32_t);
-	size += fs->fs_ncg * sizeof(u_int8_t);
+	size += fs->fs_ncg * sizeof(uint8_t);
 	free(fs->fs_csp, M_UFSMNT);
 	space = malloc(size, M_UFSMNT, M_WAITOK);
 	fs->fs_csp = space;
@@ -863,7 +863,7 @@ ffs_reload(struct mount *mp, int flags)
 		    NOCRED, &bp);
 		if (error)
 			return (error);
-		bcopy(bp->b_data, space, (u_int)size);
+		bcopy(bp->b_data, space, (uint64_t)size);
 		space = (char *)space + size;
 		brelse(bp);
 	}
@@ -876,8 +876,8 @@ ffs_reload(struct mount *mp, int flags)
 			*lp++ = fs->fs_contigsumsize;
 		space = lp;
 	}
-	size = fs->fs_ncg * sizeof(u_int8_t);
-	fs->fs_contigdirs = (u_int8_t *)space;
+	size = fs->fs_ncg * sizeof(uint8_t);
+	fs->fs_contigdirs = (uint8_t *)space;
 	bzero(fs->fs_contigdirs, size);
 	if ((flags & FFSR_UNSUSPEND) != 0) {
 		MNT_ILOCK(mp);
@@ -1034,7 +1034,7 @@ ffs_mountfs(struct vnode *odevvp, struct mount *mp, struct thread *td)
 		 * Get journal provider name.
 		 */
 		len = 1024;
-		mp->mnt_gjprovider = malloc((u_long)len, M_UFSMNT, M_WAITOK);
+		mp->mnt_gjprovider = malloc((uint64_t)len, M_UFSMNT, M_WAITOK);
 		if (g_io_getattr("GJOURNAL::provider", cp, &len,
 		    mp->mnt_gjprovider) == 0) {
 			mp->mnt_gjprovider = realloc(mp->mnt_gjprovider, len,
@@ -2070,7 +2070,7 @@ ffs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp)
 int
 ffs_inotovp(struct mount *mp,
 	ino_t ino,
-	u_int64_t gen,
*** 1043 LINES SKIPPED ***