Commit 5e4e4bc4 authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

nvmf: Group bool members of spdk_nvmf_subsystem into a bit field



This saves 2 bytes and allows it to pack nicely with the
changing state bool (which must remember separate for atomic
operations).

Change-Id: Ibb92ae3c74306e60385ae23d0aaf877f33a69095
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4553


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent e1ef1e24
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
	}

	ctrlr->feat.async_event_configuration.bits.ns_attr_notice = 1;
	if (ctrlr->subsys->ana_reporting) {
	if (ctrlr->subsys->flags.ana_reporting) {
		ctrlr->feat.async_event_configuration.bits.ana_change_notice = 1;
	}
	ctrlr->feat.volatile_write_cache.bits.wce = 1;
@@ -540,7 +540,7 @@ _nvmf_ctrlr_add_io_qpair(void *ctx)
	}

	/* If ANA reporting is enabled, check if I/O connect is on the same listener. */
	if (subsystem->ana_reporting) {
	if (subsystem->flags.ana_reporting) {
		listener = nvmf_subsystem_find_listener(subsystem, qpair->trid);
		if (listener != ctrlr->listener) {
			SPDK_ERRLOG("I/O connect is on a listener different from admin connect\n");
@@ -1930,7 +1930,7 @@ nvmf_ctrlr_get_log_page(struct spdk_nvmf_request *req)
			nvmf_get_firmware_slot_log_page(req->data, offset, len);
			return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
		case SPDK_NVME_LOG_ASYMMETRIC_NAMESPACE_ACCESS:
			if (subsystem->ana_reporting) {
			if (subsystem->flags.ana_reporting) {
				nvmf_get_ana_log_page(ctrlr, req->data, offset, len);
				return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
			} else {
@@ -1996,7 +1996,7 @@ spdk_nvmf_ctrlr_identify_ns(struct spdk_nvmf_ctrlr *ctrlr,
		nsdata->noiob = max_num_blocks;
	}

	if (subsystem->ana_reporting) {
	if (subsystem->flags.ana_reporting) {
		/* ANA group ID matches NSID. */
		nsdata->anagrpid = ns->nsid;

@@ -2055,7 +2055,7 @@ spdk_nvmf_ctrlr_identify_ctrlr(struct spdk_nvmf_ctrlr *ctrlr, struct spdk_nvme_c
	cdata->sgls = ctrlr->cdata.sgls;
	cdata->fuses.compare_and_write = 1;
	cdata->acwu = 1;
	if (subsystem->ana_reporting) {
	if (subsystem->flags.ana_reporting) {
		cdata->mnan = subsystem->max_nsid;
	}
	spdk_strcpy_pad(cdata->subnqn, subsystem->subnqn, sizeof(cdata->subnqn), '\0');
@@ -2074,12 +2074,12 @@ spdk_nvmf_ctrlr_identify_ctrlr(struct spdk_nvmf_ctrlr *ctrlr, struct spdk_nvme_c
		cdata->rab = 6;
		cdata->cmic.multi_port = 1;
		cdata->cmic.multi_host = 1;
		if (subsystem->ana_reporting) {
		if (subsystem->flags.ana_reporting) {
			/* Asymmetric Namespace Access Reporting is supported. */
			cdata->cmic.ana_reporting = 1;
		}
		cdata->oaes.ns_attribute_notices = 1;
		if (subsystem->ana_reporting) {
		if (subsystem->flags.ana_reporting) {
			cdata->oaes.ana_change_notices = 1;
		}
		cdata->ctratt.host_id_exhid_supported = 1;
@@ -2104,7 +2104,7 @@ spdk_nvmf_ctrlr_identify_ctrlr(struct spdk_nvmf_ctrlr *ctrlr, struct spdk_nvme_c
		cdata->oncs.dsm = nvmf_ctrlr_dsm_supported(ctrlr);
		cdata->oncs.write_zeroes = nvmf_ctrlr_write_zeroes_supported(ctrlr);
		cdata->oncs.reservations = 1;
		if (subsystem->ana_reporting) {
		if (subsystem->flags.ana_reporting) {
			cdata->anatt = ANA_TRANSITION_TIME_IN_SEC;
			/* ANA Change state is not used, and ANA Persistent Loss state
			 * is not supported for now.
+12 −6
Original line number Diff line number Diff line
@@ -248,24 +248,30 @@ struct spdk_nvmf_ctrlr {

struct spdk_nvmf_subsystem {
	struct spdk_thread				*thread;

	uint32_t					id;

	enum spdk_nvmf_subsystem_state			state;

	char						subnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
	enum spdk_nvmf_subtype				subtype;

	uint16_t					next_cntlid;
	bool						allow_any_host;
	bool						allow_any_listener;
	bool						ana_reporting;
	struct {
		uint8_t					allow_any_host : 1;
		uint8_t					allow_any_listener : 1;
		uint8_t					ana_reporting : 1;
		uint8_t					reserved : 5;
	} flags;

	/* boolean for state change synchronization */
	bool						changing_state;

	struct spdk_nvmf_tgt				*tgt;

	char						sn[SPDK_NVME_CTRLR_SN_LEN + 1];
	char						mn[SPDK_NVME_CTRLR_MN_LEN + 1];

	/* boolean for state change synchronization. */
	bool						changing_state;

	/* Array of pointers to namespaces of size max_nsid indexed by nsid - 1 */
	struct spdk_nvmf_ns				**ns;
	uint32_t					max_nsid;
+7 −7
Original line number Diff line number Diff line
@@ -757,7 +757,7 @@ spdk_nvmf_subsystem_set_allow_any_host(struct spdk_nvmf_subsystem *subsystem, bo
		return -EAGAIN;
	}

	subsystem->allow_any_host = allow_any_host;
	subsystem->flags.allow_any_host = allow_any_host;

	return 0;
}
@@ -765,7 +765,7 @@ spdk_nvmf_subsystem_set_allow_any_host(struct spdk_nvmf_subsystem *subsystem, bo
bool
spdk_nvmf_subsystem_get_allow_any_host(const struct spdk_nvmf_subsystem *subsystem)
{
	return subsystem->allow_any_host;
	return subsystem->flags.allow_any_host;
}

bool
@@ -775,7 +775,7 @@ spdk_nvmf_subsystem_host_allowed(struct spdk_nvmf_subsystem *subsystem, const ch
		return false;
	}

	if (subsystem->allow_any_host) {
	if (subsystem->flags.allow_any_host) {
		return true;
	}

@@ -972,13 +972,13 @@ void
spdk_nvmf_subsystem_allow_any_listener(struct spdk_nvmf_subsystem *subsystem,
				       bool allow_any_listener)
{
	subsystem->allow_any_listener = allow_any_listener;
	subsystem->flags.allow_any_listener = allow_any_listener;
}

bool
spdk_nvmf_subsytem_any_listener_allowed(struct spdk_nvmf_subsystem *subsystem)
{
	return subsystem->allow_any_listener;
	return subsystem->flags.allow_any_listener;
}


@@ -2660,7 +2660,7 @@ spdk_nvmf_subsystem_set_ana_reporting(struct spdk_nvmf_subsystem *subsystem,
		return -EAGAIN;
	}

	subsystem->ana_reporting = ana_reporting;
	subsystem->flags.ana_reporting = ana_reporting;

	return 0;
}
@@ -2716,7 +2716,7 @@ nvmf_subsystem_set_ana_state(struct spdk_nvmf_subsystem *subsystem,
	assert(subsystem->state == SPDK_NVMF_SUBSYSTEM_INACTIVE ||
	       subsystem->state == SPDK_NVMF_SUBSYSTEM_PAUSED);

	if (!subsystem->ana_reporting) {
	if (!subsystem->flags.ana_reporting) {
		SPDK_ERRLOG("ANA reporting is disabled\n");
		cb_fn(cb_arg, -EINVAL);
		return;
+1 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ test_discovery_log(void)
	/* Add one subsystem and verify that the discovery log contains it */
	subsystem = spdk_nvmf_subsystem_create(&tgt, "nqn.2016-06.io.spdk:subsystem1",
					       SPDK_NVMF_SUBTYPE_NVME, 0);
	subsystem->allow_any_host = true;
	subsystem->flags.allow_any_host = true;
	SPDK_CU_ASSERT_FATAL(subsystem != NULL);

	trid.trtype = SPDK_NVME_TRANSPORT_RDMA;