xref: /openbmc/linux/fs/ocfs2/ocfs2_ioctl.h (revision 5f66f73b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* -*- mode: c; c-basic-offset: 8; -*-
3  * vim: noexpandtab sw=8 ts=8 sts=0:
4  *
5  * ocfs2_ioctl.h
6  *
7  * Defines OCFS2 ioctls.
8  *
9  * Copyright (C) 2010 Oracle.  All rights reserved.
10  */
11 
12 #ifndef OCFS2_IOCTL_H
13 #define OCFS2_IOCTL_H
14 
15 /*
16  * Space reservation / allocation / free ioctls and argument structure
17  * are designed to be compatible with XFS.
18  *
19  * ALLOCSP* and FREESP* are not and will never be supported, but are
20  * included here for completeness.
21  */
22 struct ocfs2_space_resv {
23 	__s16		l_type;
24 	__s16		l_whence;
25 	__s64		l_start;
26 	__s64		l_len;		/* len == 0 means until end of file */
27 	__s32		l_sysid;
28 	__u32		l_pid;
29 	__s32		l_pad[4];	/* reserve area			    */
30 };
31 
32 #define OCFS2_IOC_ALLOCSP		_IOW ('X', 10, struct ocfs2_space_resv)
33 #define OCFS2_IOC_FREESP		_IOW ('X', 11, struct ocfs2_space_resv)
34 #define OCFS2_IOC_RESVSP		_IOW ('X', 40, struct ocfs2_space_resv)
35 #define OCFS2_IOC_UNRESVSP	_IOW ('X', 41, struct ocfs2_space_resv)
36 #define OCFS2_IOC_ALLOCSP64	_IOW ('X', 36, struct ocfs2_space_resv)
37 #define OCFS2_IOC_FREESP64	_IOW ('X', 37, struct ocfs2_space_resv)
38 #define OCFS2_IOC_RESVSP64	_IOW ('X', 42, struct ocfs2_space_resv)
39 #define OCFS2_IOC_UNRESVSP64	_IOW ('X', 43, struct ocfs2_space_resv)
40 
41 /* Used to pass group descriptor data when online resize is done */
42 struct ocfs2_new_group_input {
43 	__u64 group;		/* Group descriptor's blkno. */
44 	__u32 clusters;		/* Total number of clusters in this group */
45 	__u32 frees;		/* Total free clusters in this group */
46 	__u16 chain;		/* Chain for this group */
47 	__u16 reserved1;
48 	__u32 reserved2;
49 };
50 
51 #define OCFS2_IOC_GROUP_EXTEND	_IOW('o', 1, int)
52 #define OCFS2_IOC_GROUP_ADD	_IOW('o', 2,struct ocfs2_new_group_input)
53 #define OCFS2_IOC_GROUP_ADD64	_IOW('o', 3,struct ocfs2_new_group_input)
54 
55 /* Used to pass 2 file names to reflink. */
56 struct reflink_arguments {
57 	__u64 old_path;
58 	__u64 new_path;
59 	__u64 preserve;
60 };
61 #define OCFS2_IOC_REFLINK	_IOW('o', 4, struct reflink_arguments)
62 
63 /* Following definitions dedicated for ocfs2_info_request ioctls. */
64 #define OCFS2_INFO_MAX_REQUEST		(50)
65 #define OCFS2_TEXT_UUID_LEN		(OCFS2_VOL_UUID_LEN * 2)
66 
67 /* Magic number of all requests */
68 #define OCFS2_INFO_MAGIC		(0x4F32494E)
69 
70 /*
71  * Always try to separate info request into small pieces to
72  * guarantee the backward&forward compatibility.
73  */
74 struct ocfs2_info {
75 	__u64 oi_requests;	/* Array of __u64 pointers to requests */
76 	__u32 oi_count;		/* Number of requests in info_requests */
77 	__u32 oi_pad;
78 };
79 
80 struct ocfs2_info_request {
81 /*00*/	__u32 ir_magic;	/* Magic number */
82 	__u32 ir_code;	/* Info request code */
83 	__u32 ir_size;	/* Size of request */
84 	__u32 ir_flags;	/* Request flags */
85 /*10*/			/* Request specific fields */
86 };
87 
88 struct ocfs2_info_clustersize {
89 	struct ocfs2_info_request ic_req;
90 	__u32 ic_clustersize;
91 	__u32 ic_pad;
92 };
93 
94 struct ocfs2_info_blocksize {
95 	struct ocfs2_info_request ib_req;
96 	__u32 ib_blocksize;
97 	__u32 ib_pad;
98 };
99 
100 struct ocfs2_info_maxslots {
101 	struct ocfs2_info_request im_req;
102 	__u32 im_max_slots;
103 	__u32 im_pad;
104 };
105 
106 struct ocfs2_info_label {
107 	struct ocfs2_info_request il_req;
108 	__u8	il_label[OCFS2_MAX_VOL_LABEL_LEN];
109 } __attribute__ ((packed));
110 
111 struct ocfs2_info_uuid {
112 	struct ocfs2_info_request iu_req;
113 	__u8	iu_uuid_str[OCFS2_TEXT_UUID_LEN + 1];
114 } __attribute__ ((packed));
115 
116 struct ocfs2_info_fs_features {
117 	struct ocfs2_info_request if_req;
118 	__u32 if_compat_features;
119 	__u32 if_incompat_features;
120 	__u32 if_ro_compat_features;
121 	__u32 if_pad;
122 };
123 
124 struct ocfs2_info_journal_size {
125 	struct ocfs2_info_request ij_req;
126 	__u64 ij_journal_size;
127 };
128 
129 struct ocfs2_info_freeinode {
130 	struct ocfs2_info_request ifi_req;
131 	struct ocfs2_info_local_freeinode {
132 		__u64 lfi_total;
133 		__u64 lfi_free;
134 	} ifi_stat[OCFS2_MAX_SLOTS];
135 	__u32 ifi_slotnum; /* out */
136 	__u32 ifi_pad;
137 };
138 
139 #define OCFS2_INFO_MAX_HIST     (32)
140 
141 struct ocfs2_info_freefrag {
142 	struct ocfs2_info_request iff_req;
143 	struct ocfs2_info_freefrag_stats { /* (out) */
144 		struct ocfs2_info_free_chunk_list {
145 			__u32 fc_chunks[OCFS2_INFO_MAX_HIST];
146 			__u32 fc_clusters[OCFS2_INFO_MAX_HIST];
147 		} ffs_fc_hist;
148 		__u32 ffs_clusters;
149 		__u32 ffs_free_clusters;
150 		__u32 ffs_free_chunks;
151 		__u32 ffs_free_chunks_real;
152 		__u32 ffs_min; /* Minimum free chunksize in clusters */
153 		__u32 ffs_max;
154 		__u32 ffs_avg;
155 		__u32 ffs_pad;
156 	} iff_ffs;
157 	__u32 iff_chunksize; /* chunksize in clusters(in) */
158 	__u32 iff_pad;
159 };
160 
161 /* Codes for ocfs2_info_request */
162 enum ocfs2_info_type {
163 	OCFS2_INFO_CLUSTERSIZE = 1,
164 	OCFS2_INFO_BLOCKSIZE,
165 	OCFS2_INFO_MAXSLOTS,
166 	OCFS2_INFO_LABEL,
167 	OCFS2_INFO_UUID,
168 	OCFS2_INFO_FS_FEATURES,
169 	OCFS2_INFO_JOURNAL_SIZE,
170 	OCFS2_INFO_FREEINODE,
171 	OCFS2_INFO_FREEFRAG,
172 	OCFS2_INFO_NUM_TYPES
173 };
174 
175 /* Flags for struct ocfs2_info_request */
176 /* Filled by the caller */
177 #define OCFS2_INFO_FL_NON_COHERENT	(0x00000001)	/* Cluster coherency not
178 							   required. This is a hint.
179 							   It is up to ocfs2 whether
180 							   the request can be fulfilled
181 							   without locking. */
182 /* Filled by ocfs2 */
183 #define OCFS2_INFO_FL_FILLED		(0x40000000)	/* Filesystem understood
184 							   this request and
185 							   filled in the answer */
186 
187 #define OCFS2_INFO_FL_ERROR		(0x80000000)	/* Error happened during
188 							   request handling. */
189 
190 #define OCFS2_IOC_INFO		_IOR('o', 5, struct ocfs2_info)
191 
192 struct ocfs2_move_extents {
193 /* All values are in bytes */
194 	/* in */
195 	__u64 me_start;		/* Virtual start in the file to move */
196 	__u64 me_len;		/* Length of the extents to be moved */
197 	__u64 me_goal;		/* Physical offset of the goal,
198 				   it's in block unit */
199 	__u64 me_threshold;	/* Maximum distance from goal or threshold
200 				   for auto defragmentation */
201 	__u64 me_flags;		/* Flags for the operation:
202 				 * - auto defragmentation.
203 				 * - refcount,xattr cases.
204 				 */
205 	/* out */
206 	__u64 me_moved_len;	/* Moved/defraged length */
207 	__u64 me_new_offset;	/* Resulting physical location */
208 	__u32 me_reserved[2];	/* Reserved for futhure */
209 };
210 
211 #define OCFS2_MOVE_EXT_FL_AUTO_DEFRAG	(0x00000001)	/* Kernel manages to
212 							   claim new clusters
213 							   as the goal place
214 							   for extents moving */
215 #define OCFS2_MOVE_EXT_FL_PART_DEFRAG	(0x00000002)	/* Allow partial extent
216 							   moving, is to make
217 							   movement less likely
218 							   to fail, may make fs
219 							   even more fragmented */
220 #define OCFS2_MOVE_EXT_FL_COMPLETE	(0x00000004)	/* Move or defragmenation
221 							   completely gets done.
222 							 */
223 
224 #define OCFS2_IOC_MOVE_EXT	_IOW('o', 6, struct ocfs2_move_extents)
225 
226 #endif /* OCFS2_IOCTL_H */
227