Home | History | Annotate | Line # | Download | only in lfs
lfs.h revision 1.169
      1 /*	$NetBSD: lfs.h,v 1.169 2015/08/02 18:10:08 dholland Exp $	*/
      2 
      3 /*  from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp  */
      4 /*  from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp  */
      5 
      6 /*-
      7  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
      8  * All rights reserved.
      9  *
     10  * This code is derived from software contributed to The NetBSD Foundation
     11  * by Konrad E. Schroder <perseant (at) hhhh.org>.
     12  *
     13  * Redistribution and use in source and binary forms, with or without
     14  * modification, are permitted provided that the following conditions
     15  * are met:
     16  * 1. Redistributions of source code must retain the above copyright
     17  *    notice, this list of conditions and the following disclaimer.
     18  * 2. Redistributions in binary form must reproduce the above copyright
     19  *    notice, this list of conditions and the following disclaimer in the
     20  *    documentation and/or other materials provided with the distribution.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     25  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32  * POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 /*-
     35  * Copyright (c) 1991, 1993
     36  *	The Regents of the University of California.  All rights reserved.
     37  *
     38  * Redistribution and use in source and binary forms, with or without
     39  * modification, are permitted provided that the following conditions
     40  * are met:
     41  * 1. Redistributions of source code must retain the above copyright
     42  *    notice, this list of conditions and the following disclaimer.
     43  * 2. Redistributions in binary form must reproduce the above copyright
     44  *    notice, this list of conditions and the following disclaimer in the
     45  *    documentation and/or other materials provided with the distribution.
     46  * 3. Neither the name of the University nor the names of its contributors
     47  *    may be used to endorse or promote products derived from this software
     48  *    without specific prior written permission.
     49  *
     50  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     51  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     52  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     53  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     54  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     55  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     56  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     57  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     58  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     59  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     60  * SUCH DAMAGE.
     61  *
     62  *	@(#)lfs.h	8.9 (Berkeley) 5/8/95
     63  */
     64 /*
     65  * Copyright (c) 2002 Networks Associates Technology, Inc.
     66  * All rights reserved.
     67  *
     68  * This software was developed for the FreeBSD Project by Marshall
     69  * Kirk McKusick and Network Associates Laboratories, the Security
     70  * Research Division of Network Associates, Inc. under DARPA/SPAWAR
     71  * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
     72  * research program
     73  *
     74  * Copyright (c) 1982, 1989, 1993
     75  *	The Regents of the University of California.  All rights reserved.
     76  * (c) UNIX System Laboratories, Inc.
     77  * All or some portions of this file are derived from material licensed
     78  * to the University of California by American Telephone and Telegraph
     79  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     80  * the permission of UNIX System Laboratories, Inc.
     81  *
     82  * Redistribution and use in source and binary forms, with or without
     83  * modification, are permitted provided that the following conditions
     84  * are met:
     85  * 1. Redistributions of source code must retain the above copyright
     86  *    notice, this list of conditions and the following disclaimer.
     87  * 2. Redistributions in binary form must reproduce the above copyright
     88  *    notice, this list of conditions and the following disclaimer in the
     89  *    documentation and/or other materials provided with the distribution.
     90  * 3. Neither the name of the University nor the names of its contributors
     91  *    may be used to endorse or promote products derived from this software
     92  *    without specific prior written permission.
     93  *
     94  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     95  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     96  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     97  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     98  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     99  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    100  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    101  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    102  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    103  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    104  * SUCH DAMAGE.
    105  *
    106  *	@(#)dinode.h	8.9 (Berkeley) 3/29/95
    107  */
    108 /*
    109  * Copyright (c) 1982, 1986, 1989, 1993
    110  *	The Regents of the University of California.  All rights reserved.
    111  * (c) UNIX System Laboratories, Inc.
    112  * All or some portions of this file are derived from material licensed
    113  * to the University of California by American Telephone and Telegraph
    114  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
    115  * the permission of UNIX System Laboratories, Inc.
    116  *
    117  * Redistribution and use in source and binary forms, with or without
    118  * modification, are permitted provided that the following conditions
    119  * are met:
    120  * 1. Redistributions of source code must retain the above copyright
    121  *    notice, this list of conditions and the following disclaimer.
    122  * 2. Redistributions in binary form must reproduce the above copyright
    123  *    notice, this list of conditions and the following disclaimer in the
    124  *    documentation and/or other materials provided with the distribution.
    125  * 3. Neither the name of the University nor the names of its contributors
    126  *    may be used to endorse or promote products derived from this software
    127  *    without specific prior written permission.
    128  *
    129  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    130  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    131  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    132  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    133  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    134  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    135  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    136  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    137  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    138  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    139  * SUCH DAMAGE.
    140  *
    141  *	@(#)dir.h	8.5 (Berkeley) 4/27/95
    142  */
    143 
    144 /*
    145  * NOTE: COORDINATE ON-DISK FORMAT CHANGES WITH THE FREEBSD PROJECT.
    146  */
    147 
    148 #ifndef _UFS_LFS_LFS_H_
    149 #define _UFS_LFS_LFS_H_
    150 
    151 #include <sys/rwlock.h>
    152 #include <sys/mutex.h>
    153 #include <sys/queue.h>
    154 #include <sys/condvar.h>
    155 #include <sys/mount.h>
    156 #include <sys/pool.h>
    157 
    158 /*
    159  * Compile-time options for LFS.
    160  */
    161 #define LFS_IFIND_RETRIES  16
    162 #define LFS_LOGLENGTH      1024 /* size of debugging log */
    163 #define LFS_MAX_ACTIVE	   10	/* Dirty segments before ckp forced */
    164 
    165 /*
    166  * Fixed filesystem layout parameters
    167  */
    168 #define	LFS_LABELPAD	8192		/* LFS label size */
    169 #define	LFS_SBPAD	8192		/* LFS superblock size */
    170 
    171 #define	LFS_UNUSED_INUM	0		/* 0: out of band inode number */
    172 #define	LFS_IFILE_INUM	1		/* 1: IFILE inode number */
    173 					/* 2: Root inode number */
    174 #define	LFS_LOSTFOUNDINO 3		/* 3: lost+found inode number */
    175 #define	LFS_FIRST_INUM	4		/* 4: first free inode number */
    176 
    177 /*
    178  * The root inode is the root of the file system.  Inode 0 can't be used for
    179  * normal purposes and historically bad blocks were linked to inode 1, thus
    180  * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
    181  * numerous dump tapes make this assumption, so we are stuck with it).
    182  */
    183 #define	ULFS_ROOTINO	((ino_t)2)
    184 
    185 /*
    186  * The Whiteout inode# is a dummy non-zero inode number which will
    187  * never be allocated to a real file.  It is used as a place holder
    188  * in the directory entry which has been tagged as a LFS_DT_WHT entry.
    189  * See the comments about ULFS_ROOTINO above.
    190  */
    191 #define	ULFS_WINO	((ino_t)1)
    192 
    193 
    194 #define	LFS_V1_SUMMARY_SIZE	512     /* V1 fixed summary size */
    195 #define	LFS_DFL_SUMMARY_SIZE	512	/* Default summary size */
    196 
    197 #define LFS_MAX_DADDR	0x7fffffff	/* Highest addressable fsb */
    198 
    199 #define LFS_MAXNAMLEN	255		/* maximum name length in a dir */
    200 
    201 #define ULFS_NXADDR	2
    202 #define	ULFS_NDADDR	12		/* Direct addresses in inode. */
    203 #define	ULFS_NIADDR	3		/* Indirect addresses in inode. */
    204 
    205 /*
    206  * Adjustable filesystem parameters
    207  */
    208 #ifndef LFS_ATIME_IFILE
    209 # define LFS_ATIME_IFILE 0 /* Store atime info in ifile (optional in LFSv1) */
    210 #endif
    211 #define LFS_MARKV_MAXBLKCNT	65536	/* Max block count for lfs_markv() */
    212 
    213 /*
    214  * Directories
    215  */
    216 
    217 /*
    218  * A directory consists of some number of blocks of LFS_DIRBLKSIZ
    219  * bytes, where LFS_DIRBLKSIZ is chosen such that it can be transferred
    220  * to disk in a single atomic operation (e.g. 512 bytes on most machines).
    221  *
    222  * Each LFS_DIRBLKSIZ byte block contains some number of directory entry
    223  * structures, which are of variable length.  Each directory entry has
    224  * a struct lfs_direct at the front of it, containing its inode number,
    225  * the length of the entry, and the length of the name contained in
    226  * the entry.  These are followed by the name padded to a 4 byte boundary.
    227  * All names are guaranteed null terminated.
    228  * The maximum length of a name in a directory is LFS_MAXNAMLEN.
    229  *
    230  * The macro DIRSIZ(fmt, dp) gives the amount of space required to represent
    231  * a directory entry.  Free space in a directory is represented by
    232  * entries which have dp->d_reclen > DIRSIZ(fmt, dp).  All LFS_DIRBLKSIZ bytes
    233  * in a directory block are claimed by the directory entries.  This
    234  * usually results in the last entry in a directory having a large
    235  * dp->d_reclen.  When entries are deleted from a directory, the
    236  * space is returned to the previous entry in the same directory
    237  * block by increasing its dp->d_reclen.  If the first entry of
    238  * a directory block is free, then its dp->d_ino is set to 0.
    239  * Entries other than the first in a directory do not normally have
    240  * dp->d_ino set to 0.
    241  */
    242 
    243 /*
    244  * Directory block size.
    245  */
    246 #undef	LFS_DIRBLKSIZ
    247 #define	LFS_DIRBLKSIZ	DEV_BSIZE
    248 
    249 /*
    250  * Convert between stat structure types and directory types.
    251  */
    252 #define	LFS_IFTODT(mode)	(((mode) & 0170000) >> 12)
    253 #define	LFS_DTTOIF(dirtype)	((dirtype) << 12)
    254 
    255 /*
    256  * The LFS_DIRSIZ macro gives the minimum record length which will hold
    257  * the directory entry.  This requires the amount of space in struct lfs_direct
    258  * without the d_name field, plus enough space for the name with a terminating
    259  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
    260  */
    261 #define	LFS_DIRECTSIZ(namlen) \
    262 	((sizeof(struct lfs_direct) - (LFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3))
    263 
    264 #if (BYTE_ORDER == LITTLE_ENDIAN)
    265 #define LFS_DIRSIZ(oldfmt, dp, needswap)	\
    266     (((oldfmt) && !(needswap)) ?		\
    267     LFS_DIRECTSIZ((dp)->d_type) : LFS_DIRECTSIZ((dp)->d_namlen))
    268 #else
    269 #define LFS_DIRSIZ(oldfmt, dp, needswap)	\
    270     (((oldfmt) && (needswap)) ?			\
    271     LFS_DIRECTSIZ((dp)->d_type) : LFS_DIRECTSIZ((dp)->d_namlen))
    272 #endif
    273 
    274 /* Constants for the first argument of LFS_DIRSIZ */
    275 #define LFS_OLDDIRFMT	1
    276 #define LFS_NEWDIRFMT	0
    277 
    278 /*
    279  * Theoretically, directories can be more than 2Gb in length; however, in
    280  * practice this seems unlikely. So, we define the type doff_t as a 32-bit
    281  * quantity to keep down the cost of doing lookup on a 32-bit machine.
    282  */
    283 #define	doff_t		int32_t
    284 #define	lfs_doff_t	int32_t
    285 #define	LFS_MAXDIRSIZE	(0x7fffffff)
    286 
    287 /*
    288  * File types for d_type
    289  */
    290 #define	LFS_DT_UNKNOWN	 0
    291 #define	LFS_DT_FIFO	 1
    292 #define	LFS_DT_CHR	 2
    293 #define	LFS_DT_DIR	 4
    294 #define	LFS_DT_BLK	 6
    295 #define	LFS_DT_REG	 8
    296 #define	LFS_DT_LNK	10
    297 #define	LFS_DT_SOCK	12
    298 #define	LFS_DT_WHT	14
    299 
    300 /*
    301  * (See notes above)
    302  */
    303 #define d_ino d_fileno
    304 struct lfs_direct {
    305 	u_int32_t d_fileno;		/* inode number of entry */
    306 	u_int16_t d_reclen;		/* length of this record */
    307 	u_int8_t  d_type; 		/* file type, see below */
    308 	u_int8_t  d_namlen;		/* length of string in d_name */
    309 	char	  d_name[LFS_MAXNAMLEN + 1];/* name with length <= LFS_MAXNAMLEN */
    310 };
    311 
    312 /*
    313  * Template for manipulating directories.  Should use struct lfs_direct's,
    314  * but the name field is LFS_MAXNAMLEN - 1, and this just won't do.
    315  */
    316 struct lfs_dirtemplate {
    317 	u_int32_t	dot_ino;
    318 	int16_t		dot_reclen;
    319 	u_int8_t	dot_type;
    320 	u_int8_t	dot_namlen;
    321 	char		dot_name[4];	/* must be multiple of 4 */
    322 	u_int32_t	dotdot_ino;
    323 	int16_t		dotdot_reclen;
    324 	u_int8_t	dotdot_type;
    325 	u_int8_t	dotdot_namlen;
    326 	char		dotdot_name[4];	/* ditto */
    327 };
    328 
    329 /*
    330  * This is the old format of directories, sans type element.
    331  */
    332 struct lfs_odirtemplate {
    333 	u_int32_t	dot_ino;
    334 	int16_t		dot_reclen;
    335 	u_int16_t	dot_namlen;
    336 	char		dot_name[4];	/* must be multiple of 4 */
    337 	u_int32_t	dotdot_ino;
    338 	int16_t		dotdot_reclen;
    339 	u_int16_t	dotdot_namlen;
    340 	char		dotdot_name[4];	/* ditto */
    341 };
    342 
    343 /*
    344  * Inodes
    345  */
    346 
    347 /*
    348  * A dinode contains all the meta-data associated with a LFS file.
    349  * This structure defines the on-disk format of a dinode. Since
    350  * this structure describes an on-disk structure, all its fields
    351  * are defined by types with precise widths.
    352  */
    353 
    354 struct ulfs1_dinode {
    355 	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
    356 	int16_t		di_nlink;	/*   2: File link count. */
    357 	u_int32_t	di_inumber;	/*   4: Inode number. */
    358 	u_int64_t	di_size;	/*   8: File byte count. */
    359 	int32_t		di_atime;	/*  16: Last access time. */
    360 	int32_t		di_atimensec;	/*  20: Last access time. */
    361 	int32_t		di_mtime;	/*  24: Last modified time. */
    362 	int32_t		di_mtimensec;	/*  28: Last modified time. */
    363 	int32_t		di_ctime;	/*  32: Last inode change time. */
    364 	int32_t		di_ctimensec;	/*  36: Last inode change time. */
    365 	int32_t		di_db[ULFS_NDADDR]; /*  40: Direct disk blocks. */
    366 	int32_t		di_ib[ULFS_NIADDR]; /*  88: Indirect disk blocks. */
    367 	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
    368 	u_int32_t	di_blocks;	/* 104: Blocks actually held. */
    369 	int32_t		di_gen;		/* 108: Generation number. */
    370 	u_int32_t	di_uid;		/* 112: File owner. */
    371 	u_int32_t	di_gid;		/* 116: File group. */
    372 	u_int64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
    373 };
    374 
    375 struct ulfs2_dinode {
    376 	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
    377 	int16_t		di_nlink;	/*   2: File link count. */
    378 	u_int32_t	di_uid;		/*   4: File owner. */
    379 	u_int32_t	di_gid;		/*   8: File group. */
    380 	u_int32_t	di_blksize;	/*  12: Inode blocksize. */
    381 	u_int64_t	di_size;	/*  16: File byte count. */
    382 	u_int64_t	di_blocks;	/*  24: Bytes actually held. */
    383 	int64_t		di_atime;	/*  32: Last access time. */
    384 	int64_t		di_mtime;	/*  40: Last modified time. */
    385 	int64_t		di_ctime;	/*  48: Last inode change time. */
    386 	int64_t		di_birthtime;	/*  56: Inode creation time. */
    387 	int32_t		di_mtimensec;	/*  64: Last modified time. */
    388 	int32_t		di_atimensec;	/*  68: Last access time. */
    389 	int32_t		di_ctimensec;	/*  72: Last inode change time. */
    390 	int32_t		di_birthnsec;	/*  76: Inode creation time. */
    391 	int32_t		di_gen;		/*  80: Generation number. */
    392 	u_int32_t	di_kernflags;	/*  84: Kernel flags. */
    393 	u_int32_t	di_flags;	/*  88: Status flags (chflags). */
    394 	int32_t		di_extsize;	/*  92: External attributes block. */
    395 	int64_t		di_extb[ULFS_NXADDR];/* 96: External attributes block. */
    396 	int64_t		di_db[ULFS_NDADDR]; /* 112: Direct disk blocks. */
    397 	int64_t		di_ib[ULFS_NIADDR]; /* 208: Indirect disk blocks. */
    398 	u_int64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
    399 	u_int32_t	di_inumber;	/* 240: Inode number */
    400 	u_int32_t	di_spare[3];	/* 244: Reserved; currently unused */
    401 };
    402 
    403 /*
    404  * The di_db fields may be overlaid with other information for
    405  * file types that do not have associated disk storage. Block
    406  * and character devices overlay the first data block with their
    407  * dev_t value. Short symbolic links place their path in the
    408  * di_db area.
    409  */
    410 #define	di_rdev		di_db[0]
    411 
    412 /* Size of the on-disk inode. */
    413 #define	LFS_DINODE1_SIZE	(sizeof(struct ulfs1_dinode))	/* 128 */
    414 #define	LFS_DINODE2_SIZE	(sizeof(struct ulfs2_dinode))
    415 
    416 /* File types, found in the upper bits of di_mode. */
    417 #define	LFS_IFMT	0170000		/* Mask of file type. */
    418 #define	LFS_IFIFO	0010000		/* Named pipe (fifo). */
    419 #define	LFS_IFCHR	0020000		/* Character device. */
    420 #define	LFS_IFDIR	0040000		/* Directory file. */
    421 #define	LFS_IFBLK	0060000		/* Block device. */
    422 #define	LFS_IFREG	0100000		/* Regular file. */
    423 #define	LFS_IFLNK	0120000		/* Symbolic link. */
    424 #define	LFS_IFSOCK	0140000		/* UNIX domain socket. */
    425 #define	LFS_IFWHT	0160000		/* Whiteout. */
    426 
    427 /*
    428  * "struct buf" associated definitions
    429  */
    430 
    431 /* Unassigned disk addresses. */
    432 #define	UNASSIGNED	-1
    433 #define UNWRITTEN	-2
    434 
    435 /* Unused logical block number */
    436 #define LFS_UNUSED_LBN	-1
    437 
    438 /*
    439  * "struct inode" associated definitions
    440  */
    441 
    442 /* For convenience */
    443 #define IN_ALLMOD (IN_MODIFIED|IN_ACCESS|IN_CHANGE|IN_UPDATE|IN_MODIFY|IN_ACCESSED|IN_CLEANING)
    444 
    445 /*
    446  * On-disk and in-memory checkpoint segment usage structure.
    447  */
    448 typedef struct segusage SEGUSE;
    449 struct segusage {
    450 	u_int32_t su_nbytes;		/* 0: number of live bytes */
    451 	u_int32_t su_olastmod;		/* 4: SEGUSE last modified timestamp */
    452 	u_int16_t su_nsums;		/* 8: number of summaries in segment */
    453 	u_int16_t su_ninos;		/* 10: number of inode blocks in seg */
    454 
    455 #define	SEGUSE_ACTIVE		0x01	/*  segment currently being written */
    456 #define	SEGUSE_DIRTY		0x02	/*  segment has data in it */
    457 #define	SEGUSE_SUPERBLOCK	0x04	/*  segment contains a superblock */
    458 #define SEGUSE_ERROR		0x08	/*  cleaner: do not clean segment */
    459 #define SEGUSE_EMPTY		0x10	/*  segment is empty */
    460 #define SEGUSE_INVAL		0x20	/*  segment is invalid */
    461 	u_int32_t su_flags;		/* 12: segment flags */
    462 	u_int64_t su_lastmod;		/* 16: last modified timestamp */
    463 };
    464 
    465 typedef struct segusage_v1 SEGUSE_V1;
    466 struct segusage_v1 {
    467 	u_int32_t su_nbytes;		/* 0: number of live bytes */
    468 	u_int32_t su_lastmod;		/* 4: SEGUSE last modified timestamp */
    469 	u_int16_t su_nsums;		/* 8: number of summaries in segment */
    470 	u_int16_t su_ninos;		/* 10: number of inode blocks in seg */
    471 	u_int32_t su_flags;		/* 12: segment flags  */
    472 };
    473 
    474 /*
    475  * On-disk file information.  One per file with data blocks in the segment.
    476  */
    477 typedef struct finfo FINFO;
    478 struct finfo {
    479 	u_int32_t fi_nblocks;		/* number of blocks */
    480 	u_int32_t fi_version;		/* version number */
    481 	u_int32_t fi_ino;		/* inode number */
    482 	u_int32_t fi_lastlength;	/* length of last block in array */
    483 	int32_t	  fi_blocks[1];		/* array of logical block numbers */
    484 };
    485 /* sizeof FINFO except fi_blocks */
    486 #define	FINFOSIZE	(sizeof(FINFO) - sizeof(int32_t))
    487 
    488 /*
    489  * Index file inode entries.
    490  */
    491 typedef struct ifile IFILE;
    492 struct ifile {
    493 	u_int32_t if_version;		/* inode version number */
    494 #define	LFS_UNUSED_DADDR	0	/* out-of-band daddr */
    495 	int32_t	  if_daddr;		/* inode disk address */
    496 #define LFS_ORPHAN_NEXTFREE	(~(u_int32_t)0) /* indicate orphaned file */
    497 	u_int32_t if_nextfree;		/* next-unallocated inode */
    498 	u_int32_t if_atime_sec;		/* Last access time, seconds */
    499 	u_int32_t if_atime_nsec;	/* and nanoseconds */
    500 };
    501 
    502 typedef struct ifile_v1 IFILE_V1;
    503 struct ifile_v1 {
    504 	u_int32_t if_version;		/* inode version number */
    505 	int32_t	  if_daddr;		/* inode disk address */
    506 	u_int32_t if_nextfree;		/* next-unallocated inode */
    507 #if LFS_ATIME_IFILE
    508 	struct timespec if_atime;	/* Last access time */
    509 #endif
    510 };
    511 
    512 /*
    513  * Cleaner information structure.  This resides in the ifile and is used
    514  * to pass information from the kernel to the cleaner.
    515  */
    516 typedef struct _cleanerinfo {
    517 	u_int32_t clean;		/* number of clean segments */
    518 	u_int32_t dirty;		/* number of dirty segments */
    519 	/* XXX64 bfree and avail must -> 64 */
    520 	int32_t   bfree;		/* disk blocks free */
    521 	int32_t	  avail;		/* disk blocks available */
    522 	u_int32_t free_head;		/* head of the inode free list */
    523 	u_int32_t free_tail;		/* tail of the inode free list */
    524 #define LFS_CLEANER_MUST_CLEAN	0x01
    525 	u_int32_t flags;		/* status word from the kernel */
    526 } CLEANERINFO;
    527 
    528 /*
    529  * On-disk segment summary information
    530  */
    531 typedef struct segsum_v1 SEGSUM_V1;
    532 struct segsum_v1 {
    533 	u_int32_t ss_sumsum;		/* 0: check sum of summary block */
    534 	u_int32_t ss_datasum;		/* 4: check sum of data */
    535 	u_int32_t ss_magic;		/* 8: segment summary magic number */
    536 #define SS_MAGIC	0x061561
    537 	int32_t	  ss_next;		/* 12: next segment */
    538 	u_int32_t ss_create;		/* 16: creation time stamp */
    539 	u_int16_t ss_nfinfo;		/* 20: number of file info structures */
    540 	u_int16_t ss_ninos;		/* 22: number of inodes in summary */
    541 
    542 #define	SS_DIROP	0x01		/* segment begins a dirop */
    543 #define	SS_CONT		0x02		/* more partials to finish this write*/
    544 #define	SS_CLEAN	0x04		/* written by the cleaner */
    545 #define	SS_RFW		0x08		/* written by the roll-forward agent */
    546 #define	SS_RECLAIM	0x10		/* written by the roll-forward agent */
    547 	u_int16_t ss_flags;		/* 24: used for directory operations */
    548 	u_int16_t ss_pad;		/* 26: extra space */
    549 	/* FINFO's and inode daddr's... */
    550 };
    551 
    552 typedef struct segsum SEGSUM;
    553 struct segsum {
    554 	u_int32_t ss_sumsum;		/* 0: check sum of summary block */
    555 	u_int32_t ss_datasum;		/* 4: check sum of data */
    556 	u_int32_t ss_magic;		/* 8: segment summary magic number */
    557 	int32_t	  ss_next;		/* 12: next segment (disk address) */
    558 	u_int32_t ss_ident;		/* 16: roll-forward fsid */
    559 #define ss_ocreate ss_ident /* ident is where create was in v1 */
    560 	u_int16_t ss_nfinfo;		/* 20: number of file info structures */
    561 	u_int16_t ss_ninos;		/* 22: number of inodes in summary */
    562 	u_int16_t ss_flags;		/* 24: used for directory operations */
    563 	u_int8_t  ss_pad[2];		/* 26: extra space */
    564 	u_int32_t ss_reclino;           /* 28: inode being reclaimed */
    565 	u_int64_t ss_serial;		/* 32: serial number */
    566 	u_int64_t ss_create;		/* 40: time stamp */
    567 	/* FINFO's and inode daddr's... */
    568 };
    569 
    570 
    571 /*
    572  * On-disk super block.
    573  */
    574 struct dlfs {
    575 #define	       LFS_MAGIC       0x070162
    576 	u_int32_t dlfs_magic;	  /* 0: magic number */
    577 #define	       LFS_VERSION     2
    578 	u_int32_t dlfs_version;	  /* 4: version number */
    579 
    580 	u_int32_t dlfs_size;	  /* 8: number of blocks in fs (v1) */
    581 				  /*	number of frags in fs (v2) */
    582 	u_int32_t dlfs_ssize;	  /* 12: number of blocks per segment (v1) */
    583 				  /*	 number of bytes per segment (v2) */
    584 	u_int32_t dlfs_dsize;	  /* 16: number of disk blocks in fs */
    585 	u_int32_t dlfs_bsize;	  /* 20: file system block size */
    586 	u_int32_t dlfs_fsize;	  /* 24: size of frag blocks in fs */
    587 	u_int32_t dlfs_frag;	  /* 28: number of frags in a block in fs */
    588 
    589 /* Checkpoint region. */
    590 	u_int32_t dlfs_freehd;	  /* 32: start of the free inode list */
    591 	int32_t   dlfs_bfree;	  /* 36: number of free frags */
    592 	u_int32_t dlfs_nfiles;	  /* 40: number of allocated inodes */
    593 	int32_t	  dlfs_avail;	  /* 44: blocks available for writing */
    594 	int32_t	  dlfs_uinodes;	  /* 48: inodes in cache not yet on disk */
    595 	int32_t	  dlfs_idaddr;	  /* 52: inode file disk address */
    596 	u_int32_t dlfs_ifile;	  /* 56: inode file inode number */
    597 	int32_t	  dlfs_lastseg;	  /* 60: address of last segment written */
    598 	int32_t	  dlfs_nextseg;	  /* 64: address of next segment to write */
    599 	int32_t	  dlfs_curseg;	  /* 68: current segment being written */
    600 	int32_t	  dlfs_offset;	  /* 72: offset in curseg for next partial */
    601 	int32_t	  dlfs_lastpseg;  /* 76: address of last partial written */
    602 	u_int32_t dlfs_inopf;	  /* 80: v1: time stamp; v2: inodes per frag */
    603 
    604 /* These are configuration parameters. */
    605 	u_int32_t dlfs_minfree;	  /* 84: minimum percentage of free blocks */
    606 
    607 /* These fields can be computed from the others. */
    608 	u_int64_t dlfs_maxfilesize; /* 88: maximum representable file size */
    609 	u_int32_t dlfs_fsbpseg;	    /* 96: frags (fsb) per segment */
    610 	u_int32_t dlfs_inopb;	  /* 100: inodes per block */
    611 	u_int32_t dlfs_ifpb;	  /* 104: IFILE entries per block */
    612 	u_int32_t dlfs_sepb;	  /* 108: SEGUSE entries per block */
    613 	u_int32_t dlfs_nindir;	  /* 112: indirect pointers per block */
    614 	u_int32_t dlfs_nseg;	  /* 116: number of segments */
    615 	u_int32_t dlfs_nspf;	  /* 120: number of sectors per fragment */
    616 	u_int32_t dlfs_cleansz;	  /* 124: cleaner info size in blocks */
    617 	u_int32_t dlfs_segtabsz;  /* 128: segment table size in blocks */
    618 	u_int32_t dlfs_segmask;	  /* 132: calculate offset within a segment */
    619 	u_int32_t dlfs_segshift;  /* 136: fast mult/div for segments */
    620 	u_int32_t dlfs_bshift;	  /* 140: calc block number from file offset */
    621 	u_int32_t dlfs_ffshift;	  /* 144: fast mult/div for frag from file */
    622 	u_int32_t dlfs_fbshift;	  /* 148: fast mult/div for frag from block */
    623 	u_int64_t dlfs_bmask;	  /* 152: calc block offset from file offset */
    624 	u_int64_t dlfs_ffmask;	  /* 160: calc frag offset from file offset */
    625 	u_int64_t dlfs_fbmask;	  /* 168: calc frag offset from block offset */
    626 	u_int32_t dlfs_blktodb;	  /* 176: blktodb and dbtoblk shift constant */
    627 	u_int32_t dlfs_sushift;	  /* 180: fast mult/div for segusage table */
    628 
    629 	int32_t	  dlfs_maxsymlinklen; /* 184: max length of an internal symlink */
    630 #define LFS_MIN_SBINTERVAL     5  /* minimum superblock segment spacing */
    631 #define LFS_MAXNUMSB	       10 /* 188: superblock disk offsets */
    632 	int32_t	   dlfs_sboffs[LFS_MAXNUMSB];
    633 
    634 	u_int32_t dlfs_nclean;	  /* 228: Number of clean segments */
    635 	u_char	  dlfs_fsmnt[MNAMELEN];	 /* 232: name mounted on */
    636 #define LFS_PF_CLEAN 0x1
    637 	u_int16_t dlfs_pflags;	  /* 322: file system persistent flags */
    638 	int32_t	  dlfs_dmeta;	  /* 324: total number of dirty summaries */
    639 	u_int32_t dlfs_minfreeseg; /* 328: segments not counted in bfree */
    640 	u_int32_t dlfs_sumsize;	  /* 332: size of summary blocks */
    641 	u_int64_t dlfs_serial;	  /* 336: serial number */
    642 	u_int32_t dlfs_ibsize;	  /* 344: size of inode blocks */
    643 	int32_t	  dlfs_s0addr;	  /* 348: start of segment 0 */
    644 	u_int64_t dlfs_tstamp;	  /* 352: time stamp */
    645 #define LFS_44INODEFMT 0
    646 #define LFS_MAXINODEFMT 0
    647 	u_int32_t dlfs_inodefmt;  /* 360: inode format version */
    648 	u_int32_t dlfs_interleave; /* 364: segment interleave */
    649 	u_int32_t dlfs_ident;	  /* 368: per-fs identifier */
    650 	u_int32_t dlfs_fsbtodb;	  /* 372: fsbtodb and dbtodsb shift constant */
    651 	u_int32_t dlfs_resvseg;   /* 376: segments reserved for the cleaner */
    652 	int8_t	  dlfs_pad[128];  /* 380: round to 512 bytes */
    653 /* Checksum -- last valid disk field. */
    654 	u_int32_t dlfs_cksum;	  /* 508: checksum for superblock checking */
    655 };
    656 
    657 /* Type used for the inode bitmap */
    658 typedef u_int32_t lfs_bm_t;
    659 
    660 /*
    661  * Linked list of segments whose byte count needs updating following a
    662  * file truncation.
    663  */
    664 struct segdelta {
    665 	long segnum;
    666 	size_t num;
    667 	LIST_ENTRY(segdelta) list;
    668 };
    669 
    670 /*
    671  * In-memory super block.
    672  */
    673 struct lfs {
    674 	struct dlfs lfs_dlfs;		/* on-disk parameters */
    675 
    676 /* These fields are set at mount time and are meaningless on disk. */
    677 	struct segment *lfs_sp;		/* current segment being written */
    678 	struct vnode *lfs_ivnode;	/* vnode for the ifile */
    679 	u_int32_t  lfs_seglock;		/* single-thread the segment writer */
    680 	pid_t	  lfs_lockpid;		/* pid of lock holder */
    681 	lwpid_t	  lfs_locklwp;		/* lwp of lock holder */
    682 	u_int32_t lfs_iocount;		/* number of ios pending */
    683 	u_int32_t lfs_writer;		/* don't allow any dirops to start */
    684 	u_int32_t lfs_dirops;		/* count of active directory ops */
    685 	u_int32_t lfs_dirvcount;	/* count of VDIROP nodes in this fs */
    686 	u_int32_t lfs_doifile;		/* Write ifile blocks on next write */
    687 	u_int32_t lfs_nactive;		/* Number of segments since last ckp */
    688 	int8_t	  lfs_fmod;		/* super block modified flag */
    689 	int8_t	  lfs_ronly;		/* mounted read-only flag */
    690 #define LFS_NOTYET  0x01
    691 #define LFS_IFDIRTY 0x02
    692 #define LFS_WARNED  0x04
    693 #define LFS_UNDIROP 0x08
    694 	int8_t	  lfs_flags;		/* currently unused flag */
    695 	u_int16_t lfs_activesb;		/* toggle between superblocks */
    696 	daddr_t	  lfs_sbactive;		/* disk address of current sb write */
    697 	struct vnode *lfs_flushvp;	/* vnode being flushed */
    698 	int lfs_flushvp_fakevref;	/* fake vref count for flushvp */
    699 	struct vnode *lfs_unlockvp;	/* being inactivated in lfs_segunlock */
    700 	u_int32_t lfs_diropwait;	/* # procs waiting on dirop flush */
    701 	size_t lfs_devbsize;		/* Device block size */
    702 	size_t lfs_devbshift;		/* Device block shift */
    703 	krwlock_t lfs_fraglock;
    704 	krwlock_t lfs_iflock;		/* Ifile lock */
    705 	kcondvar_t lfs_stopcv;		/* Wrap lock */
    706 	struct lwp *lfs_stoplwp;
    707 	pid_t lfs_rfpid;		/* Process ID of roll-forward agent */
    708 	int	  lfs_nadirop;		/* number of active dirop nodes */
    709 	long	  lfs_ravail;		/* blocks pre-reserved for writing */
    710 	long	  lfs_favail;		/* blocks pre-reserved for writing */
    711 	struct lfs_res_blk *lfs_resblk;	/* Reserved memory for pageout */
    712 	TAILQ_HEAD(, inode) lfs_dchainhd; /* dirop vnodes */
    713 	TAILQ_HEAD(, inode) lfs_pchainhd; /* paging vnodes */
    714 #define LFS_RESHASH_WIDTH 17
    715 	LIST_HEAD(, lfs_res_blk) lfs_reshash[LFS_RESHASH_WIDTH];
    716 	int	  lfs_pdflush;		 /* pagedaemon wants us to flush */
    717 	u_int32_t **lfs_suflags;	/* Segment use flags */
    718 #ifdef _KERNEL
    719 	struct pool lfs_clpool;		/* Pool for struct lfs_cluster */
    720 	struct pool lfs_bpppool;	/* Pool for bpp */
    721 	struct pool lfs_segpool;	/* Pool for struct segment */
    722 #endif /* _KERNEL */
    723 #define LFS_MAX_CLEANIND 64
    724 	int32_t  lfs_cleanint[LFS_MAX_CLEANIND]; /* Active cleaning intervals */
    725 	int 	 lfs_cleanind;		/* Index into intervals */
    726 	int lfs_sleepers;		/* # procs sleeping this fs */
    727 	int lfs_pages;			/* dirty pages blaming this fs */
    728 	lfs_bm_t *lfs_ino_bitmap;	/* Inuse inodes bitmap */
    729 	int lfs_nowrap;			/* Suspend log wrap */
    730 	int lfs_wrappass;		/* Allow first log wrap requester to pass */
    731 	int lfs_wrapstatus;		/* Wrap status */
    732 	int lfs_reclino;		/* Inode being reclaimed */
    733 	daddr_t lfs_startseg;           /* Segment we started writing at */
    734 	LIST_HEAD(, segdelta) lfs_segdhd;	/* List of pending trunc accounting events */
    735 
    736 #ifdef _KERNEL
    737 	/* ULFS-level information */
    738 	u_int32_t um_flags;			/* ULFS flags (below) */
    739 	u_long	um_nindir;			/* indirect ptrs per block */
    740 	u_long	um_lognindir;			/* log2 of um_nindir */
    741 	u_long	um_bptrtodb;			/* indir ptr to disk block */
    742 	u_long	um_seqinc;			/* inc between seq blocks */
    743 	int um_maxsymlinklen;
    744 	int um_dirblksiz;
    745 	u_int64_t um_maxfilesize;
    746 
    747 	/* Stuff used by quota2 code, not currently operable */
    748 	unsigned lfs_use_quota2 : 1;
    749 	uint32_t lfs_quota_magic;
    750 	uint8_t lfs_quota_flags;
    751 	uint64_t lfs_quotaino[2];
    752 
    753 	/* Sleep address replacing &lfs_avail inside the on-disk superblock */
    754 	/* XXX: should be replaced with a condvar */
    755 	int lfs_availsleep;
    756 	/* This one replaces &lfs_nextseg... all ditto */
    757 	int lfs_nextsegsleep;
    758 #endif
    759 };
    760 
    761 /*
    762  * Structures used by lfs_bmapv and lfs_markv to communicate information
    763  * about inodes and data blocks.
    764  */
    765 typedef struct block_info {
    766 	u_int32_t bi_inode;		/* inode # */
    767 	int32_t	bi_lbn;			/* logical block w/in file */
    768 	int32_t	bi_daddr;		/* disk address of block */
    769 	u_int64_t bi_segcreate;		/* origin segment create time */
    770 	int	bi_version;		/* file version number */
    771 	void	*bi_bp;			/* data buffer */
    772 	int	bi_size;		/* size of the block (if fragment) */
    773 } BLOCK_INFO;
    774 
    775 /* Compatibility for 1.5 binaries */
    776 typedef struct block_info_15 {
    777 	u_int32_t bi_inode;		/* inode # */
    778 	int32_t	bi_lbn;			/* logical block w/in file */
    779 	int32_t	bi_daddr;		/* disk address of block */
    780 	u_int32_t bi_segcreate;		/* origin segment create time */
    781 	int	bi_version;		/* file version number */
    782 	void	*bi_bp;			/* data buffer */
    783 	int	bi_size;		/* size of the block (if fragment) */
    784 } BLOCK_INFO_15;
    785 
    786 /* In-memory description of a segment about to be written. */
    787 struct segment {
    788 	struct lfs	 *fs;		/* file system pointer */
    789 	struct buf	**bpp;		/* pointer to buffer array */
    790 	struct buf	**cbpp;		/* pointer to next available bp */
    791 	struct buf	**start_bpp;	/* pointer to first bp in this set */
    792 	struct buf	 *ibp;		/* buffer pointer to inode page */
    793 	struct ulfs1_dinode    *idp;          /* pointer to ifile dinode */
    794 	struct finfo	 *fip;		/* current fileinfo pointer */
    795 	struct vnode	 *vp;		/* vnode being gathered */
    796 	void	 *segsum;		/* segment summary info */
    797 	u_int32_t ninodes;		/* number of inodes in this segment */
    798 	int32_t seg_bytes_left;		/* bytes left in segment */
    799 	int32_t sum_bytes_left;		/* bytes left in summary block */
    800 	u_int32_t seg_number;		/* number of this segment */
    801 	int32_t *start_lbp;		/* beginning lbn for this set */
    802 
    803 #define SEGM_CKP	0x0001		/* doing a checkpoint */
    804 #define SEGM_CLEAN	0x0002		/* cleaner call; don't sort */
    805 #define SEGM_SYNC	0x0004		/* wait for segment */
    806 #define SEGM_PROT	0x0008		/* don't inactivate at segunlock */
    807 #define SEGM_PAGEDAEMON	0x0010		/* pagedaemon called us */
    808 #define SEGM_WRITERD	0x0020		/* LFS writed called us */
    809 #define SEGM_FORCE_CKP	0x0040		/* Force checkpoint right away */
    810 #define SEGM_RECLAIM	0x0080		/* Writing to reclaim vnode */
    811 #define SEGM_SINGLE	0x0100		/* Opportunistic writevnodes */
    812 	u_int16_t seg_flags;		/* run-time flags for this segment */
    813 	u_int32_t seg_iocount;		/* number of ios pending */
    814 	int	  ndupino;		/* number of duplicate inodes */
    815 };
    816 
    817 /* Statistics Counters */
    818 struct lfs_stats {	/* Must match sysctl list in lfs_vfsops.h ! */
    819 	u_int	segsused;
    820 	u_int	psegwrites;
    821 	u_int	psyncwrites;
    822 	u_int	pcleanwrites;
    823 	u_int	blocktot;
    824 	u_int	cleanblocks;
    825 	u_int	ncheckpoints;
    826 	u_int	nwrites;
    827 	u_int	nsync_writes;
    828 	u_int	wait_exceeded;
    829 	u_int	write_exceeded;
    830 	u_int	flush_invoked;
    831 	u_int	vflush_invoked;
    832 	u_int	clean_inlocked;
    833 	u_int	clean_vnlocked;
    834 	u_int   segs_reclaimed;
    835 };
    836 
    837 /* Fcntls to take the place of the lfs syscalls */
    838 struct lfs_fcntl_markv {
    839 	BLOCK_INFO *blkiov;	/* blocks to relocate */
    840 	int blkcnt;		/* number of blocks */
    841 };
    842 
    843 #define LFCNSEGWAITALL	_FCNR_FSPRIV('L', 14, struct timeval)
    844 #define LFCNSEGWAIT	_FCNR_FSPRIV('L', 15, struct timeval)
    845 #define LFCNBMAPV	_FCNRW_FSPRIV('L', 2, struct lfs_fcntl_markv)
    846 #define LFCNMARKV	_FCNRW_FSPRIV('L', 3, struct lfs_fcntl_markv)
    847 #define LFCNRECLAIM	 _FCNO_FSPRIV('L', 4)
    848 
    849 struct lfs_fhandle {
    850 	char space[28];	/* FHANDLE_SIZE_COMPAT (but used from userland too) */
    851 };
    852 #define LFCNREWIND       _FCNR_FSPRIV('L', 6, int)
    853 #define LFCNINVAL        _FCNR_FSPRIV('L', 7, int)
    854 #define LFCNRESIZE       _FCNR_FSPRIV('L', 8, int)
    855 #define LFCNWRAPSTOP	 _FCNR_FSPRIV('L', 9, int)
    856 #define LFCNWRAPGO	 _FCNR_FSPRIV('L', 10, int)
    857 #define LFCNIFILEFH	 _FCNW_FSPRIV('L', 11, struct lfs_fhandle)
    858 #define LFCNWRAPPASS	 _FCNR_FSPRIV('L', 12, int)
    859 # define LFS_WRAP_GOING   0x0
    860 # define LFS_WRAP_WAITING 0x1
    861 #define LFCNWRAPSTATUS	 _FCNW_FSPRIV('L', 13, int)
    862 
    863 /* Debug segment lock */
    864 #ifdef notyet
    865 # define ASSERT_SEGLOCK(fs) KASSERT(LFS_SEGLOCK_HELD(fs))
    866 # define ASSERT_NO_SEGLOCK(fs) KASSERT(!LFS_SEGLOCK_HELD(fs))
    867 # define ASSERT_DUNNO_SEGLOCK(fs)
    868 # define ASSERT_MAYBE_SEGLOCK(fs)
    869 #else /* !notyet */
    870 # define ASSERT_DUNNO_SEGLOCK(fs) \
    871 	DLOG((DLOG_SEG, "lfs func %s seglock wrong (%d)\n", __func__, \
    872 		LFS_SEGLOCK_HELD(fs)))
    873 # define ASSERT_SEGLOCK(fs) do {					\
    874 	if (!LFS_SEGLOCK_HELD(fs)) {					\
    875 		DLOG((DLOG_SEG, "lfs func %s seglock wrong (0)\n", __func__)); \
    876 	}								\
    877 } while(0)
    878 # define ASSERT_NO_SEGLOCK(fs) do {					\
    879 	if (LFS_SEGLOCK_HELD(fs)) {					\
    880 		DLOG((DLOG_SEG, "lfs func %s seglock wrong (1)\n", __func__)); \
    881 	}								\
    882 } while(0)
    883 # define ASSERT_MAYBE_SEGLOCK(x)
    884 #endif /* !notyet */
    885 
    886 /*
    887  * Arguments to mount LFS filesystems
    888  */
    889 struct ulfs_args {
    890 	char	*fspec;			/* block special device to mount */
    891 };
    892 
    893 __BEGIN_DECLS
    894 void lfs_itimes(struct inode *, const struct timespec *,
    895     const struct timespec *, const struct timespec *);
    896 __END_DECLS
    897 
    898 #endif /* !_UFS_LFS_LFS_H_ */
    899