From: Gris Ge <***@redhat.com>
* Please check python API document for detail about lsm_volume_raid_info()
method. Quick info:
Retrieves the pool id that the volume is derived from.
@param[in] c Valid connection
@param[in] v Volume ptr.
@param[out] raid_type Enum of lsm_volume_raid_type
@param[out] strip_size Size of the strip on disk or other storage extent.
@param[out] extent_count Count of disks or other storage extents in this
RAID group.
@param[out] min_io_size Minimum I/O size, also the preferred I/O size
of random I/O.
@param[out] opt_io_size Optimal I/O size, also the preferred I/O size
of sequential I/O.
@param[in] flags Reserved, set to 0
@return LSM_ERR_OK on success else error reason.
* New plugin interface: lsm_plug_volume_raid_info
* New enum type: lsm_volume_raid_type
* New capability:
LSM_CAP_VOLUME_RAID_INFO
* New constants:
LSM_VOLUME_RAID_TYPE_UNKNOWN = -1,
/**^ Unknown */
LSM_VOLUME_RAID_TYPE_RAID0 = 0,
/**^ Stripe */
LSM_VOLUME_RAID_TYPE_RAID1 = 1,
/**^ Mirror between two disks. For 4 disks or more, they are RAID10.*/
LSM_VOLUME_RAID_TYPE_RAID3 = 3,
/**^ Byte-level striping with dedicated parity */
LSM_VOLUME_RAID_TYPE_RAID4 = 4,
/**^ Block-level striping with dedicated parity */
/**^ Block-level striping with dedicated parity */
LSM_VOLUME_RAID_TYPE_RAID5 = 5,
/**^ Block-level striping with distributed parity */
LSM_VOLUME_RAID_TYPE_RAID6 = 6,
/**^ Block-level striping with two distributed parities, aka, RAID-DP */
LSM_VOLUME_RAID_TYPE_RAID10 = 10,
/**^ Stripe of mirrors */
LSM_VOLUME_RAID_TYPE_RAID15 = 15,
/**^ Parity of mirrors */
LSM_VOLUME_RAID_TYPE_RAID16 = 16,
/**^ Dual parity of mirrors */
LSM_VOLUME_RAID_TYPE_RAID50 = 50,
/**^ Stripe of parities */
LSM_VOLUME_RAID_TYPE_RAID60 = 60,
/**^ Stripe of dual parities */
LSM_VOLUME_RAID_TYPE_RAID51 = 51,
/**^ Mirror of parities */
LSM_VOLUME_RAID_TYPE_RAID61 = 61,
/**^ Mirror of dual parities */
LSM_VOLUME_RAID_TYPE_JBOD = 20,
/**^ Just bunch of disks, no parity, no striping. */
LSM_VOLUME_RAID_TYPE_MIXED = 21,
/**^ This volume contains multiple RAID settings. */
LSM_VOLUME_RAID_TYPE_OTHER = 22,
/**^ Vendor specific RAID type */
LSM_VOLUME_STRIP_SIZE_UNKNOWN
LSM_VOLUME_EXTENT_COUNT_UNKNOWN
LSM_VOLUME_MIN_IO_SIZE_UNKNOWN
LSM_VOLUME_OPT_IO_SIZE_UNKNOWN
V2: Change call back registration
Signed-off-by: Gris Ge <***@redhat.com>
Signed-off-by: Tony Asleson <***@redhat.com>
---
c_binding/include/libstoragemgmt/libstoragemgmt.h | 20 +++
.../libstoragemgmt/libstoragemgmt_capabilities.h | 3 +
.../libstoragemgmt/libstoragemgmt_plug_interface.h | 35 +++++
.../include/libstoragemgmt/libstoragemgmt_types.h | 43 +++++
c_binding/lsm_datatypes.hpp | 13 +-
c_binding/lsm_mgmt.cpp | 45 ++++++
c_binding/lsm_plugin_ipc.cpp | 175 ++++++++++++++-------
7 files changed, 274 insertions(+), 60 deletions(-)
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt.h b/c_binding/include/libstoragemgmt/libstoragemgmt.h
index 879f184..d65534c 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt.h
@@ -844,6 +844,26 @@ extern "C" {
uint32_t *count,
lsm_flag flags);
+/**
+ * Retrieves the pool id that the volume is derived from.
+ * @param[in] c Valid connection
+ * @param[in] v Volume ptr.
+ * @param[out] raid_type Enum of lsm_volume_raid_type
+ * @param[out] strip_size Size of the strip on disk or other storage extent.
+ * @param[out] extent_count Count of disks or other storage extents in this
+ * RAID group.
+ * @param[out] min_io_size Minimum I/O size, also the preferred I/O size
+ * of random I/O.
+ * @param[out] opt_io_size Optimal I/O size, also the preferred I/O size
+ * of sequential I/O.
+ * @param[in] flags Reserved, set to 0
+ * @return LSM_ERR_OK on success else error reason.
+ */
+int LSM_DLL_EXPORT lsm_volume_raid_info(
+ lsm_connect *c, lsm_volume *volume, lsm_volume_raid_type *raid_type,
+ int32_t *strip_size, int32_t *extent_count,
+ int32_t *min_io_size, int32_t *opt_io_size, lsm_flag flags);
+
#ifdef __cplusplus
}
#endif
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
index 7d6182c..18490f3 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_capabilities.h
@@ -77,6 +77,9 @@ typedef enum {
LSM_CAP_VOLUME_ISCSI_CHAP_AUTHENTICATION = 53, /**< If you can configure iSCSI chap authentication */
+ LSM_CAP_VOLUME_RAID_INFO = 54,
+ /** ^ If you can query RAID information from volume */
+
LSM_CAP_VOLUME_THIN = 55, /**< Thin provisioned volumes are supported */
LSM_CAP_FS = 100, /**< List file systems */
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index e7874f7..2ad9b71 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -319,6 +319,28 @@ typedef int (*lsm_plug_volume_resize)(lsm_plugin_ptr c, lsm_volume *volume,
*/
typedef int (*lsm_plug_volume_delete)(lsm_plugin_ptr c, lsm_volume *volume,
char **job, lsm_flag flags);
+
+/**
+ * Query the RAID information of a volume
+ * @param[in] c Valid lsm plug-in pointer
+ * @param[in] volume Volume to be deleted
+ * @param[out] raid_type Enum of lsm_volume_raid_type
+ * @param[out] strip_size Size of the strip on each disk or other
+ * storage extent.
+ * @param[out] extent_count Count of of disks of other storage extents in
+ * this RAID group.
+ * @param[out] min_io_size Minimum I/O size, also the preferred I/O size
+ * of random I/O.
+ * @param[out] opt_io_size Optimal I/O size, also the preferred I/O size
+ * of sequential I/O.
+ * @param[in] flags Reserved
+ * @return LSM_ERR_OK, else error reason
+ */
+typedef int (*lsm_plug_volume_raid_info)(lsm_plugin_ptr c, lsm_volume *volume,
+ lsm_volume_raid_type *raid_type, int32_t *strip_size,
+ int32_t *extent_count, int32_t *min_io_size,
+ int32_t *opt_io_size, lsm_flag flags);
+
/**
* Place a volume online, callback function signature.
* @param[in] c Valid lsm plug-in pointer
@@ -745,6 +767,7 @@ typedef int (*lsm_plug_nfs_export_remove)( lsm_plugin_ptr c, lsm_nfs_export *e,
lsm_flag flags);
/** \struct lsm_san_ops_v1
* \brief Block array oriented functions (callback functions)
+ * NOTE: This structure cannot change as we need to maintain backwards compatibility
*/
struct lsm_san_ops_v1 {
lsm_plug_volume_list vol_get; /**< retrieving volumes */
@@ -774,6 +797,7 @@ struct lsm_san_ops_v1 {
/** \struct lsm_fs_ops_v1
* \brief File system oriented functionality
+ * NOTE: This structure cannot change as we need to maintain backwards compatibility
*/
struct lsm_fs_ops_v1 {
lsm_plug_fs_list fs_list; /**< list file systems */
@@ -792,6 +816,7 @@ struct lsm_fs_ops_v1 {
/** \struct lsm_nas_ops_v1
* \brief NAS system oriented functionality call back functions
+ * NOTE: This structure cannot change as we need to maintain backwards compatibility
*/
struct lsm_nas_ops_v1 {
lsm_plug_nfs_auth_types nfs_auth_types; /**< List nfs authentication types */
@@ -839,6 +864,16 @@ int LSM_DLL_EXPORT lsm_register_plugin_v1( lsm_plugin_ptr plug,
struct lsm_nas_ops_v1 *nas_ops );
/**
+ * Used to register the call back function when the plugin supports volume raid
+ * info.
+ * @param plug Pointer provided by the framework
+ * @param fp Function pointer to register, can be NULL to un-reg
+ * @return LSM_ERR_OK on success, else error reason.
+ */
+int LSM_DLL_EXPORT lsm_register_callback_volume_raid_info( lsm_plugin_ptr plug,
+ lsm_plug_volume_raid_info fp);
+
+/**
* Used to retrieve private data for plug-in operation.
* @param plug Opaque plug-in pointer.
*/
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
index 309a5e8..5465dad 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_types.h
@@ -131,6 +131,49 @@ typedef enum {
LSM_VOLUME_PROVISION_DEFAULT = 3 /**< Default provisioning */
} lsm_volume_provision_type;
+/**< \enum lsm_volume_raid_type Different types of RAID */
+typedef enum {
+ LSM_VOLUME_RAID_TYPE_UNKNOWN = -1,
+ /**^ Unknown */
+ LSM_VOLUME_RAID_TYPE_RAID0 = 0,
+ /**^ Stripe */
+ LSM_VOLUME_RAID_TYPE_RAID1 = 1,
+ /**^ Mirror between two disks. For 4 disks or more, they are RAID10.*/
+ LSM_VOLUME_RAID_TYPE_RAID3 = 3,
+ /**^ Byte-level striping with dedicated parity */
+ LSM_VOLUME_RAID_TYPE_RAID4 = 4,
+ /**^ Block-level striping with dedicated parity */
+ LSM_VOLUME_RAID_TYPE_RAID5 = 5,
+ /**^ Block-level striping with distributed parity */
+ LSM_VOLUME_RAID_TYPE_RAID6 = 6,
+ /**^ Block-level striping with two distributed parities, aka, RAID-DP */
+ LSM_VOLUME_RAID_TYPE_RAID10 = 10,
+ /**^ Stripe of mirrors */
+ LSM_VOLUME_RAID_TYPE_RAID15 = 15,
+ /**^ Parity of mirrors */
+ LSM_VOLUME_RAID_TYPE_RAID16 = 16,
+ /**^ Dual parity of mirrors */
+ LSM_VOLUME_RAID_TYPE_RAID50 = 50,
+ /**^ Stripe of parities */
+ LSM_VOLUME_RAID_TYPE_RAID60 = 60,
+ /**^ Stripe of dual parities */
+ LSM_VOLUME_RAID_TYPE_RAID51 = 51,
+ /**^ Mirror of parities */
+ LSM_VOLUME_RAID_TYPE_RAID61 = 61,
+ /**^ Mirror of dual parities */
+ LSM_VOLUME_RAID_TYPE_JBOD = 20,
+ /**^ Just bunch of disks, no parity, no striping. */
+ LSM_VOLUME_RAID_TYPE_MIXED = 21,
+ /**^ This volume contains multiple RAID settings. */
+ LSM_VOLUME_RAID_TYPE_OTHER = 22,
+ /**^ Vendor specific RAID type */
+} lsm_volume_raid_type;
+
+#define LSM_VOLUME_STRIP_SIZE_UNKNOWN -1
+#define LSM_VOLUME_EXTENT_COUNT_UNKNOWN -1
+#define LSM_VOLUME_MIN_IO_SIZE_UNKNOWN -1
+#define LSM_VOLUME_OPT_IO_SIZE_UNKNOWN -1
+
/**
* Admin state for volume, enabled or disabled
*/
diff --git a/c_binding/lsm_datatypes.hpp b/c_binding/lsm_datatypes.hpp
index aed6891..0fabf54 100644
--- a/c_binding/lsm_datatypes.hpp
+++ b/c_binding/lsm_datatypes.hpp
@@ -177,6 +177,17 @@ struct _lsm_system {
#define LSM_PLUGIN_MAGIC 0xAA7A000B
#define LSM_IS_PLUGIN(obj) MAGIC_CHECK(obj, LSM_PLUGIN_MAGIC)
+struct LSM_DLL_LOCAL _lsm_san_ops_added
+{
+ lsm_plug_volume_raid_info vol_raid_info;
+};
+
+struct LSM_DLL_LOCAL _lsm_san_ops
+{
+ struct lsm_san_ops_v1 *v1;
+ struct _lsm_san_ops_added added;
+};
+
/**
* Information pertaining to the plug-in specifics.
*/
@@ -190,7 +201,7 @@ struct LSM_DLL_LOCAL _lsm_plugin {
lsm_plugin_register reg; /**< Plug-in registration */
lsm_plugin_unregister unreg; /**< Plug-in unregistration */
struct lsm_mgmt_ops_v1 *mgmt_ops; /**< Callback for management ops */
- struct lsm_san_ops_v1 *san_ops; /**< Callbacks for SAN ops */
+ struct _lsm_san_ops san_ops; /**< Callbacks for SAN ops */
struct lsm_nas_ops_v1 *nas_ops; /**< Callbacks for NAS ops */
struct lsm_fs_ops_v1 *fs_ops; /**< Callbacks for fs ops */
};
diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index 37faed4..8d51825 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -1171,6 +1171,51 @@ int lsm_volume_delete(lsm_connect *c, lsm_volume *volume, char **job,
}
+int lsm_volume_raid_info(lsm_connect *c, lsm_volume *volume,
+ lsm_volume_raid_type * raid_type,
+ int32_t *strip_size, int32_t *extent_count,
+ int32_t *min_io_size, int32_t *opt_io_size,
+ lsm_flag flags)
+{
+ int rc = LSM_ERR_OK;
+ CONN_SETUP(c);
+
+ if( !LSM_IS_VOL(volume) ) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+
+ if( !raid_type || !strip_size || !extent_count || !min_io_size ||
+ !opt_io_size) {
+ return LSM_ERR_INVALID_ARGUMENT;
+ }
+
+ try {
+ std::map<std::string, Value> p;
+ p["volume"] = volume_to_value(volume);
+ p["flags"] = Value(flags);
+
+ Value parameters(p);
+ Value response;
+
+ rc = rpc(c, "volume_raid_info", parameters, response);
+ if( LSM_ERR_OK == rc ) {
+ //We get a value back, either null or job id.
+ std::vector<Value> j = response.asArray();
+ *raid_type = (lsm_volume_raid_type) j[0].asInt32_t();
+ *strip_size = j[1].asInt32_t();
+ *extent_count = j[2].asInt32_t();
+ *min_io_size = j[3].asInt32_t();
+ *opt_io_size = j[4].asInt32_t();
+ }
+ } catch( const ValueException &ve ) {
+ rc = logException(c, LSM_ERR_LIB_BUG, "Unexpected type",
+ ve.what());
+ }
+ return rc;
+
+}
+
+
int lsm_iscsi_chap_auth(lsm_connect *c, const char *init_id,
const char *username, const char *password,
const char *out_user, const char *out_password,
diff --git a/c_binding/lsm_plugin_ipc.cpp b/c_binding/lsm_plugin_ipc.cpp
index 7e0d034..08ae877 100644
--- a/c_binding/lsm_plugin_ipc.cpp
+++ b/c_binding/lsm_plugin_ipc.cpp
@@ -115,7 +115,7 @@ int lsm_register_plugin_v1(lsm_plugin_ptr plug,
if(LSM_IS_PLUGIN(plug)) {
plug->private_data = private_data;
plug->mgmt_ops = mgm_op;
- plug->san_ops = san_op;
+ plug->san_ops.v1 = san_op;
plug->fs_ops = fs_op;
plug->nas_ops = nas_op;
rc = LSM_ERR_OK;
@@ -123,6 +123,18 @@ int lsm_register_plugin_v1(lsm_plugin_ptr plug,
return rc;
}
+int LSM_DLL_EXPORT lsm_register_callback_volume_raid_info( lsm_plugin_ptr plug,
+ lsm_plug_volume_raid_info fp)
+{
+ int rc = LSM_ERR_INVALID_ARGUMENT;
+
+ if(LSM_IS_PLUGIN(plug)) {
+ plug->san_ops.added.vol_raid_info = fp;
+ rc = LSM_ERR_OK;
+ }
+ return rc;
+}
+
void *lsm_private_data_get(lsm_plugin_ptr plug)
{
if (!LSM_IS_PLUGIN(plug)) {
@@ -514,13 +526,13 @@ static int handle_target_ports(lsm_plugin_ptr p, Value ¶ms, Value &response)
char *key = NULL;
char *val = NULL;
- if( p && p->san_ops && p->san_ops->target_port_list ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->target_port_list ) {
lsm_target_port **target_ports = NULL;
uint32_t count = 0;
if( LSM_FLAG_EXPECTED_TYPE(params) &&
((rc = get_search_params(params, &key, &val)) == LSM_ERR_OK )) {
- rc = p->san_ops->target_port_list(p, key, val, &target_ports, &count,
+ rc = p->san_ops.v1->target_port_list(p, key, val, &target_ports, &count,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_OK == rc) {
std::vector<Value> result;
@@ -599,13 +611,13 @@ static int handle_volumes(lsm_plugin_ptr p, Value ¶ms, Value &response)
char *val = NULL;
- if( p && p->san_ops && p->san_ops->vol_get ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_get ) {
lsm_volume **vols = NULL;
uint32_t count = 0;
if( LSM_FLAG_EXPECTED_TYPE(params) &&
(rc = get_search_params(params, &key, &val)) == LSM_ERR_OK ) {
- rc = p->san_ops->vol_get(p, key, val, &vols, &count,
+ rc = p->san_ops.v1->vol_get(p, key, val, &vols, &count,
LSM_FLAG_GET_VALUE(params));
get_volumes(rc, vols, count, response);
@@ -641,13 +653,13 @@ static int handle_disks(lsm_plugin_ptr p, Value ¶ms, Value &response)
char *key = NULL;
char *val = NULL;
- if( p && p->san_ops && p->san_ops->disk_get ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->disk_get ) {
lsm_disk **disks = NULL;
uint32_t count = 0;
if( LSM_FLAG_EXPECTED_TYPE(params) &&
(rc = get_search_params(params, &key, &val)) == LSM_ERR_OK ) {
- rc = p->san_ops->disk_get(p, key, val, &disks, &count,
+ rc = p->san_ops.v1->disk_get(p, key, val, &disks, &count,
LSM_FLAG_GET_VALUE(params));
get_disks(rc, disks, count, response);
free(key);
@@ -664,7 +676,7 @@ static int handle_disks(lsm_plugin_ptr p, Value ¶ms, Value &response)
static int handle_volume_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->vol_create ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_create ) {
Value v_p = params["pool"];
Value v_name = params["volume_name"];
@@ -685,7 +697,7 @@ static int handle_volume_create(lsm_plugin_ptr p, Value ¶ms, Value &response
uint64_t size = v_size.asUint64_t();
lsm_volume_provision_type pro = (lsm_volume_provision_type)v_prov.asInt32_t();
- rc = p->san_ops->vol_create(p, pool, name, size, pro, &vol, &job,
+ rc = p->san_ops.v1->vol_create(p, pool, name, size, pro, &vol, &job,
LSM_FLAG_GET_VALUE(params));
Value v = volume_to_value(vol);
@@ -710,7 +722,7 @@ static int handle_volume_create(lsm_plugin_ptr p, Value ¶ms, Value &response
static int handle_volume_resize(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->vol_resize ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_resize ) {
Value v_vol = params["volume"];
Value v_size = params["new_size_bytes"];
@@ -724,7 +736,7 @@ static int handle_volume_resize(lsm_plugin_ptr p, Value ¶ms, Value &response
uint64_t size = v_size.asUint64_t();
char *job = NULL;
- rc = p->san_ops->vol_resize(p, vol, size, &resized_vol, &job,
+ rc = p->san_ops.v1->vol_resize(p, vol, size, &resized_vol, &job,
LSM_FLAG_GET_VALUE(params));
Value v = volume_to_value(resized_vol);
@@ -749,7 +761,7 @@ static int handle_volume_replicate(lsm_plugin_ptr p, Value ¶ms, Value &respo
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->vol_replicate ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_replicate ) {
Value v_pool = params["pool"];
Value v_vol_src = params["volume_src"];
@@ -772,7 +784,7 @@ static int handle_volume_replicate(lsm_plugin_ptr p, Value ¶ms, Value &respo
char *job = NULL;
if( vol ) {
- rc = p->san_ops->vol_replicate(p, pool, rep, vol, name,
+ rc = p->san_ops.v1->vol_replicate(p, pool, rep, vol, name,
&newVolume, &job,
LSM_FLAG_GET_VALUE(params));
@@ -802,7 +814,7 @@ static int handle_volume_replicate_range_block_size( lsm_plugin_ptr p,
int rc = LSM_ERR_NO_SUPPORT;
uint32_t block_size = 0;
- if( p && p->san_ops && p->san_ops->vol_rep_range_bs ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_rep_range_bs ) {
Value v_s = params["system"];
if( IS_CLASS_SYSTEM(v_s) &&
@@ -810,7 +822,7 @@ static int handle_volume_replicate_range_block_size( lsm_plugin_ptr p,
lsm_system *sys = value_to_system(v_s);
if( sys ) {
- rc = p->san_ops->vol_rep_range_bs(p, sys, &block_size,
+ rc = p->san_ops.v1->vol_rep_range_bs(p, sys, &block_size,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_OK == rc ) {
@@ -834,7 +846,7 @@ static int handle_volume_replicate_range(lsm_plugin_ptr p, Value ¶ms,
int rc = LSM_ERR_NO_SUPPORT;
uint32_t range_count = 0;
char *job = NULL;
- if( p && p->san_ops && p->san_ops->vol_rep_range ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_rep_range ) {
Value v_rep = params["rep_type"];
Value v_vol_src = params["volume_src"];
Value v_vol_dest = params["volume_dest"];
@@ -855,7 +867,7 @@ static int handle_volume_replicate_range(lsm_plugin_ptr p, Value ¶ms,
if( source && dest && ranges ) {
- rc = p->san_ops->vol_rep_range(p, repType, source, dest, ranges,
+ rc = p->san_ops.v1->vol_rep_range(p, repType, source, dest, ranges,
range_count, &job,
LSM_FLAG_GET_VALUE(params));
@@ -880,10 +892,54 @@ static int handle_volume_replicate_range(lsm_plugin_ptr p, Value ¶ms,
return rc;
}
+static int handle_volume_raid_info(lsm_plugin_ptr p, Value ¶ms,
+ Value &response)
+{
+ int rc = LSM_ERR_NO_SUPPORT;
+ if( p && p->san_ops.added.vol_raid_info) {
+ Value v_vol = params["volume"];
+
+ if(IS_CLASS_VOLUME(v_vol) &&
+ LSM_FLAG_EXPECTED_TYPE(params) ) {
+ lsm_volume *vol = value_to_volume(v_vol);
+ std::vector<Value> result;
+
+ if( vol ) {
+ lsm_volume_raid_type raid_type;
+ int32_t strip_size;
+ int32_t extent_count;
+ int32_t min_io_size;
+ int32_t opt_io_size;
+
+ rc = p->san_ops.added.vol_raid_info(
+ p, vol, &raid_type, &strip_size, &extent_count,
+ &min_io_size, &opt_io_size, LSM_FLAG_GET_VALUE(params));
+
+ if( LSM_ERR_OK == rc ) {
+ result.push_back(Value((int32_t)raid_type));
+ result.push_back(Value(strip_size));
+ result.push_back(Value(extent_count));
+ result.push_back(Value(min_io_size));
+ result.push_back(Value(opt_io_size));
+ response = Value(result);
+ }
+
+ lsm_volume_record_free(vol);
+ } else {
+ rc = LSM_ERR_NO_MEMORY;
+ }
+
+ } else {
+ rc = LSM_ERR_TRANSPORT_INVALID_ARG;
+ }
+ }
+ return rc;
+}
+
static int handle_volume_delete(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->vol_delete ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_delete ) {
Value v_vol = params["volume"];
if(IS_CLASS_VOLUME(v_vol) &&
@@ -893,7 +949,7 @@ static int handle_volume_delete(lsm_plugin_ptr p, Value ¶ms, Value &response
if( vol ) {
char *job = NULL;
- rc = p->san_ops->vol_delete(p, vol, &job,
+ rc = p->san_ops.v1->vol_delete(p, vol, &job,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_JOB_STARTED == rc ) {
@@ -918,8 +974,8 @@ static int handle_vol_enable_disable( lsm_plugin_ptr p, Value ¶ms,
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops &&
- ((online)? p->san_ops->vol_enable : p->san_ops->vol_disable)) {
+ if( p && p->san_ops.v1 &&
+ ((online)? p->san_ops.v1->vol_enable : p->san_ops.v1->vol_disable)) {
Value v_vol = params["volume"];
@@ -928,10 +984,10 @@ static int handle_vol_enable_disable( lsm_plugin_ptr p, Value ¶ms,
lsm_volume *vol = value_to_volume(v_vol);
if( vol ) {
if( online ) {
- rc = p->san_ops->vol_enable(p, vol,
+ rc = p->san_ops.v1->vol_enable(p, vol,
LSM_FLAG_GET_VALUE(params));
} else {
- rc = p->san_ops->vol_disable(p, vol,
+ rc = p->san_ops.v1->vol_disable(p, vol,
LSM_FLAG_GET_VALUE(params));
}
@@ -962,14 +1018,14 @@ static int ag_list(lsm_plugin_ptr p, Value ¶ms, Value &response)
char *key = NULL;
char *val = NULL;
- if( p && p->san_ops && p->san_ops->ag_list ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_list ) {
if( LSM_FLAG_EXPECTED_TYPE(params) &&
(rc = get_search_params(params, &key, &val)) == LSM_ERR_OK ) {
lsm_access_group **groups = NULL;
uint32_t count;
- rc = p->san_ops->ag_list(p, key, val, &groups, &count,
+ rc = p->san_ops.v1->ag_list(p, key, val, &groups, &count,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_OK == rc ) {
response = access_group_list_to_value(groups, count);
@@ -992,7 +1048,7 @@ static int ag_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->ag_create ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_create ) {
Value v_name = params["name"];
Value v_init_id = params["init_id"];
Value v_init_type = params["init_type"];
@@ -1008,7 +1064,7 @@ static int ag_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
lsm_system *system = value_to_system(v_system);
if( system ) {
- rc = p->san_ops->ag_create(
+ rc = p->san_ops.v1->ag_create(
p,
v_name.asC_str(),
v_init_id.asC_str(),
@@ -1034,7 +1090,7 @@ static int ag_delete(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->ag_delete ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_delete ) {
Value v_access_group = params["access_group"];
if( IS_CLASS_ACCESS_GROUP(v_access_group) &&
@@ -1043,7 +1099,7 @@ static int ag_delete(lsm_plugin_ptr p, Value ¶ms, Value &response)
lsm_access_group *ag = value_to_access_group(v_access_group);
if( ag ) {
- rc = p->san_ops->ag_delete(p, ag, LSM_FLAG_GET_VALUE(params));
+ rc = p->san_ops.v1->ag_delete(p, ag, LSM_FLAG_GET_VALUE(params));
lsm_access_group_record_free(ag);
} else {
rc = LSM_ERR_NO_MEMORY;
@@ -1060,7 +1116,7 @@ static int ag_initiator_add(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->ag_add_initiator ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_add_initiator ) {
Value v_group = params["access_group"];
Value v_init_id = params["init_id"];
@@ -1079,7 +1135,7 @@ static int ag_initiator_add(lsm_plugin_ptr p, Value ¶ms, Value &response)
lsm_access_group_init_type id_type =
(lsm_access_group_init_type) v_init_type.asInt32_t();
- rc = p->san_ops->ag_add_initiator(p, ag, id, id_type,
+ rc = p->san_ops.v1->ag_add_initiator(p, ag, id, id_type,
&updated_access_group,
LSM_FLAG_GET_VALUE(params));
@@ -1105,7 +1161,7 @@ static int ag_initiator_del(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->ag_del_initiator ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_del_initiator ) {
Value v_group = params["access_group"];
Value v_init_id = params["init_id"];
@@ -1123,7 +1179,7 @@ static int ag_initiator_del(lsm_plugin_ptr p, Value ¶ms, Value &response)
const char *id = v_init_id.asC_str();
lsm_access_group_init_type id_type =
(lsm_access_group_init_type) v_init_type.asInt32_t();
- rc = p->san_ops->ag_del_initiator(p, ag, id, id_type,
+ rc = p->san_ops.v1->ag_del_initiator(p, ag, id, id_type,
&updated_access_group,
LSM_FLAG_GET_VALUE(params));
@@ -1148,7 +1204,7 @@ static int volume_mask(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->ag_grant ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_grant ) {
Value v_group = params["access_group"];
Value v_vol = params["volume"];
@@ -1161,7 +1217,7 @@ static int volume_mask(lsm_plugin_ptr p, Value ¶ms, Value &response)
lsm_volume *vol = value_to_volume(v_vol);
if( ag && vol ) {
- rc = p->san_ops->ag_grant(p, ag, vol,
+ rc = p->san_ops.v1->ag_grant(p, ag, vol,
LSM_FLAG_GET_VALUE(params));
} else {
rc = LSM_ERR_NO_MEMORY;
@@ -1182,7 +1238,7 @@ static int volume_unmask(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->ag_revoke ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_revoke ) {
Value v_group = params["access_group"];
Value v_vol = params["volume"];
@@ -1195,7 +1251,7 @@ static int volume_unmask(lsm_plugin_ptr p, Value ¶ms, Value &response)
lsm_volume *vol = value_to_volume(v_vol);
if( ag && vol ) {
- rc = p->san_ops->ag_revoke(p, ag, vol,
+ rc = p->san_ops.v1->ag_revoke(p, ag, vol,
LSM_FLAG_GET_VALUE(params));
} else {
rc = LSM_ERR_NO_MEMORY;
@@ -1216,7 +1272,7 @@ static int vol_accessible_by_ag(lsm_plugin_ptr p, Value ¶ms, Value &response
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->vol_accessible_by_ag ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_accessible_by_ag ) {
Value v_access_group = params["access_group"];
if( IS_CLASS_ACCESS_GROUP(v_access_group) &&
@@ -1227,7 +1283,7 @@ static int vol_accessible_by_ag(lsm_plugin_ptr p, Value ¶ms, Value &response
lsm_volume **vols = NULL;
uint32_t count = 0;
- rc = p->san_ops->vol_accessible_by_ag(p, ag, &vols, &count,
+ rc = p->san_ops.v1->vol_accessible_by_ag(p, ag, &vols, &count,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_OK == rc ) {
@@ -1257,7 +1313,7 @@ static int ag_granted_to_volume(lsm_plugin_ptr p, Value ¶ms, Value &response
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->ag_granted_to_vol ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->ag_granted_to_vol ) {
Value v_vol = params["volume"];
@@ -1269,7 +1325,7 @@ static int ag_granted_to_volume(lsm_plugin_ptr p, Value ¶ms, Value &response
lsm_access_group **groups = NULL;
uint32_t count = 0;
- rc = p->san_ops->ag_granted_to_vol(p, volume, &groups, &count,
+ rc = p->san_ops.v1->ag_granted_to_vol(p, volume, &groups, &count,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_OK == rc ) {
@@ -1298,7 +1354,7 @@ static int volume_dependency(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->vol_child_depends ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_child_depends ) {
Value v_vol = params["volume"];
@@ -1309,7 +1365,7 @@ static int volume_dependency(lsm_plugin_ptr p, Value ¶ms, Value &response)
if( volume ) {
uint8_t yes;
- rc = p->san_ops->vol_child_depends(p, volume, &yes,
+ rc = p->san_ops.v1->vol_child_depends(p, volume, &yes,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_OK == rc ) {
@@ -1333,7 +1389,7 @@ static int volume_dependency_rm(lsm_plugin_ptr p, Value ¶ms, Value &response
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->vol_child_depends_rm ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->vol_child_depends_rm ) {
Value v_vol = params["volume"];
@@ -1345,7 +1401,7 @@ static int volume_dependency_rm(lsm_plugin_ptr p, Value ¶ms, Value &response
char *job = NULL;
- rc = p->san_ops->vol_child_depends_rm(p, volume, &job,
+ rc = p->san_ops.v1->vol_child_depends_rm(p, volume, &job,
LSM_FLAG_GET_VALUE(params));
if( LSM_ERR_JOB_STARTED == rc ) {
@@ -1371,7 +1427,7 @@ static int fs(lsm_plugin_ptr p, Value ¶ms, Value &response)
char *key = NULL;
char *val = NULL;
- if( p && p->san_ops && p->fs_ops->fs_list ) {
+ if( p && p->san_ops.v1 && p->fs_ops->fs_list ) {
if( LSM_FLAG_EXPECTED_TYPE(params) &&
((rc = get_search_params(params, &key, &val)) == LSM_ERR_OK )) {
@@ -1407,7 +1463,7 @@ static int fs_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_create ) {
+ if( p && p->san_ops.v1 && p->fs_ops->fs_create ) {
Value v_pool = params["pool"];
Value v_name = params["name"];
@@ -1459,7 +1515,7 @@ static int fs_delete(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_delete ) {
+ if( p && p->fs_ops && p->fs_ops->fs_delete ) {
Value v_fs = params["fs"];
@@ -1493,7 +1549,7 @@ static int fs_resize(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_resize ) {
+ if( p && p->fs_ops && p->fs_ops->fs_resize ) {
Value v_fs = params["fs"];
Value v_size = params["new_size_bytes"];
@@ -1541,7 +1597,7 @@ static int fs_clone(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_clone ) {
+ if( p && p->fs_ops && p->fs_ops->fs_clone ) {
Value v_src_fs = params["src_fs"];
Value v_name = params["dest_fs_name"];
@@ -1597,7 +1653,7 @@ static int fs_file_clone(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_OK;
- if( p && p->san_ops && p->fs_ops->fs_file_clone ) {
+ if( p && p->fs_ops && p->fs_ops->fs_file_clone ) {
Value v_fs = params["fs"];
Value v_src_name = params["src_file_name"];
@@ -1648,7 +1704,7 @@ static int fs_file_clone(lsm_plugin_ptr p, Value ¶ms, Value &response)
static int fs_child_dependency(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_child_dependency ) {
+ if( p && p->fs_ops && p->fs_ops->fs_child_dependency ) {
Value v_fs = params["fs"];
Value v_files = params["files"];
@@ -1686,7 +1742,7 @@ static int fs_child_dependency(lsm_plugin_ptr p, Value ¶ms, Value &response)
static int fs_child_dependency_rm(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_child_dependency_rm ) {
+ if( p && p->fs_ops && p->fs_ops->fs_child_dependency_rm ) {
Value v_fs = params["fs"];
Value v_files = params["files"];
@@ -1725,7 +1781,7 @@ static int fs_child_dependency_rm(lsm_plugin_ptr p, Value ¶ms, Value &respon
static int ss_list(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_ss_list ) {
+ if( p && p->fs_ops && p->fs_ops->fs_ss_list ) {
Value v_fs = params["fs"];
@@ -1766,7 +1822,7 @@ static int ss_list(lsm_plugin_ptr p, Value ¶ms, Value &response)
static int ss_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_ss_create ) {
+ if( p && p->fs_ops && p->fs_ops->fs_ss_create ) {
Value v_fs = params["fs"];
Value v_ss_name = params["snapshot_name"];
@@ -1814,7 +1870,7 @@ static int ss_create(lsm_plugin_ptr p, Value ¶ms, Value &response)
static int ss_delete(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_ss_delete ) {
+ if( p && p->fs_ops && p->fs_ops->fs_ss_delete ) {
Value v_fs = params["fs"];
Value v_ss = params["snapshot"];
@@ -1851,7 +1907,7 @@ static int ss_delete(lsm_plugin_ptr p, Value ¶ms, Value &response)
static int ss_restore(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->fs_ops->fs_ss_restore ) {
+ if( p && p->fs_ops && p->fs_ops->fs_ss_restore ) {
Value v_fs = params["fs"];
Value v_ss = params["snapshot"];
@@ -2069,7 +2125,7 @@ static int iscsi_chap(lsm_plugin_ptr p, Value ¶ms, Value &response)
{
int rc = LSM_ERR_NO_SUPPORT;
- if( p && p->san_ops && p->san_ops->iscsi_chap_auth ) {
+ if( p && p->san_ops.v1 && p->san_ops.v1->iscsi_chap_auth ) {
Value v_init = params["init_id"];
Value v_in_user = params["in_user"];
Value v_in_password = params["in_password"];
@@ -2087,7 +2143,7 @@ static int iscsi_chap(lsm_plugin_ptr p, Value ¶ms, Value &response)
Value::null_t == v_out_password.valueType()) &&
LSM_FLAG_EXPECTED_TYPE(params) ) {
- rc = p->san_ops->iscsi_chap_auth(p, v_init.asC_str(),
+ rc = p->san_ops.v1->iscsi_chap_auth(p, v_init.asC_str(),
v_in_user.asC_str(),
v_in_password.asC_str(),
v_out_user.asC_str(),
@@ -2153,6 +2209,7 @@ static std::map<std::string,handler> dispatch = static_map<std::string,handler>
("volume_replicate_range", handle_volume_replicate_range)
("volume_resize", handle_volume_resize)
("volumes_accessible_by_access_group", vol_accessible_by_ag)
+ ("volume_raid_info", handle_volume_raid_info)
("volumes", handle_volumes);
static int process_request(lsm_plugin_ptr p, const std::string &method, Value &request,
--
1.8.2.1