diff mbox

ligtnvm: if LUNs are already allocated fix return

Message ID 20170513195038.GA8782@hercules.tuxera.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rakesh Pandit May 13, 2017, 7:50 p.m. UTC
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>
---
 drivers/lightnvm/core.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Javier Gonzalez May 15, 2017, 6:31 a.m. UTC | #1
> 
> On 13 May 2017, at 21.50, Rakesh Pandit <rakesh@tuxera.com> wrote:
> 
> 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>
> ---
> 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 6a4aa60..440deb5 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

Looks good.

Reviewed-by: Javier González <javier@cnexlabs.com>
Rakesh Pandit May 29, 2017, 9:05 a.m. UTC | #2
Hi Matias,

On Mon, May 15, 2017 at 06:31:58AM +0000, Javier Gonzalez wrote:
> > 
> > On 13 May 2017, at 21.50, Rakesh Pandit <rakesh@tuxera.com> wrote:
> > 
> > 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>
> > ---
> > 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 6a4aa60..440deb5 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
> 
> Looks good.
> 
> Reviewed-by: Javier González <javier@cnexlabs.com>
> 

May you review/approve this so that it gets queued ?
Matias Bjorling May 30, 2017, 1:24 p.m. UTC | #3
On Mon, May 29, 2017 at 11:05 AM, Rakesh Pandit <rakesh@tuxera.com> wrote:
> Hi Matias,
>
> On Mon, May 15, 2017 at 06:31:58AM +0000, Javier Gonzalez wrote:
>> >
>> > On 13 May 2017, at 21.50, Rakesh Pandit <rakesh@tuxera.com> wrote:
>> >
>> > 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>
>> > ---
>> > 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 6a4aa60..440deb5 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
>>
>> Looks good.
>>
>> Reviewed-by: Javier González <javier@cnexlabs.com>
>>
>
> May you review/approve this so that it gets queued ?

Thanks, Rakesh. Will do. Queued it up for 4.13.

-Matias
diff mbox

Patch

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 6a4aa60..440deb5 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);