[PATCH] ligtnvm: if LUNs are already allocated fix return

2017-05-13 Thread Rakesh Pandit
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 
---
 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



Re: Playing with BFQ

2017-05-13 Thread Sedat Dilek
On Sat, May 13, 2017 at 9:54 AM, Sedat Dilek  wrote:
> On Wed, May 3, 2017 at 11:24 AM, Paolo Valente  
> wrote:
>>
>>> Il giorno 03 mag 2017, alle ore 11:16, Markus Trippelsdorf 
>>>  ha scritto:
>>>
>>> On 2017.05.03 at 10:00 +0200, Sedat Dilek wrote:
 On Tue, May 2, 2017 at 2:16 PM, Markus Trippelsdorf
  wrote:
> On 2017.05.02 at 14:07 +0200, Sedat Dilek wrote:
>> On Tue, May 2, 2017 at 10:00 AM, Markus Trippelsdorf
>>  wrote:
>>> On 2017.05.02 at 09:54 +0200, Sedat Dilek wrote:
 Hi,

 I want to play with BFQ.

 My base is block-next as of 28-Apr-2017.
>> [...]
 Not sure if the attached patches make sense (right now).
>>>
>>> No, it doesn't make sense at all.
>>
>> Hmm, I looked at 4.11.0-v8r11 and 0001 has exactly what my 2 patches do 
>> :-).
>
> BFQ started as a conventional scheduler. But because mq is the way of
> the future it was ported before it was accepted into mainline.
>

 I am still playing and want to do my own experiences with BFQ.

 Not sure if FIO is a good testcase-tool here.

 So if MQ is the way why isn't the Kconfig called CONFIG_MQ_IOSCHED_BFQ
 according to CONFIG_MQ_IOSCHED_DEADLINE?
>>>
>>> Good point. The current naming is confusing.
>>>
>>> Also:
>>> # cat /sys/block/sda/queue/scheduler
>>> mq-deadline [kyber] bfq none
>>>
>>> These should all be prefixed with mq-.
>>>
>>
>> The logic here, as proposed by Jens, is not to add the mq tag when
>> there is no risk of ambiguity (such as between deadline and
>> mq-deadline). I'm open to any sensible choice.
>>
>
> The naming is confusing but I can understand the point of Jens.
>
> The Kconfigs of BFQ in block/Kconfig.iosched need a move (see my two
> patches attached in the initial posting).
> AFAICS you have the same in your latest BFQ-patchset for Linux v4.11.y.
>
> I am re-attaching my two patches.
>
> - Sedat -

Updated 0002 patch v2.

- Sedat -
From da3379424fc0237d5de25e946ed5482a625aaac2 Mon Sep 17 00:00:00 2001
From: Sedat Dilek 
Date: Tue, 2 May 2017 09:33:27 +0200
Subject: [PATCH] block: bfq: Introduce CONFIG_DEFAULT_BFQ

---
[ v2: s/DEFAULT_BFQ/CONFIG_DEFAULT_BFQ in subject line. -dileks ]

 block/Kconfig.iosched | 4 
 1 file changed, 4 insertions(+)

diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched
index 8ea2c8d77100..f37455dcf381 100644
--- a/block/Kconfig.iosched
+++ b/block/Kconfig.iosched
@@ -73,6 +73,9 @@ choice
 	config DEFAULT_CFQ
 		bool "CFQ" if IOSCHED_CFQ=y
 
+	config DEFAULT_BFQ
+		bool "BFQ" if IOSCHED_BFQ=y
+
 	config DEFAULT_NOOP
 		bool "No-op"
 
@@ -82,6 +85,7 @@ config DEFAULT_IOSCHED
 	string
 	default "deadline" if DEFAULT_DEADLINE
 	default "cfq" if DEFAULT_CFQ
+	default "bfq" if DEFAULT_BFQ
 	default "noop" if DEFAULT_NOOP
 
 config MQ_IOSCHED_DEADLINE
-- 
2.11.0



Re: Playing with BFQ

2017-05-13 Thread Sedat Dilek
On Wed, May 3, 2017 at 11:24 AM, Paolo Valente  wrote:
>
>> Il giorno 03 mag 2017, alle ore 11:16, Markus Trippelsdorf 
>>  ha scritto:
>>
>> On 2017.05.03 at 10:00 +0200, Sedat Dilek wrote:
>>> On Tue, May 2, 2017 at 2:16 PM, Markus Trippelsdorf
>>>  wrote:
 On 2017.05.02 at 14:07 +0200, Sedat Dilek wrote:
> On Tue, May 2, 2017 at 10:00 AM, Markus Trippelsdorf
>  wrote:
>> On 2017.05.02 at 09:54 +0200, Sedat Dilek wrote:
>>> Hi,
>>>
>>> I want to play with BFQ.
>>>
>>> My base is block-next as of 28-Apr-2017.
> [...]
>>> Not sure if the attached patches make sense (right now).
>>
>> No, it doesn't make sense at all.
>
> Hmm, I looked at 4.11.0-v8r11 and 0001 has exactly what my 2 patches do 
> :-).

 BFQ started as a conventional scheduler. But because mq is the way of
 the future it was ported before it was accepted into mainline.

