Page MenuHomeFreeBSD

D61634.1794930566.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D61634.1794930566.diff

diff --git a/share/man/man4/nvme.4 b/share/man/man4/nvme.4
--- a/share/man/man4/nvme.4
+++ b/share/man/man4/nvme.4
@@ -52,6 +52,7 @@
.Cd hw.nvme.apst_enable= Ns Ar 1
.Cd hw.nvme.apst_data
.Cd hw.nvme.timestamp= Ns Ar 0
+.Cd hw.nvme.timestamp_interval= Ns Aq Ar seconds
.Cd hw.nvme.use_nvd= Ns Ar 0
.Cd nvme_load="YES"
.Pp
@@ -191,6 +192,13 @@
Do not set the controller's Timestamp feature.
By default it is set to the system time when the root file system is
mounted and again after every controller reset.
+.It Va hw.nvme.timestamp_interval=seconds
+Also set the Timestamp feature every
+.Ar seconds ,
+for controllers whose clock drifts.
+Each set may be recorded as a Timestamp Change event in the controller's
+Persistent Event Log, so short intervals can displace older events.
+The default of 0 disables periodic updates.
.It Va hw.nvme.use_nvd=0
The
.Xr nvd 4
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -948,6 +948,20 @@
if (nvme_completion_is_error(&status.cpl) && bootverbose)
nvme_printf(ctrlr, "failed to set the timestamp\n");
free(ts, M_NVME);
+ if (ctrlr->timestamp_interval > 0)
+ taskqueue_enqueue_timeout(ctrlr->taskqueue,
+ &ctrlr->timestamp_task, ctrlr->timestamp_interval * hz);
+}
+
+static void
+nvme_ctrlr_timestamp_task(void *arg, int pending)
+{
+ struct nvme_controller *ctrlr = arg;
+
+ if (ctrlr->is_failed || ctrlr->is_failed_admin || ctrlr->is_dying ||
+ ctrlr->is_resetting)
+ return;
+ nvme_ctrlr_set_timestamp(ctrlr);
}
static void
@@ -1931,6 +1945,12 @@
ctrlr->enable_aborts = 0;
TUNABLE_INT_FETCH("hw.nvme.enable_aborts", &ctrlr->enable_aborts);
+ ctrlr->timestamp_interval = 0;
+ TUNABLE_INT_FETCH("hw.nvme.timestamp_interval",
+ &ctrlr->timestamp_interval);
+ if (ctrlr->timestamp_interval > INT_MAX / hz)
+ ctrlr->timestamp_interval = INT_MAX / hz;
+
ctrlr->alignment_splits = counter_u64_alloc(M_WAITOK);
/* Cap transfers by the maximum addressable by page-sized PRP (4KB pages -> 2MB). */
@@ -1951,6 +1971,8 @@
ctrlr->is_resetting = 0;
ctrlr->is_initialized = false;
TASK_INIT(&ctrlr->reset_task, 0, nvme_ctrlr_reset_task, ctrlr);
+ TIMEOUT_TASK_INIT(ctrlr->taskqueue, &ctrlr->timestamp_task, 0,
+ nvme_ctrlr_timestamp_task, ctrlr);
for (int i = 0; i < NVME_MAX_ASYNC_EVENTS; i++) {
struct nvme_async_event_request *aer = &ctrlr->aer[i];
@@ -2050,6 +2072,8 @@
noadminq:
if (ctrlr->taskqueue) {
+ taskqueue_drain_timeout(ctrlr->taskqueue,
+ &ctrlr->timestamp_task);
taskqueue_free(ctrlr->taskqueue);
for (int i = 0; i < NVME_MAX_ASYNC_EVENTS; i++) {
struct nvme_async_event_request *aer = &ctrlr->aer[i];
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -337,6 +337,8 @@
bool is_initialized;
eventhandler_tag timestamp_tag;
+ struct timeout_task timestamp_task;
+ int timestamp_interval;
/* Host Memory Buffer */
int hmb_nchunks;

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 17, 3:49 PM (18 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41802437
Default Alt Text
D61634.1794930566.diff (2 KB)

Event Timeline