Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Apr 2013 17:41:24 +0000 (UTC)
From:      Jim Harris <jimharris@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r249418 - head/sys/dev/nvme
Message-ID:  <201304121741.r3CHfODp092136@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jimharris
Date: Fri Apr 12 17:41:24 2013
New Revision: 249418
URL: http://svnweb.freebsd.org/changeset/base/249418

Log:
  Add a mutex to each namespace, for general locking operations on the namespace.
  
  Sponsored by:	Intel

Modified:
  head/sys/dev/nvme/nvme_ns.c
  head/sys/dev/nvme/nvme_private.h

Modified: head/sys/dev/nvme/nvme_ns.c
==============================================================================
--- head/sys/dev/nvme/nvme_ns.c	Fri Apr 12 17:36:48 2013	(r249417)
+++ head/sys/dev/nvme/nvme_ns.c	Fri Apr 12 17:41:24 2013	(r249418)
@@ -300,6 +300,17 @@ nvme_ns_construct(struct nvme_namespace 
 	ns->ctrlr = ctrlr;
 	ns->id = id;
 
+	/*
+	 * Namespaces are reconstructed after a controller reset, so check
+	 *  to make sure we only call mtx_init once on each mtx.
+	 *
+	 * TODO: Move this somewhere where it gets called at controller
+	 *  construction time, which is not invoked as part of each
+	 *  controller reset.
+	 */
+	if (!mtx_initialized(&ns->lock))
+		mtx_init(&ns->lock, "nvme ns lock", NULL, MTX_DEF);
+
 #ifdef CHATHAM2
 	if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID)
 		nvme_ns_populate_chatham_data(ns);

Modified: head/sys/dev/nvme/nvme_private.h
==============================================================================
--- head/sys/dev/nvme/nvme_private.h	Fri Apr 12 17:36:48 2013	(r249417)
+++ head/sys/dev/nvme/nvme_private.h	Fri Apr 12 17:41:24 2013	(r249418)
@@ -238,6 +238,7 @@ struct nvme_namespace {
 	uint16_t			flags;
 	struct cdev			*cdev;
 	void				*cons_cookie[NVME_MAX_CONSUMERS];
+	struct mtx			lock;
 };
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304121741.r3CHfODp092136>