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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
/*
*
* (C) Copyright IBM Corp. 2001, 2003
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Module: libcsm.so
*
* File: csm_plugin.c
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <uuid/uuid.h>
#include <plugin.h>
#include <csm_funcs.h>
#include "csm_plugin.h"
/*-------------------------------------------------------------------------------------+
+ +
+ PRIVATE DATA AREAS AND SUBROUTINES +
+ +
+-------------------------------------------------------------------------------------*/
static plugin_record_t csm_plugin_record;
plugin_record_t *csm_plugin_record_ptr = &csm_plugin_record;
struct engine_functions_s *EngFncs=NULL;
ece_nodeid_t csm_nodeid;
ece_clusterid_t csm_clusterid;
boolean csm_has_quorum;
boolean csm_admin_mode;
/*-------------------------------------------------------------------------------------+
+ +
+ Plugin Setup and Cleanup Functions +
+ +
+--------------------------------------------------------------------------------------*/
static int csm_setup( engine_functions_t * engine_functions )
{
int rc = 0;
EngFncs = engine_functions;
LOG_ENTRY();
memset(&csm_nodeid, 0, sizeof(ece_nodeid_t));
memset(&csm_clusterid, 0, sizeof(ece_clusterid_t));
csm_has_quorum = FALSE;
rc = EngFncs->get_config_bool("csm.admin_mode",&csm_admin_mode);
if (rc) {
LOG_DEBUG("bad rc back from get_config_bool\n");
csm_admin_mode = FALSE;
}
else {
LOG_DEBUG("good rc back from get config_bool\n");
}
if (csm_admin_mode == TRUE)
LOG_DEBUG("running with admin mode ON\n");
else
LOG_DEBUG("running with admin mode OFF\n");
rc = EngFncs->register_name( "csm" );
LOG_EXIT_INT(rc);
return rc;
}
static void csm_cleanup(void)
{
LOG_ENTRY();
delete_all_csm_segment_private_data();
delete_all_csm_container_private_data();
delete_all_csm_disk_private_data();
LOG_EXIT_VOID();
}
/*-------------------------------------------------------------------------------------+
+ +
+ PLUGIN FUNCTION TABLE +
+ +
+--------------------------------------------------------------------------------------*/
static struct plugin_functions_s csm_plugin_functions = {
setup_evms_plugin: csm_setup,
cleanup_evms_plugin: csm_cleanup,
can_set_volume: csm_can_set_volume,
can_delete: csm_can_delete,
can_expand: csm_can_expand,
can_expand_by: csm_can_expand_by,
can_shrink: csm_can_shrink,
can_shrink_by: csm_can_shrink_by,
discover: csm_discover,
assign: csm_assign,
can_unassign: csm_can_unassign,
unassign: csm_unassign,
create: csm_create,
discard: csm_discard,
delete: csm_destroy,
expand: csm_expand,
shrink: csm_shrink,
add_sectors_to_kill_list: csm_add_sectors_to_kill_list,
commit_changes: csm_commit_changes,
read: csm_read,
write: csm_write,
set_volume: csm_set_volume,
get_option_count: csm_get_option_count,
init_task: csm_init_task,
set_option: csm_set_option,
set_objects: csm_set_objects,
get_info: csm_get_info,
get_plugin_info: csm_get_plugin_info,
can_activate: csm_can_activate,
activate: csm_activate,
can_deactivate: csm_can_deactivate,
deactivate: csm_deactivate,
backup_metadata: csm_backup_metadata,
};
/*-------------------------------------------------------------------------------------+
+ +
+ CONTAINER FUNCTION TABLE +
+ +
+--------------------------------------------------------------------------------------*/
static container_functions_t csm_container_functions = {
can_delete_container: csm_can_delete_container,
can_expand_container: csm_can_expand_container,
can_expand_container_by: csm_can_expand_container_by,
can_shrink_container: csm_can_shrink_container,
can_shrink_container_by: csm_can_shrink_container_by,
create_container: csm_create_container,
expand_container: csm_expand_container,
shrink_container: csm_shrink_container,
discard_container: csm_discard_container,
delete_container: csm_delete_container,
commit_container_changes: csm_commit_container_changes,
get_container_info: csm_get_container_info,
set_container_info: csm_set_container_info,
get_plugin_functions: csm_get_plugin_functions,
plugin_function: csm_plugin_function,
backup_container_metadata: csm_backup_container_metadata,
};
/*-------------------------------------------------------------------------------------+
+ +
+ BUILD AND EXPORT AN EVMS PLUGIN RECORD +
+ +
+--------------------------------------------------------------------------------------*/
static plugin_record_t csm_plugin_record = {
id: CSM_PLUGIN_ID,
version: {MAJOR_VERSION, MINOR_VERSION, PATCH_LEVEL},
required_engine_api_version: {15,0,0},
required_plugin_api_version: {plugin: {13,1,0}},
required_container_api_version: {10,1,0},
short_name: "CSM",
long_name: "Cluster Segment Manager",
oem_name: "IBM",
functions: {plugin: &csm_plugin_functions},
container_functions: &csm_container_functions
};
// Vector of plugin record ptrs that we export for the EVMS Engine.
plugin_record_t *evms_plugin_records[] = {
&csm_plugin_record,
NULL
};
|