lvol: add get_lvol_stores RPC
This patch shows UUID and base bdev for logical volume stores when get_lvol_stores() RPC is called. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: Idbd0bc6c4a0334e5af8d4a674a203ddb2270f3e4 Reviewed-on: https://review.gerrithub.io/374604 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Maciej Szwed <maciej.szwed@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
2b1d8415cd
commit
e21aede946
@ -37,6 +37,9 @@
|
||||
#include "spdk/lvol.h"
|
||||
#include "spdk_internal/bdev.h"
|
||||
|
||||
/* Length of string returned from uuid_unparse() */
|
||||
#define UUID_STRING_LEN 37
|
||||
|
||||
struct spdk_lvol_store_req {
|
||||
union {
|
||||
struct {
|
||||
@ -90,4 +93,7 @@ struct lvol_task {
|
||||
enum spdk_bdev_io_status status;
|
||||
};
|
||||
|
||||
struct lvol_store_bdev *vbdev_lvol_store_first(void);
|
||||
struct lvol_store_bdev *vbdev_lvol_store_next(struct lvol_store_bdev *prev);
|
||||
|
||||
#endif /* SPDK_INTERNAL_LVOLSTORE_H */
|
||||
|
@ -162,8 +162,8 @@ vbdev_lvs_destruct(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn,
|
||||
}
|
||||
}
|
||||
|
||||
static struct lvol_store_bdev *
|
||||
_vbdev_lvol_store_first(void)
|
||||
struct lvol_store_bdev *
|
||||
vbdev_lvol_store_first(void)
|
||||
{
|
||||
struct lvol_store_bdev *lvs_bdev;
|
||||
|
||||
@ -175,8 +175,8 @@ _vbdev_lvol_store_first(void)
|
||||
return lvs_bdev;
|
||||
}
|
||||
|
||||
static struct lvol_store_bdev *
|
||||
_vbdev_lvol_store_next(struct lvol_store_bdev *prev)
|
||||
struct lvol_store_bdev *
|
||||
vbdev_lvol_store_next(struct lvol_store_bdev *prev)
|
||||
{
|
||||
struct lvol_store_bdev *lvs_bdev;
|
||||
|
||||
@ -192,14 +192,14 @@ struct spdk_lvol_store *
|
||||
vbdev_get_lvol_store_by_uuid(uuid_t uuid)
|
||||
{
|
||||
struct spdk_lvol_store *lvs = NULL;
|
||||
struct lvol_store_bdev *lvs_bdev = _vbdev_lvol_store_first();
|
||||
struct lvol_store_bdev *lvs_bdev = vbdev_lvol_store_first();
|
||||
|
||||
while (lvs_bdev != NULL) {
|
||||
lvs = lvs_bdev->lvs;
|
||||
if (uuid_compare(lvs->uuid, uuid) == 0) {
|
||||
return lvs;
|
||||
}
|
||||
lvs_bdev = _vbdev_lvol_store_next(lvs_bdev);
|
||||
lvs_bdev = vbdev_lvol_store_next(lvs_bdev);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -208,14 +208,14 @@ struct lvol_store_bdev *
|
||||
vbdev_get_lvs_bdev_by_lvs(struct spdk_lvol_store *lvs_orig)
|
||||
{
|
||||
struct spdk_lvol_store *lvs = NULL;
|
||||
struct lvol_store_bdev *lvs_bdev = _vbdev_lvol_store_first();
|
||||
struct lvol_store_bdev *lvs_bdev = vbdev_lvol_store_first();
|
||||
|
||||
while (lvs_bdev != NULL) {
|
||||
lvs = lvs_bdev->lvs;
|
||||
if (lvs == lvs_orig) {
|
||||
return lvs_bdev;
|
||||
}
|
||||
lvs_bdev = _vbdev_lvol_store_next(lvs_bdev);
|
||||
lvs_bdev = vbdev_lvol_store_next(lvs_bdev);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ static void
|
||||
_spdk_rpc_lvol_store_construct_cb(void *cb_arg, struct spdk_lvol_store *lvol_store, int lvserrno)
|
||||
{
|
||||
struct spdk_json_write_ctx *w;
|
||||
char lvol_store_uuid[37];
|
||||
char lvol_store_uuid[UUID_STRING_LEN];
|
||||
struct spdk_jsonrpc_request *request = cb_arg;
|
||||
char buf[64];
|
||||
|
||||
@ -378,3 +378,44 @@ invalid:
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("resize_lvol_bdev", spdk_rpc_resize_lvol_bdev)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_lvol_stores(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct spdk_json_write_ctx *w;
|
||||
struct lvol_store_bdev *lvs_bdev;
|
||||
char uuid[UUID_STRING_LEN];
|
||||
|
||||
if (params != NULL) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"get_lvol_stores requires no parameters");
|
||||
return;
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
if (w == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_json_write_array_begin(w);
|
||||
|
||||
for (lvs_bdev = vbdev_lvol_store_first(); lvs_bdev != NULL;
|
||||
lvs_bdev = vbdev_lvol_store_next(lvs_bdev)) {
|
||||
spdk_json_write_object_begin(w);
|
||||
|
||||
uuid_unparse(lvs_bdev->lvs->uuid, uuid);
|
||||
spdk_json_write_name(w, "uuid");
|
||||
spdk_json_write_string(w, uuid);
|
||||
|
||||
spdk_json_write_name(w, "base_bdev");
|
||||
spdk_json_write_string(w, spdk_bdev_get_name(lvs_bdev->bdev));
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
spdk_json_write_array_end(w);
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("get_lvol_stores", spdk_rpc_get_lvol_stores)
|
||||
|
@ -288,6 +288,13 @@ p.add_argument('lvol_store_uuid', help='lvol store UUID')
|
||||
p.set_defaults(func=destroy_lvol_store)
|
||||
|
||||
|
||||
def get_lvol_stores(args):
|
||||
print_dict(jsonrpc_call('get_lvol_stores'))
|
||||
|
||||
p = subparsers.add_parser('get_lvol_stores', help='Display current logical volume store list')
|
||||
p.set_defaults(func=get_lvol_stores)
|
||||
|
||||
|
||||
def set_trace_flag(args):
|
||||
params = {'flag': args.flag}
|
||||
jsonrpc_call('set_trace_flag', params)
|
||||
|
Loading…
x
Reference in New Issue
Block a user