* [PATCH] null_blk: fix return value from null_add_dev()
@ 2022-02-15 11:59 Chaitanya Kulkarni
2022-02-15 14:51 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Chaitanya Kulkarni @ 2022-02-15 11:59 UTC (permalink / raw)
To: linux-block
Cc: axboe, ming.lei, shinichiro.kawasaki, damien.lemoal, colin.king,
mgurtovoy, jiangguoqing, Chaitanya Kulkarni
The function nullb_device_power_store() returns -ENOMEM when
null_add_dev() fails. null_add_dev() can fail with return value
other than -ENOMEM such as -EINVAL when Zoned Block Device option
is used, see :
nullb_device_power_store()
null_add_dev()
null_init_zoned_dev()
return -EINVAL;
When trying to load the module having -ENOMEM value returned on the
command line creates confusion when pleanty of memory is free on the
machine.
Instead of hardcoding -ENOMEM return the value of null_add_dev()
function.
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
* without this patch nr_zones set to 23 :-
loading devices
++ seq 0 1
+ for i in `seq 0 $NN`
+ NULLB_DIR=config/nullb/nullb0
+ mkdir config/nullb/nullb0
+ echo 1
+ echo 23
+ echo 0
+ echo 1
+ echo 512
+ echo 2048
+ echo 1
./nullbtests.sh: line 23: echo: write error: Cannot allocate memory
* with this patch nr_zones set to 23 :-
+ for i in `seq 0 $NN`
+ NULLB_DIR=config/nullb/nullb1
+ mkdir config/nullb/nullb1
+ echo 1
+ echo 23
+ echo 1
+ echo 512
+ echo 2048
+ echo 1
./nullbtests.sh: line 23: echo: write error: Invalid argument
---
drivers/block/null_blk/main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 323af5c9c802..1666bd9c4ad7 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -431,9 +431,10 @@ static ssize_t nullb_device_power_store(struct config_item *item,
if (!dev->power && newp) {
if (test_and_set_bit(NULLB_DEV_FL_UP, &dev->flags))
return count;
- if (null_add_dev(dev)) {
+ ret = null_add_dev(dev);
+ if (ret) {
clear_bit(NULLB_DEV_FL_UP, &dev->flags);
- return -ENOMEM;
+ return ret;
}
set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
--
2.29.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] null_blk: fix return value from null_add_dev()
2022-02-15 11:59 [PATCH] null_blk: fix return value from null_add_dev() Chaitanya Kulkarni
@ 2022-02-15 14:51 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-02-15 14:51 UTC (permalink / raw)
To: Chaitanya Kulkarni, linux-block
Cc: damien.lemoal, jiangguoqing, shinichiro.kawasaki, ming.lei,
mgurtovoy, colin.king
On Tue, 15 Feb 2022 03:59:51 -0800, Chaitanya Kulkarni wrote:
> The function nullb_device_power_store() returns -ENOMEM when
> null_add_dev() fails. null_add_dev() can fail with return value
> other than -ENOMEM such as -EINVAL when Zoned Block Device option
> is used, see :
>
> nullb_device_power_store()
> null_add_dev()
> null_init_zoned_dev()
> return -EINVAL;
>
> [...]
Applied, thanks!
[1/1] null_blk: fix return value from null_add_dev()
(no commit info)
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-15 14:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 11:59 [PATCH] null_blk: fix return value from null_add_dev() Chaitanya Kulkarni
2022-02-15 14:51 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.