Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1438262

[PATCH 11/17] lightnvm: remove nested lock conflict with mm

From Matias Bjørling <m@bjorling.me>
Newsgroups linux.kernel
Subject [PATCH 11/17] lightnvm: remove nested lock conflict with mm
Date 2016-07-07 10:00 +0200
Message-ID <rSco2-3Zm-41@gated-at.bofh.it> (permalink)
References <rSco1-3Zm-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/17] LightNVM pull request for 4.8 Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 03/17] lightnvm: initialize ppa_addr in dev_to_generic_addr() Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 06/17] lightnvm: remove checkpatch warning for unsigned ints Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 12/17] lightnvm: remove unused lists from struct rrpc_block Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 13/17] lightnvm: remove _unlocked variant of [get/put]_blk Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 11/17] lightnvm: remove nested lock conflict with mm Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 15/17] lightnvm: fix lun offset calculation for mark blk Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 04/17] nvme: lightnvm: make MLC num_pairs little endian Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 02/17] lightnvm: add media manager mark_blk helper Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 05/17] lightnvm: Make functions not used by ouside static Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 09/17] lightnvm: rename gennvm and update description Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 17/17] lightnvm: make __nvm_submit_ppa static Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 16/17] lightnvm: make ppa_list const in nvm_set_rqd_list Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 07/17] lightnvm: fix checkpatch terse errors Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 10/17] lightnvm: move target mgmt into media mgr Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 14/17] lightnvm: make rrpc_map_page call nvm_get_blk outside locks Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  [PATCH 01/17] lightnvm: break the loop when rqd is not null Matias Bjørling <m@bjorling.me> - 2016-07-07 10:00 +0200
  Re: [GIT PULL 00/17] LightNVM pull request for 4.8 Jens Axboe <axboe@kernel.dk> - 2016-07-07 17:00 +0200

csiph-web