nvme: Rename max_active_ns_idx to active_ns_count
This was sometimes used as the maximum array index and sometimes as the maximum count. Make it consistent everywhere and give it a better name. Signed-off-by: Ben Walker <benjamin.walker@intel.com> Change-Id: I518efd99a7d36584624490b0b3497bb6e81ce9ac Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10101 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
c7888feebc
commit
84688fdb1c
@ -720,7 +720,7 @@ nvme_ctrlr_alloc_ana_log_page(struct spdk_nvme_ctrlr *ctrlr)
|
||||
uint32_t ana_log_page_size;
|
||||
|
||||
ana_log_page_size = sizeof(struct spdk_nvme_ana_page) + ctrlr->cdata.nanagrpid *
|
||||
sizeof(struct spdk_nvme_ana_group_descriptor) + ctrlr->max_active_ns_idx *
|
||||
sizeof(struct spdk_nvme_ana_group_descriptor) + ctrlr->active_ns_count *
|
||||
sizeof(uint32_t);
|
||||
|
||||
/* Number of active namespaces may have changed.
|
||||
@ -2142,18 +2142,20 @@ static void
|
||||
nvme_ctrlr_identify_active_ns_swap(struct spdk_nvme_ctrlr *ctrlr, uint32_t **new_ns_list,
|
||||
size_t max_entries)
|
||||
{
|
||||
uint32_t max_active_ns_idx = 0;
|
||||
uint32_t active_ns_count = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < max_entries; i++) {
|
||||
if ((*new_ns_list)[max_active_ns_idx++] == 0) {
|
||||
if ((*new_ns_list)[active_ns_count] == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
active_ns_count++;
|
||||
}
|
||||
|
||||
spdk_free(ctrlr->active_ns_list);
|
||||
ctrlr->active_ns_list = *new_ns_list;
|
||||
ctrlr->max_active_ns_idx = max_active_ns_idx;
|
||||
ctrlr->active_ns_count = active_ns_count;
|
||||
*new_ns_list = NULL;
|
||||
}
|
||||
|
||||
@ -4098,7 +4100,7 @@ nvme_ctrlr_destruct_poll_async(struct spdk_nvme_ctrlr *ctrlr,
|
||||
nvme_ctrlr_destruct_namespaces(ctrlr);
|
||||
spdk_free(ctrlr->active_ns_list);
|
||||
ctrlr->active_ns_list = NULL;
|
||||
ctrlr->max_active_ns_idx = 0;
|
||||
ctrlr->active_ns_count = 0;
|
||||
|
||||
spdk_bit_array_free(&ctrlr->free_io_qids);
|
||||
|
||||
@ -4307,12 +4309,15 @@ nvme_ctrlr_active_ns_idx(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid)
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (ctrlr->active_ns_list == NULL || nsid == 0 || nsid > ctrlr->cdata.nn) {
|
||||
if (ctrlr->active_ns_list == NULL ||
|
||||
ctrlr->active_ns_count == 0 ||
|
||||
nsid == 0 ||
|
||||
nsid > ctrlr->cdata.nn) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t lower = 0;
|
||||
int32_t upper = ctrlr->max_active_ns_idx;
|
||||
int32_t upper = ctrlr->active_ns_count - 1;
|
||||
int32_t mid;
|
||||
|
||||
while (lower <= upper) {
|
||||
@ -4349,7 +4354,7 @@ uint32_t
|
||||
spdk_nvme_ctrlr_get_next_active_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t prev_nsid)
|
||||
{
|
||||
int32_t nsid_idx = nvme_ctrlr_active_ns_idx(ctrlr, prev_nsid);
|
||||
if (nsid_idx >= 0 && (uint32_t)nsid_idx < ctrlr->max_active_ns_idx) {
|
||||
if (nsid_idx >= 0 && (uint32_t)(nsid_idx + 1) < ctrlr->active_ns_count) {
|
||||
return ctrlr->active_ns_list[nsid_idx + 1];
|
||||
}
|
||||
return 0;
|
||||
|
@ -937,7 +937,7 @@ struct spdk_nvme_ctrlr {
|
||||
/**
|
||||
* Keep track of active namespaces
|
||||
*/
|
||||
uint32_t max_active_ns_idx;
|
||||
uint32_t active_ns_count;
|
||||
uint32_t *active_ns_list;
|
||||
|
||||
struct spdk_bit_array *free_io_qids;
|
||||
|
@ -2870,7 +2870,7 @@ test_nvme_ctrlr_identify_namespaces_iocs_specific_next(void)
|
||||
|
||||
ctrlr.ns = ns;
|
||||
ctrlr.cdata.nn = 5;
|
||||
ctrlr.max_active_ns_idx = 5;
|
||||
ctrlr.active_ns_count = 5;
|
||||
ctrlr.num_ns = 5;
|
||||
/* case 1: No first/next active NS, move on to the next state, expect: pass */
|
||||
prev_nsid = 0;
|
||||
@ -2971,7 +2971,7 @@ test_nvme_ctrlr_set_supported_log_pages(void)
|
||||
ctrlr.cdata.cmic.ana_reporting = true;
|
||||
ctrlr.cdata.lpa.celp = 1;
|
||||
ctrlr.cdata.nanagrpid = 1;
|
||||
ctrlr.max_active_ns_idx = 1;
|
||||
ctrlr.active_ns_count = 1;
|
||||
|
||||
rc = nvme_ctrlr_set_supported_log_pages(&ctrlr);
|
||||
CU_ASSERT(rc == 0);
|
||||
@ -3002,7 +3002,7 @@ test_nvme_ctrlr_parse_ana_log_page(void)
|
||||
ctrlr.cdata.nn = 3;
|
||||
ctrlr.cdata.nanagrpid = 3;
|
||||
ctrlr.num_ns = 3;
|
||||
ctrlr.max_active_ns_idx = 3;
|
||||
ctrlr.active_ns_count = 3;
|
||||
|
||||
rc = nvme_ctrlr_init_ana_log_page(&ctrlr);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
Loading…
Reference in New Issue
Block a user