1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38#ifndef _LINUX_NILFS_FS_H
39#define _LINUX_NILFS_FS_H
40
41#include <linux/types.h>
42#include <linux/ioctl.h>
43
44
45
46
47
48
49
50#define NILFS_SECRM_FL 0x00000001
51#define NILFS_UNRM_FL 0x00000002
52#define NILFS_SYNC_FL 0x00000008
53#define NILFS_IMMUTABLE_FL 0x00000010
54#define NILFS_APPEND_FL 0x00000020
55#define NILFS_NODUMP_FL 0x00000040
56#define NILFS_NOATIME_FL 0x00000080
57
58#define NILFS_NOTAIL_FL 0x00008000
59#define NILFS_DIRSYNC_FL 0x00010000
60
61#define NILFS_FL_USER_VISIBLE 0x0003DFFF
62#define NILFS_FL_USER_MODIFIABLE 0x000380FF
63
64
65#define NILFS_INODE_BMAP_SIZE 7
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84struct nilfs_inode {
85 __le64 i_blocks;
86 __le64 i_size;
87 __le64 i_ctime;
88 __le64 i_mtime;
89 __le32 i_ctime_nsec;
90 __le32 i_mtime_nsec;
91 __le32 i_uid;
92 __le32 i_gid;
93 __le16 i_mode;
94 __le16 i_links_count;
95 __le32 i_flags;
96 __le64 i_bmap[NILFS_INODE_BMAP_SIZE];
97#define i_device_code i_bmap[0]
98 __le64 i_xattr;
99 __le32 i_generation;
100 __le32 i_pad;
101};
102
103
104
105
106
107
108
109
110
111
112
113struct nilfs_super_root {
114 __le32 sr_sum;
115 __le16 sr_bytes;
116 __le16 sr_flags;
117 __le64 sr_nongc_ctime;
118 struct nilfs_inode sr_dat;
119 struct nilfs_inode sr_cpfile;
120 struct nilfs_inode sr_sufile;
121};
122
123#define NILFS_SR_MDT_OFFSET(inode_size, i) \
124 ((unsigned long)&((struct nilfs_super_root *)0)->sr_dat + \
125 (inode_size) * (i))
126#define NILFS_SR_DAT_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 0)
127#define NILFS_SR_CPFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 1)
128#define NILFS_SR_SUFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 2)
129#define NILFS_SR_BYTES (sizeof(struct nilfs_super_root))
130
131
132
133
134#define NILFS_DFL_MAX_MNT_COUNT 50
135
136
137
138
139#define NILFS_VALID_FS 0x0001
140#define NILFS_ERROR_FS 0x0002
141#define NILFS_RESIZE_FS 0x0004
142
143
144
145
146#define NILFS_MOUNT_ERROR_MODE 0x0070
147#define NILFS_MOUNT_ERRORS_CONT 0x0010
148#define NILFS_MOUNT_ERRORS_RO 0x0020
149#define NILFS_MOUNT_ERRORS_PANIC 0x0040
150#define NILFS_MOUNT_SNAPSHOT 0x0080
151#define NILFS_MOUNT_BARRIER 0x1000
152#define NILFS_MOUNT_STRICT_ORDER 0x2000
153
154
155
156
157
158
159struct nilfs_super_block {
160 __le32 s_rev_level;
161 __le16 s_minor_rev_level;
162 __le16 s_magic;
163
164 __le16 s_bytes;
165
166
167 __le16 s_flags;
168 __le32 s_crc_seed;
169 __le32 s_sum;
170
171 __le32 s_log_block_size;
172
173
174 __le64 s_nsegments;
175 __le64 s_dev_size;
176 __le64 s_first_data_block;
177 __le32 s_blocks_per_segment;
178 __le32 s_r_segments_percentage;
179
180 __le64 s_last_cno;
181 __le64 s_last_pseg;
182 __le64 s_last_seq;
183 __le64 s_free_blocks_count;
184
185 __le64 s_ctime;
186
187 __le64 s_mtime;
188 __le64 s_wtime;
189 __le16 s_mnt_count;
190 __le16 s_max_mnt_count;
191 __le16 s_state;
192 __le16 s_errors;
193 __le64 s_lastcheck;
194
195 __le32 s_checkinterval;
196 __le32 s_creator_os;
197 __le16 s_def_resuid;
198 __le16 s_def_resgid;
199 __le32 s_first_ino;
200
201 __le16 s_inode_size;
202 __le16 s_dat_entry_size;
203 __le16 s_checkpoint_size;
204 __le16 s_segment_usage_size;
205
206 __u8 s_uuid[16];
207 char s_volume_name[16];
208 char s_last_mounted[64];
209
210 __le32 s_c_interval;
211 __le32 s_c_block_max;
212
213 __u32 s_reserved[192];
214};
215
216
217
218
219#define NILFS_OS_LINUX 0
220
221
222
223
224
225#define NILFS_CURRENT_REV 2
226#define NILFS_MINOR_REV 0
227
228
229
230
231#define NILFS_SB_BYTES \
232 ((long)&((struct nilfs_super_block *)0)->s_reserved)
233
234
235
236
237#define NILFS_ROOT_INO 2
238#define NILFS_DAT_INO 3
239#define NILFS_CPFILE_INO 4
240#define NILFS_SUFILE_INO 5
241#define NILFS_IFILE_INO 6
242#define NILFS_ATIME_INO 7
243#define NILFS_XATTR_INO 8
244#define NILFS_SKETCH_INO 10
245#define NILFS_USER_INO 11
246
247#define NILFS_SB_OFFSET_BYTES 1024
248#define NILFS_SUPER_MAGIC 0x3434
249
250#define NILFS_SEG_MIN_BLOCKS 16
251
252#define NILFS_PSEG_MIN_BLOCKS 2
253
254#define NILFS_MIN_NRSVSEGS 8
255
256
257
258
259
260#define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12)
261
262
263
264
265#define NILFS_LINK_MAX 32000
266
267
268
269
270
271
272#define NILFS_NAME_LEN 255
273
274
275
276
277
278
279
280struct nilfs_dir_entry {
281 __le64 inode;
282 __le16 rec_len;
283 __u8 name_len;
284 __u8 file_type;
285 char name[NILFS_NAME_LEN];
286 char pad;
287};
288
289
290
291
292
293enum {
294 NILFS_FT_UNKNOWN,
295 NILFS_FT_REG_FILE,
296 NILFS_FT_DIR,
297 NILFS_FT_CHRDEV,
298 NILFS_FT_BLKDEV,
299 NILFS_FT_FIFO,
300 NILFS_FT_SOCK,
301 NILFS_FT_SYMLINK,
302 NILFS_FT_MAX
303};
304
305
306
307
308
309
310#define NILFS_DIR_PAD 8
311#define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1)
312#define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \
313 ~NILFS_DIR_ROUND)
314
315
316
317
318
319
320
321
322
323struct nilfs_finfo {
324 __le64 fi_ino;
325 __le64 fi_cno;
326 __le32 fi_nblocks;
327 __le32 fi_ndatablk;
328
329};
330
331
332
333
334
335
336struct nilfs_binfo_v {
337 __le64 bi_vblocknr;
338 __le64 bi_blkoff;
339};
340
341
342
343
344
345
346
347struct nilfs_binfo_dat {
348 __le64 bi_blkoff;
349 __u8 bi_level;
350 __u8 bi_pad[7];
351};
352
353
354
355
356
357
358union nilfs_binfo {
359 struct nilfs_binfo_v bi_v;
360 struct nilfs_binfo_dat bi_dat;
361};
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378struct nilfs_segment_summary {
379 __le32 ss_datasum;
380 __le32 ss_sumsum;
381 __le32 ss_magic;
382 __le16 ss_bytes;
383 __le16 ss_flags;
384 __le64 ss_seq;
385 __le64 ss_create;
386 __le64 ss_next;
387 __le32 ss_nblocks;
388 __le32 ss_nfinfo;
389 __le32 ss_sumbytes;
390 __le32 ss_pad;
391
392};
393
394#define NILFS_SEGSUM_MAGIC 0x1eaffa11
395
396
397
398
399#define NILFS_SS_LOGBGN 0x0001
400#define NILFS_SS_LOGEND 0x0002
401#define NILFS_SS_SR 0x0004
402#define NILFS_SS_SYNDT 0x0008
403#define NILFS_SS_GC 0x0010
404
405
406
407
408
409struct nilfs_palloc_group_desc {
410 __le32 pg_nfrees;
411};
412
413
414
415
416
417
418
419
420struct nilfs_dat_entry {
421 __le64 de_blocknr;
422 __le64 de_start;
423 __le64 de_end;
424 __le64 de_rsv;
425};
426
427
428
429
430
431
432struct nilfs_snapshot_list {
433 __le64 ssl_next;
434 __le64 ssl_prev;
435};
436
437
438
439
440
441
442
443
444
445
446
447
448
449struct nilfs_checkpoint {
450 __le32 cp_flags;
451 __le32 cp_checkpoints_count;
452 struct nilfs_snapshot_list cp_snapshot_list;
453 __le64 cp_cno;
454 __le64 cp_create;
455 __le64 cp_nblk_inc;
456 __le64 cp_inodes_count;
457 __le64 cp_blocks_count;
458
459
460
461
462 struct nilfs_inode cp_ifile_inode;
463};
464
465
466enum {
467 NILFS_CHECKPOINT_SNAPSHOT,
468 NILFS_CHECKPOINT_INVALID,
469 NILFS_CHECKPOINT_SKETCH,
470 NILFS_CHECKPOINT_MINOR,
471};
472
473#define NILFS_CHECKPOINT_FNS(flag, name) \
474static inline void \
475nilfs_checkpoint_set_##name(struct nilfs_checkpoint *cp) \
476{ \
477 cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) | \
478 (1UL << NILFS_CHECKPOINT_##flag)); \
479} \
480static inline void \
481nilfs_checkpoint_clear_##name(struct nilfs_checkpoint *cp) \
482{ \
483 cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) & \
484 ~(1UL << NILFS_CHECKPOINT_##flag)); \
485} \
486static inline int \
487nilfs_checkpoint_##name(const struct nilfs_checkpoint *cp) \
488{ \
489 return !!(le32_to_cpu(cp->cp_flags) & \
490 (1UL << NILFS_CHECKPOINT_##flag)); \
491}
492
493NILFS_CHECKPOINT_FNS(SNAPSHOT, snapshot)
494NILFS_CHECKPOINT_FNS(INVALID, invalid)
495NILFS_CHECKPOINT_FNS(MINOR, minor)
496
497
498
499
500
501
502
503
504
505
506
507
508struct nilfs_cpinfo {
509 __u32 ci_flags;
510 __u32 ci_pad;
511 __u64 ci_cno;
512 __u64 ci_create;
513 __u64 ci_nblk_inc;
514 __u64 ci_inodes_count;
515 __u64 ci_blocks_count;
516 __u64 ci_next;
517};
518
519#define NILFS_CPINFO_FNS(flag, name) \
520static inline int \
521nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \
522{ \
523 return !!(cpinfo->ci_flags & (1UL << NILFS_CHECKPOINT_##flag)); \
524}
525
526NILFS_CPINFO_FNS(SNAPSHOT, snapshot)
527NILFS_CPINFO_FNS(INVALID, invalid)
528NILFS_CPINFO_FNS(MINOR, minor)
529
530
531
532
533
534
535
536
537struct nilfs_cpfile_header {
538 __le64 ch_ncheckpoints;
539 __le64 ch_nsnapshots;
540 struct nilfs_snapshot_list ch_snapshot_list;
541};
542
543#define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \
544 ((sizeof(struct nilfs_cpfile_header) + \
545 sizeof(struct nilfs_checkpoint) - 1) / \
546 sizeof(struct nilfs_checkpoint))
547
548
549
550
551
552
553
554struct nilfs_segment_usage {
555 __le64 su_lastmod;
556 __le32 su_nblocks;
557 __le32 su_flags;
558};
559
560
561enum {
562 NILFS_SEGMENT_USAGE_ACTIVE,
563 NILFS_SEGMENT_USAGE_DIRTY,
564 NILFS_SEGMENT_USAGE_ERROR,
565
566
567};
568
569#define NILFS_SEGMENT_USAGE_FNS(flag, name) \
570static inline void \
571nilfs_segment_usage_set_##name(struct nilfs_segment_usage *su) \
572{ \
573 su->su_flags = cpu_to_le32(le32_to_cpu(su->su_flags) | \
574 (1UL << NILFS_SEGMENT_USAGE_##flag));\
575} \
576static inline void \
577nilfs_segment_usage_clear_##name(struct nilfs_segment_usage *su) \
578{ \
579 su->su_flags = \
580 cpu_to_le32(le32_to_cpu(su->su_flags) & \
581 ~(1UL << NILFS_SEGMENT_USAGE_##flag)); \
582} \
583static inline int \
584nilfs_segment_usage_##name(const struct nilfs_segment_usage *su) \
585{ \
586 return !!(le32_to_cpu(su->su_flags) & \
587 (1UL << NILFS_SEGMENT_USAGE_##flag)); \
588}
589
590NILFS_SEGMENT_USAGE_FNS(ACTIVE, active)
591NILFS_SEGMENT_USAGE_FNS(DIRTY, dirty)
592NILFS_SEGMENT_USAGE_FNS(ERROR, error)
593
594static inline void
595nilfs_segment_usage_set_clean(struct nilfs_segment_usage *su)
596{
597 su->su_lastmod = cpu_to_le64(0);
598 su->su_nblocks = cpu_to_le32(0);
599 su->su_flags = cpu_to_le32(0);
600}
601
602static inline int
603nilfs_segment_usage_clean(const struct nilfs_segment_usage *su)
604{
605 return !le32_to_cpu(su->su_flags);
606}
607
608
609
610
611
612
613
614struct nilfs_sufile_header {
615 __le64 sh_ncleansegs;
616 __le64 sh_ndirtysegs;
617 __le64 sh_last_alloc;
618
619};
620
621#define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \
622 ((sizeof(struct nilfs_sufile_header) + \
623 sizeof(struct nilfs_segment_usage) - 1) / \
624 sizeof(struct nilfs_segment_usage))
625
626
627
628
629
630
631
632struct nilfs_suinfo {
633 __u64 sui_lastmod;
634 __u32 sui_nblocks;
635 __u32 sui_flags;
636};
637
638#define NILFS_SUINFO_FNS(flag, name) \
639static inline int \
640nilfs_suinfo_##name(const struct nilfs_suinfo *si) \
641{ \
642 return si->sui_flags & (1UL << NILFS_SEGMENT_USAGE_##flag); \
643}
644
645NILFS_SUINFO_FNS(ACTIVE, active)
646NILFS_SUINFO_FNS(DIRTY, dirty)
647NILFS_SUINFO_FNS(ERROR, error)
648
649static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si)
650{
651 return !si->sui_flags;
652}
653
654
655enum {
656 NILFS_CHECKPOINT,
657 NILFS_SNAPSHOT,
658};
659
660
661
662
663
664
665struct nilfs_cpmode {
666 __u64 cm_cno;
667 __u32 cm_mode;
668 __u32 cm_pad;
669};
670
671
672
673
674
675
676
677
678
679struct nilfs_argv {
680 __u64 v_base;
681 __u32 v_nmembs;
682 __u16 v_size;
683 __u16 v_flags;
684 __u64 v_index;
685};
686
687
688
689
690
691
692struct nilfs_period {
693 __u64 p_start;
694 __u64 p_end;
695};
696
697
698
699
700
701
702
703struct nilfs_cpstat {
704 __u64 cs_cno;
705 __u64 cs_ncps;
706 __u64 cs_nsss;
707};
708
709
710
711
712
713
714
715
716
717
718struct nilfs_sustat {
719 __u64 ss_nsegs;
720 __u64 ss_ncleansegs;
721 __u64 ss_ndirtysegs;
722 __u64 ss_ctime;
723 __u64 ss_nongc_ctime;
724 __u64 ss_prot_seq;
725};
726
727
728
729
730
731
732
733
734struct nilfs_vinfo {
735 __u64 vi_vblocknr;
736 __u64 vi_start;
737 __u64 vi_end;
738 __u64 vi_blocknr;
739};
740
741
742
743
744struct nilfs_vdesc {
745 __u64 vd_ino;
746 __u64 vd_cno;
747 __u64 vd_vblocknr;
748 struct nilfs_period vd_period;
749 __u64 vd_blocknr;
750 __u64 vd_offset;
751 __u32 vd_flags;
752 __u32 vd_pad;
753};
754
755
756
757
758struct nilfs_bdesc {
759 __u64 bd_ino;
760 __u64 bd_oblocknr;
761 __u64 bd_blocknr;
762 __u64 bd_offset;
763 __u32 bd_level;
764 __u32 bd_pad;
765};
766
767#define NILFS_IOCTL_IDENT 'n'
768
769#define NILFS_IOCTL_CHANGE_CPMODE \
770 _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode)
771#define NILFS_IOCTL_DELETE_CHECKPOINT \
772 _IOW(NILFS_IOCTL_IDENT, 0x81, __u64)
773#define NILFS_IOCTL_GET_CPINFO \
774 _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv)
775#define NILFS_IOCTL_GET_CPSTAT \
776 _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat)
777#define NILFS_IOCTL_GET_SUINFO \
778 _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv)
779#define NILFS_IOCTL_GET_SUSTAT \
780 _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat)
781#define NILFS_IOCTL_GET_VINFO \
782 _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv)
783#define NILFS_IOCTL_GET_BDESCS \
784 _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv)
785#define NILFS_IOCTL_CLEAN_SEGMENTS \
786 _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5])
787#define NILFS_IOCTL_SYNC \
788 _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64)
789#define NILFS_IOCTL_RESIZE \
790 _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64)
791
792#endif
793