* 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

Changes in V3:

 * New implementation for adding new methods:
    * New struct lsm_ops_v1_2:
        Free to change during version 1.2 development phase.
        Will frozen it once 1.2 released.

    * New plugin register method: lsm_register_plugin_v1_2()
        It takes all arguments required by old lsm_register_plugin_v1()
        addition to struct lsm_ops_v1_2 pointer.

    * Once version 1.2 released, we could work on struct lsm_ops_v1_3 and
      lsm_register_plugin_v1_3().

 * Add 'New in version 1.2' comment of lsm_volume_raid_info() function.

Changes in V4:

 * Add LSM_FLAG_UNUSED_CHECK in public lsm_volume_raid_info() function.
 * Changed the value of these constants from -1 to 0 to align with
   libblkid/sysfs:
    * LSM_VOLUME_STRIP_SIZE_UNKNOWN
    * LSM_VOLUME_EXTENT_COUNT_UNKNOWN
    * LSM_VOLUME_MIN_IO_SIZE_UNKNOWN
    * LSM_VOLUME_OPT_IO_SIZE_UNKNOWN

Changes in V5:
 * Rename output argument 'extent_count' to 'disk_count'.
 * Change constant name from LSM_VOLUME_EXTENT_COUNT_UNKNOWN to
   LSM_VOLUME_DISK_COUNT_UNKNOWN.
 * Change data type from 'int32_t' to 'uint32_t' for these output arugments:
    * strip_size
    * disk_count
    * min_io_size
    * opt_io_size

Signed-off-by: Gris Ge <f...@redhat.com>
Signed-off-by: Tony Asleson <tasle...@redhat.com>
---
 c_binding/include/libstoragemgmt/libstoragemgmt.h  | 20 +++++++
 .../libstoragemgmt/libstoragemgmt_capabilities.h   |  3 ++
 .../libstoragemgmt/libstoragemgmt_plug_interface.h | 55 +++++++++++++++++++
 .../include/libstoragemgmt/libstoragemgmt_types.h  | 43 +++++++++++++++
 c_binding/lsm_datatypes.hpp                        |  1 +
 c_binding/lsm_mgmt.cpp                             | 48 +++++++++++++++++
 c_binding/lsm_plugin_ipc.cpp                       | 62 +++++++++++++++++++++-
 7 files changed, 231 insertions(+), 1 deletion(-)

diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt.h 
b/c_binding/include/libstoragemgmt/libstoragemgmt.h
index 879f184..6e03f78 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. New in version 1.2.
+ * @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] disk_count   Count of disks of RAID group(s) where this volume
+ *                          allocated from.
+ * @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,
+    uint32_t *strip_size, uint32_t *disk_count,
+    uint32_t *min_io_size, uint32_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..b36586c 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -745,6 +745,8 @@ 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 +776,8 @@ 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 +796,8 @@ 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 */
@@ -801,6 +807,37 @@ struct lsm_nas_ops_v1 {
 };
 
 /**
+ * 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]  disk_count      Count of of disks of RAID group(s) where this
+ *                              volume allocated from.
+ * @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, uint32_t *strip_size,
+    uint32_t *disk_count, uint32_t *min_io_size, uint32_t *opt_io_size,
+    lsm_flag flags);
+
+/** \struct lsm_ops_v1_2
+ * \brief Functions added in version 1.2
+ * NOTE: This structure will change during the developement util version 1.2
+ *       released.
+ */
+struct lsm_ops_v1_2 {
+    lsm_plug_volume_raid_info vol_raid_info;
+    /**^ Query volume RAID information*/
+};
+
+/**
  * Copies the memory pointed to by item with given type t.
  * @param t         Type of item to copy
  * @param item      Pointer to src
@@ -839,6 +876,24 @@ int LSM_DLL_EXPORT lsm_register_plugin_v1( lsm_plugin_ptr 
plug,
                         struct lsm_nas_ops_v1 *nas_ops );
 
 /**
+ * Used to register version 1.2 APIs plug-in operation.
+ * @param plug              Pointer provided by the framework
+ * @param private_data      Private data to be used for whatever the plug-in
+ *                          needs
+ * @param mgm_ops           Function pointers for struct lsm_mgmt_ops_v1
+ * @param san_ops           Function pointers for struct lsm_san_ops_v1
+ * @param fs_ops            Function pointers for struct lsm_fs_ops_v1
+ * @param nas_ops           Function pointers for struct lsm_nas_ops_v1
+ * @param ops_v1_2          Function pointers for struct lsm_ops_v1_2
+ * @return LSM_ERR_OK on success, else error reason.
+ */
+int LSM_DLL_EXPORT lsm_register_plugin_v1_2(
+    lsm_plugin_ptr plug,
+    void * private_data, struct lsm_mgmt_ops_v1 *mgm_ops,
+    struct lsm_san_ops_v1 *san_ops, struct lsm_fs_ops_v1 *fs_ops,
+    struct lsm_nas_ops_v1 *nas_ops, struct lsm_ops_v1_2 *ops_v1_2);
+
+/**
  * 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..562fcff 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       0
+#define LSM_VOLUME_DISK_COUNT_UNKNOWN       0
+#define LSM_VOLUME_MIN_IO_SIZE_UNKNOWN      0
+#define LSM_VOLUME_OPT_IO_SIZE_UNKNOWN      0
+
 /**
  * Admin state for volume, enabled or disabled
  */
