Commit a1d6e2bd authored by Dor Deri's avatar Dor Deri Committed by Tomasz Zawadzki
Browse files

nvmf: handle reservation notification log page count rollover



According to the NVMe specification, the reservation notification
log page count must roll over to 1h when it reaches its maximum value
(FFFFFFFF_FFFFFFFFh).

Log Page Count (LPC): This is a 64-bit incrementing Reservation
Notification log page count, indicating a unique identifier
(modulo 64 bit) for this notification. The count starts at 0h following
a Controller Level Reset and is incremented for every event that causes
a reservation notification regardless of whether that notification is
added to the queue. If the value of this field is FFFFFFFF_FFFFFFFFh,
then the field is set to 1h when incremented (i.e., rolls over to 1h)
and a new log page is created.

Change-Id: Ia03be3a344eb695bc1a47a1a07a85f7b19a7fe46
Signed-off-by: default avatarDor Deri <dor.deri@dell.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26463


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
parent 6178d62e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4204,6 +4204,10 @@ _nvmf_ctrlr_add_reservation_log(void *ctx)
	struct spdk_nvmf_reservation_log *log = (struct spdk_nvmf_reservation_log *)ctx;
	struct spdk_nvmf_ctrlr *ctrlr = log->ctrlr;

	if (spdk_unlikely(ctrlr->log_page_count == UINT64_MAX)) {
		ctrlr->log_page_count = 0;
	}

	ctrlr->log_page_count++;

	/* Maximum number of queued log pages is 255 */
+10 −0
Original line number Diff line number Diff line
@@ -1780,6 +1780,16 @@ test_reservation_notification_log_page(void)
	nvmf_get_reservation_notification_log_page(&ctrlr, &iov, 1, 0, sizeof(logs), 0);
	SPDK_CU_ASSERT_FATAL(ctrlr.num_avail_log_pages == 0);

	/* Test Case: log page count rollover */
	ctrlr.log_page_count = UINT64_MAX;
	nvmf_ctrlr_reservation_notice_log(&ctrlr, &ns,
					  SPDK_NVME_REGISTRATION_PREEMPTED);
	poll_threads();
	iov.iov_base = &logs[1];
	iov.iov_len = sizeof(logs);
	nvmf_get_reservation_notification_log_page(&ctrlr, &iov, 1, 0, sizeof(logs), 0);
	SPDK_CU_ASSERT_FATAL(logs[1].log_page_count == 1);

	cleanup_pending_async_events(&ctrlr);
}