bdev/nvme: Set per-controller PRCHK options by JSON RPC

Add prchk_reftag and prchk_guard to construct_nvme_bdev RPC.
In spdk_rpc_construct_nvme_bdev, create prchk_flags based on them
and pass it to spdk_bdev_nvme_create, and in spdk_bdev_nvme_create,
pass it to create_ctrlr.

A single option enable_prchk may be enough but add separate options
for reftag and guard to clarify that apptag is not supported yet.

The next patch will make per-controller PRCHK options configurable
by .INI config file.

Change-Id: I370ebbe984ee83d133b7f50bdc648ea746c8d42d
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/443833
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-02-08 10:06:45 +09:00 committed by Darek Stojaczyk
parent a827a91e6d
commit 260f9a77c3
6 changed files with 45 additions and 7 deletions

View File

@ -1459,6 +1459,8 @@ subnqn | Optional | string | NVMe-oF target subnqn
hostnqn | Optional | string | NVMe-oF target hostnqn
hostaddr | Optional | string | NVMe-oF host address: ip address
hostsvcid | Optional | string | NVMe-oF host trsvcid: port number
prchk_reftag | Optional | bool | Enable checking of PI reference tag for I/O processing
prchk_guard | Optional | bool | Enable checking of PI guard for I/O processing
### Example

View File

@ -1216,7 +1216,8 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
struct spdk_nvme_host_id *hostid,
const char *base_name,
const char **names, size_t *count,
const char *hostnqn)
const char *hostnqn,
uint32_t prchk_flags)
{
struct spdk_nvme_ctrlr_opts opts;
struct spdk_nvme_ctrlr *ctrlr;
@ -1255,7 +1256,7 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
return -1;
}
if (create_ctrlr(ctrlr, base_name, trid, 0)) {
if (create_ctrlr(ctrlr, base_name, trid, prchk_flags)) {
SPDK_ERRLOG("Failed to create new device\n");
return -1;
}
@ -1912,6 +1913,10 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)
spdk_json_write_named_object_begin(w, "params");
spdk_json_write_named_string(w, "name", nvme_ctrlr->name);
spdk_bdev_nvme_dump_trid_json(trid, w);
spdk_json_write_named_bool(w, "prchk_reftag",
(nvme_ctrlr->prchk_flags & SPDK_NVME_IO_FLAGS_PRCHK_REFTAG) != 0);
spdk_json_write_named_bool(w, "prchk_guard",
(nvme_ctrlr->prchk_flags & SPDK_NVME_IO_FLAGS_PRCHK_GUARD) != 0);
spdk_json_write_object_end(w);

View File

@ -100,7 +100,8 @@ int spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
struct spdk_nvme_host_id *hostid,
const char *base_name,
const char **names, size_t *count,
const char *hostnqn);
const char *hostnqn,
uint32_t prchk_flags);
struct spdk_nvme_ctrlr *spdk_bdev_nvme_get_ctrlr(struct spdk_bdev *bdev);
/**

View File

@ -167,6 +167,8 @@ struct rpc_construct_nvme {
char *hostnqn;
char *hostaddr;
char *hostsvcid;
bool prchk_reftag;
bool prchk_guard;
};
static void
@ -193,8 +195,10 @@ static const struct spdk_json_object_decoder rpc_construct_nvme_decoders[] = {
{"subnqn", offsetof(struct rpc_construct_nvme, subnqn), spdk_json_decode_string, true},
{"hostnqn", offsetof(struct rpc_construct_nvme, hostnqn), spdk_json_decode_string, true},
{"hostaddr", offsetof(struct rpc_construct_nvme, hostaddr), spdk_json_decode_string, true},
{"hostsvcid", offsetof(struct rpc_construct_nvme, hostsvcid), spdk_json_decode_string, true}
{"hostsvcid", offsetof(struct rpc_construct_nvme, hostsvcid), spdk_json_decode_string, true},
{"prchk_reftag", offsetof(struct rpc_construct_nvme, prchk_reftag), spdk_json_decode_bool, true},
{"prchk_guard", offsetof(struct rpc_construct_nvme, prchk_guard), spdk_json_decode_bool, true}
};
#define NVME_MAX_BDEVS_PER_RPC 128
@ -210,6 +214,7 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
const char *names[NVME_MAX_BDEVS_PER_RPC];
size_t count;
size_t i;
uint32_t prchk_flags = 0;
int rc;
if (spdk_json_decode_object(params, rpc_construct_nvme_decoders,
@ -256,8 +261,17 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
snprintf(hostid.hostsvcid, sizeof(hostid.hostsvcid), "%s", req.hostsvcid);
}
if (req.prchk_reftag) {
prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG;
}
if (req.prchk_guard) {
prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_GUARD;
}
count = NVME_MAX_BDEVS_PER_RPC;
if (spdk_bdev_nvme_create(&trid, &hostid, req.name, names, &count, req.hostnqn)) {
if (spdk_bdev_nvme_create(&trid, &hostid, req.name, names, &count, req.hostnqn,
prchk_flags)) {
goto invalid;
}

View File

@ -291,7 +291,9 @@ if __name__ == "__main__":
subnqn=args.subnqn,
hostnqn=args.hostnqn,
hostaddr=args.hostaddr,
hostsvcid=args.hostsvcid))
hostsvcid=args.hostsvcid,
prchk_reftag=args.prchk_reftag,
prchk_guard=args.prchk_guard))
p = subparsers.add_parser('construct_nvme_bdev',
help='Add bdevs with nvme backend')
@ -310,6 +312,10 @@ if __name__ == "__main__":
help='NVMe-oF host address: e.g., an ip address')
p.add_argument('-c', '--hostsvcid',
help='NVMe-oF host svcid: e.g., a port number')
p.add_argument('-r', '--prchk-reftag',
help='Enable checking of PI reference tag for I/O processing.', action='store_true')
p.add_argument('-g', '--prchk-guard',
help='Enable checking of PI guard for I/O processing.', action='store_true')
p.set_defaults(func=construct_nvme_bdev)
def get_nvme_controllers(args):

View File

@ -276,7 +276,9 @@ def set_bdev_nvme_hotplug(client, enable, period_us=None):
return client.call('set_bdev_nvme_hotplug', params)
def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None, subnqn=None, hostnqn=None, hostaddr=None, hostsvcid=None):
def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None,
subnqn=None, hostnqn=None, hostaddr=None, hostsvcid=None,
prchk_reftag=None, prchk_guard=None):
"""Construct NVMe namespace block devices.
Args:
@ -289,6 +291,8 @@ def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None,
hostnqn: NQN to connect from (optional)
hostaddr: host transport address (IP address for IP-based transports, NULL for PCIe or FC; optional)
hostsvcid: host transport service ID (port number for IP-based transports, NULL for PCIe or FC; optional)
prchk_reftag: Enable checking of PI reference tag for I/O processing (optional)
prchk_guard: Enable checking of PI guard for I/O processing (optional)
Returns:
Names of created block devices.
@ -315,6 +319,12 @@ def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None,
if subnqn:
params['subnqn'] = subnqn
if prchk_reftag:
params['prchk_reftag'] = prchk_reftag
if prchk_guard:
params['prchk_guard'] = prchk_guard
return client.call('construct_nvme_bdev', params)