1 /*-
2  * Copyright (c) 2010-2012 Semihalf
3  * Copyright (c) 2008, 2009 Reinoud Zandijk
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * Original definitions written by Koji Sato <koji@osrg.net>
27  *                    and Ryusuke Konishi <ryusuke@osrg.net>
28  * From: NetBSD: nandfs_fs.h,v 1.1 2009/07/18 16:31:42 reinoud
29  *
30  * $FreeBSD: stable/10/sys/fs/nandfs/nandfs_fs.h 235537 2012-05-17 10:11:18Z gber $
31  */
32 
33 #ifndef _NANDFS_FS_H
34 #define _NANDFS_FS_H
35 
36 #include <sys/uuid.h>
37 
38 #define	MNINDIR(fsdev)	((fsdev)->nd_blocksize / sizeof(nandfs_daddr_t))
39 
40 /*
41  * Inode structure. There are a few dedicated inode numbers that are
42  * defined here first.
43  */
44 #define	NANDFS_WHT_INO		1	/* Whiteout ino			*/
45 #define	NANDFS_ROOT_INO		2	/* Root file inode		*/
46 #define	NANDFS_DAT_INO		3	/* DAT file			*/
47 #define	NANDFS_CPFILE_INO	4	/* checkpoint file		*/
48 #define	NANDFS_SUFILE_INO	5	/* segment usage file		*/
49 #define	NANDFS_IFILE_INO	6	/* ifile			*/
50 #define	NANDFS_GC_INO		7	/* Cleanerd node		*/
51 #define	NANDFS_ATIME_INO	8	/* Atime file (reserved)	*/
52 #define	NANDFS_XATTR_INO	9	/* Xattribute file (reserved)	*/
53 #define	NANDFS_SKETCH_INO	10	/* Sketch file (obsolete)	*/
54 #define	NANDFS_USER_INO		11	/* First user's file inode number */
55 
56 #define	NANDFS_SYS_NODE(ino) \
57 	(((ino) >= NANDFS_DAT_INO) && ((ino) <= NANDFS_GC_INO))
58 
59 #define	NDADDR		12		/* Direct addresses in inode. */
60 #define	NIADDR		3		/* Indirect addresses in inode. */
61 
62 typedef	int64_t		nandfs_daddr_t;
63 typedef	int64_t		nandfs_lbn_t;
64 
65 struct nandfs_inode {
66 	uint64_t	i_blocks;	/* 0: size in device blocks		*/
67 	uint64_t	i_size;		/* 8: size in bytes			*/
68 	uint64_t	i_ctime;	/* 16: creation time in seconds		*/
69 	uint64_t	i_mtime;	/* 24: modification time in seconds part*/
70 	uint32_t	i_ctime_nsec;	/* 32: creation time nanoseconds part	*/
71 	uint32_t	i_mtime_nsec;	/* 36: modification time in nanoseconds	*/
72 	uint32_t	i_uid;		/* 40: user id				*/
73 	uint32_t	i_gid;		/* 44: group id				*/
74 	uint16_t	i_mode;		/* 48: file mode			*/
75 	uint16_t	i_links_count;	/* 50: number of references to the inode*/
76 	uint32_t	i_flags;	/* 52: NANDFS_*_FL flags		*/
77 	nandfs_daddr_t	i_special;	/* 56: special				*/
78 	nandfs_daddr_t	i_db[NDADDR];	/* 64: Direct disk blocks.		*/
79 	nandfs_daddr_t	i_ib[NIADDR];	/* 160: Indirect disk blocks.		*/
80 	uint64_t	i_xattr;	/* 184: reserved for extended attributes*/
81 	uint32_t	i_generation;	/* 192: file generation for NFS		*/
82 	uint32_t	i_pad[15];	/* 196: make it 64 bits aligned		*/
83 };
84 
85 #ifdef _KERNEL
86 CTASSERT(sizeof(struct nandfs_inode) == 256);
87 #endif
88 
89 /*
90  * Each checkpoint/snapshot has a super root.
91  *
92  * The super root holds the inodes of the three system files: `dat', `cp' and
93  * 'su' files. All other FS state is defined by those.
94  *
95  * It is CRC checksum'ed and time stamped.
96  */
97 
98 struct nandfs_super_root {
99 	uint32_t	sr_sum;		/* check-sum				*/
100 	uint16_t	sr_bytes;	/* byte count of this structure		*/
101 	uint16_t	sr_flags;	/* reserved for flags			*/
102 	uint64_t	sr_nongc_ctime;	/* timestamp, not for cleaner(?)	*/
103 	struct nandfs_inode sr_dat;	/* DAT, virt->phys translation inode	*/
104 	struct nandfs_inode sr_cpfile;	/* CP, checkpoints inode		*/
105 	struct nandfs_inode sr_sufile;	/* SU, segment usage inode		*/
106 };
107 
108 #define	NANDFS_SR_MDT_OFFSET(inode_size, i)			\
109 	((uint32_t)&((struct nandfs_super_root *)0)->sr_dat +	\
110 	(inode_size) * (i))
111 
112 #define	NANDFS_SR_DAT_OFFSET(inode_size)	NANDFS_SR_MDT_OFFSET(inode_size, 0)
113 #define	NANDFS_SR_CPFILE_OFFSET(inode_size)	NANDFS_SR_MDT_OFFSET(inode_size, 1)
114 #define	NANDFS_SR_SUFILE_OFFSET(inode_size)	NANDFS_SR_MDT_OFFSET(inode_size, 2)
115 #define	NANDFS_SR_BYTES			(sizeof(struct nandfs_super_root))
116 
117 /*
118  * The superblock describes the basic structure and mount history. It also
119  * records some sizes of structures found on the disc for sanity checks.
120  *
121  * The superblock is stored at two places: NANDFS_SB_OFFSET_BYTES and
122  * NANDFS_SB2_OFFSET_BYTES.
123  */
124 
125 /* File system states stored on media in superblock's sbp->s_state */
126 #define	NANDFS_VALID_FS		0x0001	/* cleanly unmounted and all is ok  */
127 #define	NANDFS_ERROR_FS		0x0002	/* there were errors detected, fsck */
128 #define	NANDFS_RESIZE_FS	0x0004	/* resize required, XXX unknown flag*/
129 #define	NANDFS_MOUNT_STATE_BITS	"\20\1VALID_FS\2ERROR_FS\3RESIZE_FS"
130 
131 /*
132  * Brief description of control structures:
133  *
134  * NANDFS_NFSAREAS first blocks contain fsdata and some amount of super blocks.
135  * Simple round-robin policy is used in order to choose which block will
136  * contain new super block.
137  *
138  * Simple case with 2 blocks:
139  * 1: fsdata sblock1 [sblock3 [sblock5 ..]]
140  * 2: fsdata sblock2 [sblock4 [sblock6 ..]]
141  */
142 struct nandfs_fsdata {
143 	uint16_t	f_magic;
144 	uint16_t	f_bytes;
145 
146 	uint32_t	f_sum;		/* checksum of fsdata		*/
147 	uint32_t	f_rev_level;	/* major disk format revision	*/
148 
149 	uint64_t	f_ctime;	/* creation time (execution time
150 					   of newfs)			*/
151 	/* Block size represented as: blocksize = 1 << (f_log_block_size + 10)	*/
152 	uint32_t	f_log_block_size;
153 
154 	uint16_t	f_inode_size;		/* size of an inode		*/
155 	uint16_t	f_dat_entry_size;	/* size of a dat entry		*/
156 	uint16_t	f_checkpoint_size;	/* size of a checkpoint		*/
157 	uint16_t	f_segment_usage_size;	/* size of a segment usage	*/
158 
159 	uint16_t	f_sbbytes;		/* byte count of CRC calculation
160 						   for super blocks. s_reserved
161 						   is excluded!			*/
162 
163 	uint16_t	f_errors;		/* behaviour on detecting errors	*/
164 
165 	uint32_t	f_erasesize;
166 	uint64_t	f_nsegments;		/* number of segm. in filesystem	*/
167 	nandfs_daddr_t	f_first_data_block;	/* 1st seg disk block number		*/
168 	uint32_t	f_blocks_per_segment;	/* number of blocks per segment		*/
169 	uint32_t	f_r_segments_percentage;	/* reserved segments percentage		*/
170 
171 	struct uuid	f_uuid;			/* 128-bit uuid for volume		*/
172 	char		f_volume_name[16];	/* volume name				*/
173 	uint32_t	f_pad[104];
174 } __packed;
175 
176 #ifdef _KERNEL
177 CTASSERT(sizeof(struct nandfs_fsdata) == 512);
178 #endif
179 
180 struct nandfs_super_block {
181 	uint16_t	s_magic;		/* magic value for identification */
182 
183 	uint32_t	s_sum;			/* check sum of super block       */
184 
185 	uint64_t	s_last_cno;		/* last checkpoint number         */
186 	uint64_t	s_last_pseg;		/* addr part. segm. written last  */
187 	uint64_t	s_last_seq;		/* seq.number of seg written last */
188 	uint64_t	s_free_blocks_count;	/* free blocks count              */
189 
190 	uint64_t	s_mtime;		/* mount time                     */
191 	uint64_t	s_wtime;		/* write time                     */
192 	uint16_t	s_state;		/* file system state              */
193 
194 	char		s_last_mounted[64];	/* directory where last mounted   */
195 
196 	uint32_t	s_c_interval;		/* commit interval of segment     */
197 	uint32_t	s_c_block_max;		/* threshold of data amount for
198 						   the segment construction */
199 	uint32_t	s_reserved[32];		/* padding to end of the block    */
200 } __packed;
201 
202 #ifdef _KERNEL
203 CTASSERT(sizeof(struct nandfs_super_block) == 256);
204 #endif
205 
206 #define	NANDFS_FSDATA_MAGIC	0xf8da
207 #define	NANDFS_SUPER_MAGIC	0x8008
208 
209 #define	NANDFS_NFSAREAS		4
210 #define	NANDFS_DATA_OFFSET_BYTES(esize)	(NANDFS_NFSAREAS * (esize))
211 
212 #define	NANDFS_SBLOCK_OFFSET_BYTES (sizeof(struct nandfs_fsdata))
213 
214 #define	NANDFS_DEF_BLOCKSIZE	4096
215 #define	NANDFS_MIN_BLOCKSIZE	512
216 
217 #define	NANDFS_DEF_ERASESIZE	(2 << 16)
218 
219 #define	NANDFS_MIN_SEGSIZE	NANDFS_DEF_ERASESIZE
220 
221 #define	NANDFS_CURRENT_REV	9	/* current major revision */
222 
223 #define	NANDFS_FSDATA_CRC_BYTES offsetof(struct nandfs_fsdata, f_pad)
224 /* Bytes count of super_block for CRC-calculation */
225 #define	NANDFS_SB_BYTES  offsetof(struct nandfs_super_block, s_reserved)
226 
227 /* Maximal count of links to a file */
228 #define	NANDFS_LINK_MAX		32000
229 
230 /*
231  * Structure of a directory entry.
232  *
233  * Note that they can't span blocks; the rec_len fills out.
234  */
235 
236 #define	NANDFS_NAME_LEN 255
237 struct nandfs_dir_entry {
238 	uint64_t	inode;			/* inode number */
239 	uint16_t	rec_len;		/* directory entry length */
240 	uint8_t		name_len;		/* name length */
241 	uint8_t		file_type;
242 	char		name[NANDFS_NAME_LEN];	/* file name */
243 	char		pad;
244 };
245 
246 /*
247  * NANDFS_DIR_PAD defines the directory entries boundaries
248  *
249  * NOTE: It must be a multiple of 8
250  */
251 #define	NANDFS_DIR_PAD			8
252 #define	NANDFS_DIR_ROUND		(NANDFS_DIR_PAD - 1)
253 #define	NANDFS_DIR_NAME_OFFSET		(offsetof(struct nandfs_dir_entry, name))
254 #define	NANDFS_DIR_REC_LEN(name_len)					\
255 	(((name_len) + NANDFS_DIR_NAME_OFFSET + NANDFS_DIR_ROUND)	\
256 	& ~NANDFS_DIR_ROUND)
257 #define	NANDFS_DIR_NAME_LEN(name_len)	\
258 	(NANDFS_DIR_REC_LEN(name_len) - NANDFS_DIR_NAME_OFFSET)
259 
260 /*
261  * NiLFS/NANDFS devides the disc into fixed length segments. Each segment is
262  * filled with one or more partial segments of variable lengths.
263  *
264  * Each partial segment has a segment summary header followed by updates of
265  * files and optionally a super root.
266  */
267 
268 /*
269  * Virtual to physical block translation information. For data blocks it maps
270  * logical block number bi_blkoff to virtual block nr bi_vblocknr. For non
271  * datablocks it is the virtual block number assigned to an indirect block
272  * and has no bi_blkoff. The physical block number is the next
273  * available data block in the partial segment after all the binfo's.
274  */
275 struct nandfs_binfo_v {
276 	uint64_t	bi_ino;		/* file's inode			     */
277 	uint64_t	bi_vblocknr;	/* assigned virtual block number     */
278 	uint64_t	bi_blkoff;	/* for file's logical block number   */
279 };
280 
281 /*
282  * DAT allocation. For data blocks just the logical block number that maps on
283  * the next available data block in the partial segment after the binfo's.
284  */
285 struct nandfs_binfo_dat {
286 	uint64_t	bi_ino;
287 	uint64_t	bi_blkoff;	/* DAT file's logical block number */
288 	uint8_t		bi_level;	/* whether this is meta block */
289 	uint8_t		bi_pad[7];
290 };
291 
292 #ifdef _KERNEL
293 CTASSERT(sizeof(struct nandfs_binfo_v) == sizeof(struct nandfs_binfo_dat));
294 #endif
295 
296 /* Convenience union for both types of binfo's */
297 union nandfs_binfo {
298 	struct nandfs_binfo_v bi_v;
299 	struct nandfs_binfo_dat bi_dat;
300 };
301 
302 /* Indirect buffers path */
303 struct nandfs_indir {
304 	nandfs_daddr_t	in_lbn;
305 	int		in_off;
306 };
307 
308 /* The (partial) segment summary */
309 struct nandfs_segment_summary {
310 	uint32_t	ss_datasum;	/* CRC of complete data block        */
311 	uint32_t	ss_sumsum;	/* CRC of segment summary only       */
312 	uint32_t	ss_magic;	/* magic to identify segment summary */
313 	uint16_t	ss_bytes;	/* size of segment summary structure */
314 	uint16_t	ss_flags;	/* NANDFS_SS_* flags                  */
315 	uint64_t	ss_seq;		/* sequence number of this segm. sum */
316 	uint64_t	ss_create;	/* creation timestamp in seconds     */
317 	uint64_t	ss_next;	/* blocknumber of next segment       */
318 	uint32_t	ss_nblocks;	/* number of blocks used by summary  */
319 	uint32_t	ss_nbinfos;	/* number of binfo structures	     */
320 	uint32_t	ss_sumbytes;	/* total size of segment summary     */
321 	uint32_t	ss_pad;
322 	/* stream of binfo structures */
323 };
324 
325 #define	NANDFS_SEGSUM_MAGIC	0x8e680011	/* segment summary magic number */
326 
327 /* Segment summary flags */
328 #define	NANDFS_SS_LOGBGN	0x0001	/* begins a logical segment */
329 #define	NANDFS_SS_LOGEND	0x0002	/* ends a logical segment */
330 #define	NANDFS_SS_SR		0x0004	/* has super root */
331 #define	NANDFS_SS_SYNDT		0x0008	/* includes data only updates */
332 #define	NANDFS_SS_GC		0x0010	/* segment written for cleaner operation */
333 #define	NANDFS_SS_FLAG_BITS	"\20\1LOGBGN\2LOGEND\3SR\4SYNDT\5GC"
334 
335 /* Segment summary constrains */
336 #define	NANDFS_SEG_MIN_BLOCKS	16	/* minimum number of blocks in a
337 					   full segment */
338 #define	NANDFS_PSEG_MIN_BLOCKS	2	/* minimum number of blocks in a
339 					   partial segment */
340 #define	NANDFS_MIN_NRSVSEGS	8	/* minimum number of reserved
341 					   segments */
342 
343 /*
344  * Structure of DAT/inode file.
345  *
346  * A DAT file is devided into groups. The maximum number of groups is the
347  * number of block group descriptors that fit into one block; this descriptor
348  * only gives the number of free entries in the associated group.
349  *
350  * Each group has a block sized bitmap indicating if an entry is taken or
351  * empty. Each bit stands for a DAT entry.
352  *
353  * The inode file has exactly the same format only the entries are inode
354  * entries.
355  */
356 
357 struct nandfs_block_group_desc {
358 	uint32_t	bg_nfrees;	/* num. free entries in block group  */
359 };
360 
361 /* DAT entry in a super root's DAT file */
362 struct nandfs_dat_entry {
363 	uint64_t	de_blocknr;	/* block number                      */
364 	uint64_t	de_start;	/* valid from checkpoint             */
365 	uint64_t	de_end;		/* valid till checkpoint             */
366 	uint64_t	de_rsv;		/* reserved for future use           */
367 };
368 
369 /*
370  * Structure of CP file.
371  *
372  * A snapshot is just a checkpoint only it's protected against removal by the
373  * cleaner. The snapshots are kept on a double linked list of checkpoints.
374  */
375 struct nandfs_snapshot_list {
376 	uint64_t	ssl_next;	/* checkpoint nr. forward */
377 	uint64_t	ssl_prev;	/* checkpoint nr. back    */
378 };
379 
380 /* Checkpoint entry structure */
381 struct nandfs_checkpoint {
382 	uint32_t	cp_flags;		/* NANDFS_CHECKPOINT_* flags          */
383 	uint32_t	cp_checkpoints_count;	/* ZERO, not used anymore?           */
384 	struct nandfs_snapshot_list cp_snapshot_list; /* list of snapshots   */
385 	uint64_t	cp_cno;			/* checkpoint number                 */
386 	uint64_t	cp_create;		/* creation timestamp                */
387 	uint64_t	cp_nblk_inc;		/* number of blocks incremented      */
388 	uint64_t	cp_blocks_count;	/* reserved (might be deleted)       */
389 	struct nandfs_inode cp_ifile_inode;	/* inode file inode          */
390 };
391 
392 /* Checkpoint flags */
393 #define	NANDFS_CHECKPOINT_SNAPSHOT	1
394 #define	NANDFS_CHECKPOINT_INVALID	2
395 #define	NANDFS_CHECKPOINT_SKETCH	4
396 #define	NANDFS_CHECKPOINT_MINOR		8
397 #define	NANDFS_CHECKPOINT_BITS		"\20\1SNAPSHOT\2INVALID\3SKETCH\4MINOR"
398 
399 /* Header of the checkpoint file */
400 struct nandfs_cpfile_header {
401 	uint64_t	ch_ncheckpoints;	/* number of checkpoints             */
402 	uint64_t	ch_nsnapshots;	/* number of snapshots               */
403 	struct nandfs_snapshot_list ch_snapshot_list;	/* snapshot list     */
404 };
405 
406 #define	NANDFS_CPFILE_FIRST_CHECKPOINT_OFFSET		\
407 	((sizeof(struct nandfs_cpfile_header) +		\
408 	sizeof(struct nandfs_checkpoint) - 1) /		\
409 	sizeof(struct nandfs_checkpoint))
410 
411 
412 #define NANDFS_NOSEGMENT        0xffffffff
413 
414 /*
415  * Structure of SU file.
416  *
417  * The segment usage file sums up how each of the segments are used. They are
418  * indexed by their segment number.
419  */
420 
421 /* Segment usage entry */
422 struct nandfs_segment_usage {
423 	uint64_t	su_lastmod;	/* last modified timestamp           */
424 	uint32_t	su_nblocks;	/* number of blocks in segment       */
425 	uint32_t	su_flags;	/* NANDFS_SEGMENT_USAGE_* flags       */
426 };
427 
428 /* Segment usage flag */
429 #define	NANDFS_SEGMENT_USAGE_ACTIVE	1
430 #define	NANDFS_SEGMENT_USAGE_DIRTY	2
431 #define	NANDFS_SEGMENT_USAGE_ERROR	4
432 #define	NANDFS_SEGMENT_USAGE_GC		8
433 #define	NANDFS_SEGMENT_USAGE_BITS	"\20\1ACTIVE\2DIRTY\3ERROR"
434 
435 /* Header of the segment usage file */
436 struct nandfs_sufile_header {
437 	uint64_t	sh_ncleansegs;	/* number of segments marked clean   */
438 	uint64_t	sh_ndirtysegs;	/* number of segments marked dirty   */
439 	uint64_t	sh_last_alloc;	/* last allocated segment number     */
440 };
441 
442 #define	NANDFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET	\
443 	((sizeof(struct nandfs_sufile_header) +		\
444 	sizeof(struct nandfs_segment_usage) - 1) /	\
445 	sizeof(struct nandfs_segment_usage))
446 
447 struct nandfs_seg_stat {
448 	uint64_t	nss_nsegs;
449 	uint64_t	nss_ncleansegs;
450 	uint64_t	nss_ndirtysegs;
451 	uint64_t	nss_ctime;
452 	uint64_t	nss_nongc_ctime;
453 	uint64_t	nss_prot_seq;
454 };
455 
456 enum {
457 	NANDFS_CHECKPOINT,
458 	NANDFS_SNAPSHOT
459 };
460 
461 #define	NANDFS_CPINFO_MAX		512
462 
463 struct nandfs_cpinfo {
464 	uint32_t	nci_flags;
465 	uint32_t	nci_pad;
466 	uint64_t	nci_cno;
467 	uint64_t	nci_create;
468 	uint64_t	nci_nblk_inc;
469 	uint64_t	nci_blocks_count;
470 	uint64_t	nci_next;
471 };
472 
473 #define	NANDFS_SEGMENTS_MAX	512
474 
475 struct nandfs_suinfo {
476 	uint64_t	nsi_num;
477 	uint64_t	nsi_lastmod;
478 	uint32_t	nsi_blocks;
479 	uint32_t	nsi_flags;
480 };
481 
482 #define	NANDFS_VINFO_MAX	512
483 
484 struct nandfs_vinfo {
485 	uint64_t	nvi_ino;
486 	uint64_t	nvi_vblocknr;
487 	uint64_t	nvi_start;
488 	uint64_t	nvi_end;
489 	uint64_t	nvi_blocknr;
490 	int		nvi_alive;
491 };
492 
493 struct nandfs_cpmode {
494 	uint64_t	ncpm_cno;
495 	uint32_t	ncpm_mode;
496 	uint32_t	ncpm_pad;
497 };
498 
499 struct nandfs_argv {
500 	uint64_t	nv_base;
501 	uint32_t	nv_nmembs;
502 	uint16_t	nv_size;
503 	uint16_t	nv_flags;
504 	uint64_t	nv_index;
505 };
506 
507 struct nandfs_cpstat {
508 	uint64_t	ncp_cno;
509 	uint64_t	ncp_ncps;
510 	uint64_t	ncp_nss;
511 };
512 
513 struct nandfs_period {
514 	uint64_t	p_start;
515 	uint64_t	p_end;
516 };
517 
518 struct nandfs_vdesc {
519 	uint64_t	vd_ino;
520 	uint64_t	vd_cno;
521 	uint64_t	vd_vblocknr;
522 	struct nandfs_period	vd_period;
523 	uint64_t	vd_blocknr;
524 	uint64_t	vd_offset;
525 	uint32_t	vd_flags;
526 	uint32_t	vd_pad;
527 };
528 
529 struct nandfs_bdesc {
530 	uint64_t	bd_ino;
531 	uint64_t	bd_oblocknr;
532 	uint64_t	bd_blocknr;
533 	uint64_t	bd_offset;
534 	uint32_t	bd_level;
535 	uint32_t	bd_alive;
536 };
537 
538 #ifndef _KERNEL
539 #ifndef	MNAMELEN
540 #define	MNAMELEN	88
541 #endif
542 #endif
543 
544 struct nandfs_fsinfo {
545 	struct nandfs_fsdata		fs_fsdata;
546 	struct nandfs_super_block	fs_super;
547 	char				fs_dev[MNAMELEN];
548 };
549 
550 #define	NANDFS_MAX_MOUNTS	65535
551 
552 #define	NANDFS_IOCTL_GET_SUSTAT		_IOR('N', 100, struct nandfs_seg_stat)
553 #define	NANDFS_IOCTL_CHANGE_CPMODE	_IOWR('N', 101, struct nandfs_cpmode)
554 #define	NANDFS_IOCTL_GET_CPINFO		_IOWR('N', 102, struct nandfs_argv)
555 #define	NANDFS_IOCTL_DELETE_CP		_IOWR('N', 103, uint64_t[2])
556 #define	NANDFS_IOCTL_GET_CPSTAT		_IOR('N', 104, struct nandfs_cpstat)
557 #define	NANDFS_IOCTL_GET_SUINFO		_IOWR('N', 105, struct nandfs_argv)
558 #define	NANDFS_IOCTL_GET_VINFO		_IOWR('N', 106, struct nandfs_argv)
559 #define	NANDFS_IOCTL_GET_BDESCS		_IOWR('N', 107, struct nandfs_argv)
560 #define	NANDFS_IOCTL_GET_FSINFO		_IOR('N', 108, struct nandfs_fsinfo)
561 #define	NANDFS_IOCTL_MAKE_SNAP		_IOWR('N', 109, uint64_t)
562 #define	NANDFS_IOCTL_DELETE_SNAP	_IOWR('N', 110, uint64_t)
563 #define	NANDFS_IOCTL_SYNC		_IOWR('N', 111, uint64_t)
564 
565 #endif /* _NANDFS_FS_H */
566