RPC: rename rpc snapshot_lvol_bdev to bdev_lvol_snapshot

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I2cd186c0b4f38752d4f12594fe455c59bf503620
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466699
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Maciej Wawryk 2019-08-29 11:40:39 +02:00 committed by Ben Walker
parent 7a294f4cf3
commit f5cf8ea1fc
9 changed files with 52 additions and 49 deletions

View File

@ -307,7 +307,7 @@ Example response:
"bdev_lvol_inflate",
"bdev_lvol_rename",
"bdev_lvol_clone",
"snapshot_lvol_bdev",
"bdev_lvol_snapshot",
"construct_lvol_bdev",
"destroy_lvol_store",
"rename_lvol_store",
@ -4989,7 +4989,7 @@ Example response:
}
~~~
## snapshot_lvol_bdev {#rpc_snapshot_lvol_bdev}
## bdev_lvol_snapshot {#rpc_bdev_lvol_snapshot}
Capture a snapshot of the current state of a logical volume.
@ -5011,7 +5011,7 @@ Example request:
~~~
{
"jsonrpc": "2.0",
"method": "snapshot_lvol_bdev",
"method": "bdev_lvol_snapshot",
"id": 1,
"params": {
"lvol_name": "1b38702c-7f0c-411e-a962-92c6a5a8a602",

View File

@ -129,7 +129,7 @@ destroy_lvol_bdev [-h] bdev_name
Deletes a logical volume previously created by construct_lvol_bdev.
optional arguments:
-h, --help show help
snapshot_lvol_bdev [-h] lvol_name snapshot_name
bdev_lvol_snapshot [-h] lvol_name snapshot_name
Create a snapshot with snapshot_name of a given lvol bdev.
optional arguments:
-h, --help show help

View File

@ -405,25 +405,25 @@ cleanup:
SPDK_RPC_REGISTER("construct_lvol_bdev", spdk_rpc_construct_lvol_bdev, SPDK_RPC_RUNTIME)
struct rpc_snapshot_lvol_bdev {
struct rpc_bdev_lvol_snapshot {
char *lvol_name;
char *snapshot_name;
};
static void
free_rpc_snapshot_lvol_bdev(struct rpc_snapshot_lvol_bdev *req)
free_rpc_bdev_lvol_snapshot(struct rpc_bdev_lvol_snapshot *req)
{
free(req->lvol_name);
free(req->snapshot_name);
}
static const struct spdk_json_object_decoder rpc_snapshot_lvol_bdev_decoders[] = {
{"lvol_name", offsetof(struct rpc_snapshot_lvol_bdev, lvol_name), spdk_json_decode_string},
{"snapshot_name", offsetof(struct rpc_snapshot_lvol_bdev, snapshot_name), spdk_json_decode_string},
static const struct spdk_json_object_decoder rpc_bdev_lvol_snapshot_decoders[] = {
{"lvol_name", offsetof(struct rpc_bdev_lvol_snapshot, lvol_name), spdk_json_decode_string},
{"snapshot_name", offsetof(struct rpc_bdev_lvol_snapshot, snapshot_name), spdk_json_decode_string},
};
static void
_spdk_rpc_snapshot_lvol_bdev_cb(void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)
_spdk_rpc_bdev_lvol_snapshot_cb(void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)
{
struct spdk_json_write_ctx *w;
struct spdk_jsonrpc_request *request = cb_arg;
@ -443,17 +443,17 @@ invalid:
}
static void
spdk_rpc_snapshot_lvol_bdev(struct spdk_jsonrpc_request *request,
spdk_rpc_bdev_lvol_snapshot(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
struct rpc_snapshot_lvol_bdev req = {};
struct rpc_bdev_lvol_snapshot req = {};
struct spdk_bdev *bdev;
struct spdk_lvol *lvol;
SPDK_INFOLOG(SPDK_LOG_LVOL_RPC, "Snapshotting blob\n");
if (spdk_json_decode_object(params, rpc_snapshot_lvol_bdev_decoders,
SPDK_COUNTOF(rpc_snapshot_lvol_bdev_decoders),
if (spdk_json_decode_object(params, rpc_bdev_lvol_snapshot_decoders,
SPDK_COUNTOF(rpc_bdev_lvol_snapshot_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,
@ -475,13 +475,14 @@ spdk_rpc_snapshot_lvol_bdev(struct spdk_jsonrpc_request *request,
goto cleanup;
}
vbdev_lvol_create_snapshot(lvol, req.snapshot_name, _spdk_rpc_snapshot_lvol_bdev_cb, request);
vbdev_lvol_create_snapshot(lvol, req.snapshot_name, _spdk_rpc_bdev_lvol_snapshot_cb, request);
cleanup:
free_rpc_snapshot_lvol_bdev(&req);
free_rpc_bdev_lvol_snapshot(&req);
}
SPDK_RPC_REGISTER("snapshot_lvol_bdev", spdk_rpc_snapshot_lvol_bdev, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER("bdev_lvol_snapshot", spdk_rpc_bdev_lvol_snapshot, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_lvol_snapshot, snapshot_lvol_bdev)
struct rpc_bdev_lvol_clone {
char *snapshot_name;

View File

@ -1196,15 +1196,16 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
p.add_argument('size', help='size in MiB for this bdev', type=int)
p.set_defaults(func=construct_lvol_bdev)
def snapshot_lvol_bdev(args):
print_json(rpc.lvol.snapshot_lvol_bdev(args.client,
def bdev_lvol_snapshot(args):
print_json(rpc.lvol.bdev_lvol_snapshot(args.client,
lvol_name=args.lvol_name,
snapshot_name=args.snapshot_name))
p = subparsers.add_parser('snapshot_lvol_bdev', help='Create a snapshot of an lvol bdev')
p = subparsers.add_parser('bdev_lvol_snapshot', aliases=['snapshot_lvol_bdev'],
help='Create a snapshot of an lvol bdev')
p.add_argument('lvol_name', help='lvol bdev name')
p.add_argument('snapshot_name', help='lvol snapshot name')
p.set_defaults(func=snapshot_lvol_bdev)
p.set_defaults(func=bdev_lvol_snapshot)
def bdev_lvol_clone(args):
print_json(rpc.lvol.bdev_lvol_clone(args.client,

View File

@ -65,7 +65,8 @@ def construct_lvol_bdev(client, lvol_name, size, thin_provision=False, uuid=None
return client.call('construct_lvol_bdev', params)
def snapshot_lvol_bdev(client, lvol_name, snapshot_name):
@deprecated_alias('snapshot_lvol_bdev')
def bdev_lvol_snapshot(client, lvol_name, snapshot_name):
"""Capture a snapshot of the current state of a logical volume.
Args:
@ -79,7 +80,7 @@ def snapshot_lvol_bdev(client, lvol_name, snapshot_name):
'lvol_name': lvol_name,
'snapshot_name': snapshot_name
}
return client.call('snapshot_lvol_bdev', params)
return client.call('bdev_lvol_snapshot', params)
@deprecated_alias('clone_lvol_bdev')

View File

@ -203,7 +203,7 @@ function create_bdev_subsystem_config() {
tgt_rpc construct_lvol_store -c 1048576 ${lvol_store_base_bdev}p0 lvs_test
tgt_rpc construct_lvol_bdev -l lvs_test lvol0 32
tgt_rpc construct_lvol_bdev -l lvs_test -t lvol1 32
tgt_rpc snapshot_lvol_bdev lvs_test/lvol0 snapshot0
tgt_rpc bdev_lvol_snapshot lvs_test/lvol0 snapshot0
tgt_rpc bdev_lvol_clone lvs_test/snapshot0 clone0
expected_notifications+=(

View File

@ -214,9 +214,9 @@ class Commands_Rpc(object):
output, rc = self.rpc.bdev_lvol_rename(old_name, new_name)
return rc
def snapshot_lvol_bdev(self, bdev_name, snapshot_name):
print("INFO: RPC COMMAND snapshot_lvol_bdev")
output, rc = self.rpc.snapshot_lvol_bdev(bdev_name, snapshot_name)
def bdev_lvol_snapshot(self, bdev_name, snapshot_name):
print("INFO: RPC COMMAND bdev_lvol_snapshot")
output, rc = self.rpc.bdev_lvol_snapshot(bdev_name, snapshot_name)
return rc
def bdev_lvol_clone(self, snapshot_name, clone_name):

View File

@ -1230,7 +1230,7 @@ class TestCases(object):
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)
# Create snapshot of thin provisioned lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
# Create clone of snapshot and check if it ends with success
@ -1293,13 +1293,13 @@ class TestCases(object):
uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size, thin=True)
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
fail_count += self.c.bdev_lvol_clone(self.lvs_name + "/" + snapshot_name, clone_name)
clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name)
fail_count += self.c.snapshot_lvol_bdev(clone_bdev['name'], snapshot_name2)
fail_count += self.c.bdev_lvol_snapshot(clone_bdev['name'], snapshot_name2)
snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2)
# Try to destroy snapshot with 2 clones and check if it fails
@ -1354,13 +1354,13 @@ class TestCases(object):
uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size, thin=True)
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
fail_count += self.c.bdev_lvol_clone(self.lvs_name + "/" + snapshot_name, clone_name)
clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name)
fail_count += self.c.snapshot_lvol_bdev(clone_bdev['name'], snapshot_name2)
fail_count += self.c.bdev_lvol_snapshot(clone_bdev['name'], snapshot_name2)
snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2)
# Delete malloc bdev
@ -2148,7 +2148,7 @@ class TestCases(object):
bdev_size)
lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name)
# Create snapshot of lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
fail_count += self.c.start_nbd_disk(snapshot_bdev['name'], nbd_name0)
@ -2214,8 +2214,8 @@ class TestCases(object):
fail_count += self.run_fio_test(nbd_name[1], 0, fill_size, "write", "0xcc", 0)
# Create snapshots of lvol bdevs
fail_count += self.c.snapshot_lvol_bdev(uuid_bdev0, snapshot_name0)
fail_count += self.c.snapshot_lvol_bdev(uuid_bdev1, snapshot_name1)
fail_count += self.c.bdev_lvol_snapshot(uuid_bdev0, snapshot_name0)
fail_count += self.c.bdev_lvol_snapshot(uuid_bdev1, snapshot_name1)
fail_count += self.c.start_nbd_disk(self.lvs_name + "/" + snapshot_name0, nbd_name[2])
fail_count += self.c.start_nbd_disk(self.lvs_name + "/" + snapshot_name1, nbd_name[3])
# Compare every lvol bdev with corresponding snapshot
@ -2285,7 +2285,7 @@ class TestCases(object):
fail_count += is_process_alive(current_fio_pid)
# During write operation create snapshot of created lvol bdev
# and check that snapshot has been created successfully
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
fail_count += is_process_alive(current_fio_pid)
thread.join()
# Check that write operation ended with success
@ -2330,10 +2330,10 @@ class TestCases(object):
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev)
# Create snapshot of created lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name0)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name0)
# Create snapshot of previously created snapshot
# and check if operation will fail
if self.c.snapshot_lvol_bdev(snapshot_name0, snapshot_name1) == 0:
if self.c.bdev_lvol_snapshot(snapshot_name0, snapshot_name1) == 0:
print("ERROR: Creating snapshot of snapshot should fail")
fail_count += 1
# Delete lvol bdev
@ -2383,7 +2383,7 @@ class TestCases(object):
print("ERROR: Creating clone of lvol bdev ended with unexpected success")
fail_count += 1
# Create snapshot of lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
# Create again clone of lvol bdev and check if it fails
rv = self.c.bdev_lvol_clone(lvol_bdev['name'], clone_name)
if rv == 0:
@ -2446,7 +2446,7 @@ class TestCases(object):
fail_count += self.run_fio_test(nbd_name[0], 0, fill_size, "write", "0xcc", 0)
# Create snapshot of thick provisioned lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
# Create two clones of created snapshot
fail_count += self.c.bdev_lvol_clone(snapshot_bdev['name'], clone_name0)
@ -2514,7 +2514,7 @@ class TestCases(object):
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev)
# Create snapshot of thick provisioned lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
# Create clone of created snapshot
@ -2610,7 +2610,7 @@ class TestCases(object):
self.c.stop_nbd_disk(nbd_name)
# Create snapshot of thick provisioned lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
# Create two clones of created snapshot
@ -2702,7 +2702,7 @@ class TestCases(object):
fail_count += 1
# Create snapshot of thin provisioned lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
# Decouple parent lvol bdev
@ -2774,7 +2774,7 @@ class TestCases(object):
end_fill * MEGABYTE, "write", "0xdd", 0)
# Create snapshot of thin provisioned lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
# Fill second and fourth cluster of clone with data of known pattern
@ -2787,7 +2787,7 @@ class TestCases(object):
fill_range * MEGABYTE, "write", "0xcc", 0)
# Create second snapshot of thin provisioned lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name2)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name2)
snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2)
# Fill second cluster of clone with data of known pattern
@ -2935,7 +2935,7 @@ class TestCases(object):
fail_count += self.run_fio_test(nbd_name0, 0, size, "write", "0xcc")
# Create snapshot of lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
if snapshot_bdev['driver_specific']['lvol']['clone'] is not False\
or snapshot_bdev['driver_specific']['lvol']['snapshot'] is not True:
@ -3015,7 +3015,7 @@ class TestCases(object):
fail_count += self.run_fio_test(nbd_name0, 0, size-1, "write", "0xcc")
# Create snapshot of lvol bdev
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name)
if lvol_bdev['driver_specific']['lvol']['base_snapshot'] != snapshot_name:
@ -3032,7 +3032,7 @@ class TestCases(object):
# Create second snapshot of lvol_bdev
# First snapshot becomes snapshot of second snapshot
fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name2)
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name2)
snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2)
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
if snapshot_bdev2['driver_specific']['lvol']['base_snapshot'] != snapshot_name:

View File

@ -49,7 +49,7 @@ perf_pid=$!
sleep 1
# Perform some operations on the logical volume
snapshot=$($rpc_py snapshot_lvol_bdev $lvol "MY_SNAPSHOT")
snapshot=$($rpc_py bdev_lvol_snapshot $lvol "MY_SNAPSHOT")
$rpc_py bdev_lvol_resize $lvol $LVOL_BDEV_FINAL_SIZE
clone=$($rpc_py bdev_lvol_clone $snapshot "MY_CLONE")
$rpc_py bdev_lvol_inflate $clone