examples/nvme_reserve: unregister the registrant key at last
When testing the application, after release the reservation, the registrant is still there, so we need to unregister the registrant at last to restore the drive to a clean state. Also set the CPTPL to 10b, it means Reservations are released and registrants are cleared on a power on, we will move the tool to test/nvme directory in following patch as this is only one test case for NVMe reservation feature. Change-Id: I271a61985940958b9f36887f9cd97841841ba2d6 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2731 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
e757878190
commit
4088860a03
@ -129,23 +129,31 @@ reservation_ns_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
reservation_ns_register(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair,
|
reservation_ns_register(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair,
|
||||||
uint32_t ns_id)
|
uint32_t ns_id, bool reg)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct spdk_nvme_reservation_register_data rr_data;
|
struct spdk_nvme_reservation_register_data rr_data;
|
||||||
|
enum spdk_nvme_reservation_register_action action;
|
||||||
struct spdk_nvme_ns *ns;
|
struct spdk_nvme_ns *ns;
|
||||||
|
|
||||||
ns = spdk_nvme_ctrlr_get_ns(ctrlr, ns_id);
|
ns = spdk_nvme_ctrlr_get_ns(ctrlr, ns_id);
|
||||||
|
|
||||||
rr_data.crkey = CR_KEY;
|
if (reg) {
|
||||||
|
rr_data.crkey = 0;
|
||||||
rr_data.nrkey = CR_KEY;
|
rr_data.nrkey = CR_KEY;
|
||||||
|
action = SPDK_NVME_RESERVE_REGISTER_KEY;
|
||||||
|
} else {
|
||||||
|
rr_data.crkey = CR_KEY;
|
||||||
|
rr_data.nrkey = 0;
|
||||||
|
action = SPDK_NVME_RESERVE_UNREGISTER_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
outstanding_commands = 0;
|
outstanding_commands = 0;
|
||||||
reserve_command_result = -1;
|
reserve_command_result = -1;
|
||||||
|
|
||||||
ret = spdk_nvme_ns_cmd_reservation_register(ns, qpair, &rr_data, true,
|
ret = spdk_nvme_ns_cmd_reservation_register(ns, qpair, &rr_data, true,
|
||||||
SPDK_NVME_RESERVE_REGISTER_KEY,
|
action,
|
||||||
SPDK_NVME_RESERVE_PTPL_NO_CHANGES,
|
SPDK_NVME_RESERVE_PTPL_CLEAR_POWER_ON,
|
||||||
reservation_ns_completion, NULL);
|
reservation_ns_completion, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
fprintf(stderr, "Reservation Register Failed\n");
|
fprintf(stderr, "Reservation Register Failed\n");
|
||||||
@ -316,10 +324,11 @@ reserve_controller(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair,
|
|||||||
get_host_identifier(ctrlr);
|
get_host_identifier(ctrlr);
|
||||||
|
|
||||||
/* tested 1 namespace */
|
/* tested 1 namespace */
|
||||||
reservation_ns_register(ctrlr, qpair, 1);
|
reservation_ns_register(ctrlr, qpair, 1, 1);
|
||||||
reservation_ns_acquire(ctrlr, qpair, 1);
|
reservation_ns_acquire(ctrlr, qpair, 1);
|
||||||
reservation_ns_report(ctrlr, qpair, 1);
|
|
||||||
reservation_ns_release(ctrlr, qpair, 1);
|
reservation_ns_release(ctrlr, qpair, 1);
|
||||||
|
reservation_ns_register(ctrlr, qpair, 1, 0);
|
||||||
|
reservation_ns_report(ctrlr, qpair, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
Loading…
Reference in New Issue
Block a user