Commit c6a78e83 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

nvmf: wrap checking for ptpl_file into a function



With a custom reservations implementation the ptpl file may not be used
to provide Persist Through Power Loss capability. Instead of checking it
directly, put it in a function to simplify further changes.

Change-Id: Id9cee6047f17ae010c940e1a3db009eaf84f8200
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21355


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent c623bf39
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1833,12 +1833,12 @@ nvmf_ctrlr_set_features_reservation_persistence(struct spdk_nvmf_request *req)
	ns = _nvmf_subsystem_get_ns(ctrlr->subsys, cmd->nsid);
	ptpl = cmd->cdw11_bits.feat_rsv_persistence.bits.ptpl;

	if (cmd->nsid != SPDK_NVME_GLOBAL_NS_TAG && ns && ns->ptpl_file) {
	if (cmd->nsid != SPDK_NVME_GLOBAL_NS_TAG && ns && nvmf_ns_is_ptpl_capable(ns)) {
		ns->ptpl_activated = ptpl;
	} else if (cmd->nsid == SPDK_NVME_GLOBAL_NS_TAG) {
		for (ns = spdk_nvmf_subsystem_get_first_ns(ctrlr->subsys); ns;
		     ns = spdk_nvmf_subsystem_get_next_ns(ctrlr->subsys, ns)) {
			if (ns->ptpl_file) {
			if (nvmf_ns_is_ptpl_capable(ns)) {
				ns->ptpl_activated = ptpl;
			}
		}
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ nvmf_bdev_ctrlr_identify_ns(struct spdk_nvmf_ns *ns, struct spdk_nvme_ns_data *n
		nsdata->noiob = spdk_bdev_get_optimal_io_boundary(bdev);
	}
	nsdata->nmic.can_share = 1;
	if (ns->ptpl_file != NULL) {
	if (nvmf_ns_is_ptpl_capable(ns)) {
		nsdata->nsrescap.rescap.persist = 1;
	}
	nsdata->nsrescap.rescap.write_exclusive = 1;
+5 −0
Original line number Diff line number Diff line
@@ -437,6 +437,11 @@ void nvmf_ctrlr_reservation_notice_log(struct spdk_nvmf_ctrlr *ctrlr,
				       struct spdk_nvmf_ns *ns,
				       enum spdk_nvme_reservation_notification_log_page_type type);

static inline bool
nvmf_ns_is_ptpl_capable(struct spdk_nvmf_ns *ns)
{
	return ns->ptpl_file != NULL;
}

/*
 * Abort zero-copy requests that already got the buffer (received zcopy_start cb), but haven't
+2 −2
Original line number Diff line number Diff line
@@ -2423,7 +2423,7 @@ nvmf_ns_update_reservation_info(struct spdk_nvmf_ns *ns)

	assert(ns != NULL);

	if (!ns->bdev || !ns->ptpl_file) {
	if (!ns->bdev || !nvmf_ns_is_ptpl_capable(ns)) {
		return 0;
	}

@@ -2730,7 +2730,7 @@ nvmf_ns_reservation_register(struct spdk_nvmf_ns *ns,
			update_sgroup = true;
		}
	} else if (cptpl == SPDK_NVME_RESERVE_PTPL_PERSIST_POWER_LOSS) {
		if (ns->ptpl_file == NULL) {
		if (!nvmf_ns_is_ptpl_capable(ns)) {
			status = SPDK_NVME_SC_INVALID_FIELD;
			goto exit;
		} else if (ns->ptpl_activated == 0) {