From owner-svn-src-stable@freebsd.org Thu Feb 1 16:40:38 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E7C4EDCBAD; Thu, 1 Feb 2018 16:40:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EB00A761C0; Thu, 1 Feb 2018 16:40:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E605977EA; Thu, 1 Feb 2018 16:40:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w11Geb1v021956; Thu, 1 Feb 2018 16:40:37 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w11GebCJ021950; Thu, 1 Feb 2018 16:40:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201802011640.w11GebCJ021950@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 1 Feb 2018 16:40:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328681 - in stable/11/sys: conf dev/nvd dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys: conf dev/nvd dev/nvme X-SVN-Commit-Revision: 328681 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 16:40:38 -0000 Author: mav Date: Thu Feb 1 16:40:37 2018 New Revision: 328681 URL: https://svnweb.freebsd.org/changeset/base/328681 Log: MFC r322036 (by imp): Make nvd vs nda choice boot-time rather than build-time Introduce hw.nvme.use_nvd tunable. This tunable allows both nvd and nda to be installed in the kernel, while allowing only one of them to create devices. This is an all-or-nothing setting, and you can't change it after boot-time. However, it will allow easier A/B testing. Modified: stable/11/sys/conf/files stable/11/sys/conf/files.amd64 stable/11/sys/dev/nvd/nvd.c stable/11/sys/dev/nvme/nvme.h stable/11/sys/dev/nvme/nvme_sim.c stable/11/sys/dev/nvme/nvme_sysctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Thu Feb 1 16:35:40 2018 (r328680) +++ stable/11/sys/conf/files Thu Feb 1 16:40:37 2018 (r328681) @@ -86,8 +86,8 @@ cam/cam_xpt.c optional scbus cam/ata/ata_all.c optional scbus cam/ata/ata_xpt.c optional scbus cam/ata/ata_pmp.c optional scbus -cam/nvme/nvme_all.c optional scbus nvme -cam/nvme/nvme_da.c optional scbus nvme da !nvd +cam/nvme/nvme_all.c optional scbus nvme +cam/nvme/nvme_da.c optional scbus nvme da cam/nvme/nvme_xpt.c optional scbus nvme cam/scsi/scsi_xpt.c optional scbus cam/scsi/scsi_all.c optional scbus Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Thu Feb 1 16:35:40 2018 (r328680) +++ stable/11/sys/conf/files.amd64 Thu Feb 1 16:40:37 2018 (r328681) @@ -336,7 +336,7 @@ dev/nvme/nvme_ctrlr_cmd.c optional nvme dev/nvme/nvme_ns.c optional nvme dev/nvme/nvme_ns_cmd.c optional nvme dev/nvme/nvme_qpair.c optional nvme -dev/nvme/nvme_sim.c optional nvme scbus !nvd +dev/nvme/nvme_sim.c optional nvme scbus dev/nvme/nvme_sysctl.c optional nvme dev/nvme/nvme_test.c optional nvme dev/nvme/nvme_util.c optional nvme Modified: stable/11/sys/dev/nvd/nvd.c ============================================================================== --- stable/11/sys/dev/nvd/nvd.c Thu Feb 1 16:35:40 2018 (r328680) +++ stable/11/sys/dev/nvd/nvd.c Thu Feb 1 16:40:37 2018 (r328681) @@ -134,6 +134,8 @@ MODULE_DEPEND(nvd, nvme, 1, 1, 1); static int nvd_load() { + if (!nvme_use_nvd) + return 0; TAILQ_INIT(&ctrlr_head); TAILQ_INIT(&disk_head); @@ -149,6 +151,9 @@ nvd_unload() { struct nvd_controller *ctrlr; struct nvd_disk *disk; + + if (!nvme_use_nvd) + return; while (!TAILQ_EMPTY(&ctrlr_head)) { ctrlr = TAILQ_FIRST(&ctrlr_head); Modified: stable/11/sys/dev/nvme/nvme.h ============================================================================== --- stable/11/sys/dev/nvme/nvme.h Thu Feb 1 16:35:40 2018 (r328680) +++ stable/11/sys/dev/nvme/nvme.h Thu Feb 1 16:40:37 2018 (r328681) @@ -1003,6 +1003,8 @@ void nvme_ns_trim_cmd(struct nvme_command *cmd, uint16 cmd->cdw11 = NVME_DSM_ATTR_DEALLOCATE; } +extern int nvme_use_nvd; + #endif /* _KERNEL */ #endif /* __NVME_H__ */ Modified: stable/11/sys/dev/nvme/nvme_sim.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_sim.c Thu Feb 1 16:35:40 2018 (r328680) +++ stable/11/sys/dev/nvme/nvme_sim.c Thu Feb 1 16:40:37 2018 (r328681) @@ -379,6 +379,8 @@ struct nvme_consumer *consumer_cookie; static void nvme_sim_init(void) { + if (nvme_use_nvd) + return; consumer_cookie = nvme_register_consumer(nvme_sim_new_ns, nvme_sim_new_controller, NULL, nvme_sim_controller_fail); @@ -390,6 +392,8 @@ SYSINIT(nvme_sim_register, SI_SUB_DRIVERS, SI_ORDER_AN static void nvme_sim_uninit(void) { + if (nvme_use_nvd) + return; /* XXX Cleanup */ nvme_unregister_consumer(consumer_cookie); Modified: stable/11/sys/dev/nvme/nvme_sysctl.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_sysctl.c Thu Feb 1 16:35:40 2018 (r328680) +++ stable/11/sys/dev/nvme/nvme_sysctl.c Thu Feb 1 16:40:37 2018 (r328681) @@ -33,6 +33,12 @@ __FBSDID("$FreeBSD$"); #include "nvme_private.h" +int nvme_use_nvd = 1; + +SYSCTL_NODE(_hw, OID_AUTO, nvme, CTLFLAG_RD, 0, "NVMe sysctl tunables"); +SYSCTL_INT(_hw_nvme, OID_AUTO, use_nvd, CTLFLAG_RDTUN, + &nvme_use_nvd, 1, "1 = Create NVD devices, 0 = Create NDA devices"); + /* * CTLTYPE_S64 and sysctl_handle_64 were added in r217616. Define these * explicitly here for older kernels that don't include the r217616