summaryrefslogtreecommitdiffstats
path: root/sys/dev/nvd/nvd.c
diff options
context:
space:
mode:
authorjimharris <jimharris@FreeBSD.org>2016-02-17 15:38:05 +0000
committerjimharris <jimharris@FreeBSD.org>2016-02-17 15:38:05 +0000
commitefd4fe5452c6487edb2d6291278f022cd05d2296 (patch)
treebb952af01dd1d0ea1bf66f34324d086588f26a6e /sys/dev/nvd/nvd.c
parentb9d4be0c4e918d40c0526998dc097fccb3d08426 (diff)
downloadFreeBSD-src-efd4fe5452c6487edb2d6291278f022cd05d2296.zip
FreeBSD-src-efd4fe5452c6487edb2d6291278f022cd05d2296.tar.gz
MFC r295022:
nvd: add hw.nvd.delete_max tunable The NVMe specification does not define a maximum or optimal delete size, so technically max delete size is min(full size of namespace, 2^32 - 1 LBAs). A single delete operation for a multi-TB NVMe namespace though may take much longer to complete than the nvme(4) I/O timeout period. So choose a sensible default here that is still suitably large to minimize the number of overall delete operations. This also fixes possible uint32_t overflow on initial TRIM operation for zpool create operations for NVMe namespaces with >4G LBAs. Approved by: re (glebius) Sponsored by: Intel
Diffstat (limited to 'sys/dev/nvd/nvd.c')
-rw-r--r--sys/dev/nvd/nvd.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/dev/nvd/nvd.c b/sys/dev/nvd/nvd.c
index 24ee075..e062f57 100644
--- a/sys/dev/nvd/nvd.c
+++ b/sys/dev/nvd/nvd.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (C) 2012-2013 Intel Corporation
+ * Copyright (C) 2012-2016 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
+#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/taskqueue.h>
@@ -88,6 +89,19 @@ struct nvd_controller {
static TAILQ_HEAD(, nvd_controller) ctrlr_head;
static TAILQ_HEAD(disk_list, nvd_disk) disk_head;
+static SYSCTL_NODE(_hw, OID_AUTO, nvd, CTLFLAG_RD, 0, "nvd driver parameters");
+/*
+ * The NVMe specification does not define a maximum or optimal delete size, so
+ * technically max delete size is min(full size of the namespace, 2^32 - 1
+ * LBAs). A single delete for a multi-TB NVMe namespace though may take much
+ * longer to complete than the nvme(4) I/O timeout period. So choose a sensible
+ * default here that is still suitably large to minimize the number of overall
+ * delete operations.
+ */
+static uint64_t nvd_delete_max = (1024 * 1024 * 1024); /* 1GB */
+SYSCTL_UQUAD(_hw_nvd, OID_AUTO, delete_max, CTLFLAG_RDTUN, &nvd_delete_max, 0,
+ "nvd maximum BIO_DELETE size in bytes");
+
static int nvd_modevent(module_t mod, int type, void *arg)
{
int error = 0;
@@ -295,6 +309,8 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg)
disk->d_sectorsize = nvme_ns_get_sector_size(ns);
disk->d_mediasize = (off_t)nvme_ns_get_size(ns);
disk->d_delmaxsize = (off_t)nvme_ns_get_size(ns);
+ if (disk->d_delmaxsize > nvd_delete_max)
+ disk->d_delmaxsize = nvd_delete_max;
disk->d_stripesize = nvme_ns_get_optimal_sector_size(ns);
if (TAILQ_EMPTY(&disk_head))
OpenPOWER on IntegriCloud