[PATCH v2 3/3] md: Fix the return value of mddev_stack_new_rdev

linan666@huaweicloud.com posted 3 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH v2 3/3] md: Fix the return value of mddev_stack_new_rdev
Posted by linan666@huaweicloud.com 2 months, 2 weeks ago
From: Li Nan <linan122@huawei.com>

In mddev_stack_new_rdev(), if the integrity profile check fails, it
returns -ENXIO, which means "No such device or address". This is
inaccurate and can mislead users. Change it to return -EINVAL.

Fixes: c6e56cf6b2e7 ("block: move integrity information into queue_limits")
Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/md.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index ad8d44493c0f..f2dfe0a72c51 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5920,7 +5920,7 @@ int mddev_stack_new_rdev(struct mddev *mddev, struct md_rdev *rdev)
 		pr_err("%s: incompatible integrity profile for %pg\n",
 		       mdname(mddev), rdev->bdev);
 		queue_limits_cancel_update(mddev->gendisk->queue);
-		return -ENXIO;
+		return -EINVAL;
 	}
 
 	return queue_limits_commit_update(mddev->gendisk->queue, &lim);
-- 
2.39.2
Re: [PATCH v2 3/3] md: Fix the return value of mddev_stack_new_rdev
Posted by Martin K. Petersen 2 months, 1 week ago
> In mddev_stack_new_rdev(), if the integrity profile check fails, it
> returns -ENXIO, which means "No such device or address". This is
> inaccurate and can mislead users. Change it to return -EINVAL.

> Fixes: c6e56cf6b2e7 ("block: move integrity information into queue_limits")

Returning -ENXIO predates the above commit by many, many years. Changing
the return value might break applications which rely on the original
behavior.

In case of a stacking failure, an appropriate message is logged and the
function returns an errno. How is that misleading?

-- 
Martin K. Petersen
Re: [PATCH v2 3/3] md: Fix the return value of mddev_stack_new_rdev
Posted by Li Nan 1 month, 1 week ago

在 2025/7/31 13:01, Martin K. Petersen 写道:
> 
>> In mddev_stack_new_rdev(), if the integrity profile check fails, it
>> returns -ENXIO, which means "No such device or address". This is
>> inaccurate and can mislead users. Change it to return -EINVAL.
> 
>> Fixes: c6e56cf6b2e7 ("block: move integrity information into queue_limits")
> 
> Returning -ENXIO predates the above commit by many, many years. Changing
> the return value might break applications which rely on the original
> behavior.
> 
> In case of a stacking failure, an appropriate message is logged and the
> function returns an errno. How is that misleading?
> 

Thanks for your review, I will delete it in v3.

-- 
Thanks,
Nan