3 * Copyright (c) International Business Machines Corp., 2001
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * Module: enginestructs.h
22 #ifndef EVMS_ENGINESTRUCTS_H_INCLUDED
23 #define EVMS_ENGINESTRUCTS_H_INCLUDED 1
30 struct plugin_functions_s;
31 struct fsim_functions_s;
32 struct container_functions_s;
35 * The so_record_t contains information about a .so that was loaded which
36 * contains plug-in(s).
38 typedef struct so_record_s {
40 module_handle_t handle;
45 typedef struct plugin_record_s {
46 object_handle_t app_handle; /* External API handle for this structure; */
47 /* used only by the Engine */
48 plugin_id_t id; /* Plug-in's ID */
49 evms_version_t version; /* Plug-in's version */
50 #if (EVMS_ABI_CODE == 100)
51 evms_version_t required_api_version; /* Version of the Engine plug-in API */
52 /* that the plug-in requires */
54 evms_version_t required_engine_api_version;
55 /* Version of the Engine services API */
56 /* that the plug-in requires */
58 evms_version_t plugin; /* Version of the Engine plug-in API */
59 /* that the plug-in requires */
60 evms_version_t fsim; /* Version of the Engine FSIM API */
61 /* that the FSIM plug-in requires */
62 } required_plugin_api_version;
63 evms_version_t required_container_api_version;
64 /* Version of the Engine container API */
65 /* that the plug-in requires */
67 so_record_t * so_record; /* Record for the shared object from */
68 /* which the plug-in was loaded */
73 struct plugin_functions_s * plugin;
74 struct fsim_functions_s * fsim;
76 struct container_functions_s * container_functions; /* Optional container functions if the */
77 /* plug-in supports containers */
81 typedef struct storage_object_s {
82 object_handle_t app_handle; /* External API handle for this structure; */
83 /* used only by the Engine */
84 object_type_t object_type; /* SEGMENT, REGION, DISK ,... */
85 data_type_t data_type; /* DATA_TYPE, META_DATA_TYPE, FREE_SPACE_TYPE */
86 plugin_record_t * plugin; /* Plug-in record of plug-in that manages this object */
87 struct storage_container_s * producing_container; /* storage_container that produced this object */
88 struct storage_container_s * consuming_container; /* storage_container that consumed this object */
89 dlist_t parent_objects; /* List of parent objects, filled in by parent */
90 dlist_t child_objects; /* List of child objects, filled in by owner */
91 struct storage_object_s * associated_object; /* Object to which this object is associated */
92 u_int32_t flags; /* Defined by SOFLAG_???? in common.h */
93 lsn_t start; /* Relative starting sector of this object */
94 sector_count_t size; /* Size of object in sectors */
95 struct logical_volume_s * volume; /* Volume which comprises this object */
96 evms_feature_header_t * feature_header; /* Copy of EVMS storage object's top feature header */
97 /* read in by Engine */
98 /* NULL if it does not exist */
99 geometry_t geometry; /* Optional geometry of the object */
100 void * private_data; /* Optional plug-in's data for the object */
101 void * consuming_private_data;/* Optional consuming plug-in's data for the object */
102 char name[EVMS_NAME_SIZE+1];/* Object's name, filled in by owner */
106 typedef struct storage_container_s {
107 object_handle_t app_handle; /* External API handle for this structure; */
108 /* used only by the Engine */
109 plugin_record_t * plugin; /* Plug-in record of the plug-in that manages */
111 /* Filled in by the plug-in during discover */
112 /* or create_container() */
113 uint flags; /* Defined by SCFLAG_???? in common.h */
114 dlist_t objects_consumed; /* List of objects in this container */
115 /* The Engine allocate_container API will create the */
116 /* dlist_t anchor for this list. */
117 /* The plug-in inserts storage_object_t structures */
118 /* into this list when it assigns objects to this */
120 dlist_t objects_produced; /* List of objects produced from this container, */
121 /* including free space objects */
122 /* The Engine allocate_container API will create the */
123 /* dlist_t anchor for this list. */
124 /* The plug-in inserts storage_object_t structures */
125 /* into this list when it produces objects from this */
127 sector_count_t size; /* Total size of all objects on the objects_produced list */
128 void * private_data; /* Optional plug-in data for the container */
129 char name[EVMS_NAME_SIZE+1]; /* Container name, filled in by the plug-in */
130 } storage_container_t;
134 * The logical_volume structures are created and managed by the Engine.
136 typedef struct logical_volume_s {
137 object_handle_t app_handle; /* External API handle for this structure; */
138 /* used only by the Engine */
139 plugin_record_t * file_system_manager; /* Plug-in record of the File System Interface */
140 /* Module that handles this volume */
141 plugin_record_t * original_fsim; /* Plug-in record of the File System Interface */
142 /* Module that was initially discovered for this volume */
143 char * mount_point; /* Dir where the volume is mounted, NULL if not mounted */
144 sector_count_t fs_size; /* Size of the file system */
145 sector_count_t min_fs_size; /* Minimum size for the file system */
146 sector_count_t max_fs_size; /* Maximum size for the file system */
147 sector_count_t original_vol_size; /* Size of the file system before expand or shrink */
148 sector_count_t vol_size; /* Size of the volume */
149 sector_count_t max_vol_size; /* Maximum size for the volume */
150 #if (EVMS_ABI_CODE >= 110)
151 sector_count_t shrink_vol_size; /* Size to which to shrink the volume */
153 struct logical_volume_s * associated_volume; /* Volume to which this volume is associated */
154 /* by an associative feature */
155 option_array_t * mkfs_options; /* Options for mkfs */
156 option_array_t * fsck_options; /* Options for fsck */
157 option_array_t * defrag_options; /* Options for defrag */
158 storage_object_t * object; /* Top level storage_object_t for the volume */
159 uint minor_number; /* Volume's minor number */
160 u_int64_t serial_number; /* Volume's serial number */
161 u_int32_t flags; /* Defined by VOLFLAG_???? defines */
162 void * private_data; /* Private data pointer for FSIMs. */
163 #if (EVMS_ABI_CODE >= 110)
164 void * original_fsim_private_data;
165 /* Private data of original FSIM. */
167 char name[EVMS_VOLUME_NAME_SIZE+1];
168 /* Volume name, filled in by the Engine */
169 #if (EVMS_ABI_CODE >= 110)
170 char dev_node[EVMS_VOLUME_NAME_SIZE+1];
177 * Structure for a declined object. Includes a pointer to the declined object
178 * and a reason (usually an error code).
180 typedef struct declined_object_s {
181 storage_object_t * object;
187 * Tags for objects in dlists
192 SEGMENT_TAG = SEGMENT,
194 EVMS_OBJECT_TAG = EVMS_OBJECT,
195 CONTAINER_TAG = CONTAINER,
197 DECLINED_OBJECT_TAG = (1<<7),
198 VOLUME_DATA_TAG = (1<<8),
200 KILL_SECTOR_TAG = (1<<10),
201 BLOCK_RUN_TAG = (1<<11),
202 EXPAND_OBJECT_TAG = (1<<12),
203 SHRINK_OBJECT_TAG = (1<<13)
207 typedef struct chs_s {
214 * The block_run_t is used to describe a run of contiguous physical sectors on
217 typedef struct block_run_s {
218 storage_object_t * disk;
220 u_int64_t number_of_blocks;
224 * The kill_sector_record_t structure records a run of contiguous physical
225 * sectors on a disk that are to be zeroed out as part of the committing of
226 * changes to the disk. Kill sectors are used to wipe data off of the disk
227 * so that it will not be found on a rediscover.
229 typedef struct kill_sector_record_s {
230 storage_object_t * logical_disk;
232 sector_count_t sector_count;
233 } kill_sector_record_t;
236 * The expand_object_info_t structure contains information about an object
237 * that is a candidate for expanding. It contains a pointer to the object
238 * and the maximum delta size by which the object can expand.
240 typedef struct expand_object_info_s {
241 storage_object_t * object;
242 sector_count_t max_expand_size;
243 } expand_object_info_t;
246 * The shrink_object_info_t structure contains information about an object
247 * that is a candidate for shrinking. It contains a pointer to the object
248 * and the maximum delta size by which the object can shrink.
250 typedef struct shrink_object_info_s {
251 storage_object_t * object;
252 sector_count_t max_shrink_size;
253 } shrink_object_info_t;
256 * Option descriptor structure
258 typedef struct option_desc_array_s {
259 u_int32_t count; /* Number of option descriptors in the following array */
260 option_descriptor_t option[1]; /* option_descriptor_t is defined in option.h */
261 } option_desc_array_t;
265 * Task context structure
267 typedef struct task_context_s {
268 plugin_record_t * plugin; /* Plug-in being communicated with */
269 storage_object_t * object; /* Object upon which to do the action */
270 storage_container_t * container; /* Container upon which to do the action */
271 logical_volume_t * volume; /* Volume upon which to do the action */
272 task_action_t action; /* API application is interested in calling */
273 option_desc_array_t * option_descriptors; /* Array of current task option descriptors */
274 dlist_t acceptable_objects; /* Current list of acceptable parameters */
275 dlist_t selected_objects; /* Current list of selected parameters */
276 u_int32_t min_selected_objects; /* Minimum number of objects that must be selected. */
277 u_int32_t max_selected_objects; /* Maximum number of objects that can be selected. */
281 /* Enum for the phases of the commit process. */
284 FIRST_METADATA_WRITE = 1,
285 SECOND_METADATA_WRITE = 2,
291 * Macros for referencing fields in disk structures.
292 * EVMS writes all disk structures in little endian format. These macros can
293 * be used to access the fields of structures on disk regardless of the
294 * endianness of the CPU architecture.
297 #if __BYTE_ORDER == __BIG_ENDIAN
298 #define CPU_TO_DISK16(x) (bswap_16(x))
299 #define CPU_TO_DISK32(x) (bswap_32(x))
300 #define CPU_TO_DISK64(x) (bswap_64(x))
302 #define DISK_TO_CPU16(x) (bswap_16(x))
303 #define DISK_TO_CPU32(x) (bswap_32(x))
304 #define DISK_TO_CPU64(x) (bswap_64(x))
306 #elif __BYTE_ORDER == __LITTLE_ENDIAN
307 #define CPU_TO_DISK16(x) (x)
308 #define CPU_TO_DISK32(x) (x)
309 #define CPU_TO_DISK64(x) (x)
311 #define DISK_TO_CPU16(x) (x)
312 #define DISK_TO_CPU32(x) (x)
313 #define DISK_TO_CPU64(x) (x)
316 #error "__BYTE_ORDER must be defined as __LITTLE_ENDIAN or __BIG_ENDIAN"