mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Matias Bjørling" <m@bjorling.me>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com
Cc: "Matias Bjørling" <m@bjorling.me>
Subject: [PATCH 8/9] lightnvm: prevent gennvm module unload on use
Date: Sun,  6 Dec 2015 11:25:50 +0100	[thread overview]
Message-ID: <1449397551-16525-9-git-send-email-m@bjorling.me> (raw)
In-Reply-To: <1449397551-16525-1-git-send-email-m@bjorling.me>

After the gennvm module has been initialized. It might be attached to
one or several devices. In that case, the module is in use. Make sure
that it can not be unloaded.

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

diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
index 52b513a..f434e89 100644
--- a/drivers/lightnvm/gennvm.c
+++ b/drivers/lightnvm/gennvm.c
@@ -219,6 +219,9 @@ static int gennvm_register(struct nvm_dev *dev)
 	struct gen_nvm *gn;
 	int ret;
 
+	if (!try_module_get(THIS_MODULE))
+		return -ENODEV;
+
 	gn = kzalloc(sizeof(struct gen_nvm), GFP_KERNEL);
 	if (!gn)
 		return -ENOMEM;
@@ -242,12 +245,14 @@ static int gennvm_register(struct nvm_dev *dev)
 	return 1;
 err:
 	gennvm_free(dev);
+	module_put(THIS_MODULE);
 	return ret;
 }
 
 static void gennvm_unregister(struct nvm_dev *dev)
 {
 	gennvm_free(dev);
+	module_put(THIS_MODULE);
 }
 
 static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
-- 
2.1.4


  parent reply	other threads:[~2015-12-06 10:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-06 10:25 [PATCH 0/9] Fixes for LightNVM Matias Bjørling
2015-12-06 10:25 ` [PATCH 1/9] lightnvm: use flags in rrpc_get_blk Matias Bjørling
2015-12-06 10:25 ` [PATCH 2/9] lightnvm: put blks when luns configure failed Matias Bjørling
2015-12-06 10:25 ` [PATCH 3/9] lightnvm: refactor spin_unlock in gennvm_get_blk Matias Bjørling
2015-12-06 10:25 ` [PATCH 4/9] lightnvm: check mm before use Matias Bjørling
2015-12-06 10:25 ` [PATCH 5/9] lightnvm: comments on constants Matias Bjørling
2015-12-06 10:25 ` [PATCH 6/9] lightnvm: replace req queue with nvmdev for lld Matias Bjørling
2015-12-06 10:25 ` [PATCH 7/9] lightnvm: fix media mgr registration Matias Bjørling
2015-12-06 10:25 ` Matias Bjørling [this message]
2015-12-06 10:25 ` [PATCH 9/9] lightnvm: do not compile in debugging by default Matias Bjørling
2015-12-07 16:11 ` [PATCH 0/9] Fixes for LightNVM Jens Axboe
2015-12-07 17:52   ` 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=1449397551-16525-9-git-send-email-m@bjorling.me \
    --to=m@bjorling.me \
    --cc=axboe@fb.com \
    --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

all inboxes | Powered by JetHome®