diff --git a/lib/libprocstat/common_kvm.c b/lib/libprocstat/common_kvm.c --- a/lib/libprocstat/common_kvm.c +++ b/lib/libprocstat/common_kvm.c @@ -42,8 +42,8 @@ #include #include #include -#define _KERNEL #include +#define _WANT_MOUNT #include #include #include @@ -51,7 +51,6 @@ #include #include #include -#undef _KERNEL #include #include #include diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -68,15 +68,12 @@ #include #include #include -#define _KERNEL +#define _WANT_MOUNT #include #include #include -#include -#include #include #include -#undef _KERNEL #include #include #include diff --git a/lib/libprocstat/zfs_defs.c b/lib/libprocstat/zfs_defs.c --- a/lib/libprocstat/zfs_defs.c +++ b/lib/libprocstat/zfs_defs.c @@ -71,7 +71,7 @@ long va_spare; /* remain quad aligned */ }; - +#define _WANT_MOUNT #include #include diff --git a/lib/libufs/block.c b/lib/libufs/block.c --- a/lib/libufs/block.c +++ b/lib/libufs/block.c @@ -36,6 +36,8 @@ #include #include +#include +#include #include #include #include diff --git a/lib/libufs/cgroup.c b/lib/libufs/cgroup.c --- a/lib/libufs/cgroup.c +++ b/lib/libufs/cgroup.c @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include #include diff --git a/lib/libufs/inode.c b/lib/libufs/inode.c --- a/lib/libufs/inode.c +++ b/lib/libufs/inode.c @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include #include diff --git a/lib/libufs/sblock.c b/lib/libufs/sblock.c --- a/lib/libufs/sblock.c +++ b/lib/libufs/sblock.c @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include #include diff --git a/lib/libufs/type.c b/lib/libufs/type.c --- a/lib/libufs/type.c +++ b/lib/libufs/type.c @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include #include diff --git a/sbin/dump/main.c b/sbin/dump/main.c --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -48,6 +48,8 @@ #include #include +#include +#include #include #include #include diff --git a/sbin/ffsinfo/ffsinfo.c b/sbin/ffsinfo/ffsinfo.c --- a/sbin/ffsinfo/ffsinfo.c +++ b/sbin/ffsinfo/ffsinfo.c @@ -59,6 +59,8 @@ #include #include +#include +#include #include #include #include diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c --- a/sbin/fsck_ffs/suj.c +++ b/sbin/fsck_ffs/suj.c @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include #include diff --git a/sbin/mksnap_ffs/mksnap_ffs.c b/sbin/mksnap_ffs/mksnap_ffs.c --- a/sbin/mksnap_ffs/mksnap_ffs.c +++ b/sbin/mksnap_ffs/mksnap_ffs.c @@ -40,7 +40,11 @@ #include #include #include + +#include +#include #include + #include #include #include diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -65,6 +65,8 @@ #include #include #include +#include +#include #include #include diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c --- a/sbin/tunefs/tunefs.c +++ b/sbin/tunefs/tunefs.c @@ -51,6 +51,8 @@ #include #include +#include +#include #include #include #include diff --git a/sys/conf/options b/sys/conf/options --- a/sys/conf/options +++ b/sys/conf/options @@ -570,7 +570,6 @@ # Misc debug flags. Most of these should probably be replaced with # 'DEBUG', and then let people recompile just the interesting modules # with 'make CC="cc -DDEBUG"'. -CLUSTERDEBUG opt_debug_cluster.h DEBUG_1284 opt_ppb_1284.h LPT_DEBUG opt_lpt.h PLIP_DEBUG opt_plip.h diff --git a/sys/fs/devfs/devfs.h b/sys/fs/devfs/devfs.h --- a/sys/fs/devfs/devfs.h +++ b/sys/fs/devfs/devfs.h @@ -124,6 +124,8 @@ MALLOC_DECLARE(M_DEVFS); #endif +#endif /* _KERNEL */ + struct componentname; TAILQ_HEAD(devfs_dlist_head, devfs_dirent); @@ -156,6 +158,9 @@ int de_usecount; }; +#include +#include + struct devfs_mount { u_int dm_idx; struct mount *dm_mount; @@ -168,6 +173,8 @@ #define DEVFS_ROOTINO 2 +#ifdef _KERNEL + extern unsigned devfs_rule_depth; #define VFSTODEVFS(mp) ((struct devfs_mount *)((mp)->mnt_data)) diff --git a/sys/fs/devfs/devfs_int.h b/sys/fs/devfs/devfs_int.h --- a/sys/fs/devfs/devfs_int.h +++ b/sys/fs/devfs/devfs_int.h @@ -37,8 +37,6 @@ #include -#ifdef _KERNEL - struct devfs_dirent; struct devfs_mount; @@ -76,6 +74,8 @@ #define cdev2priv(c) __containerof(c, struct cdev_priv, cdp_c) +#ifdef _KERNEL + struct cdev *devfs_alloc(int); int devfs_dev_exists(const char *); void devfs_free(struct cdev *); diff --git a/sys/fs/ext2fs/ext2_inode.c b/sys/fs/ext2fs/ext2_inode.c --- a/sys/fs/ext2fs/ext2_inode.c +++ b/sys/fs/ext2fs/ext2_inode.c @@ -581,6 +581,7 @@ error = ext2_ext_truncate(vp, length, flags, cred, td); else error = ext2_ind_truncate(vp, length, flags, cred, td); + cluster_init_vn(&ip->i_clusterw); return (error); } diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -1229,6 +1229,7 @@ ip->i_e2fs = fs = ump->um_e2fs; ip->i_ump = ump; ip->i_number = ino; + cluster_init_vn(&ip->i_clusterw); lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); error = insmntque(vp, mp); diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -2313,7 +2313,8 @@ } else if (xfersize + blkoffset == fs->e2fs_fsize) { if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) { bp->b_flags |= B_CLUSTEROK; - cluster_write(vp, bp, ip->i_size, seqcount, 0); + cluster_write(vp, &ip->i_clusterw, bp, + ip->i_size, seqcount, 0); } else { bawrite(bp); } diff --git a/sys/fs/ext2fs/inode.h b/sys/fs/ext2fs/inode.h --- a/sys/fs/ext2fs/inode.h +++ b/sys/fs/ext2fs/inode.h @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -118,6 +119,8 @@ }; struct ext4_extent_cache i_ext_cache; /* cache for ext4 extent */ + + struct vn_clusterw i_clusterw; /* Buffer clustering information */ }; /* diff --git a/sys/fs/fuse/fuse_io.c b/sys/fs/fuse/fuse_io.c --- a/sys/fs/fuse/fuse_io.c +++ b/sys/fs/fuse/fuse_io.c @@ -870,7 +870,8 @@ bp->b_flags |= B_CLUSTEROK; SDT_PROBE2(fusefs, , io, write_biobackend_issue, 4, bp); - cluster_write(vp, bp, filesize, seqcount, 0); + cluster_write(vp, &fvdat->clusterw, bp, + filesize, seqcount, 0); } else { SDT_PROBE2(fusefs, , io, write_biobackend_issue, 5, bp); diff --git a/sys/fs/fuse/fuse_node.h b/sys/fs/fuse/fuse_node.h --- a/sys/fs/fuse/fuse_node.h +++ b/sys/fs/fuse/fuse_node.h @@ -68,6 +68,7 @@ #include #include #include +#include #include "fuse_file.h" @@ -118,6 +119,7 @@ struct vattr cached_attrs; uint64_t nlookup; enum vtype vtype; + struct vn_clusterw clusterw; }; /* diff --git a/sys/fs/fuse/fuse_node.c b/sys/fs/fuse/fuse_node.c --- a/sys/fs/fuse/fuse_node.c +++ b/sys/fs/fuse/fuse_node.c @@ -164,6 +164,7 @@ } vp->v_type = vtyp; vp->v_data = fvdat; + cluster_init_vn(&fvdat->clusterw); counter_u64_add(fuse_node_count, 1); } diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -52,6 +52,8 @@ #ifndef _FS_MSDOSFS_DENODE_H_ #define _FS_MSDOSFS_DENODE_H_ +#include + /* * This is the pc filesystem specific portion of the vnode structure. * @@ -142,6 +144,7 @@ */ struct denode { struct vnode *de_vnode; /* addr of vnode we are part of */ + struct vn_clusterw de_clusterw; /* buffer clustering information */ u_long de_flag; /* flag bits */ u_long de_dirclust; /* cluster of the directory file containing this entry */ u_long de_diroffset; /* offset of this entry in the directory cluster */ @@ -271,6 +274,7 @@ /* * Internal service routine prototypes. */ +struct componentname; int deget(struct msdosfsmount *, u_long, u_long, struct denode **); int uniqdosname(struct denode *, struct componentname *, u_char *); diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -162,6 +162,7 @@ ldep->de_dirclust = dirclust; ldep->de_diroffset = diroffset; ldep->de_inode = inode; + cluster_init_vn(&ldep->de_clusterw); lockmgr(nvp->v_vnlock, LK_EXCLUSIVE, NULL); fc_purge(ldep, 0); /* init the FAT cache for this denode */ error = insmntque(nvp, mntp); diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -796,8 +796,8 @@ bawrite(bp); else if (n + croffset == pmp->pm_bpcluster) { if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) - cluster_write(vp, bp, dep->de_FileSize, - seqcount, 0); + cluster_write(vp, &dep->de_clusterw, bp, + dep->de_FileSize, seqcount, 0); else bawrite(bp); } else diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -36,8 +36,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_debug_cluster.h" - #include #include #include @@ -56,18 +54,12 @@ #include #include -#if defined(CLUSTERDEBUG) -static int rcluster= 0; -SYSCTL_INT(_debug, OID_AUTO, rcluster, CTLFLAG_RW, &rcluster, 0, - "Debug VFS clustering code"); -#endif - static MALLOC_DEFINE(M_SEGMENT, "cl_savebuf", "cluster_save buffer"); static uma_zone_t cluster_pbuf_zone; static void cluster_init(void *); static struct cluster_save *cluster_collectbufs(struct vnode *vp, - struct buf *last_bp, int gbflags); + struct vn_clusterw *vnc, struct buf *last_bp, int gbflags); static struct buf *cluster_rbuild(struct vnode *vp, u_quad_t filesize, daddr_t lbn, daddr_t blkno, long size, int run, int gbflags, struct buf *fbp); @@ -651,8 +643,8 @@ * 4. end of a cluster - asynchronously write cluster */ void -cluster_write(struct vnode *vp, struct buf *bp, u_quad_t filesize, int seqcount, - int gbflags) +cluster_write(struct vnode *vp, struct vn_clusterw *vnc, struct buf *bp, + u_quad_t filesize, int seqcount, int gbflags) { daddr_t lbn; int maxclen, cursize; @@ -674,12 +666,12 @@ /* Initialize vnode to beginning of file. */ if (lbn == 0) - vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0; + vnc->v_lasta = vnc->v_clen = vnc->v_cstart = vnc->v_lastw = 0; - if (vp->v_clen == 0 || lbn != vp->v_lastw + 1 || - (bp->b_blkno != vp->v_lasta + btodb(lblocksize))) { + if (vnc->v_clen == 0 || lbn != vnc->v_lastw + 1 || + (bp->b_blkno != vnc->v_lasta + btodb(lblocksize))) { maxclen = vp->v_mount->mnt_iosize_max / lblocksize - 1; - if (vp->v_clen != 0) { + if (vnc->v_clen != 0) { /* * Next block is not sequential. * @@ -696,18 +688,19 @@ * later on in the buf_daemon or update daemon * flush. */ - cursize = vp->v_lastw - vp->v_cstart + 1; - if (((u_quad_t) bp->b_offset + lblocksize) != filesize || - lbn != vp->v_lastw + 1 || vp->v_clen <= cursize) { + cursize = vnc->v_lastw - vnc->v_cstart + 1; + if ((u_quad_t)bp->b_offset + lblocksize != filesize || + lbn != vnc->v_lastw + 1 || vnc->v_clen <= cursize) { if (!async && seqcount > 0) { cluster_wbuild_wb(vp, lblocksize, - vp->v_cstart, cursize, gbflags); + vnc->v_cstart, cursize, gbflags); } } else { struct buf **bpp, **endbp; struct cluster_save *buflist; - buflist = cluster_collectbufs(vp, bp, gbflags); + buflist = cluster_collectbufs(vp, vnc, bp, + gbflags); if (buflist == NULL) { /* * Cluster build failed so just write @@ -733,7 +726,7 @@ free(buflist, M_SEGMENT); if (seqcount > 1) { cluster_wbuild_wb(vp, - lblocksize, vp->v_cstart, + lblocksize, vnc->v_cstart, cursize, gbflags); } } else { @@ -744,8 +737,8 @@ bpp <= endbp; bpp++) bdwrite(*bpp); free(buflist, M_SEGMENT); - vp->v_lastw = lbn; - vp->v_lasta = bp->b_blkno; + vnc->v_lastw = lbn; + vnc->v_lasta = bp->b_blkno; return; } } @@ -755,27 +748,27 @@ * cluster as large as possible, otherwise find size of * existing cluster. */ - if ((vp->v_type == VREG) && - ((u_quad_t) bp->b_offset + lblocksize) != filesize && - (bp->b_blkno == bp->b_lblkno) && - (VOP_BMAP(vp, lbn, NULL, &bp->b_blkno, &maxclen, NULL) || - bp->b_blkno == -1)) { + if (vp->v_type == VREG && + (u_quad_t) bp->b_offset + lblocksize != filesize && + bp->b_blkno == bp->b_lblkno && + (VOP_BMAP(vp, lbn, NULL, &bp->b_blkno, &maxclen, + NULL) != 0 || bp->b_blkno == -1)) { bawrite(bp); - vp->v_clen = 0; - vp->v_lasta = bp->b_blkno; - vp->v_cstart = lbn + 1; - vp->v_lastw = lbn; + vnc->v_clen = 0; + vnc->v_lasta = bp->b_blkno; + vnc->v_cstart = lbn + 1; + vnc->v_lastw = lbn; return; } - vp->v_clen = maxclen; + vnc->v_clen = maxclen; if (!async && maxclen == 0) { /* I/O not contiguous */ - vp->v_cstart = lbn + 1; + vnc->v_cstart = lbn + 1; bawrite(bp); } else { /* Wait for rest of cluster */ - vp->v_cstart = lbn; + vnc->v_cstart = lbn; bdwrite(bp); } - } else if (lbn == vp->v_cstart + vp->v_clen) { + } else if (lbn == vnc->v_cstart + vnc->v_clen) { /* * At end of cluster, write it out if seqcount tells us we * are operating sequentially, otherwise let the buf or @@ -783,11 +776,11 @@ */ bdwrite(bp); if (seqcount > 1) { - cluster_wbuild_wb(vp, lblocksize, vp->v_cstart, - vp->v_clen + 1, gbflags); + cluster_wbuild_wb(vp, lblocksize, vnc->v_cstart, + vnc->v_clen + 1, gbflags); } - vp->v_clen = 0; - vp->v_cstart = lbn + 1; + vnc->v_clen = 0; + vnc->v_cstart = lbn + 1; } else if (vm_page_count_severe()) { /* * We are low on memory, get it going NOW @@ -799,8 +792,8 @@ */ bdwrite(bp); } - vp->v_lastw = lbn; - vp->v_lasta = bp->b_blkno; + vnc->v_lastw = lbn; + vnc->v_lasta = bp->b_blkno; } /* @@ -1047,19 +1040,20 @@ * Plus add one additional buffer. */ static struct cluster_save * -cluster_collectbufs(struct vnode *vp, struct buf *last_bp, int gbflags) +cluster_collectbufs(struct vnode *vp, struct vn_clusterw *vnc, + struct buf *last_bp, int gbflags) { struct cluster_save *buflist; struct buf *bp; daddr_t lbn; int i, j, len, error; - len = vp->v_lastw - vp->v_cstart + 1; + len = vnc->v_lastw - vnc->v_cstart + 1; buflist = malloc(sizeof(struct buf *) * (len + 1) + sizeof(*buflist), M_SEGMENT, M_WAITOK); buflist->bs_nchildren = 0; buflist->bs_children = (struct buf **) (buflist + 1); - for (lbn = vp->v_cstart, i = 0; i < len; lbn++, i++) { + for (lbn = vnc->v_cstart, i = 0; i < len; lbn++, i++) { error = bread_gb(vp, lbn, last_bp->b_bcount, NOCRED, gbflags, &bp); if (error != 0) { @@ -1083,3 +1077,12 @@ buflist->bs_nchildren = i + 1; return (buflist); } + +void +cluster_init_vn(struct vn_clusterw *vnc) +{ + vnc->v_lasta = 0; + vnc->v_clen = 0; + vnc->v_cstart = 0; + vnc->v_lastw = 0; +} diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1823,7 +1823,6 @@ vp->v_unpcb = NULL; vp->v_rdev = NULL; vp->v_fifoinfo = NULL; - vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0; vp->v_iflag = 0; vp->v_vflag = 0; bo->bo_flag = 0; diff --git a/sys/sys/buf.h b/sys/sys/buf.h --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -132,7 +132,8 @@ union { TAILQ_ENTRY(buf) b_freelist; /* (Q) */ struct { - void (*b_pgiodone)(void *, vm_page_t *, int, int); + void (*b_pgiodone)(void *, struct vm_page *, + int, int); int b_pgbefore; int b_pgafter; }; @@ -406,6 +407,16 @@ struct buf **bs_children; /* List of associated buffers. */ }; +/* + * Vnode clustering tracker + */ +struct vn_clusterw { + daddr_t v_cstart; /* v start block of cluster */ + daddr_t v_lasta; /* v last allocation */ + daddr_t v_lastw; /* v last write */ + int v_clen; /* v length of cur. cluster */ +}; + #ifdef _KERNEL static __inline int @@ -570,10 +581,14 @@ extern uma_zone_t pbuf_zone; uma_zone_t pbuf_zsecond_create(const char *name, int max); +struct vn_clusterw; + +void cluster_init_vn(struct vn_clusterw *vnc); int cluster_read(struct vnode *, u_quad_t, daddr_t, long, struct ucred *, long, int, int, struct buf **); int cluster_wbuild(struct vnode *, long, daddr_t, int, int); -void cluster_write(struct vnode *, struct buf *, u_quad_t, int, int); +void cluster_write(struct vnode *, struct vn_clusterw *, struct buf *, + u_quad_t, int, int); void vfs_bio_brelse(struct buf *bp, int ioflags); void vfs_bio_bzero_buf(struct buf *bp, int base, int size); void vfs_bio_clrbuf(struct buf *); diff --git a/sys/sys/mount.h b/sys/sys/mount.h --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -163,7 +163,9 @@ */ long f_spare[2]; /* unused spare */ }; +#endif /* _KERNEL */ +#if defined(_WANT_MOUNT) || defined(_KERNEL) TAILQ_HEAD(vnodelst, vnode); /* Mount options list */ @@ -243,7 +245,9 @@ TAILQ_ENTRY(mount) mnt_upper_link; /* (m) we in the all uppers */ TAILQ_HEAD(, mount) mnt_uppers; /* (m) upper mounts over us*/ }; +#endif /* _WANT_MOUNT || _KERNEL */ +#ifdef _KERNEL /* * Definitions for MNT_VNODE_FOREACH_ALL. */ diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h --- a/sys/sys/pipe.h +++ b/sys/sys/pipe.h @@ -24,10 +24,6 @@ #ifndef _SYS_PIPE_H_ #define _SYS_PIPE_H_ -#ifndef _KERNEL -#error "no user-serviceable parts inside" -#endif - /* * Pipe buffer size, keep moderate in value, pipes take kva space. */ @@ -53,11 +49,13 @@ #define PIPENPAGES (BIG_PIPE_SIZE / PAGE_SIZE + 1) +#ifdef _KERNEL /* * See sys_pipe.c for info on what these limits mean. */ extern long maxpipekva; extern struct fileops pipeops; +#endif /* * Pipe buffer information. @@ -147,7 +145,9 @@ #define PIPE_UNLOCK(pipe) mtx_unlock(PIPE_MTX(pipe)) #define PIPE_LOCK_ASSERT(pipe, type) mtx_assert(PIPE_MTX(pipe), (type)) +#ifdef _KERNEL void pipe_dtor(struct pipe *dpipe); int pipe_named_ctor(struct pipe **ppipe, struct thread *td); void pipeselwakeup(struct pipe *cpipe); +#endif #endif /* !_SYS_PIPE_H_ */ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -163,14 +163,6 @@ struct lockf *v_lockf; /* Byte-level advisory lock list */ struct rangelock v_rl; /* Byte-range lock */ - /* - * clustering stuff - */ - daddr_t v_cstart; /* v start block of cluster */ - daddr_t v_lasta; /* v last allocation */ - daddr_t v_lastw; /* v last write */ - int v_clen; /* v length of cur. cluster */ - u_int v_holdcnt; /* I prevents recycling. */ u_int v_usecount; /* I ref count of users */ u_short v_iflag; /* i vnode flags (see below) */ diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -354,7 +354,7 @@ panic("ffs_truncate: read-only filesystem"); if (IS_SNAPSHOT(ip)) ffs_snapremove(vp); - vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0; + cluster_init_vn(&ip->i_clusterw); osize = ip->i_size; /* * Lengthen the size of the file. We must ensure that the diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2011,6 +2011,7 @@ ip->i_nextclustercg = -1; ip->i_flag = fs->fs_magic == FS_UFS1_MAGIC ? 0 : IN_UFS2; ip->i_mode = 0; /* ensure error cases below throw away vnode */ + cluster_init_vn(&ip->i_clusterw); #ifdef DIAGNOSTIC ufs_init_trackers(ip); #endif diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -976,8 +976,8 @@ } else if (xfersize + blkoffset == fs->fs_bsize) { if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) { bp->b_flags |= B_CLUSTEROK; - cluster_write(vp, bp, ip->i_size, seqcount, - GB_UNMAPPED); + cluster_write(vp, &ip->i_clusterw, bp, + ip->i_size, seqcount, GB_UNMAPPED); } else { bawrite(bp); } diff --git a/sys/ufs/ufs/extattr.h b/sys/ufs/ufs/extattr.h --- a/sys/ufs/ufs/extattr.h +++ b/sys/ufs/ufs/extattr.h @@ -104,10 +104,6 @@ #define EXTATTR_BASE_LENGTH(eap) \ roundup2((sizeof(struct extattr) - 1 + (eap)->ea_namelength), 8) -#ifdef _KERNEL - -#include - struct vnode; LIST_HEAD(ufs_extattr_list_head, ufs_extattr_list_entry); struct ufs_extattr_list_entry { @@ -118,6 +114,9 @@ struct vnode *uele_backing_vnode; }; +#include +#include + struct ucred; struct ufs_extattr_per_mount { struct sx uepm_lock; @@ -126,6 +125,8 @@ int uepm_flags; }; +#ifdef _KERNEL + struct vop_getextattr_args; struct vop_deleteextattr_args; struct vop_setextattr_args; diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -47,6 +47,7 @@ #ifdef DIAGNOSTIC #include #endif +#include /* * This must agree with the definition in . @@ -115,6 +116,8 @@ int i_nextclustercg; /* last cg searched for cluster */ + struct vn_clusterw i_clusterw; /* Buffer clustering information */ + /* * Data for extended attribute modification. */ @@ -207,14 +210,14 @@ #define i_din1 dinode_u.din1 #define i_din2 dinode_u.din2 -#ifdef _KERNEL - #define ITOUMP(ip) ((ip)->i_ump) #define ITODEV(ip) (ITOUMP(ip)->um_dev) #define ITODEVVP(ip) (ITOUMP(ip)->um_devvp) #define ITOFS(ip) (ITOUMP(ip)->um_fs) #define ITOVFS(ip) ((ip)->i_vnode->v_mount) +#ifdef _KERNEL + static inline _Bool I_IS_UFS1(const struct inode *ip) { @@ -228,6 +231,7 @@ return ((ip->i_flag & IN_UFS2) != 0); } +#endif /* _KERNEL */ /* * The DIP macro is used to access fields in the dinode that are @@ -275,6 +279,7 @@ uint32_t ufid_gen; /* Generation number. */ }; +#ifdef _KERNEL #ifdef DIAGNOSTIC void ufs_init_trackers(struct inode *ip); void ufs_unlock_tracker(struct inode *ip); diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -43,14 +43,14 @@ struct oexport_args export; /* network export information */ }; -#ifdef _KERNEL - #include +#ifdef _KERNEL #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_UFSMNT); MALLOC_DECLARE(M_TRIM); #endif +#endif /* _KERNEL */ struct buf; struct inode; @@ -72,6 +72,9 @@ fsid_t fsid; }; +#include +#include + /* * This structure describes the UFS specific mount structure data. * The function operators are used to support different versions of @@ -190,6 +193,5 @@ #define MNINDIR(ump) ((ump)->um_nindir) #define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) #define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) -#endif /* _KERNEL */ #endif diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c --- a/usr.sbin/makefs/ffs.c +++ b/usr.sbin/makefs/ffs.c @@ -90,9 +90,6 @@ #include #include -#include "makefs.h" -#include "ffs.h" - #if HAVE_STRUCT_STATVFS_F_IOSIZE && HAVE_FSTATVFS #include #endif @@ -101,12 +98,15 @@ #include #include - #include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/newfs_extern.h" #include "ffs/ffs_extern.h" +#undef clrbuf +#include "makefs.h" +#include "ffs.h" + #undef DIP #define DIP(dp, field) \ ((ffs_opts->version == 1) ? \ @@ -896,9 +896,9 @@ off_t bufleft, chunk, offset; ssize_t nread; struct inode in; - struct buf * bp; + struct m_buf * bp; ffs_opt_t *ffs_opts = fsopts->fs_specific; - struct vnode vp = { fsopts, NULL }; + struct m_vnode vp = { fsopts, NULL }; assert (din != NULL); assert (buf != NULL); @@ -911,7 +911,7 @@ p = NULL; in.i_fs = (struct fs *)fsopts->superblock; - in.i_devvp = &vp; + in.i_devvp = (void *)&vp; if (debug & DEBUG_FS_WRITE_FILE) { printf( diff --git a/usr.sbin/makefs/ffs/buf.h b/usr.sbin/makefs/ffs/buf.h --- a/usr.sbin/makefs/ffs/buf.h +++ b/usr.sbin/makefs/ffs/buf.h @@ -49,12 +49,12 @@ struct makefs_fsinfo; struct ucred; -struct vnode { +struct m_vnode { struct makefs_fsinfo *fs; void *v_data; }; -struct buf { +struct m_buf { char * b_data; long b_bufsize; long b_bcount; @@ -62,15 +62,15 @@ daddr_t b_lblkno; struct makefs_fsinfo *b_fs; - TAILQ_ENTRY(buf) b_tailq; + TAILQ_ENTRY(m_buf) b_tailq; }; void bcleanup(void); -int bread(struct vnode *, daddr_t, int, struct ucred *, - struct buf **); -void brelse(struct buf *); -int bwrite(struct buf *); -struct buf * getblk(struct vnode *, daddr_t, int, int, int, int); +int bread(struct m_vnode *, daddr_t, int, struct ucred *, + struct m_buf **); +void brelse(struct m_buf *); +int bwrite(struct m_buf *); +struct m_buf * getblk(struct m_vnode *, daddr_t, int, int, int, int); #define bdwrite(bp) bwrite(bp) #define clrbuf(bp) memset((bp)->b_data, 0, (u_int)(bp)->b_bcount) diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c --- a/usr.sbin/makefs/ffs/buf.c +++ b/usr.sbin/makefs/ffs/buf.c @@ -54,11 +54,11 @@ #include "makefs.h" #include "buf.h" -static TAILQ_HEAD(buftailhead,buf) buftail; +static TAILQ_HEAD(buftailhead, m_buf) buftail; int -bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused, - struct buf **bpp) +bread(struct m_vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused, + struct m_buf **bpp) { off_t offset; ssize_t rv; @@ -93,7 +93,7 @@ } void -brelse(struct buf *bp) +brelse(struct m_buf *bp) { assert (bp != NULL); @@ -123,7 +123,7 @@ } int -bwrite(struct buf *bp) +bwrite(struct m_buf *bp) { off_t offset; ssize_t rv; @@ -152,7 +152,7 @@ void bcleanup(void) { - struct buf *bp; + struct m_buf *bp; /* * XXX this really shouldn't be necessary, but i'm curious to @@ -172,12 +172,12 @@ printf("bcleanup: done\n"); } -struct buf * -getblk(struct vnode *vp, daddr_t blkno, int size, int u1 __unused, +struct m_buf * +getblk(struct m_vnode *vp, daddr_t blkno, int size, int u1 __unused, int u2 __unused, int u3 __unused) { static int buftailinitted; - struct buf *bp; + struct m_buf *bp; void *n; if (debug & DEBUG_BUF_GETBLK) diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c --- a/usr.sbin/makefs/ffs/ffs_alloc.c +++ b/usr.sbin/makefs/ffs/ffs_alloc.c @@ -65,7 +65,7 @@ static int scanc(u_int, const u_char *, const u_char *, int); static daddr_t ffs_alloccg(struct inode *, int, daddr_t, int); -static daddr_t ffs_alloccgblk(struct inode *, struct buf *, daddr_t); +static daddr_t ffs_alloccgblk(struct inode *, struct m_buf *, daddr_t); static daddr_t ffs_hashalloc(struct inode *, u_int, daddr_t, int, daddr_t (*)(struct inode *, int, daddr_t, int)); static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int); @@ -294,7 +294,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size) { struct cg *cgp; - struct buf *bp; + struct m_buf *bp; daddr_t bno, blkno; int error, frags, allocsiz, i; struct fs *fs = ip->i_fs; @@ -302,8 +302,8 @@ if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize) return (0); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, - NULL, &bp); + error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NULL, &bp); if (error) { brelse(bp); return (0); @@ -377,7 +377,7 @@ * blocks may be fragmented by the routine that allocates them. */ static daddr_t -ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref) +ffs_alloccgblk(struct inode *ip, struct m_buf *bp, daddr_t bpref) { struct cg *cgp; daddr_t blkno; @@ -429,7 +429,7 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size) { struct cg *cgp; - struct buf *bp; + struct m_buf *bp; int32_t fragno, cgbno; int i, error, cg, blk, frags, bbase; struct fs *fs = ip->i_fs; @@ -446,8 +446,8 @@ (uintmax_t)ip->i_number); return; } - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, - NULL, &bp); + error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NULL, &bp); if (error) { brelse(bp); return; diff --git a/usr.sbin/makefs/ffs/ffs_balloc.c b/usr.sbin/makefs/ffs/ffs_balloc.c --- a/usr.sbin/makefs/ffs/ffs_balloc.c +++ b/usr.sbin/makefs/ffs/ffs_balloc.c @@ -56,8 +56,8 @@ #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" -static int ffs_balloc_ufs1(struct inode *, off_t, int, struct buf **); -static int ffs_balloc_ufs2(struct inode *, off_t, int, struct buf **); +static int ffs_balloc_ufs1(struct inode *, off_t, int, struct m_buf **); +static int ffs_balloc_ufs2(struct inode *, off_t, int, struct m_buf **); /* * Balloc defines the structure of file system storage @@ -68,7 +68,7 @@ */ int -ffs_balloc(struct inode *ip, off_t offset, int bufsize, struct buf **bpp) +ffs_balloc(struct inode *ip, off_t offset, int bufsize, struct m_buf **bpp) { if (ip->i_fs->fs_magic == FS_UFS2_MAGIC) return ffs_balloc_ufs2(ip, offset, bufsize, bpp); @@ -77,12 +77,13 @@ } static int -ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, struct buf **bpp) +ffs_balloc_ufs1(struct inode *ip, off_t offset, int bufsize, + struct m_buf **bpp) { daddr_t lbn, lastlbn; int size; int32_t nb; - struct buf *bp, *nbp; + struct m_buf *bp, *nbp; struct fs *fs = ip->i_fs; struct indir indirs[UFS_NIADDR + 2]; daddr_t newb, pref; @@ -135,8 +136,8 @@ */ if (bpp != NULL) { - error = bread(ip->i_devvp, lbn, fs->fs_bsize, - NULL, bpp); + error = bread((void *)ip->i_devvp, lbn, + fs->fs_bsize, NULL, bpp); if (error) { brelse(*bpp); return (error); @@ -161,8 +162,8 @@ */ if (bpp != NULL) { - error = bread(ip->i_devvp, lbn, osize, - NULL, bpp); + error = bread((void *)ip->i_devvp, lbn, + osize, NULL, bpp); if (error) { brelse(*bpp); return (error); @@ -191,7 +192,8 @@ if (error) return (error); if (bpp != NULL) { - bp = getblk(ip->i_devvp, lbn, nsize, 0, 0, 0); + bp = getblk((void *)ip->i_devvp, lbn, nsize, + 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -229,7 +231,8 @@ return error; nb = newb; *allocblk++ = nb; - bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); + bp = getblk((void *)ip->i_devvp, indirs[1].in_lbn, + fs->fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -247,8 +250,8 @@ */ for (i = 1;;) { - error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, - NULL, &bp); + error = bread((void *)ip->i_devvp, indirs[i].in_lbn, + fs->fs_bsize, NULL, &bp); if (error) { brelse(bp); return error; @@ -271,7 +274,8 @@ } nb = newb; *allocblk++ = nb; - nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk((void *)ip->i_devvp, indirs[i].in_lbn, + fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -302,7 +306,8 @@ nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk((void *)ip->i_devvp, lbn, fs->fs_bsize, + 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -318,7 +323,8 @@ } brelse(bp); if (bpp != NULL) { - error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, NULL, &nbp); + error = bread((void *)ip->i_devvp, lbn, (int)fs->fs_bsize, + NULL, &nbp); if (error) { brelse(nbp); return error; @@ -329,11 +335,12 @@ } static int -ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, struct buf **bpp) +ffs_balloc_ufs2(struct inode *ip, off_t offset, int bufsize, + struct m_buf **bpp) { daddr_t lbn, lastlbn; int size; - struct buf *bp, *nbp; + struct m_buf *bp, *nbp; struct fs *fs = ip->i_fs; struct indir indirs[UFS_NIADDR + 2]; daddr_t newb, pref, nb; @@ -386,8 +393,8 @@ */ if (bpp != NULL) { - error = bread(ip->i_devvp, lbn, fs->fs_bsize, - NULL, bpp); + error = bread((void *)ip->i_devvp, lbn, + fs->fs_bsize, NULL, bpp); if (error) { brelse(*bpp); return (error); @@ -412,8 +419,8 @@ */ if (bpp != NULL) { - error = bread(ip->i_devvp, lbn, osize, - NULL, bpp); + error = bread((void *)ip->i_devvp, lbn, + osize, NULL, bpp); if (error) { brelse(*bpp); return (error); @@ -442,7 +449,8 @@ if (error) return (error); if (bpp != NULL) { - bp = getblk(ip->i_devvp, lbn, nsize, 0, 0, 0); + bp = getblk((void *)ip->i_devvp, lbn, nsize, + 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -480,7 +488,8 @@ return error; nb = newb; *allocblk++ = nb; - bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); + bp = getblk((void *)ip->i_devvp, indirs[1].in_lbn, + fs->fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -498,8 +507,8 @@ */ for (i = 1;;) { - error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, - NULL, &bp); + error = bread((void *)ip->i_devvp, indirs[i].in_lbn, + fs->fs_bsize, NULL, &bp); if (error) { brelse(bp); return error; @@ -522,7 +531,8 @@ } nb = newb; *allocblk++ = nb; - nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk((void *)ip->i_devvp, indirs[i].in_lbn, + fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -553,7 +563,8 @@ nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk((void *)ip->i_devvp, lbn, fs->fs_bsize, + 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -569,7 +580,8 @@ } brelse(bp); if (bpp != NULL) { - error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, NULL, &nbp); + error = bread((void *)ip->i_devvp, lbn, (int)fs->fs_bsize, + NULL, &nbp); if (error) { brelse(nbp); return error; diff --git a/usr.sbin/makefs/ffs/ffs_extern.h b/usr.sbin/makefs/ffs/ffs_extern.h --- a/usr.sbin/makefs/ffs/ffs_extern.h +++ b/usr.sbin/makefs/ffs/ffs_extern.h @@ -59,7 +59,7 @@ void ffs_clusteracct(struct fs *, struct cg *, int32_t, int); /* ffs_balloc.c */ -int ffs_balloc(struct inode *, off_t, int, struct buf **); +int ffs_balloc(struct inode *, off_t, int, struct m_buf **); /* ffs_bswap.c */ void ffs_sb_swap(struct fs*, struct fs *); diff --git a/usr.sbin/makefs/msdos.h b/usr.sbin/makefs/msdos.h --- a/usr.sbin/makefs/msdos.h +++ b/usr.sbin/makefs/msdos.h @@ -51,11 +51,21 @@ size_t cn_namelen; }; +struct m_vnode; +struct m_buf; + int msdosfs_fsiflush(struct msdosfsmount *); -struct msdosfsmount *msdosfs_mount(struct vnode *); -int msdosfs_root(struct msdosfsmount *, struct vnode *); +struct msdosfsmount *msdosfs_mount(struct m_vnode *); +int msdosfs_root(struct msdosfsmount *, struct m_vnode *); struct denode *msdosfs_mkfile(const char *, struct denode *, fsnode *); struct denode *msdosfs_mkdire(const char *, struct denode *, fsnode *); +int m_readde(struct denode *dep, struct m_buf **bpp, struct direntry **epp); +int m_readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, + struct m_buf **bpp, struct direntry **epp); +int m_extendfile(struct denode *dep, u_long count, struct m_buf **bpp, + u_long *ncp, int flags); + +struct msdosfsmount *m_msdosfs_mount(struct m_vnode *devvp); #endif diff --git a/usr.sbin/makefs/msdos.c b/usr.sbin/makefs/msdos.c --- a/usr.sbin/makefs/msdos.c +++ b/usr.sbin/makefs/msdos.c @@ -55,16 +55,17 @@ #include #include -#include "ffs/buf.h" -#include "makefs.h" -#include "msdos.h" - #include #include #include "msdos/direntry.h" #include #include +#undef clrbuf +#include "ffs/buf.h" +#include "makefs.h" +#include "msdos.h" + static int msdos_populate_dir(const char *, struct denode *, fsnode *, fsnode *, fsinfo_t *); @@ -146,7 +147,7 @@ msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts) { struct msdos_options_ex *msdos_opt = fsopts->fs_specific; - struct vnode vp, rootvp; + struct m_vnode vp, rootvp; struct timeval start; struct msdosfsmount *pmp; uint32_t flags; @@ -184,7 +185,7 @@ vp.fs = fsopts; flags = 0; - if ((pmp = msdosfs_mount(&vp)) == NULL) + if ((pmp = m_msdosfs_mount(&vp)) == NULL) err(1, "msdosfs_mount"); if (msdosfs_root(pmp, &rootvp) != 0) diff --git a/usr.sbin/makefs/msdos/msdosfs_denode.c b/usr.sbin/makefs/msdos/msdosfs_denode.c --- a/usr.sbin/makefs/msdos/msdosfs_denode.c +++ b/usr.sbin/makefs/msdos/msdosfs_denode.c @@ -61,14 +61,14 @@ #include #include -#include "ffs/buf.h" - #include #include #include #include #include +#undef clrbuf +#include "ffs/buf.h" #include "makefs.h" #include "msdos.h" @@ -93,7 +93,7 @@ uint64_t inode; struct direntry *direntptr; struct denode *ldep; - struct buf *bp; + struct m_buf *bp; MSDOSFS_DPRINTF(("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n", pmp, dirclust, diroffset, depp)); @@ -155,7 +155,7 @@ ldep->de_MDate = ldep->de_CDate; /* leave the other fields as garbage */ } else { - error = readep(pmp, dirclust, diroffset, &bp, &direntptr); + error = m_readep(pmp, dirclust, diroffset, &bp, &direntptr); if (error) { ldep->de_Name[0] = SLOT_DELETED; @@ -219,7 +219,7 @@ daddr_t bn; int boff; int isadir = dep->de_Attributes & ATTR_DIRECTORY; - struct buf *bp; + struct m_buf *bp; struct msdosfsmount *pmp = dep->de_pmp; MSDOSFS_DPRINTF(("detrunc(): file %s, length %lu, flags %x\n", @@ -277,8 +277,8 @@ if ((boff = length & pmp->pm_crbomask) != 0) { if (isadir) { bn = cntobn(pmp, eofentry); - error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, - 0, &bp); + error = bread((void *)pmp->pm_devvp, bn, + pmp->pm_bpcluster, 0, &bp); if (error) { brelse(bp); MSDOSFS_DPRINTF(("detrunc(): bread fails %d\n", @@ -359,7 +359,7 @@ if (count > 0) { if (count > pmp->pm_freeclustercount) return (ENOSPC); - error = extendfile(dep, count, NULL, NULL, DE_CLEAR); + error = m_extendfile(dep, count, NULL, NULL, DE_CLEAR); if (error) { /* truncate the added clusters away again */ (void) detrunc(dep, dep->de_FileSize, 0, cred); diff --git a/usr.sbin/makefs/msdos/msdosfs_fat.c b/usr.sbin/makefs/msdos/msdosfs_fat.c --- a/usr.sbin/makefs/msdos/msdosfs_fat.c +++ b/usr.sbin/makefs/msdos/msdosfs_fat.c @@ -59,14 +59,14 @@ #include #include -#include "ffs/buf.h" - #include #include "msdos/direntry.h" #include #include #include +#undef clrbuf +#include "ffs/buf.h" #include "makefs.h" #include "msdos.h" @@ -84,7 +84,7 @@ u_long fillwith); static void fc_lookup(struct denode *dep, u_long findcn, u_long *frcnp, u_long *fsrcnp); -static void updatefats(struct msdosfsmount *pmp, struct buf *bp, +static void updatefats(struct msdosfsmount *pmp, struct m_buf *bp, u_long fatbn); static __inline void usemap_alloc(struct msdosfsmount *pmp, u_long cn); @@ -142,7 +142,7 @@ u_long byteoffset; u_long bn; u_long bo; - struct buf *bp = NULL; + struct m_buf *bp = NULL; u_long bp_bn = -1; struct msdosfsmount *pmp = dep->de_pmp; u_long bsize; @@ -206,7 +206,8 @@ if (bn != bp_bn) { if (bp) brelse(bp); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); + error = bread((void *)pmp->pm_devvp, bn, bsize, + NOCRED, &bp); if (error) { brelse(bp); return (error); @@ -309,9 +310,9 @@ * fatbn - block number relative to begin of filesystem of the modified FAT block. */ static void -updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn) +updatefats(struct msdosfsmount *pmp, struct m_buf *bp, u_long fatbn) { - struct buf *bpn; + struct m_buf *bpn; int cleanfat, i; #ifdef MSDOSFS_DEBUG @@ -338,8 +339,8 @@ for (i = 1; i < pmp->pm_FATs; i++) { fatbn += pmp->pm_FATsecs; /* getblk() never fails */ - bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, - 0, 0, 0); + bpn = getblk((void *)pmp->pm_devvp, fatbn, + bp->b_bcount, 0, 0, 0); memcpy(bpn->b_data, bp->b_data, bp->b_bcount); /* Force the clean bit on in the other copies. */ if (cleanfat == 16) @@ -456,7 +457,7 @@ int error; u_long readcn; u_long bn, bo, bsize, byteoffset; - struct buf *bp; + struct m_buf *bp; #ifdef MSDOSFS_DEBUG printf("fatentry(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n", @@ -494,7 +495,7 @@ byteoffset = FATOFS(pmp, cn); fatblock(pmp, byteoffset, &bn, &bsize, &bo); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); + error = bread((void *)pmp->pm_devvp, bn, bsize, NOCRED, &bp); if (error) { brelse(bp); return (error); @@ -562,7 +563,7 @@ { int error; u_long bn, bo, bsize, byteoffset, readcn, newc; - struct buf *bp; + struct m_buf *bp; #ifdef MSDOSFS_DEBUG printf("fatchain(pmp %p, start %lu, count %lu, fillwith %lx)\n", @@ -577,7 +578,7 @@ while (count > 0) { byteoffset = FATOFS(pmp, start); fatblock(pmp, byteoffset, &bn, &bsize, &bo); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); + error = bread((void *)pmp->pm_devvp, bn, bsize, NOCRED, &bp); if (error) { brelse(bp); return (error); @@ -813,7 +814,7 @@ freeclusterchain(struct msdosfsmount *pmp, u_long cluster) { int error; - struct buf *bp = NULL; + struct m_buf *bp = NULL; u_long bn, bo, bsize, byteoffset; u_long readcn, lbn = -1; @@ -823,7 +824,8 @@ if (lbn != bn) { if (bp) updatefats(pmp, bp, lbn); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); + error = bread((void *)pmp->pm_devvp, bn, bsize, + NOCRED, &bp); if (error) { brelse(bp); return (error); @@ -871,7 +873,7 @@ int fillinusemap(struct msdosfsmount *pmp) { - struct buf *bp; + struct m_buf *bp; u_long bn, bo, bsize, byteoffset, cn, readcn; int error; @@ -898,7 +900,8 @@ if (bp != NULL) brelse(bp); fatblock(pmp, byteoffset, &bn, &bsize, NULL); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); + error = bread((void *)pmp->pm_devvp, bn, bsize, + NOCRED, &bp); if (error != 0) return (error); } @@ -951,14 +954,14 @@ * field. This is left for the caller to do. */ int -extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, +m_extendfile(struct denode *dep, u_long count, struct m_buf **bpp, u_long *ncp, int flags) { int error; u_long frcn; u_long cn, got; struct msdosfsmount *pmp = dep->de_pmp; - struct buf *bp; + struct m_buf *bp; /* * Don't try to extend the root directory @@ -1039,7 +1042,7 @@ if ((flags & DE_CLEAR) && (dep->de_Attributes & ATTR_DIRECTORY)) { while (got-- > 0) { - bp = getblk(pmp->pm_devvp, + bp = getblk((void *)pmp->pm_devvp, cntobn(pmp, cn++), pmp->pm_bpcluster, 0, 0, 0); clrbuf(bp); diff --git a/usr.sbin/makefs/msdos/msdosfs_lookup.c b/usr.sbin/makefs/msdos/msdosfs_lookup.c --- a/usr.sbin/makefs/msdos/msdosfs_lookup.c +++ b/usr.sbin/makefs/msdos/msdosfs_lookup.c @@ -57,13 +57,14 @@ #include #include -#include "ffs/buf.h" #include #include "msdos/direntry.h" #include #include #include +#undef clrbuf +#include "ffs/buf.h" #include "makefs.h" #include "msdos.h" @@ -82,7 +83,7 @@ u_long dirclust, diroffset; struct direntry *ndep; struct msdosfsmount *pmp = ddep->de_pmp; - struct buf *bp; + struct m_buf *bp; daddr_t bn; int blsize; @@ -101,7 +102,7 @@ diroffset = ddep->de_fndoffset + sizeof(struct direntry) - ddep->de_FileSize; dirclust = de_clcount(pmp, diroffset); - error = extendfile(ddep, dirclust, 0, 0, DE_CLEAR); + error = m_extendfile(ddep, dirclust, 0, 0, DE_CLEAR); if (error) { (void)detrunc(ddep, ddep->de_FileSize, 0, NULL); return error; @@ -125,7 +126,8 @@ diroffset = ddep->de_fndoffset; if (dirclust != MSDOSFSROOT) diroffset &= pmp->pm_crbomask; - if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) { + if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED, + &bp)) != 0) { brelse(bp); return error; } @@ -155,7 +157,7 @@ if (error) return error; - error = bread(pmp->pm_devvp, bn, blsize, + error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED, &bp); if (error) { brelse(bp); @@ -200,8 +202,8 @@ * directory entry within the block. */ int -readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, - struct buf **bpp, struct direntry **epp) +m_readep(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, + struct m_buf **bpp, struct direntry **epp) { int error; daddr_t bn; @@ -212,7 +214,8 @@ && de_blk(pmp, diroffset + blsize) > pmp->pm_rootdirsize) blsize = de_bn2off(pmp, pmp->pm_rootdirsize) & pmp->pm_crbomask; bn = detobn(pmp, dirclust, diroffset); - if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, bpp)) != 0) { + if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED, + bpp)) != 0) { brelse(*bpp); *bpp = NULL; return (error); @@ -228,10 +231,10 @@ * entry within the block. */ int -readde(struct denode *dep, struct buf **bpp, struct direntry **epp) +m_readde(struct denode *dep, struct m_buf **bpp, struct direntry **epp) { - return (readep(dep->de_pmp, dep->de_dirclust, dep->de_diroffset, + return (m_readep(dep->de_pmp, dep->de_dirclust, dep->de_diroffset, bpp, epp)); } @@ -247,7 +250,7 @@ int blsize; u_long cn; daddr_t bn; - struct buf *bp; + struct m_buf *bp; int error; if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME) @@ -271,7 +274,8 @@ return 0; return error; } - error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp); + error = bread((void *)pmp->pm_devvp, bn, blsize, + NOCRED, &bp); if (error) { brelse(bp); return error; diff --git a/usr.sbin/makefs/msdos/msdosfs_vfsops.c b/usr.sbin/makefs/msdos/msdosfs_vfsops.c --- a/usr.sbin/makefs/msdos/msdosfs_vfsops.c +++ b/usr.sbin/makefs/msdos/msdosfs_vfsops.c @@ -61,7 +61,6 @@ #include #include -#include "ffs/buf.h" #include #include #include "msdos/direntry.h" @@ -71,16 +70,16 @@ #include +#undef clrbuf +#include "ffs/buf.h" #include "makefs.h" #include "msdos.h" - - struct msdosfsmount * -msdosfs_mount(struct vnode *devvp) +m_msdosfs_mount(struct m_vnode *devvp) { struct msdosfsmount *pmp = NULL; - struct buf *bp; + struct m_buf *bp; union bootsector *bsp; struct byte_bpb33 *b33; struct byte_bpb50 *b50; @@ -91,7 +90,7 @@ unsigned secsize = 512; MSDOSFS_DPRINTF(("%s(bread 0)\n", __func__)); - if ((error = bread(devvp, 0, secsize, 0, &bp)) != 0) + if ((error = bread((void *)devvp, 0, secsize, 0, &bp)) != 0) goto error_exit; bsp = (union bootsector *)bp->b_data; @@ -273,8 +272,8 @@ * 2KB or larger sectors, is the fsinfo structure * padded at the end or in the middle? */ - if ((error = bread(devvp, pmp->pm_fsinfo, pmp->pm_BytesPerSec, - 0, &bp)) != 0) + if ((error = bread((void *)devvp, pmp->pm_fsinfo, + pmp->pm_BytesPerSec, 0, &bp)) != 0) goto error_exit; fp = (struct fsinfo *)bp->b_data; if (!memcmp(fp->fsisig1, "RRaA", 4) @@ -307,7 +306,7 @@ * fillinusemap() needs pm_devvp. */ pmp->pm_dev = 0; - pmp->pm_devvp = devvp; + pmp->pm_devvp = (void *)devvp; /* * Have the inuse map filled in. @@ -348,11 +347,11 @@ } int -msdosfs_root(struct msdosfsmount *pmp, struct vnode *vp) { +msdosfs_root(struct msdosfsmount *pmp, struct m_vnode *vp) { struct denode *ndep; int error; - *vp = *pmp->pm_devvp; + *vp = *(struct m_vnode *)pmp->pm_devvp; if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep)) != 0) { errno = error; return -1; @@ -368,15 +367,15 @@ msdosfs_fsiflush(struct msdosfsmount *pmp) { struct fsinfo *fp; - struct buf *bp; + struct m_buf *bp; int error; if (pmp->pm_fsinfo == 0 || (pmp->pm_flags & MSDOSFS_FSIMOD) == 0) { error = 0; goto out; } - error = bread(pmp->pm_devvp, pmp->pm_fsinfo, pmp->pm_BytesPerSec, - NOCRED, &bp); + error = bread((void *)pmp->pm_devvp, pmp->pm_fsinfo, + pmp->pm_BytesPerSec, NOCRED, &bp); if (error != 0) { brelse(bp); goto out; diff --git a/usr.sbin/makefs/msdos/msdosfs_vnops.c b/usr.sbin/makefs/msdos/msdosfs_vnops.c --- a/usr.sbin/makefs/msdos/msdosfs_vnops.c +++ b/usr.sbin/makefs/msdos/msdosfs_vnops.c @@ -64,13 +64,14 @@ #include #include -#include "ffs/buf.h" #include #include "msdos/direntry.h" #include #include #include +#undef clrbuf +#include "ffs/buf.h" #include "makefs.h" #include "msdos.h" @@ -161,7 +162,7 @@ u_int diroff; int blsize; struct msdosfsmount *pmp; - struct buf *bp = 0; + struct m_buf *bp = 0; struct direntry *dep; u_char dosfilename[12]; int wincnt = 1; @@ -216,7 +217,7 @@ break; return (error); } - error = bread(pmp->pm_devvp, bn, blsize, 0, &bp); + error = bread((void *)pmp->pm_devvp, bn, blsize, 0, &bp); if (error) { return (error); } @@ -417,12 +418,12 @@ static int msdosfs_updatede(struct denode *dep) { - struct buf *bp; + struct m_buf *bp; struct direntry *dirp; int error; dep->de_flag &= ~DE_MODIFIED; - error = readde(dep, &bp, &dirp); + error = m_readde(dep, &bp, &dirp); if (error) return error; DE_EXTERNALIZE(dirp, dep); @@ -441,7 +442,7 @@ struct stat *st = &node->inode->st; size_t nsize, offs; struct msdosfsmount *pmp = dep->de_pmp; - struct buf *bp; + struct m_buf *bp; char *dat; u_long cn = 0; @@ -494,7 +495,8 @@ MSDOSFS_DPRINTF(("%s(cn=%lu, bn=%llu, blsize=%d)\n", __func__, cn, (unsigned long long)bn, blsize)); - if ((error = bread(pmp->pm_devvp, bn, blsize, 0, &bp)) != 0) { + if ((error = bread((void *)pmp->pm_devvp, bn, blsize, 0, + &bp)) != 0) { MSDOSFS_DPRINTF(("bread %d\n", error)); goto out; } @@ -546,7 +548,7 @@ int error; u_long newcluster, pcl, bn; struct direntry *denp; - struct buf *bp; + struct m_buf *bp; cn.cn_nameptr = node->name; cn.cn_namelen = strlen(node->name); @@ -582,7 +584,7 @@ MSDOSFS_DPRINTF(("%s(newcluster %lu, bn=%lu)\n", __func__, newcluster, bn)); /* always succeeds */ - bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0, 0); + bp = getblk((void *)pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0, 0); memset(bp->b_data, 0, pmp->pm_bpcluster); memcpy(bp->b_data, &dosdirtemplate, sizeof dosdirtemplate); denp = (struct direntry *)bp->b_data;