rpc/nvmf: add RPC support to add the persistent configuration file for one NS
Change-Id: Ic4963d3e55cffceca35d18ba8d406658e51a189a Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455913 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
7b74274fbf
commit
5317a9f795
@ -12,6 +12,12 @@ A new file API `spdk_posix_file_load` was added to load file content into a data
|
||||
|
||||
### NVMe-oF Target
|
||||
|
||||
Persistent reservation emulation has been added to the NVMe-oF target. Persistent reservation
|
||||
state is stored in a JSON file on the local filesystem between target restart. To support this,
|
||||
an optional parameter to the RPC method `nvmf_subsystem_add_ns` called `--ptpl-file` was added.
|
||||
This allows the user to specify which file to store the persistent reservation state in. Note
|
||||
that this is done per namespace.
|
||||
|
||||
The c2h success optimization under which a command capsule response is not sent
|
||||
for reads is turned on. A config knob was added to allow for enable/disable.
|
||||
|
||||
|
@ -3808,6 +3808,7 @@ bdev_name | Required | string | Name of bdev to expose as a n
|
||||
nguid | Optional | string | 16-byte namespace globally unique identifier in hexadecimal (e.g. "ABCDEF0123456789ABCDEF0123456789")
|
||||
eui64 | Optional | string | 8-byte namespace EUI-64 in hexadecimal (e.g. "ABCDEF0123456789")
|
||||
uuid | Optional | string | RFC 4122 UUID (e.g. "ceccf520-691e-4b46-9546-34af789907c5")
|
||||
ptpl_file | Optional | string | File path to save/restore persistent reservation information
|
||||
|
||||
### Example
|
||||
|
||||
@ -3822,7 +3823,8 @@ Example request:
|
||||
"nqn": "nqn.2016-06.io.spdk:cnode1",
|
||||
"namespace": {
|
||||
"nsid": 3,
|
||||
"bdev_name": "Nvme0n1"
|
||||
"bdev_name": "Nvme0n1",
|
||||
"ptpl_file": "/opt/Nvme0n1PR.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -789,6 +789,7 @@ SPDK_RPC_REGISTER("nvmf_subsystem_remove_listener", spdk_rpc_nvmf_subsystem_remo
|
||||
|
||||
struct spdk_nvmf_ns_params {
|
||||
char *bdev_name;
|
||||
char *ptpl_file;
|
||||
uint32_t nsid;
|
||||
char nguid[16];
|
||||
char eui64[8];
|
||||
@ -804,6 +805,7 @@ struct rpc_namespaces {
|
||||
static const struct spdk_json_object_decoder rpc_ns_params_decoders[] = {
|
||||
{"nsid", offsetof(struct spdk_nvmf_ns_params, nsid), spdk_json_decode_uint32, true},
|
||||
{"bdev_name", offsetof(struct spdk_nvmf_ns_params, bdev_name), spdk_json_decode_string},
|
||||
{"ptpl_file", offsetof(struct spdk_nvmf_ns_params, ptpl_file), spdk_json_decode_string, true},
|
||||
{"nguid", offsetof(struct spdk_nvmf_ns_params, nguid), decode_ns_nguid, true},
|
||||
{"eui64", offsetof(struct spdk_nvmf_ns_params, eui64), decode_ns_eui64, true},
|
||||
{"uuid", offsetof(struct spdk_nvmf_ns_params, uuid), decode_ns_uuid, true},
|
||||
@ -837,6 +839,7 @@ nvmf_rpc_ns_ctx_free(struct nvmf_rpc_ns_ctx *ctx)
|
||||
{
|
||||
free(ctx->nqn);
|
||||
free(ctx->ns_params.bdev_name);
|
||||
free(ctx->ns_params.ptpl_file);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
@ -895,7 +898,8 @@ nvmf_rpc_ns_paused(struct spdk_nvmf_subsystem *subsystem,
|
||||
ns_opts.uuid = ctx->ns_params.uuid;
|
||||
}
|
||||
|
||||
ctx->ns_params.nsid = spdk_nvmf_subsystem_add_ns(subsystem, bdev, &ns_opts, sizeof(ns_opts), NULL);
|
||||
ctx->ns_params.nsid = spdk_nvmf_subsystem_add_ns(subsystem, bdev, &ns_opts, sizeof(ns_opts),
|
||||
ctx->ns_params.ptpl_file);
|
||||
if (ctx->ns_params.nsid == 0) {
|
||||
SPDK_ERRLOG("Unable to add namespace\n");
|
||||
spdk_jsonrpc_send_error_response(ctx->request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
|
@ -1518,6 +1518,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
rpc.nvmf.nvmf_subsystem_add_ns(args.client,
|
||||
nqn=args.nqn,
|
||||
bdev_name=args.bdev_name,
|
||||
ptpl_file=args.ptpl_file,
|
||||
nsid=args.nsid,
|
||||
nguid=args.nguid,
|
||||
eui64=args.eui64,
|
||||
@ -1526,6 +1527,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
p = subparsers.add_parser('nvmf_subsystem_add_ns', help='Add a namespace to an NVMe-oF subsystem')
|
||||
p.add_argument('nqn', help='NVMe-oF subsystem NQN')
|
||||
p.add_argument('bdev_name', help='The name of the bdev that will back this namespace')
|
||||
p.add_argument('-p', '--ptpl-file', help='The persistent reservation storage location (optional)', type=str)
|
||||
p.add_argument('-n', '--nsid', help='The requested NSID (optional)', type=int)
|
||||
p.add_argument('-g', '--nguid', help='Namespace globally unique identifier (optional)')
|
||||
p.add_argument('-e', '--eui64', help='Namespace EUI-64 identifier (optional)')
|
||||
|
@ -212,7 +212,7 @@ def nvmf_subsystem_remove_listener(
|
||||
return client.call('nvmf_subsystem_remove_listener', params)
|
||||
|
||||
|
||||
def nvmf_subsystem_add_ns(client, nqn, bdev_name, nsid=None, nguid=None, eui64=None, uuid=None):
|
||||
def nvmf_subsystem_add_ns(client, nqn, bdev_name, ptpl_file=None, nsid=None, nguid=None, eui64=None, uuid=None):
|
||||
"""Add a namespace to a subsystem.
|
||||
|
||||
Args:
|
||||
@ -228,6 +228,9 @@ def nvmf_subsystem_add_ns(client, nqn, bdev_name, nsid=None, nguid=None, eui64=N
|
||||
"""
|
||||
ns = {'bdev_name': bdev_name}
|
||||
|
||||
if ptpl_file:
|
||||
ns['ptpl_file'] = ptpl_file
|
||||
|
||||
if nsid:
|
||||
ns['nsid'] = nsid
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user