mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Matias Bjørling" <m@bjorling.me>
To: axboe@fb.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Rakesh Pandit" <rakesh@tuxera.com>,
	"Matias Bjørling" <matias@cnexlabs.com>
Subject: [PATCH] ligtnvm: if LUNs are already allocated fix return
Date: Tue, 27 Jun 2017 10:39:50 +0200	[thread overview]
Message-ID: <20170627083950.11312-2-matias@cnexlabs.com> (raw)
In-Reply-To: <20170627083950.11312-1-matias@cnexlabs.com>

From: Rakesh Pandit <rakesh@tuxera.com>

While creating new device with NVM_DEV_CREATE if LUNs are already
allocated ioctl would return -ENOMEM which is wrong.  This patch
propagates -EBUSY from nvm_reserve_luns which is correct response.

Fixes: ade69e243 ("lightnvm: merge gennvm with core")
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
---
 drivers/lightnvm/core.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index b8f82f5..9ff348f 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -235,7 +235,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
 	struct nvm_target *t;
 	struct nvm_tgt_dev *tgt_dev;
 	void *targetdata;
-	int ret;
+	int ret = 0;
 
 	tt = nvm_find_target_type(create->tgttype, 1);
 	if (!tt) {
@@ -252,8 +252,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
 	}
 	mutex_unlock(&dev->mlock);
 
-	if (nvm_reserve_luns(dev, s->lun_begin, s->lun_end))
-		return -ENOMEM;
+	ret = nvm_reserve_luns(dev, s->lun_begin, s->lun_end);
+	if (ret)
+		goto err;
 
 	t = kmalloc(sizeof(struct nvm_target), GFP_KERNEL);
 	if (!t) {
@@ -314,8 +315,8 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
 	mutex_lock(&dev->mlock);
 	list_add_tail(&t->list, &dev->targets);
 	mutex_unlock(&dev->mlock);
-
-	return 0;
+err:
+	return ret;
 err_sysfs:
 	if (tt->exit)
 		tt->exit(targetdata);
-- 
2.9.3

  reply	other threads:[~2017-06-27  8:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27  8:39 [PATCH] Small patch for 4.13 window Matias Bjørling
2017-06-27  8:39 ` Matias Bjørling [this message]
2017-06-27  9:06   ` [PATCH] ligtnvm: if LUNs are already allocated fix return Frans Klaver
2017-06-27  9:58     ` Rakesh Pandit
  -- strict thread matches above, loose matches on Subject: below --
2017-05-13 19:50 Rakesh Pandit
2017-05-15  6:31 ` Javier Gonzalez
2017-05-29  9:05   ` Rakesh Pandit
2017-05-30 13:24     ` 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=20170627083950.11312-2-matias@cnexlabs.com \
    --to=m@bjorling.me \
    --cc=axboe@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matias@cnexlabs.com \
    --cc=rakesh@tuxera.com \
    /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®