lightnvm: if LUNs are already allocated fix return
authorRakesh Pandit <rakesh@tuxera.com>
Tue, 27 Jun 2017 11:55:33 +0000 (14:55 +0300)
committerJens Axboe <axboe@kernel.dk>
Tue, 27 Jun 2017 14:22:09 +0000 (08:22 -0600)
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")
Reviewed-by: Frans Klaver <fransklaver@gmail.com>
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/core.c

index b8f82f5c6c0d942de77f4f6840f59925251d6781..ddae430b6eae879333a84885256fcd8b14c0c1b6 100644 (file)
@@ -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)
+               return ret;
 
        t = kmalloc(sizeof(struct nvm_target), GFP_KERNEL);
        if (!t) {