diff --git a/c_binding/lsm_datatypes.hpp b/c_binding/lsm_datatypes.hpp
index aed6891..6a6271f 100644
--- a/c_binding/lsm_datatypes.hpp
+++ b/c_binding/lsm_datatypes.hpp
@@ -193,6 +193,7 @@ struct LSM_DLL_LOCAL _lsm_plugin {
     struct lsm_san_ops_v1    *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 */
+    struct lsm_ops_v1_2      *ops_v1_2;   /**< Callbacks for v1.2 ops */
 };
 
 
diff --git a/c_binding/lsm_mgmt.cpp b/c_binding/lsm_mgmt.cpp
index 37faed4..cb2665a 100644
--- a/c_binding/lsm_mgmt.cpp
+++ b/c_binding/lsm_mgmt.cpp
@@ -1171,6 +1171,54 @@ 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,
+                         uint32_t *strip_size, uint32_t *disk_count,
+                         uint32_t *min_io_size, uint32_t *opt_io_size,
+                         lsm_flag flags)
+{
+    if( LSM_FLAG_UNUSED_CHECK(flags) ) {
+        return LSM_ERR_INVALID_ARGUMENT;
+    }
+
+    int rc = LSM_ERR_OK;
+    CONN_SETUP(c);
+
+    if( !LSM_IS_VOL(volume) ) {
+        return LSM_ERR_INVALID_ARGUMENT;
+    }
+
+    if( !raid_type || !strip_size || !disk_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].asUint32_t();
+            *disk_count = j[2].asUint32_t();
+            *min_io_size = j[3].asUint32_t();
+            *opt_io_size = j[4].asUint32_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 f5374b9..d2a43d4 100644
--- a/c_binding/lsm_plugin_ipc.cpp
+++ b/c_binding/lsm_plugin_ipc.cpp
@@ -123,6 +123,21 @@ int lsm_register_plugin_v1(lsm_plugin_ptr plug,
     return rc;
 }
 
+int lsm_register_plugin_v1_2(
+    lsm_plugin_ptr plug, void *private_data, struct lsm_mgmt_ops_v1 *mgm_op,
+    struct lsm_san_ops_v1 *san_op, struct lsm_fs_ops_v1 *fs_op,
+    struct lsm_nas_ops_v1 *nas_op, struct lsm_ops_v1_2 *ops_v1_2)
+{
+    int rc = lsm_register_plugin_v1(
+        plug, private_data, mgm_op, san_op, fs_op, nas_op);
+
+    if (rc != LSM_ERR_OK){
+        return rc;
+    }
+    plug->ops_v1_2 = ops_v1_2;
+    return rc;
+}
+
 void *lsm_private_data_get(lsm_plugin_ptr plug)
 {
     if (!LSM_IS_PLUGIN(plug)) {
@@ -956,6 +971,50 @@ static int handle_volume_disable(lsm_plugin_ptr p, Value 
&params, Value &respons
     return handle_vol_enable_disable(p, params, response, 0);
 }
 
+static int handle_volume_raid_info(lsm_plugin_ptr p, Value &params,
+                                   Value &response)
+{
+    int rc = LSM_ERR_NO_SUPPORT;
+    if( p && p->ops_v1_2 && p->ops_v1_2->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;
+                uint32_t strip_size;
+                uint32_t disk_count;
+                uint32_t min_io_size;
+                uint32_t opt_io_size;
+
+                rc = p->ops_v1_2->vol_raid_info(
+                    p, vol, &raid_type, &strip_size, &disk_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(disk_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 ag_list(lsm_plugin_ptr p, Value &params, Value &response)
 {
     int rc = LSM_ERR_NO_SUPPORT;
@@ -2153,7 +2212,8 @@ 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)
-    ("volumes", handle_volumes);
+    ("volumes", handle_volumes)
+    ("volume_raid_info", handle_volume_raid_info);
 
 static int process_request(lsm_plugin_ptr p, const std::string &method, Value 
&request,
                     Value &response)
-- 
1.8.3.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Libstoragemgmt-devel mailing list
Libstoragemgmt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libstoragemgmt-devel

Reply via email to