linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matias Bjørling" <m@bjorling.me>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Matias Bjørling" <m@bjorling.me>
Subject: [RFC PATCH 06/11] lightnvm: remove nested lock conflict with mm
Date: Wed, 29 Jun 2016 16:41:51 +0200	[thread overview]
Message-ID: <1467211316-22373-7-git-send-email-m@bjorling.me> (raw)
In-Reply-To: <1467211316-22373-1-git-send-email-m@bjorling.me>

If a media manager tries to initialize it targets upon media manager
initialization, the media manager will need to know which target types
are available in LightNVM. The lists of which managers and target types
are available shares the same lock.

Therefore, on initialization, the nvm_lock is taken by LightNVM core,
which later leads to a deadlock when target types are enumerated by the
media manager.

Add an exclusive lock for target types to resolve this conflict.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/core.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 8afb04c..04469e0 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -28,6 +28,7 @@
 #include <linux/sched/sysctl.h>
 
 static LIST_HEAD(nvm_tgt_types);
+static DECLARE_RWSEM(nvm_tgtt_lock);
 static LIST_HEAD(nvm_mgrs);
 static LIST_HEAD(nvm_devices);
 static DECLARE_RWSEM(nvm_lock);
@@ -37,7 +38,7 @@ struct nvm_tgt_type *nvm_find_target_type(const char *name, int lock)
 	struct nvm_tgt_type *tmp, *tt = NULL;
 
 	if (lock)
-		down_write(&nvm_lock);
+		down_write(&nvm_tgtt_lock);
 
 	list_for_each_entry(tmp, &nvm_tgt_types, list)
 		if (!strcmp(name, tmp->name)) {
@@ -46,7 +47,7 @@ struct nvm_tgt_type *nvm_find_target_type(const char *name, int lock)
 		}
 
 	if (lock)
-		up_write(&nvm_lock);
+		up_write(&nvm_tgtt_lock);
 	return tt;
 }
 EXPORT_SYMBOL(nvm_find_target_type);
@@ -55,12 +56,12 @@ int nvm_register_tgt_type(struct nvm_tgt_type *tt)
 {
 	int ret = 0;
 
-	down_write(&nvm_lock);
+	down_write(&nvm_tgtt_lock);
 	if (nvm_find_target_type(tt->name, 0))
 		ret = -EEXIST;
 	else
 		list_add(&tt->list, &nvm_tgt_types);
-	up_write(&nvm_lock);
+	up_write(&nvm_tgtt_lock);
 
 	return ret;
 }
-- 
2.1.4

  parent reply	other threads:[~2016-06-29 14:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 14:41 [RFC PATCH 00/11] Small fixes for LightNVM Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 01/11] lightnvm: remove checkpatch warning for unsigned ints Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 02/11] lightnvm: fix checkpatch terse errors Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 03/11] lightnvm: remove open/close statistics for gennvm Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 04/11] lightnvm: rename gennvm and update description Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 05/11] lightnvm: move target mgmt into media mgr Matias Bjørling
2016-06-29 14:41 ` Matias Bjørling [this message]
2016-06-29 14:41 ` [RFC PATCH 07/11] lightnvm: remove unused lists from struct rrpc_block Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 08/11] lightnvm: remove _unlocked variant of [get/put]_blk Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 09/11] lightnvm: fix lun offset calculation for mark blk Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 10/11] lightnvm: make ppa_list const in nvm_set_rqd_list Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 11/11] lightnvm: make __nvm_submit_ppa static Matias Bjørling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467211316-22373-7-git-send-email-m@bjorling.me \
    --to=m@bjorling.me \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).