diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2016-08-02 17:05:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-02 19:35:21 -0400 |
commit | e63e88bc53bac7e4c3f592f8126c51a7569be673 (patch) | |
tree | 6e5855b0b227b520f1590afec9def6e5c47b4bee | |
parent | 4ce5c3426cbe9193f82345fb103e17dc3335eb4f (diff) |
nilfs2: move ioctl interface and disk layout to uapi separately
The header file "include/linux/nilfs2_fs.h" is composed of parts for
ioctl and disk format, and both are intended to be shared with user
space programs.
This moves them to the uapi directory "include/uapi/linux" splitting the
file to "nilfs2_api.h" and "nilfs2_ondisk.h". The following minor
changes are accompanied by this migration:
- nilfs_direct_node struct in nilfs2/direct.h is converged to
nilfs2_ondisk.h because it's an on-disk structure.
- inline functions nilfs_rec_len_from_disk() and
nilfs_rec_len_to_disk() are moved to nilfs2/dir.c.
Link: http://lkml.kernel.org/r/1465825507-3407-4-git-send-email-konishi.ryusuke@lab.ntt.co.jp
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Documentation/filesystems/nilfs2.txt | 3 | ||||
-rw-r--r-- | Documentation/ioctl/ioctl-number.txt | 2 | ||||
-rw-r--r-- | MAINTAINERS | 3 | ||||
-rw-r--r-- | fs/nilfs2/bmap.h | 2 | ||||
-rw-r--r-- | fs/nilfs2/btree.h | 2 | ||||
-rw-r--r-- | fs/nilfs2/cpfile.c | 1 | ||||
-rw-r--r-- | fs/nilfs2/cpfile.h | 3 | ||||
-rw-r--r-- | fs/nilfs2/dat.h | 1 | ||||
-rw-r--r-- | fs/nilfs2/dir.c | 22 | ||||
-rw-r--r-- | fs/nilfs2/direct.h | 10 | ||||
-rw-r--r-- | fs/nilfs2/ifile.h | 1 | ||||
-rw-r--r-- | fs/nilfs2/ioctl.c | 1 | ||||
-rw-r--r-- | fs/nilfs2/nilfs.h | 3 | ||||
-rw-r--r-- | fs/nilfs2/segment.h | 1 | ||||
-rw-r--r-- | fs/nilfs2/sufile.c | 1 | ||||
-rw-r--r-- | fs/nilfs2/sufile.h | 1 | ||||
-rw-r--r-- | include/uapi/linux/nilfs2_api.h | 292 | ||||
-rw-r--r-- | include/uapi/linux/nilfs2_ondisk.h (renamed from include/linux/nilfs2_fs.h) | 328 |
18 files changed, 348 insertions, 329 deletions
diff --git a/Documentation/filesystems/nilfs2.txt b/Documentation/filesystems/nilfs2.txt index 5b21ef76f751..c0727dc36271 100644 --- a/Documentation/filesystems/nilfs2.txt +++ b/Documentation/filesystems/nilfs2.txt | |||
@@ -267,7 +267,8 @@ among NILFS2 files can be depicted as follows: | |||
267 | `-- file (ino=yy) | 267 | `-- file (ino=yy) |
268 | ( regular file, directory, or symlink ) | 268 | ( regular file, directory, or symlink ) |
269 | 269 | ||
270 | For detail on the format of each file, please see include/linux/nilfs2_fs.h. | 270 | For detail on the format of each file, please see nilfs2_ondisk.h |
271 | located at include/uapi/linux directory. | ||
271 | 272 | ||
272 | There are no patents or other intellectual property that we protect | 273 | There are no patents or other intellectual property that we protect |
273 | with regard to the design of NILFS2. It is allowed to replicate the | 274 | with regard to the design of NILFS2. It is allowed to replicate the |
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 56af5e43e9c0..81c7f2bb7daf 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt | |||
@@ -248,7 +248,7 @@ Code Seq#(hex) Include File Comments | |||
248 | 'm' 00 drivers/scsi/megaraid/megaraid_ioctl.h conflict! | 248 | 'm' 00 drivers/scsi/megaraid/megaraid_ioctl.h conflict! |
249 | 'm' 00-1F net/irda/irmod.h conflict! | 249 | 'm' 00-1F net/irda/irmod.h conflict! |
250 | 'n' 00-7F linux/ncp_fs.h and fs/ncpfs/ioctl.c | 250 | 'n' 00-7F linux/ncp_fs.h and fs/ncpfs/ioctl.c |
251 | 'n' 80-8F linux/nilfs2_fs.h NILFS2 | 251 | 'n' 80-8F uapi/linux/nilfs2_api.h NILFS2 |
252 | 'n' E0-FF linux/matroxfb.h matroxfb | 252 | 'n' E0-FF linux/matroxfb.h matroxfb |
253 | 'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2 | 253 | 'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2 |
254 | 'o' 00-03 mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps) | 254 | 'o' 00-03 mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps) |
diff --git a/MAINTAINERS b/MAINTAINERS index bb51bbbc9e1d..e9eacacf0f08 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -8258,8 +8258,9 @@ T: git git://github.com/konis/nilfs2.git | |||
8258 | S: Supported | 8258 | S: Supported |
8259 | F: Documentation/filesystems/nilfs2.txt | 8259 | F: Documentation/filesystems/nilfs2.txt |
8260 | F: fs/nilfs2/ | 8260 | F: fs/nilfs2/ |
8261 | F: include/linux/nilfs2_fs.h | ||
8262 | F: include/trace/events/nilfs2.h | 8261 | F: include/trace/events/nilfs2.h |
8262 | F: include/uapi/linux/nilfs2_api.h | ||
8263 | F: include/uapi/linux/nilfs2_ondisk.h | ||
8263 | 8264 | ||
8264 | NINJA SCSI-3 / NINJA SCSI-32Bi (16bit/CardBus) PCMCIA SCSI HOST ADAPTER DRIVER | 8265 | NINJA SCSI-3 / NINJA SCSI-32Bi (16bit/CardBus) PCMCIA SCSI HOST ADAPTER DRIVER |
8265 | M: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp> | 8266 | M: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp> |
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index b6a4c8f93ac8..2b6ffbe5997a 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/fs.h> | 23 | #include <linux/fs.h> |
24 | #include <linux/buffer_head.h> | 24 | #include <linux/buffer_head.h> |
25 | #include <linux/nilfs2_fs.h> | 25 | #include <linux/nilfs2_ondisk.h> /* nilfs_binfo, nilfs_inode, etc */ |
26 | #include "alloc.h" | 26 | #include "alloc.h" |
27 | #include "dat.h" | 27 | #include "dat.h" |
28 | 28 | ||
diff --git a/fs/nilfs2/btree.h b/fs/nilfs2/btree.h index df1a25faa83b..2184e47fa4bf 100644 --- a/fs/nilfs2/btree.h +++ b/fs/nilfs2/btree.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/nilfs2_fs.h> | 25 | #include <linux/nilfs2_ondisk.h> /* nilfs_btree_node */ |
26 | #include "btnode.h" | 26 | #include "btnode.h" |
27 | #include "bmap.h" | 27 | #include "bmap.h" |
28 | 28 | ||
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index 19d9f4ae8347..a15a1601e931 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/buffer_head.h> | 22 | #include <linux/buffer_head.h> |
23 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/nilfs2_fs.h> | ||
25 | #include "mdt.h" | 24 | #include "mdt.h" |
26 | #include "cpfile.h" | 25 | #include "cpfile.h" |
27 | 26 | ||
diff --git a/fs/nilfs2/cpfile.h b/fs/nilfs2/cpfile.h index 0249744ae234..6eca972f9673 100644 --- a/fs/nilfs2/cpfile.h +++ b/fs/nilfs2/cpfile.h | |||
@@ -21,7 +21,8 @@ | |||
21 | 21 | ||
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/nilfs2_fs.h> | 24 | #include <linux/nilfs2_api.h> /* nilfs_cpstat */ |
25 | #include <linux/nilfs2_ondisk.h> /* nilfs_inode, nilfs_checkpoint */ | ||
25 | 26 | ||
26 | 27 | ||
27 | int nilfs_cpfile_get_checkpoint(struct inode *, __u64, int, | 28 | int nilfs_cpfile_get_checkpoint(struct inode *, __u64, int, |
diff --git a/fs/nilfs2/dat.h b/fs/nilfs2/dat.h index abbfdabcabea..57dc6cf466d0 100644 --- a/fs/nilfs2/dat.h +++ b/fs/nilfs2/dat.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
25 | #include <linux/nilfs2_ondisk.h> /* nilfs_inode, nilfs_checkpoint */ | ||
25 | 26 | ||
26 | 27 | ||
27 | struct nilfs_palloc_req; | 28 | struct nilfs_palloc_req; |
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 746956d2937a..908ebbf0ac7e 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c | |||
@@ -42,6 +42,28 @@ | |||
42 | #include "nilfs.h" | 42 | #include "nilfs.h" |
43 | #include "page.h" | 43 | #include "page.h" |
44 | 44 | ||
45 | static inline unsigned int nilfs_rec_len_from_disk(__le16 dlen) | ||
46 | { | ||
47 | unsigned int len = le16_to_cpu(dlen); | ||
48 | |||
49 | #if (PAGE_SIZE >= 65536) | ||
50 | if (len == NILFS_MAX_REC_LEN) | ||
51 | return 1 << 16; | ||
52 | #endif | ||
53 | return len; | ||
54 | } | ||
55 | |||
56 | static inline __le16 nilfs_rec_len_to_disk(unsigned int len) | ||
57 | { | ||
58 | #if (PAGE_SIZE >= 65536) | ||
59 | if (len == (1 << 16)) | ||
60 | return cpu_to_le16(NILFS_MAX_REC_LEN); | ||
61 | |||
62 | BUG_ON(len > (1 << 16)); | ||
63 | #endif | ||
64 | return cpu_to_le16(len); | ||
65 | } | ||
66 | |||
45 | /* | 67 | /* |
46 | * nilfs uses block-sized chunks. Arguably, sector-sized ones would be | 68 | * nilfs uses block-sized chunks. Arguably, sector-sized ones would be |
47 | * more robust, but we have what we have | 69 | * more robust, but we have what we have |
diff --git a/fs/nilfs2/direct.h b/fs/nilfs2/direct.h index 3015a6e78724..cfe85e848bba 100644 --- a/fs/nilfs2/direct.h +++ b/fs/nilfs2/direct.h | |||
@@ -24,16 +24,6 @@ | |||
24 | #include "bmap.h" | 24 | #include "bmap.h" |
25 | 25 | ||
26 | 26 | ||
27 | /** | ||
28 | * struct nilfs_direct_node - direct node | ||
29 | * @dn_flags: flags | ||
30 | * @dn_pad: padding | ||
31 | */ | ||
32 | struct nilfs_direct_node { | ||
33 | __u8 dn_flags; | ||
34 | __u8 pad[7]; | ||
35 | }; | ||
36 | |||
37 | #define NILFS_DIRECT_NBLOCKS (NILFS_BMAP_SIZE / sizeof(__le64) - 1) | 27 | #define NILFS_DIRECT_NBLOCKS (NILFS_BMAP_SIZE / sizeof(__le64) - 1) |
38 | #define NILFS_DIRECT_KEY_MIN 0 | 28 | #define NILFS_DIRECT_KEY_MIN 0 |
39 | #define NILFS_DIRECT_KEY_MAX (NILFS_DIRECT_NBLOCKS - 1) | 29 | #define NILFS_DIRECT_KEY_MAX (NILFS_DIRECT_NBLOCKS - 1) |
diff --git a/fs/nilfs2/ifile.h b/fs/nilfs2/ifile.h index 23ad2f091e76..188b94fe0ec5 100644 --- a/fs/nilfs2/ifile.h +++ b/fs/nilfs2/ifile.h | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
25 | #include <linux/buffer_head.h> | 25 | #include <linux/buffer_head.h> |
26 | #include <linux/nilfs2_fs.h> | ||
27 | #include "mdt.h" | 26 | #include "mdt.h" |
28 | #include "alloc.h" | 27 | #include "alloc.h" |
29 | 28 | ||
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index 827283fe9525..f1d7989459fd 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/compat.h> /* compat_ptr() */ | 25 | #include <linux/compat.h> /* compat_ptr() */ |
26 | #include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */ | 26 | #include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */ |
27 | #include <linux/buffer_head.h> | 27 | #include <linux/buffer_head.h> |
28 | #include <linux/nilfs2_fs.h> | ||
29 | #include "nilfs.h" | 28 | #include "nilfs.h" |
30 | #include "segment.h" | 29 | #include "segment.h" |
31 | #include "bmap.h" | 30 | #include "bmap.h" |
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 2ba8a146af1f..33f8c8fc96e8 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h | |||
@@ -23,7 +23,8 @@ | |||
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/blkdev.h> | 25 | #include <linux/blkdev.h> |
26 | #include <linux/nilfs2_fs.h> | 26 | #include <linux/nilfs2_api.h> |
27 | #include <linux/nilfs2_ondisk.h> | ||
27 | #include "the_nilfs.h" | 28 | #include "the_nilfs.h" |
28 | #include "bmap.h" | 29 | #include "bmap.h" |
29 | 30 | ||
diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h index 6565c10b7b76..1060949d7dd2 100644 --- a/fs/nilfs2/segment.h +++ b/fs/nilfs2/segment.h | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/fs.h> | 23 | #include <linux/fs.h> |
24 | #include <linux/buffer_head.h> | 24 | #include <linux/buffer_head.h> |
25 | #include <linux/workqueue.h> | 25 | #include <linux/workqueue.h> |
26 | #include <linux/nilfs2_fs.h> | ||
27 | #include "nilfs.h" | 26 | #include "nilfs.h" |
28 | 27 | ||
29 | struct nilfs_root; | 28 | struct nilfs_root; |
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index 12d11de93602..1541a1e9221a 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/string.h> | 22 | #include <linux/string.h> |
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/errno.h> | 24 | #include <linux/errno.h> |
25 | #include <linux/nilfs2_fs.h> | ||
26 | #include "mdt.h" | 25 | #include "mdt.h" |
27 | #include "sufile.h" | 26 | #include "sufile.h" |
28 | 27 | ||
diff --git a/fs/nilfs2/sufile.h b/fs/nilfs2/sufile.h index 46e89872294c..158a9190c8ec 100644 --- a/fs/nilfs2/sufile.h +++ b/fs/nilfs2/sufile.h | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/nilfs2_fs.h> | ||
25 | #include "mdt.h" | 24 | #include "mdt.h" |
26 | 25 | ||
27 | 26 | ||
diff --git a/include/uapi/linux/nilfs2_api.h b/include/uapi/linux/nilfs2_api.h new file mode 100644 index 000000000000..ef4c1de89b11 --- /dev/null +++ b/include/uapi/linux/nilfs2_api.h | |||
@@ -0,0 +1,292 @@ | |||
1 | /* | ||
2 | * nilfs2_api.h - NILFS2 user space API | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Lesser General Public License as published | ||
8 | * by the Free Software Foundation; either version 2.1 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef _LINUX_NILFS2_API_H | ||
13 | #define _LINUX_NILFS2_API_H | ||
14 | |||
15 | #include <linux/types.h> | ||
16 | #include <linux/ioctl.h> | ||
17 | |||
18 | /** | ||
19 | * struct nilfs_cpinfo - checkpoint information | ||
20 | * @ci_flags: flags | ||
21 | * @ci_pad: padding | ||
22 | * @ci_cno: checkpoint number | ||
23 | * @ci_create: creation timestamp | ||
24 | * @ci_nblk_inc: number of blocks incremented by this checkpoint | ||
25 | * @ci_inodes_count: inodes count | ||
26 | * @ci_blocks_count: blocks count | ||
27 | * @ci_next: next checkpoint number in snapshot list | ||
28 | */ | ||
29 | struct nilfs_cpinfo { | ||
30 | __u32 ci_flags; | ||
31 | __u32 ci_pad; | ||
32 | __u64 ci_cno; | ||
33 | __u64 ci_create; | ||
34 | __u64 ci_nblk_inc; | ||
35 | __u64 ci_inodes_count; | ||
36 | __u64 ci_blocks_count; | ||
37 | __u64 ci_next; | ||
38 | }; | ||
39 | |||
40 | /* checkpoint flags */ | ||
41 | enum { | ||
42 | NILFS_CPINFO_SNAPSHOT, | ||
43 | NILFS_CPINFO_INVALID, | ||
44 | NILFS_CPINFO_SKETCH, | ||
45 | NILFS_CPINFO_MINOR, | ||
46 | }; | ||
47 | |||
48 | #define NILFS_CPINFO_FNS(flag, name) \ | ||
49 | static inline int \ | ||
50 | nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \ | ||
51 | { \ | ||
52 | return !!(cpinfo->ci_flags & (1UL << NILFS_CPINFO_##flag)); \ | ||
53 | } | ||
54 | |||
55 | NILFS_CPINFO_FNS(SNAPSHOT, snapshot) | ||
56 | NILFS_CPINFO_FNS(INVALID, invalid) | ||
57 | NILFS_CPINFO_FNS(MINOR, minor) | ||
58 | |||
59 | /** | ||
60 | * nilfs_suinfo - segment usage information | ||
61 | * @sui_lastmod: timestamp of last modification | ||
62 | * @sui_nblocks: number of written blocks in segment | ||
63 | * @sui_flags: segment usage flags | ||
64 | */ | ||
65 | struct nilfs_suinfo { | ||
66 | __u64 sui_lastmod; | ||
67 | __u32 sui_nblocks; | ||
68 | __u32 sui_flags; | ||
69 | }; | ||
70 | |||
71 | /* segment usage flags */ | ||
72 | enum { | ||
73 | NILFS_SUINFO_ACTIVE, | ||
74 | NILFS_SUINFO_DIRTY, | ||
75 | NILFS_SUINFO_ERROR, | ||
76 | }; | ||
77 | |||
78 | #define NILFS_SUINFO_FNS(flag, name) \ | ||
79 | static inline int \ | ||
80 | nilfs_suinfo_##name(const struct nilfs_suinfo *si) \ | ||
81 | { \ | ||
82 | return si->sui_flags & (1UL << NILFS_SUINFO_##flag); \ | ||
83 | } | ||
84 | |||
85 | NILFS_SUINFO_FNS(ACTIVE, active) | ||
86 | NILFS_SUINFO_FNS(DIRTY, dirty) | ||
87 | NILFS_SUINFO_FNS(ERROR, error) | ||
88 | |||
89 | static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si) | ||
90 | { | ||
91 | return !si->sui_flags; | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * nilfs_suinfo_update - segment usage information update | ||
96 | * @sup_segnum: segment number | ||
97 | * @sup_flags: flags for which fields are active in sup_sui | ||
98 | * @sup_reserved: reserved necessary for alignment | ||
99 | * @sup_sui: segment usage information | ||
100 | */ | ||
101 | struct nilfs_suinfo_update { | ||
102 | __u64 sup_segnum; | ||
103 | __u32 sup_flags; | ||
104 | __u32 sup_reserved; | ||
105 | struct nilfs_suinfo sup_sui; | ||
106 | }; | ||
107 | |||
108 | enum { | ||
109 | NILFS_SUINFO_UPDATE_LASTMOD, | ||
110 | NILFS_SUINFO_UPDATE_NBLOCKS, | ||
111 | NILFS_SUINFO_UPDATE_FLAGS, | ||
112 | __NR_NILFS_SUINFO_UPDATE_FIELDS, | ||
113 | }; | ||
114 | |||
115 | #define NILFS_SUINFO_UPDATE_FNS(flag, name) \ | ||
116 | static inline void \ | ||
117 | nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \ | ||
118 | { \ | ||
119 | sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \ | ||
120 | } \ | ||
121 | static inline void \ | ||
122 | nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \ | ||
123 | { \ | ||
124 | sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \ | ||
125 | } \ | ||
126 | static inline int \ | ||
127 | nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \ | ||
128 | { \ | ||
129 | return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\ | ||
130 | } | ||
131 | |||
132 | NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod) | ||
133 | NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks) | ||
134 | NILFS_SUINFO_UPDATE_FNS(FLAGS, flags) | ||
135 | |||
136 | enum { | ||
137 | NILFS_CHECKPOINT, | ||
138 | NILFS_SNAPSHOT, | ||
139 | }; | ||
140 | |||
141 | /** | ||
142 | * struct nilfs_cpmode - change checkpoint mode structure | ||
143 | * @cm_cno: checkpoint number | ||
144 | * @cm_mode: mode of checkpoint | ||
145 | * @cm_pad: padding | ||
146 | */ | ||
147 | struct nilfs_cpmode { | ||
148 | __u64 cm_cno; | ||
149 | __u32 cm_mode; | ||
150 | __u32 cm_pad; | ||
151 | }; | ||
152 | |||
153 | /** | ||
154 | * struct nilfs_argv - argument vector | ||
155 | * @v_base: pointer on data array from userspace | ||
156 | * @v_nmembs: number of members in data array | ||
157 | * @v_size: size of data array in bytes | ||
158 | * @v_flags: flags | ||
159 | * @v_index: start number of target data items | ||
160 | */ | ||
161 | struct nilfs_argv { | ||
162 | __u64 v_base; | ||
163 | __u32 v_nmembs; /* number of members */ | ||
164 | __u16 v_size; /* size of members */ | ||
165 | __u16 v_flags; | ||
166 | __u64 v_index; | ||
167 | }; | ||
168 | |||
169 | /** | ||
170 | * struct nilfs_period - period of checkpoint numbers | ||
171 | * @p_start: start checkpoint number (inclusive) | ||
172 | * @p_end: end checkpoint number (exclusive) | ||
173 | */ | ||
174 | struct nilfs_period { | ||
175 | __u64 p_start; | ||
176 | __u64 p_end; | ||
177 | }; | ||
178 | |||
179 | /** | ||
180 | * struct nilfs_cpstat - checkpoint statistics | ||
181 | * @cs_cno: checkpoint number | ||
182 | * @cs_ncps: number of checkpoints | ||
183 | * @cs_nsss: number of snapshots | ||
184 | */ | ||
185 | struct nilfs_cpstat { | ||
186 | __u64 cs_cno; | ||
187 | __u64 cs_ncps; | ||
188 | __u64 cs_nsss; | ||
189 | }; | ||
190 | |||
191 | /** | ||
192 | * struct nilfs_sustat - segment usage statistics | ||
193 | * @ss_nsegs: number of segments | ||
194 | * @ss_ncleansegs: number of clean segments | ||
195 | * @ss_ndirtysegs: number of dirty segments | ||
196 | * @ss_ctime: creation time of the last segment | ||
197 | * @ss_nongc_ctime: creation time of the last segment not for GC | ||
198 | * @ss_prot_seq: least sequence number of segments which must not be reclaimed | ||
199 | */ | ||
200 | struct nilfs_sustat { | ||
201 | __u64 ss_nsegs; | ||
202 | __u64 ss_ncleansegs; | ||
203 | __u64 ss_ndirtysegs; | ||
204 | __u64 ss_ctime; | ||
205 | __u64 ss_nongc_ctime; | ||
206 | __u64 ss_prot_seq; | ||
207 | }; | ||
208 | |||
209 | /** | ||
210 | * struct nilfs_vinfo - virtual block number information | ||
211 | * @vi_vblocknr: virtual block number | ||
212 | * @vi_start: start checkpoint number (inclusive) | ||
213 | * @vi_end: end checkpoint number (exclusive) | ||
214 | * @vi_blocknr: disk block number | ||
215 | */ | ||
216 | struct nilfs_vinfo { | ||
217 | __u64 vi_vblocknr; | ||
218 | __u64 vi_start; | ||
219 | __u64 vi_end; | ||
220 | __u64 vi_blocknr; | ||
221 | }; | ||
222 | |||
223 | /** | ||
224 | * struct nilfs_vdesc - descriptor of virtual block number | ||
225 | * @vd_ino: inode number | ||
226 | * @vd_cno: checkpoint number | ||
227 | * @vd_vblocknr: virtual block number | ||
228 | * @vd_period: period of checkpoint numbers | ||
229 | * @vd_blocknr: disk block number | ||
230 | * @vd_offset: logical block offset inside a file | ||
231 | * @vd_flags: flags (data or node block) | ||
232 | * @vd_pad: padding | ||
233 | */ | ||
234 | struct nilfs_vdesc { | ||
235 | __u64 vd_ino; | ||
236 | __u64 vd_cno; | ||
237 | __u64 vd_vblocknr; | ||
238 | struct nilfs_period vd_period; | ||
239 | __u64 vd_blocknr; | ||
240 | __u64 vd_offset; | ||
241 | __u32 vd_flags; | ||
242 | __u32 vd_pad; | ||
243 | }; | ||
244 | |||
245 | /** | ||
246 | * struct nilfs_bdesc - descriptor of disk block number | ||
247 | * @bd_ino: inode number | ||
248 | * @bd_oblocknr: disk block address (for skipping dead blocks) | ||
249 | * @bd_blocknr: disk block address | ||
250 | * @bd_offset: logical block offset inside a file | ||
251 | * @bd_level: level in the b-tree organization | ||
252 | * @bd_pad: padding | ||
253 | */ | ||
254 | struct nilfs_bdesc { | ||
255 | __u64 bd_ino; | ||
256 | __u64 bd_oblocknr; | ||
257 | __u64 bd_blocknr; | ||
258 | __u64 bd_offset; | ||
259 | __u32 bd_level; | ||
260 | __u32 bd_pad; | ||
261 | }; | ||
262 | |||
263 | #define NILFS_IOCTL_IDENT 'n' | ||
264 | |||
265 | #define NILFS_IOCTL_CHANGE_CPMODE \ | ||
266 | _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode) | ||
267 | #define NILFS_IOCTL_DELETE_CHECKPOINT \ | ||
268 | _IOW(NILFS_IOCTL_IDENT, 0x81, __u64) | ||
269 | #define NILFS_IOCTL_GET_CPINFO \ | ||
270 | _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv) | ||
271 | #define NILFS_IOCTL_GET_CPSTAT \ | ||
272 | _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat) | ||
273 | #define NILFS_IOCTL_GET_SUINFO \ | ||
274 | _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv) | ||
275 | #define NILFS_IOCTL_GET_SUSTAT \ | ||
276 | _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat) | ||
277 | #define NILFS_IOCTL_GET_VINFO \ | ||
278 | _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv) | ||
279 | #define NILFS_IOCTL_GET_BDESCS \ | ||
280 | _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv) | ||
281 | #define NILFS_IOCTL_CLEAN_SEGMENTS \ | ||
282 | _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5]) | ||
283 | #define NILFS_IOCTL_SYNC \ | ||
284 | _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64) | ||
285 | #define NILFS_IOCTL_RESIZE \ | ||
286 | _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64) | ||
287 | #define NILFS_IOCTL_SET_ALLOC_RANGE \ | ||
288 | _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2]) | ||
289 | #define NILFS_IOCTL_SET_SUINFO \ | ||
290 | _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv) | ||
291 | |||
292 | #endif /* _LINUX_NILFS2_API_H */ | ||
diff --git a/include/linux/nilfs2_fs.h b/include/uapi/linux/nilfs2_ondisk.h index 5988dd57ba66..2a8a3addb675 100644 --- a/include/linux/nilfs2_fs.h +++ b/include/uapi/linux/nilfs2_ondisk.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * nilfs2_fs.h - NILFS2 on-disk structures and common declarations. | 2 | * nilfs2_ondisk.h - NILFS2 on-disk structures |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. | 4 | * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. |
5 | * | 5 | * |
@@ -7,13 +7,6 @@ | |||
7 | * it under the terms of the GNU Lesser General Public License as published | 7 | * it under the terms of the GNU Lesser General Public License as published |
8 | * by the Free Software Foundation; either version 2.1 of the License, or | 8 | * by the Free Software Foundation; either version 2.1 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU Lesser General Public License for more details. | ||
15 | * | ||
16 | * Written by Koji Sato and Ryusuke Konishi. | ||
17 | */ | 10 | */ |
18 | /* | 11 | /* |
19 | * linux/include/linux/ext2_fs.h | 12 | * linux/include/linux/ext2_fs.h |
@@ -30,16 +23,15 @@ | |||
30 | * Copyright (C) 1991, 1992 Linus Torvalds | 23 | * Copyright (C) 1991, 1992 Linus Torvalds |
31 | */ | 24 | */ |
32 | 25 | ||
33 | #ifndef _LINUX_NILFS_FS_H | 26 | #ifndef _LINUX_NILFS2_ONDISK_H |
34 | #define _LINUX_NILFS_FS_H | 27 | #define _LINUX_NILFS2_ONDISK_H |
35 | 28 | ||
36 | #include <linux/types.h> | 29 | #include <linux/types.h> |
37 | #include <linux/ioctl.h> | ||
38 | #include <linux/magic.h> | 30 | #include <linux/magic.h> |
39 | #include <linux/bug.h> | ||
40 | 31 | ||
41 | 32 | ||
42 | #define NILFS_INODE_BMAP_SIZE 7 | 33 | #define NILFS_INODE_BMAP_SIZE 7 |
34 | |||
43 | /** | 35 | /** |
44 | * struct nilfs_inode - structure of an inode on disk | 36 | * struct nilfs_inode - structure of an inode on disk |
45 | * @i_blocks: blocks count | 37 | * @i_blocks: blocks count |
@@ -56,7 +48,7 @@ | |||
56 | * @i_bmap: block mapping | 48 | * @i_bmap: block mapping |
57 | * @i_xattr: extended attributes | 49 | * @i_xattr: extended attributes |
58 | * @i_generation: file generation (for NFS) | 50 | * @i_generation: file generation (for NFS) |
59 | * @i_pad: padding | 51 | * @i_pad: padding |
60 | */ | 52 | */ |
61 | struct nilfs_inode { | 53 | struct nilfs_inode { |
62 | __le64 i_blocks; | 54 | __le64 i_blocks; |
@@ -338,29 +330,7 @@ enum { | |||
338 | #define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) | 330 | #define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) |
339 | #define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ | 331 | #define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ |
340 | ~NILFS_DIR_ROUND) | 332 | ~NILFS_DIR_ROUND) |
341 | #define NILFS_MAX_REC_LEN ((1<<16)-1) | 333 | #define NILFS_MAX_REC_LEN ((1 << 16) - 1) |
342 | |||
343 | static inline unsigned int nilfs_rec_len_from_disk(__le16 dlen) | ||
344 | { | ||
345 | unsigned int len = le16_to_cpu(dlen); | ||
346 | |||
347 | #if !defined(__KERNEL__) || (PAGE_SIZE >= 65536) | ||
348 | if (len == NILFS_MAX_REC_LEN) | ||
349 | return 1 << 16; | ||
350 | #endif | ||
351 | return len; | ||
352 | } | ||
353 | |||
354 | static inline __le16 nilfs_rec_len_to_disk(unsigned int len) | ||
355 | { | ||
356 | #if !defined(__KERNEL__) || (PAGE_SIZE >= 65536) | ||
357 | if (len == (1 << 16)) | ||
358 | return cpu_to_le16(NILFS_MAX_REC_LEN); | ||
359 | else if (len > (1 << 16)) | ||
360 | BUG(); | ||
361 | #endif | ||
362 | return cpu_to_le16(len); | ||
363 | } | ||
364 | 334 | ||
365 | /** | 335 | /** |
366 | * struct nilfs_finfo - file information | 336 | * struct nilfs_finfo - file information |
@@ -374,11 +344,10 @@ struct nilfs_finfo { | |||
374 | __le64 fi_cno; | 344 | __le64 fi_cno; |
375 | __le32 fi_nblocks; | 345 | __le32 fi_nblocks; |
376 | __le32 fi_ndatablk; | 346 | __le32 fi_ndatablk; |
377 | /* array of virtual block numbers */ | ||
378 | }; | 347 | }; |
379 | 348 | ||
380 | /** | 349 | /** |
381 | * struct nilfs_binfo_v - information for the block to which a virtual block number is assigned | 350 | * struct nilfs_binfo_v - information on a data block (except DAT) |
382 | * @bi_vblocknr: virtual block number | 351 | * @bi_vblocknr: virtual block number |
383 | * @bi_blkoff: block offset | 352 | * @bi_blkoff: block offset |
384 | */ | 353 | */ |
@@ -388,7 +357,7 @@ struct nilfs_binfo_v { | |||
388 | }; | 357 | }; |
389 | 358 | ||
390 | /** | 359 | /** |
391 | * struct nilfs_binfo_dat - information for the block which belongs to the DAT file | 360 | * struct nilfs_binfo_dat - information on a DAT node block |
392 | * @bi_blkoff: block offset | 361 | * @bi_blkoff: block offset |
393 | * @bi_level: level | 362 | * @bi_level: level |
394 | * @bi_pad: padding | 363 | * @bi_pad: padding |
@@ -454,7 +423,7 @@ struct nilfs_segment_summary { | |||
454 | #define NILFS_SS_GC 0x0010 /* segment written for cleaner operation */ | 423 | #define NILFS_SS_GC 0x0010 /* segment written for cleaner operation */ |
455 | 424 | ||
456 | /** | 425 | /** |
457 | * struct nilfs_btree_node - B-tree node | 426 | * struct nilfs_btree_node - header of B-tree node block |
458 | * @bn_flags: flags | 427 | * @bn_flags: flags |
459 | * @bn_level: level | 428 | * @bn_level: level |
460 | * @bn_nchildren: number of children | 429 | * @bn_nchildren: number of children |
@@ -476,6 +445,16 @@ struct nilfs_btree_node { | |||
476 | #define NILFS_BTREE_LEVEL_MAX 14 /* Max level (exclusive) */ | 445 | #define NILFS_BTREE_LEVEL_MAX 14 /* Max level (exclusive) */ |
477 | 446 | ||
478 | /** | 447 | /** |
448 | * struct nilfs_direct_node - header of built-in bmap array | ||
449 | * @dn_flags: flags | ||
450 | * @dn_pad: padding | ||
451 | */ | ||
452 | struct nilfs_direct_node { | ||
453 | __u8 dn_flags; | ||
454 | __u8 pad[7]; | ||
455 | }; | ||
456 | |||
457 | /** | ||
479 | * struct nilfs_palloc_group_desc - block group descriptor | 458 | * struct nilfs_palloc_group_desc - block group descriptor |
480 | * @pg_nfrees: number of free entries in block group | 459 | * @pg_nfrees: number of free entries in block group |
481 | */ | 460 | */ |
@@ -574,40 +553,6 @@ NILFS_CHECKPOINT_FNS(INVALID, invalid) | |||
574 | NILFS_CHECKPOINT_FNS(MINOR, minor) | 553 | NILFS_CHECKPOINT_FNS(MINOR, minor) |
575 | 554 | ||
576 | /** | 555 | /** |
577 | * struct nilfs_cpinfo - checkpoint information | ||
578 | * @ci_flags: flags | ||
579 | * @ci_pad: padding | ||
580 | * @ci_cno: checkpoint number | ||
581 | * @ci_create: creation timestamp | ||
582 | * @ci_nblk_inc: number of blocks incremented by this checkpoint | ||
583 | * @ci_inodes_count: inodes count | ||
584 | * @ci_blocks_count: blocks count | ||
585 | * @ci_next: next checkpoint number in snapshot list | ||
586 | */ | ||
587 | struct nilfs_cpinfo { | ||
588 | __u32 ci_flags; | ||
589 | __u32 ci_pad; | ||
590 | __u64 ci_cno; | ||
591 | __u64 ci_create; | ||
592 | __u64 ci_nblk_inc; | ||
593 | __u64 ci_inodes_count; | ||
594 | __u64 ci_blocks_count; | ||
595 | __u64 ci_next; | ||
596 | }; | ||
597 | |||
598 | #define NILFS_CPINFO_FNS(flag, name) \ | ||
599 | static inline int \ | ||
600 | nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \ | ||
601 | { \ | ||
602 | return !!(cpinfo->ci_flags & (1UL << NILFS_CHECKPOINT_##flag)); \ | ||
603 | } | ||
604 | |||
605 | NILFS_CPINFO_FNS(SNAPSHOT, snapshot) | ||
606 | NILFS_CPINFO_FNS(INVALID, invalid) | ||
607 | NILFS_CPINFO_FNS(MINOR, minor) | ||
608 | |||
609 | |||
610 | /** | ||
611 | * struct nilfs_cpfile_header - checkpoint file header | 556 | * struct nilfs_cpfile_header - checkpoint file header |
612 | * @ch_ncheckpoints: number of checkpoints | 557 | * @ch_ncheckpoints: number of checkpoints |
613 | * @ch_nsnapshots: number of snapshots | 558 | * @ch_nsnapshots: number of snapshots |
@@ -619,7 +564,7 @@ struct nilfs_cpfile_header { | |||
619 | struct nilfs_snapshot_list ch_snapshot_list; | 564 | struct nilfs_snapshot_list ch_snapshot_list; |
620 | }; | 565 | }; |
621 | 566 | ||
622 | #define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \ | 567 | #define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \ |
623 | ((sizeof(struct nilfs_cpfile_header) + \ | 568 | ((sizeof(struct nilfs_cpfile_header) + \ |
624 | sizeof(struct nilfs_checkpoint) - 1) / \ | 569 | sizeof(struct nilfs_checkpoint) - 1) / \ |
625 | sizeof(struct nilfs_checkpoint)) | 570 | sizeof(struct nilfs_checkpoint)) |
@@ -643,8 +588,6 @@ enum { | |||
643 | NILFS_SEGMENT_USAGE_ACTIVE, | 588 | NILFS_SEGMENT_USAGE_ACTIVE, |
644 | NILFS_SEGMENT_USAGE_DIRTY, | 589 | NILFS_SEGMENT_USAGE_DIRTY, |
645 | NILFS_SEGMENT_USAGE_ERROR, | 590 | NILFS_SEGMENT_USAGE_ERROR, |
646 | |||
647 | /* ... */ | ||
648 | }; | 591 | }; |
649 | 592 | ||
650 | #define NILFS_SEGMENT_USAGE_FNS(flag, name) \ | 593 | #define NILFS_SEGMENT_USAGE_FNS(flag, name) \ |
@@ -699,236 +642,9 @@ struct nilfs_sufile_header { | |||
699 | /* ... */ | 642 | /* ... */ |
700 | }; | 643 | }; |
701 | 644 | ||
702 | #define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \ | 645 | #define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \ |
703 | ((sizeof(struct nilfs_sufile_header) + \ | 646 | ((sizeof(struct nilfs_sufile_header) + \ |
704 | sizeof(struct nilfs_segment_usage) - 1) / \ | 647 | sizeof(struct nilfs_segment_usage) - 1) / \ |
705 | sizeof(struct nilfs_segment_usage)) | 648 | sizeof(struct nilfs_segment_usage)) |
706 | 649 | ||
707 | /** | 650 | #endif /* _LINUX_NILFS2_ONDISK_H */ |
708 | * nilfs_suinfo - segment usage information | ||
709 | * @sui_lastmod: timestamp of last modification | ||
710 | * @sui_nblocks: number of written blocks in segment | ||
711 | * @sui_flags: segment usage flags | ||
712 | */ | ||
713 | struct nilfs_suinfo { | ||
714 | __u64 sui_lastmod; | ||
715 | __u32 sui_nblocks; | ||
716 | __u32 sui_flags; | ||
717 | }; | ||
718 | |||
719 | #define NILFS_SUINFO_FNS(flag, name) \ | ||
720 | static inline int \ | ||
721 | nilfs_suinfo_##name(const struct nilfs_suinfo *si) \ | ||
722 | { \ | ||
723 | return si->sui_flags & (1UL << NILFS_SEGMENT_USAGE_##flag); \ | ||
724 | } | ||
725 | |||
726 | NILFS_SUINFO_FNS(ACTIVE, active) | ||
727 | NILFS_SUINFO_FNS(DIRTY, dirty) | ||
728 | NILFS_SUINFO_FNS(ERROR, error) | ||
729 | |||
730 | static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si) | ||
731 | { | ||
732 | return !si->sui_flags; | ||
733 | } | ||
734 | |||
735 | /* ioctl */ | ||
736 | /** | ||
737 | * nilfs_suinfo_update - segment usage information update | ||
738 | * @sup_segnum: segment number | ||
739 | * @sup_flags: flags for which fields are active in sup_sui | ||
740 | * @sup_reserved: reserved necessary for alignment | ||
741 | * @sup_sui: segment usage information | ||
742 | */ | ||
743 | struct nilfs_suinfo_update { | ||
744 | __u64 sup_segnum; | ||
745 | __u32 sup_flags; | ||
746 | __u32 sup_reserved; | ||
747 | struct nilfs_suinfo sup_sui; | ||
748 | }; | ||
749 | |||
750 | enum { | ||
751 | NILFS_SUINFO_UPDATE_LASTMOD, | ||
752 | NILFS_SUINFO_UPDATE_NBLOCKS, | ||
753 | NILFS_SUINFO_UPDATE_FLAGS, | ||
754 | __NR_NILFS_SUINFO_UPDATE_FIELDS, | ||
755 | }; | ||
756 | |||
757 | #define NILFS_SUINFO_UPDATE_FNS(flag, name) \ | ||
758 | static inline void \ | ||
759 | nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \ | ||
760 | { \ | ||
761 | sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \ | ||
762 | } \ | ||
763 | static inline void \ | ||
764 | nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \ | ||
765 | { \ | ||
766 | sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \ | ||
767 | } \ | ||
768 | static inline int \ | ||
769 | nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \ | ||
770 | { \ | ||
771 | return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\ | ||
772 | } | ||
773 | |||
774 | NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod) | ||
775 | NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks) | ||
776 | NILFS_SUINFO_UPDATE_FNS(FLAGS, flags) | ||
777 | |||
778 | enum { | ||
779 | NILFS_CHECKPOINT, | ||
780 | NILFS_SNAPSHOT, | ||
781 | }; | ||
782 | |||
783 | /** | ||
784 | * struct nilfs_cpmode - change checkpoint mode structure | ||
785 | * @cm_cno: checkpoint number | ||
786 | * @cm_mode: mode of checkpoint | ||
787 | * @cm_pad: padding | ||
788 | */ | ||
789 | struct nilfs_cpmode { | ||
790 | __u64 cm_cno; | ||
791 | __u32 cm_mode; | ||
792 | __u32 cm_pad; | ||
793 | }; | ||
794 | |||
795 | /** | ||
796 | * struct nilfs_argv - argument vector | ||
797 | * @v_base: pointer on data array from userspace | ||
798 | * @v_nmembs: number of members in data array | ||
799 | * @v_size: size of data array in bytes | ||
800 | * @v_flags: flags | ||
801 | * @v_index: start number of target data items | ||
802 | */ | ||
803 | struct nilfs_argv { | ||
804 | __u64 v_base; | ||
805 | __u32 v_nmembs; /* number of members */ | ||
806 | __u16 v_size; /* size of members */ | ||
807 | __u16 v_flags; | ||
808 | __u64 v_index; | ||
809 | }; | ||
810 | |||
811 | /** | ||
812 | * struct nilfs_period - period of checkpoint numbers | ||
813 | * @p_start: start checkpoint number (inclusive) | ||
814 | * @p_end: end checkpoint number (exclusive) | ||
815 | */ | ||
816 | struct nilfs_period { | ||
817 | __u64 p_start; | ||
818 | __u64 p_end; | ||
819 | }; | ||
820 | |||
821 | /** | ||
822 | * struct nilfs_cpstat - checkpoint statistics | ||
823 | * @cs_cno: checkpoint number | ||
824 | * @cs_ncps: number of checkpoints | ||
825 | * @cs_nsss: number of snapshots | ||
826 | */ | ||
827 | struct nilfs_cpstat { | ||
828 | __u64 cs_cno; | ||
829 | __u64 cs_ncps; | ||
830 | __u64 cs_nsss; | ||
831 | }; | ||
832 | |||
833 | /** | ||
834 | * struct nilfs_sustat - segment usage statistics | ||
835 | * @ss_nsegs: number of segments | ||
836 | * @ss_ncleansegs: number of clean segments | ||
837 | * @ss_ndirtysegs: number of dirty segments | ||
838 | * @ss_ctime: creation time of the last segment | ||
839 | * @ss_nongc_ctime: creation time of the last segment not for GC | ||
840 | * @ss_prot_seq: least sequence number of segments which must not be reclaimed | ||
841 | */ | ||
842 | struct nilfs_sustat { | ||
843 | __u64 ss_nsegs; | ||
844 | __u64 ss_ncleansegs; | ||
845 | __u64 ss_ndirtysegs; | ||
846 | __u64 ss_ctime; | ||
847 | __u64 ss_nongc_ctime; | ||
848 | __u64 ss_prot_seq; | ||
849 | }; | ||
850 | |||
851 | /** | ||
852 | * struct nilfs_vinfo - virtual block number information | ||
853 | * @vi_vblocknr: virtual block number | ||
854 | * @vi_start: start checkpoint number (inclusive) | ||
855 | * @vi_end: end checkpoint number (exclusive) | ||
856 | * @vi_blocknr: disk block number | ||
857 | */ | ||
858 | struct nilfs_vinfo { | ||
859 | __u64 vi_vblocknr; | ||
860 | __u64 vi_start; | ||
861 | __u64 vi_end; | ||
862 | __u64 vi_blocknr; | ||
863 | }; | ||
864 | |||
865 | /** | ||
866 | * struct nilfs_vdesc - descriptor of virtual block number | ||
867 | * @vd_ino: inode number | ||
868 | * @vd_cno: checkpoint number | ||
869 | * @vd_vblocknr: virtual block number | ||
870 | * @vd_period: period of checkpoint numbers | ||
871 | * @vd_blocknr: disk block number | ||
872 | * @vd_offset: logical block offset inside a file | ||
873 | * @vd_flags: flags (data or node block) | ||
874 | * @vd_pad: padding | ||
875 | */ | ||
876 | struct nilfs_vdesc { | ||
877 | __u64 vd_ino; | ||
878 | __u64 vd_cno; | ||
879 | __u64 vd_vblocknr; | ||
880 | struct nilfs_period vd_period; | ||
881 | __u64 vd_blocknr; | ||
882 | __u64 vd_offset; | ||
883 | __u32 vd_flags; | ||
884 | __u32 vd_pad; | ||
885 | }; | ||
886 | |||
887 | /** | ||
888 | * struct nilfs_bdesc - descriptor of disk block number | ||
889 | * @bd_ino: inode number | ||
890 | * @bd_oblocknr: disk block address (for skipping dead blocks) | ||
891 | * @bd_blocknr: disk block address | ||
892 | * @bd_offset: logical block offset inside a file | ||
893 | * @bd_level: level in the b-tree organization | ||
894 | * @bd_pad: padding | ||
895 | */ | ||
896 | struct nilfs_bdesc { | ||
897 | __u64 bd_ino; | ||
898 | __u64 bd_oblocknr; | ||
899 | __u64 bd_blocknr; | ||
900 | __u64 bd_offset; | ||
901 | __u32 bd_level; | ||
902 | __u32 bd_pad; | ||
903 | }; | ||
904 | |||
905 | #define NILFS_IOCTL_IDENT 'n' | ||
906 | |||
907 | #define NILFS_IOCTL_CHANGE_CPMODE \ | ||
908 | _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode) | ||
909 | #define NILFS_IOCTL_DELETE_CHECKPOINT \ | ||
910 | _IOW(NILFS_IOCTL_IDENT, 0x81, __u64) | ||
911 | #define NILFS_IOCTL_GET_CPINFO \ | ||
912 | _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv) | ||
913 | #define NILFS_IOCTL_GET_CPSTAT \ | ||
914 | _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat) | ||
915 | #define NILFS_IOCTL_GET_SUINFO \ | ||
916 | _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv) | ||
917 | #define NILFS_IOCTL_GET_SUSTAT \ | ||
918 | _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat) | ||
919 | #define NILFS_IOCTL_GET_VINFO \ | ||
920 | _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv) | ||
921 | #define NILFS_IOCTL_GET_BDESCS \ | ||
922 | _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv) | ||
923 | #define NILFS_IOCTL_CLEAN_SEGMENTS \ | ||
924 | _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5]) | ||
925 | #define NILFS_IOCTL_SYNC \ | ||
926 | _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64) | ||
927 | #define NILFS_IOCTL_RESIZE \ | ||
928 | _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64) | ||
929 | #define NILFS_IOCTL_SET_ALLOC_RANGE \ | ||
930 | _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2]) | ||
931 | #define NILFS_IOCTL_SET_SUINFO \ | ||
932 | _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv) | ||
933 | |||
934 | #endif /* _LINUX_NILFS_FS_H */ | ||