Commit c57cd922 authored by Maciej Wawryk's avatar Maciej Wawryk Committed by Ben Walker
Browse files

RPC: rename rpc construct_lvol_bdev to bdev_lvol_create

parent b5fdf4ec
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -460,14 +460,14 @@ Example commands

## Lvols {#bdev_ug_lvols}

To create lvols on existing lvol store user should use `construct_lvol_bdev` RPC command.
To create lvols on existing lvol store user should use `bdev_lvol_create` RPC command.
Each created lvol will be represented by new bdev.

Example commands

`rpc.py construct_lvol_bdev lvol1 25 -l lvs`
`rpc.py bdev_lvol_create lvol1 25 -l lvs`

`rpc.py construct_lvol_bdev lvol2 25 -u 330a6ab2-f468-11e7-983e-001e67edf35d`
`rpc.py bdev_lvol_create lvol2 25 -u 330a6ab2-f468-11e7-983e-001e67edf35d`

# RAID {#bdev_ug_raid}

+3 −3
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ Example response:
    "bdev_lvol_rename",
    "bdev_lvol_clone",
    "bdev_lvol_snapshot",
    "construct_lvol_bdev",
    "bdev_lvol_create",
    "destroy_lvol_store",
    "rename_lvol_store",
    "construct_lvol_store"
@@ -4938,7 +4938,7 @@ Example response:
}
~~~

## construct_lvol_bdev {#rpc_construct_lvol_bdev}
## bdev_lvol_create {#rpc_bdev_lvol_create}

Create a logical volume on a logical volume store.