>>>
>>> I am still playing and want to do my own experiences with BFQ.
>>>
>>> Not sure if FIO is a good testcase-tool here.
>>>
>>> So if MQ is the way why isn't the Kconfig called CONFIG_MQ_IOSCHED_BFQ
>>> according to CONFIG_MQ_IOSCHED_DEADLINE?
>>
>> Good point. The current naming is confusing.
>>
>> Also:
>> # cat /sys/block/sda/queue/scheduler
>> mq-deadline [kyber] bfq none
>>
>> These should all be prefixed with mq-.
>>
>
> The logic here, as proposed by Jens, is not to add the mq tag when
> there is no risk of ambiguity (such as between deadline and
> mq-deadline). I'm open to any sensible choice.
>

The naming is confusing but I can understand the point of Jens.

The Kconfigs of BFQ in block/Kconfig.iosched need a move (see my two
patches attached in the initial posting).
AFAICS you have the same in your latest BFQ-patchset for Linux v4.11.y.

I am re-attaching my two patches.

- Sedat -
From 7d922302a3af8934da46e8fc04d256025d8ddb27 Mon Sep 17 00:00:00 2001
From: Sedat Dilek 
Date: Tue, 2 May 2017 09:31:37 +0200
Subject: [PATCH] block: bfq: Move CONFIG_IOSCHED_BFQ and
 CONFIG_BFQ_GROUP_IOSCHED

---
 block/Kconfig.iosched | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched
index fd2cefa47d35..8ea2c8d77100 100644
--- a/block/Kconfig.iosched
+++ b/block/Kconfig.iosched
@@ -39,6 +39,26 @@ config CFQ_GROUP_IOSCHED
 	---help---
 	  Enable group IO scheduling in CFQ.
 
+config IOSCHED_BFQ
+tristate "BFQ I/O scheduler"
+default n
+---help---
+BFQ I/O scheduler for BLK-MQ. BFQ distributes the bandwidth of
+of the device among all processes according to their weights,
+regardless of the device parameters and with any workload. It
+also guarantees a low latency to interactive and soft
+real-time applications.  Details in
+Documentation/block/bfq-iosched.txt
+
+config BFQ_GROUP_IOSCHED
+   bool "BFQ hierarchical scheduling support"
+   depends on IOSCHED_BFQ && BLK_CGROUP
+   default n
+   ---help---
+
+   Enable hierarchical scheduling in BFQ, using the blkio
+   (cgroups-v1) or io (cgroups-v2) controller.
+
 choice
 
 	prompt "Default I/O scheduler"
@@ -79,26 +99,6 @@ config MQ_IOSCHED_KYBER
 	  synchronous writes, it will self-tune queue depths to achieve that
 	  goal.
 
-config IOSCHED_BFQ
-	tristate "BFQ I/O scheduler"
-	default n
-	---help---
-	BFQ I/O scheduler for BLK-MQ. BFQ distributes the bandwidth of
-	of the device among all processes according to their weights,
-	regardless of the device parameters and with any workload. It
-	also guarantees a low latency to interactive and soft
-	real-time applications.  Details in
-	Documentation/block/bfq-iosched.txt
-
-config BFQ_GROUP_IOSCHED
-   bool "BFQ hierarchical scheduling support"
-   depends on IOSCHED_BFQ && BLK_CGROUP
-   default n
-   ---help---
-
-   Enable hierarchical scheduling in BFQ, using the blkio
-   (cgroups-v1) or io (cgroups-v2) controller.
-
 endmenu
 
 endif
-- 
2.11.0

From da3379424fc0237d5de25e946ed5482a625aaac2 Mon Sep 17 00:00:00 2001
From: Sedat Dilek 
Date: Tue, 2 May 2017 09:33:27 +0200
Subject: [PATCH] block: bfq: Introduce DEFAULT_BFQ

---
 block/Kconfig.iosched | 4 
 1 file changed, 4 insertions(+)

diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched
index 8ea2c8d77100..f37455dcf381 100644
--- a/block/Kconfig.iosched
+++ b/block/Kconfig.iosched
@@ -73,6 +73,9 @@ choice
 	config DEFAULT_CFQ
 		bool "CFQ" if IOSCHED_CFQ=y
 
+	config DEFAULT_BFQ
+		bool "BFQ" if IOSCHED_BFQ=y
+
 	config DEFAULT_NOOP
 		bool "No-op"
 
@@ -82,6 +85,7 @@ config DEFAULT_IOSCHED
 	string
 	default "deadline" if DEFAULT_DEADLINE
 	default "cfq" if DEFAULT_CFQ
+	default "bfq" if DEFAULT_BFQ
 	default "noop" if DEFAULT_NOOP
 
 config MQ_IOSCHED_DEADLINE
-- 
2.11.0