Home | History | Annotate | Line # | Download | only in lfs
lfs.h revision 1.10
      1 /*	$NetBSD: lfs.h,v 1.10 1998/09/11 21:27:12 pk Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1991, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the University of
     18  *	California, Berkeley and its contributors.
     19  * 4. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  *	@(#)lfs.h	8.9 (Berkeley) 5/8/95
     36  */
     37 
     38 #define	LFS_LABELPAD	8192		/* LFS label size */
     39 #define	LFS_SBPAD	8192		/* LFS superblock size */
     40 
     41 /*
     42  * XXX
     43  * This is a kluge and NEEDS to go away.
     44  *
     45  * Right now, ufs code handles most of the calls for directory operations
     46  * such as create, mkdir, link, etc.  As a result VOP_UPDATE is being
     47  * called with waitfor set (since ffs does these things synchronously).
     48  * Since LFS does not want to do these synchronously, we treat the last
     49  * argument to lfs_update as a set of flags.  If LFS_SYNC is set, then
     50  * the update should be synchronous, if not, do it asynchronously.
     51  * Unfortunately, this means that LFS won't work with NFS yet because
     52  * NFS goes through paths that will make normal calls to ufs which will
     53  * call lfs with a last argument of 1.
     54  */
     55 #define	LFS_SYNC	0x02
     56 
     57 /* On-disk and in-memory checkpoint segment usage structure. */
     58 typedef struct segusage SEGUSE;
     59 struct segusage {
     60 	u_int32_t su_nbytes;		/* number of live bytes */
     61 	u_int32_t su_lastmod;		/* SEGUSE last modified timestamp */
     62 	u_int16_t su_nsums;		/* number of summaries in segment */
     63 	u_int16_t su_ninos;		/* number of inode blocks in seg */
     64 
     65 #define	SEGUSE_ACTIVE		0x01	/* segment is currently being written */
     66 #define	SEGUSE_DIRTY		0x02	/* segment has data in it */
     67 #define	SEGUSE_SUPERBLOCK	0x04	/* segment contains a superblock */
     68 	u_int32_t su_flags;
     69 };
     70 
     71 #define	SEGUPB(fs)	(1 << (fs)->lfs_sushift)
     72 #define	SEGTABSIZE_SU(fs)						\
     73 	(((fs)->lfs_nseg + SEGUPB(fs) - 1) >> (fs)->lfs_sushift)
     74 
     75 /* On-disk file information.  One per file with data blocks in the segment. */
     76 typedef struct finfo FINFO;
     77 struct finfo {
     78 	u_int32_t fi_nblocks;		/* number of blocks */
     79 	u_int32_t fi_version;		/* version number */
     80 	u_int32_t fi_ino;		/* inode number */
     81 	u_int32_t fi_lastlength;	/* length of last block in array */
     82 	ufs_daddr_t	  fi_blocks[1];		/* array of logical block numbers */
     83 };
     84 
     85 /* On-disk super block. */
     86 struct dlfs {
     87 #define	LFS_MAGIC	0x070162
     88         u_int32_t dlfs_magic;     /* 0: magic number */
     89 #define	LFS_VERSION	1
     90         u_int32_t dlfs_version;   /* 4: version number */
     91 
     92         u_int32_t dlfs_size;      /* 8: number of blocks in fs */
     93         u_int32_t dlfs_ssize;     /* 12: number of blocks per segment */
     94         u_int32_t dlfs_dsize;     /* 16: number of disk blocks in fs */
     95         u_int32_t dlfs_bsize;     /* 20: file system block size */
     96         u_int32_t dlfs_fsize;     /* 24: size of frag blocks in fs */
     97         u_int32_t dlfs_frag;      /* 28: number of frags in a block in fs */
     98 
     99 /* Checkpoint region. */
    100         ino_t     dlfs_free;      /* 32: start of the free list */
    101         u_int32_t dlfs_bfree;     /* 36: number of free disk blocks */
    102         u_int32_t dlfs_nfiles;    /* 40: number of allocated inodes */
    103         int32_t   dlfs_avail;     /* 44: blocks available for writing */
    104         u_int32_t dlfs_uinodes;   /* 48: inodes in cache not yet on disk */
    105         ufs_daddr_t  dlfs_idaddr; /* 52: inode file disk address */
    106         ino_t     dlfs_ifile;     /* 56: inode file inode number */
    107         ufs_daddr_t  dlfs_lastseg; /* 60: address of last segment written */
    108         ufs_daddr_t  dlfs_nextseg; /* 64: address of next segment to write */
    109         ufs_daddr_t  dlfs_curseg; /* 68: current segment being written */
    110         ufs_daddr_t  dlfs_offset; /* 72: offset in curseg for next partial */
    111         ufs_daddr_t  dlfs_lastpseg; /* 76: address of last partial written */
    112         u_int32_t dlfs_tstamp;    /* 80: time stamp */
    113 
    114 /* These are configuration parameters. */
    115         u_int32_t dlfs_minfree;   /* 84: minimum percentage of free blocks */
    116 
    117 /* These fields can be computed from the others. */
    118         u_int64_t dlfs_maxfilesize; /* 88: maximum representable file size */
    119         u_int32_t dlfs_dbpseg;    /* 96: disk blocks per segment */
    120         u_int32_t dlfs_inopb;     /* 100: inodes per block */
    121         u_int32_t dlfs_ifpb;      /* 104: IFILE entries per block */
    122         u_int32_t dlfs_sepb;      /* 108: SEGUSE entries per block */
    123         u_int32_t dlfs_nindir;    /* 112: indirect pointers per block */
    124         u_int32_t dlfs_nseg;      /* 116: number of segments */
    125         u_int32_t dlfs_nspf;      /* 120: number of sectors per fragment */
    126         u_int32_t dlfs_cleansz;   /* 124: cleaner info size in blocks */
    127         u_int32_t dlfs_segtabsz;  /* 128: segment table size in blocks */
    128         u_int32_t dlfs_segmask;   /* 132: calculate offset within a segment */
    129         u_int32_t dlfs_segshift;  /* 136: fast mult/div for segments */
    130         u_int32_t dlfs_bshift;    /* 140: calc block number from file offset */
    131         u_int32_t dlfs_ffshift;   /* 144: fast mult/div for frag from file */
    132         u_int32_t dlfs_fbshift;   /* 148: fast mult/div for frag from block */
    133         u_int64_t dlfs_bmask;     /* 152: calc block offset from file offset */
    134         u_int64_t dlfs_ffmask;    /* 160: calc frag offset from file offset */
    135         u_int64_t dlfs_fbmask;    /* 168: calc frag offset from block offset */
    136         u_int32_t dlfs_fsbtodb;   /* 176: fsbtodb and dbtofsb shift constant */
    137         u_int32_t dlfs_sushift;   /* 180: fast mult/div for segusage table */
    138 
    139         int32_t   dlfs_maxsymlinklen; /* 184: max length of an internal symlink */
    140 
    141 #define	LFS_MIN_SBINTERVAL	5	/* minimum superblock segment spacing */
    142 #define LFS_MAXNUMSB            10 /* 188: superblock disk offsets */
    143         ufs_daddr_t       dlfs_sboffs[LFS_MAXNUMSB];
    144 
    145 /* Checksum -- last valid disk field. */
    146         u_int32_t dlfs_cksum;     /* 228: checksum for superblock checking */
    147         int32_t   dlfs_pad[70];   /* 232: round to 512 bytes */
    148 };
    149 
    150 /* In-memory super block. */
    151 struct lfs {
    152         struct dlfs lfs_dlfs;           /* on-disk parameters */
    153 #define lfs_magic lfs_dlfs.dlfs_magic
    154 #define lfs_version lfs_dlfs.dlfs_version
    155 #define lfs_size lfs_dlfs.dlfs_size
    156 #define lfs_ssize lfs_dlfs.dlfs_ssize
    157 #define lfs_dsize lfs_dlfs.dlfs_dsize
    158 #define lfs_bsize lfs_dlfs.dlfs_bsize
    159 #define lfs_fsize lfs_dlfs.dlfs_fsize
    160 #define lfs_frag lfs_dlfs.dlfs_frag
    161 #define lfs_free lfs_dlfs.dlfs_free
    162 #define lfs_bfree lfs_dlfs.dlfs_bfree
    163 #define lfs_nfiles lfs_dlfs.dlfs_nfiles
    164 #define lfs_avail lfs_dlfs.dlfs_avail
    165 #define lfs_uinodes lfs_dlfs.dlfs_uinodes
    166 #define lfs_idaddr lfs_dlfs.dlfs_idaddr
    167 #define lfs_ifile lfs_dlfs.dlfs_ifile
    168 #define lfs_lastseg lfs_dlfs.dlfs_lastseg
    169 #define lfs_nextseg lfs_dlfs.dlfs_nextseg
    170 #define lfs_curseg lfs_dlfs.dlfs_curseg
    171 #define lfs_offset lfs_dlfs.dlfs_offset
    172 #define lfs_lastpseg lfs_dlfs.dlfs_lastpseg
    173 #define lfs_tstamp lfs_dlfs.dlfs_tstamp
    174 #define lfs_minfree lfs_dlfs.dlfs_minfree
    175 #define lfs_maxfilesize lfs_dlfs.dlfs_maxfilesize
    176 #define lfs_dbpseg lfs_dlfs.dlfs_dbpseg
    177 #define lfs_inopb lfs_dlfs.dlfs_inopb
    178 #define lfs_ifpb lfs_dlfs.dlfs_ifpb
    179 #define lfs_sepb lfs_dlfs.dlfs_sepb
    180 #define lfs_nindir lfs_dlfs.dlfs_nindir
    181 #define lfs_nseg lfs_dlfs.dlfs_nseg
    182 #define lfs_nspf lfs_dlfs.dlfs_nspf
    183 #define lfs_cleansz lfs_dlfs.dlfs_cleansz
    184 #define lfs_segtabsz lfs_dlfs.dlfs_segtabsz
    185 #define lfs_segmask lfs_dlfs.dlfs_segmask
    186 #define lfs_segshift lfs_dlfs.dlfs_segshift
    187 #define lfs_bmask lfs_dlfs.dlfs_bmask
    188 #define lfs_bshift lfs_dlfs.dlfs_bshift
    189 #define lfs_ffmask lfs_dlfs.dlfs_ffmask
    190 #define lfs_ffshift lfs_dlfs.dlfs_ffshift
    191 #define lfs_fbmask lfs_dlfs.dlfs_fbmask
    192 #define lfs_fbshift lfs_dlfs.dlfs_fbshift
    193 #define lfs_fsbtodb lfs_dlfs.dlfs_fsbtodb
    194 #define lfs_sushift lfs_dlfs.dlfs_sushift
    195 #define lfs_maxsymlinklen lfs_dlfs.dlfs_maxsymlinklen
    196 #define lfs_sboffs lfs_dlfs.dlfs_sboffs
    197 #define lfs_cksum lfs_dlfs.dlfs_cksum
    198 /* These fields are set at mount time and are meaningless on disk. */
    199 	struct segment *lfs_sp;		/* current segment being written */
    200 	struct vnode *lfs_ivnode;	/* vnode for the ifile */
    201 	u_int32_t  lfs_seglock;		/* single-thread the segment writer */
    202 	pid_t	  lfs_lockpid;		/* pid of lock holder */
    203 	u_int32_t lfs_iocount;		/* number of ios pending */
    204 	u_int32_t lfs_writer;		/* don't allow any dirops to start */
    205 	u_int32_t lfs_dirops;		/* count of active directory ops */
    206 	u_int32_t lfs_doifile;		/* Write ifile blocks on next write */
    207 	u_int32_t lfs_nactive;		/* Number of segments since last ckp */
    208 	int8_t	  lfs_fmod;		/* super block modified flag */
    209 	int8_t	  lfs_clean;		/* file system is clean flag */
    210 	int8_t	  lfs_ronly;		/* mounted read-only flag */
    211 	int8_t	  lfs_flags;		/* currently unused flag */
    212 	u_char	  lfs_fsmnt[MNAMELEN];	/* name mounted on */
    213 };
    214 
    215 /*
    216  * Inode 0:	out-of-band inode number
    217  * Inode 1:	IFILE inode number
    218  * Inode 2:	root inode
    219  * Inode 3:	lost+found inode number
    220  */
    221 #define	LFS_UNUSED_INUM	0		/* out of band inode number */
    222 #define	LFS_IFILE_INUM	1		/* IFILE inode number */
    223 #define	LOSTFOUNDINO	3		/* lost+found inode number */
    224 #define	LFS_FIRST_INUM	4		/* first free inode number */
    225 
    226 /* Address calculations for metadata located in the inode */
    227 #define	S_INDIR(fs)	-NDADDR
    228 #define	D_INDIR(fs)	(S_INDIR(fs) - NINDIR(fs) - 1)
    229 #define	T_INDIR(fs)	(D_INDIR(fs) - NINDIR(fs) * NINDIR(fs) - 1)
    230 
    231 /* Unassigned disk address. */
    232 #define	UNASSIGNED	-1
    233 
    234 /* Unused logical block number */
    235 #define LFS_UNUSED_LBN	-1
    236 
    237 typedef struct ifile IFILE;
    238 struct ifile {
    239 	u_int32_t if_version;		/* inode version number */
    240 #define	LFS_UNUSED_DADDR	0	/* out-of-band daddr */
    241 	ufs_daddr_t if_daddr;		/* inode disk address */
    242 	ino_t	  if_nextfree;		/* next-unallocated inode */
    243 };
    244 
    245 /*
    246  * Cleaner information structure.  This resides in the ifile and is used
    247  * to pass information between the cleaner and the kernel.
    248  */
    249 typedef struct _cleanerinfo {
    250 	u_int32_t clean;		/* K: number of clean segments */
    251 	u_int32_t dirty;		/* K: number of dirty segments */
    252 } CLEANERINFO;
    253 
    254 #define	CLEANSIZE_SU(fs)						\
    255 	((sizeof(CLEANERINFO) + (fs)->lfs_bsize - 1) >> (fs)->lfs_bshift)
    256 
    257 /*
    258  * All summary blocks are the same size, so we can always read a summary
    259  * block easily from a segment.
    260  */
    261 #define	LFS_SUMMARY_SIZE	512
    262 
    263 /* On-disk segment summary information */
    264 typedef struct segsum SEGSUM;
    265 struct segsum {
    266 	u_int32_t ss_sumsum;		/* check sum of summary block */
    267 	u_int32_t ss_datasum;		/* check sum of data */
    268 	u_int32_t ss_magic;		/* segment summary magic number */
    269 #define SS_MAGIC	0x061561
    270 	ufs_daddr_t ss_next;		/* next segment */
    271 	u_int32_t ss_create;		/* creation time stamp */
    272 	u_int16_t ss_nfinfo;		/* number of file info structures */
    273 	u_int16_t ss_ninos;		/* number of inodes in summary */
    274 
    275 #define	SS_DIROP	0x01		/* segment begins a dirop */
    276 #define	SS_CONT		0x02		/* more partials to finish this write*/
    277 	u_int16_t ss_flags;		/* used for directory operations */
    278 	u_int16_t ss_pad;		/* extra space */
    279 	/* FINFO's and inode daddr's... */
    280 };
    281 
    282 /* NINDIR is the number of indirects in a file system block. */
    283 #define	NINDIR(fs)	((fs)->lfs_nindir)
    284 
    285 /* INOPB is the number of inodes in a secondary storage block. */
    286 #define	INOPB(fs)	((fs)->lfs_inopb)
    287 
    288 #define	blksize(fs, ip, lbn) \
    289 	(((lbn) >= NDADDR || (ip)->i_ffs_size >= ((lbn) + 1) << (fs)->lfs_bshift) \
    290 	    ? (fs)->lfs_bsize \
    291 	    : (fragroundup(fs, blkoff(fs, (ip)->i_ffs_size))))
    292 #define	blkoff(fs, loc)		((int)(loc) & (fs)->lfs_bmask)
    293 #define fragoff(fs, loc)    /* calculates (loc % fs->lfs_fsize) */ \
    294     ((int)((loc) & (fs)->lfs_ffmask))
    295 #define	fsbtodb(fs, b)		((b) << (fs)->lfs_fsbtodb)
    296 #define	dbtofsb(fs, b)		((b) >> (fs)->lfs_fsbtodb)
    297 #define fragstodb(fs, b)	((b) << ((fs)->lfs_fsbtodb - (fs)->lfs_fbshift))
    298 #define dbtofrags(fs, b)	((b) >> ((fs)->lfs_fsbtodb - (fs)->lfs_fbshift))
    299 #define	lblkno(fs, loc)		((loc) >> (fs)->lfs_bshift)
    300 #define	lblktosize(fs, blk)	((blk) << (fs)->lfs_bshift)
    301 #define numfrags(fs, loc)	/* calculates (loc / fs->lfs_fsize) */	\
    302 	((loc) >> (fs)->lfs_ffshift)
    303 #define blkroundup(fs, size)	/* calculates roundup(size, fs->lfs_bsize) */ \
    304 	((int)(((size) + (fs)->lfs_bmask) & (~(fs)->lfs_bmask)))
    305 #define fragroundup(fs, size)	/* calculates roundup(size, fs->lfs_fsize) */ \
    306 	((int)(((size) + (fs)->lfs_ffmask) & (~(fs)->lfs_ffmask)))
    307 #define fragstoblks(fs, frags)	/* calculates (frags / fs->lfs_frag) */ \
    308 	((frags) >> (fs)->lfs_fbshift)
    309 #define blkstofrags(fs, blks)	/* calculates (blks * fs->lfs_frag) */ \
    310 	((blks) << (fs)->lfs_fbshift)
    311 #define fragnum(fs, fsb)	/* calculates (fsb % fs->lfs_frag) */ \
    312 	((fsb) & ((fs)->lfs_frag - 1))
    313 #define blknum(fs, fsb)		/* calculates rounddown(fsb, fs->lfs_frag) */ \
    314 	((fsb) &~ ((fs)->lfs_frag - 1))
    315 #define dblksize(fs, dip, lbn) \
    316 	(((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << (fs)->lfs_bshift)\
    317 	    ? (fs)->lfs_bsize \
    318 	    : (fragroundup(fs, blkoff(fs, (dip)->di_size))))
    319 #define	datosn(fs, daddr)	/* disk address to segment number */	\
    320 	(((daddr) - (fs)->lfs_sboffs[0]) / fsbtodb((fs), (fs)->lfs_ssize))
    321 #define sntoda(fs, sn) 		/* segment number to disk address */	\
    322 	((ufs_daddr_t)((sn) * ((fs)->lfs_ssize << (fs)->lfs_fsbtodb) +	\
    323 	    (fs)->lfs_sboffs[0]))
    324 
    325 /* Read in the block with the cleaner info from the ifile. */
    326 #define LFS_CLEANERINFO(CP, F, BP) {					\
    327 	VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;			\
    328 	if (bread((F)->lfs_ivnode,					\
    329 	    (ufs_daddr_t)0, (F)->lfs_bsize, NOCRED, &(BP)))		\
    330 		panic("lfs: ifile read");				\
    331 	(CP) = (CLEANERINFO *)(BP)->b_data;				\
    332 }
    333 
    334 /* Read in the block with a specific inode from the ifile. */
    335 #define	LFS_IENTRY(IP, F, IN, BP) {					\
    336 	int _e;								\
    337 	VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;			\
    338 	if ((_e = bread((F)->lfs_ivnode,				\
    339 	    (IN) / (F)->lfs_ifpb + (F)->lfs_cleansz + (F)->lfs_segtabsz,\
    340 	    (F)->lfs_bsize, NOCRED, &(BP))) != 0)			\
    341 		panic("lfs: ifile read %d", _e);			\
    342 	(IP) = (IFILE *)(BP)->b_data + (IN) % (F)->lfs_ifpb;		\
    343 }
    344 
    345 /* Read in the block with a specific segment usage entry from the ifile. */
    346 #define	LFS_SEGENTRY(SP, F, IN, BP) {					\
    347 	int _e;								\
    348 	VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;			\
    349 	if ((_e = bread((F)->lfs_ivnode,				\
    350 	    ((IN) >> (F)->lfs_sushift) + (F)->lfs_cleansz,		\
    351 	    (F)->lfs_bsize, NOCRED, &(BP))) != 0)			\
    352 		panic("lfs: ifile read: %d", _e);			\
    353 	(SP) = (SEGUSE *)(BP)->b_data + ((IN) & ((F)->lfs_sepb - 1));	\
    354 }
    355 
    356 /*
    357  * Determine if there is enough room currently available to write db
    358  * disk blocks.  We need enough blocks for the new blocks, the current,
    359  * inode blocks, a summary block, plus potentially the ifile inode and
    360  * the segment usage table, plus an ifile page.
    361  */
    362 #define LFS_FITS(fs, db)						\
    363 	((int32_t)((db + ((fs)->lfs_uinodes + INOPB((fs))) / 		\
    364 	INOPB((fs)) + fsbtodb(fs, 1) + LFS_SUMMARY_SIZE / DEV_BSIZE +	\
    365 	(fs)->lfs_segtabsz)) < (fs)->lfs_avail)
    366 
    367 /* Determine if a buffer belongs to the ifile */
    368 #define IS_IFILE(bp)	(VTOI(bp->b_vp)->i_number == LFS_IFILE_INUM)
    369 
    370 /*
    371  * Structures used by lfs_bmapv and lfs_markv to communicate information
    372  * about inodes and data blocks.
    373  */
    374 typedef struct block_info {
    375 	ino_t	bi_inode;		/* inode # */
    376 	ufs_daddr_t bi_lbn;		/* logical block w/in file */
    377 	ufs_daddr_t bi_daddr;		/* disk address of block */
    378 	time_t	bi_segcreate;		/* origin segment create time */
    379 	int	bi_version;		/* file version number */
    380 	void	*bi_bp;			/* data buffer */
    381 	int     bi_size;		/* size of the block (if fragment) */
    382 } BLOCK_INFO;
    383 
    384 /* In-memory description of a segment about to be written. */
    385 struct segment {
    386 	struct lfs	 *fs;		/* file system pointer */
    387 	struct buf	**bpp;		/* pointer to buffer array */
    388 	struct buf	**cbpp;		/* pointer to next available bp */
    389 	struct buf	**start_bpp;	/* pointer to first bp in this set */
    390 	struct buf	 *ibp;		/* buffer pointer to inode page */
    391 	struct finfo	 *fip;		/* current fileinfo pointer */
    392 	struct vnode	 *vp;		/* vnode being gathered */
    393 	void	 *segsum;		/* segment summary info */
    394 	u_int32_t ninodes;		/* number of inodes in this segment */
    395 	u_int32_t seg_bytes_left;	/* bytes left in segment */
    396 	u_int32_t sum_bytes_left;	/* bytes left in summary block */
    397 	u_int32_t seg_number;		/* number of this segment */
    398 	ufs_daddr_t *start_lbp;		/* beginning lbn for this set */
    399 
    400 #define	SEGM_CKP	0x01		/* doing a checkpoint */
    401 #define	SEGM_CLEAN	0x02		/* cleaner call; don't sort */
    402 #define	SEGM_SYNC	0x04		/* wait for segment */
    403 	u_int16_t seg_flags;		/* run-time flags for this segment */
    404 };
    405 
    406 #define ISSPACE(F, BB, C)						\
    407 	(((C)->cr_uid == 0 && (F)->lfs_bfree >= (BB)) ||		\
    408 	((C)->cr_uid != 0 && IS_FREESPACE(F, BB)))
    409 
    410 #define IS_FREESPACE(F, BB)						\
    411 	((F)->lfs_bfree > ((F)->lfs_dsize * (F)->lfs_minfree / 100 + (BB)))
    412 
    413 #define ISSPACE_XXX(F, BB)						\
    414 	((F)->lfs_bfree >= (BB))
    415 
    416 #define DOSTATS
    417 #ifdef DOSTATS
    418 /* Statistics Counters */
    419 struct lfs_stats {
    420 	u_int	segsused;
    421 	u_int	psegwrites;
    422 	u_int	psyncwrites;
    423 	u_int	pcleanwrites;
    424 	u_int	blocktot;
    425 	u_int	cleanblocks;
    426 	u_int	ncheckpoints;
    427 	u_int	nwrites;
    428 	u_int	nsync_writes;
    429 	u_int	wait_exceeded;
    430 	u_int	write_exceeded;
    431 	u_int	flush_invoked;
    432 };
    433 extern struct lfs_stats lfs_stats;
    434 #endif
    435