@@ -4967,7 +4967,7 @@ Example request:
~~~
{
  "jsonrpc": "2.0",
  "method": "construct_lvol_bdev",
  "method": "bdev_lvol_create",
  "id": 1,
  "params": {
    "lvol_name": "LVOL0",
+2 −2
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ rename_lvol_store [-h] old_name new_name
RPC regarding lvol and spdk bdev:

```
construct_lvol_bdev [-h] [-u UUID] [-l LVS_NAME] [-t] [-c CLEAR_METHOD] lvol_name size
bdev_lvol_create [-h] [-u UUID] [-l LVS_NAME] [-t] [-c CLEAR_METHOD] lvol_name size
    Creates lvol with specified size and name on lvolstore specified by its uuid
    or name. Then constructs spdk bdev on top of that lvol and presents it as spdk bdev.
    User may use -t switch to create thin provisioned lvol.
@@ -126,7 +126,7 @@ get_bdevs [-h] [-b NAME]
    -h, --help  show help
    -b NAME, --name NAME  Name of the block device. Example: Nvme0n1
bdev_lvol_delete [-h] bdev_name
    Deletes a logical volume previously created by construct_lvol_bdev.
    Deletes a logical volume previously created by bdev_lvol_create.
    optional arguments:
    -h, --help  show help
bdev_lvol_snapshot [-h] lvol_name snapshot_name
+19 −18
Original line number Diff line number Diff line
@@ -304,7 +304,7 @@ cleanup:
}
SPDK_RPC_REGISTER("destroy_lvol_store", spdk_rpc_destroy_lvol_store, SPDK_RPC_RUNTIME)

struct rpc_construct_lvol_bdev {
struct rpc_bdev_lvol_create {
	char *uuid;
	char *lvs_name;
	char *lvol_name;
@@ -314,7 +314,7 @@ struct rpc_construct_lvol_bdev {
};

static void
free_rpc_construct_lvol_bdev(struct rpc_construct_lvol_bdev *req)
free_rpc_bdev_lvol_create(struct rpc_bdev_lvol_create *req)
{
	free(req->uuid);
	free(req->lvs_name);
@@ -322,17 +322,17 @@ free_rpc_construct_lvol_bdev(struct rpc_construct_lvol_bdev *req)
	free(req->clear_method);
}

static const struct spdk_json_object_decoder rpc_construct_lvol_bdev_decoders[] = {
	{"uuid", offsetof(struct rpc_construct_lvol_bdev, uuid), spdk_json_decode_string, true},
	{"lvs_name", offsetof(struct rpc_construct_lvol_bdev, lvs_name), spdk_json_decode_string, true},
	{"lvol_name", offsetof(struct rpc_construct_lvol_bdev, lvol_name), spdk_json_decode_string},
	{"size", offsetof(struct rpc_construct_lvol_bdev, size), spdk_json_decode_uint64},
	{"thin_provision", offsetof(struct rpc_construct_lvol_bdev, thin_provision), spdk_json_decode_bool, true},
	{"clear_method", offsetof(struct rpc_construct_lvol_bdev, clear_method), spdk_json_decode_string, true},
static const struct spdk_json_object_decoder rpc_bdev_lvol_create_decoders[] = {
	{"uuid", offsetof(struct rpc_bdev_lvol_create, uuid), spdk_json_decode_string, true},
	{"lvs_name", offsetof(struct rpc_bdev_lvol_create, lvs_name), spdk_json_decode_string, true},
	{"lvol_name", offsetof(struct rpc_bdev_lvol_create, lvol_name), spdk_json_decode_string},
	{"size", offsetof(struct rpc_bdev_lvol_create, size), spdk_json_decode_uint64},
	{"thin_provision", offsetof(struct rpc_bdev_lvol_create, thin_provision), spdk_json_decode_bool, true},
	{"clear_method", offsetof(struct rpc_bdev_lvol_create, clear_method), spdk_json_decode_string, true},
};

static void
_spdk_rpc_construct_lvol_bdev_cb(void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)
_spdk_rpc_bdev_lvol_create_cb(void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)
{
	struct spdk_json_write_ctx *w;
	struct spdk_jsonrpc_request *request = cb_arg;
@@ -352,18 +352,18 @@ invalid:
}

static void
spdk_rpc_construct_lvol_bdev(struct spdk_jsonrpc_request *request,
spdk_rpc_bdev_lvol_create(struct spdk_jsonrpc_request *request,
			  const struct spdk_json_val *params)
{
	struct rpc_construct_lvol_bdev req = {};
	struct rpc_bdev_lvol_create req = {};
	enum lvol_clear_method clear_method;
	int rc = 0;
	struct spdk_lvol_store *lvs = NULL;

	SPDK_INFOLOG(SPDK_LOG_LVOL_RPC, "Creating blob\n");

	if (spdk_json_decode_object(params, rpc_construct_lvol_bdev_decoders,
				    SPDK_COUNTOF(rpc_construct_lvol_bdev_decoders),
	if (spdk_json_decode_object(params, rpc_bdev_lvol_create_decoders,
				    SPDK_COUNTOF(rpc_bdev_lvol_create_decoders),
				    &req)) {
		SPDK_INFOLOG(SPDK_LOG_LVOL_RPC, "spdk_json_decode_object failed\n");
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
@@ -393,17 +393,18 @@ spdk_rpc_construct_lvol_bdev(struct spdk_jsonrpc_request *request,
	}

	rc = vbdev_lvol_create(lvs, req.lvol_name, req.size, req.thin_provision,
			       clear_method, _spdk_rpc_construct_lvol_bdev_cb, request);
			       clear_method, _spdk_rpc_bdev_lvol_create_cb, request);
	if (rc < 0) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		goto cleanup;
	}

cleanup:
	free_rpc_construct_lvol_bdev(&req);
	free_rpc_bdev_lvol_create(&req);
}

SPDK_RPC_REGISTER("construct_lvol_bdev", spdk_rpc_construct_lvol_bdev, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER("bdev_lvol_create", spdk_rpc_bdev_lvol_create, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_lvol_create, construct_lvol_bdev)

struct rpc_bdev_lvol_snapshot {
	char *lvol_name;
+12 −11
Original line number Diff line number Diff line
@@ -1177,8 +1177,8 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
    p.add_argument('new_name', help='new name')
    p.set_defaults(func=rename_lvol_store)

    def construct_lvol_bdev(args):
        print_json(rpc.lvol.construct_lvol_bdev(args.client,
    def bdev_lvol_create(args):
        print_json(rpc.lvol.bdev_lvol_create(args.client,
                                             lvol_name=args.lvol_name,
                                             size=args.size * 1024 * 1024,
                                             thin_provision=args.thin_provision,
@@ -1186,7 +1186,8 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
                                             uuid=args.uuid,
                                             lvs_name=args.lvs_name))

    p = subparsers.add_parser('construct_lvol_bdev', help='Add a bdev with an logical volume backend')
    p = subparsers.add_parser('bdev_lvol_create', aliases=['construct_lvol_bdev'],
                              help='Add a bdev with an logical volume backend')
    p.add_argument('-u', '--uuid', help='lvol store UUID', required=False)
    p.add_argument('-l', '--lvs-name', help='lvol store name', required=False)
    p.add_argument('-t', '--thin-provision', action='store_true', help='create lvol bdev as thin provisioned')
@@ -1194,7 +1195,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
        Available: none, unmap, write_zeroes""", required=False)
    p.add_argument('lvol_name', help='name for this lvol')
    p.add_argument('size', help='size in MiB for this bdev', type=int)
    p.set_defaults(func=construct_lvol_bdev)
    p.set_defaults(func=bdev_lvol_create)

    def bdev_lvol_snapshot(args):
        print_json(rpc.lvol.bdev_lvol_snapshot(args.client,
Loading