* [PATCH] scsi/sg: fix checking return value of blk_get_queue()
@ 2023-07-05 2:40 Yu Kuai
2023-07-05 6:13 ` Marc Hartmayer
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Yu Kuai @ 2023-07-05 2:40 UTC (permalink / raw)
To: mhartmay, bblock, bvanassche, hch, axboe, yukuai3
Cc: linux-scsi, linux-kernel, yukuai1
From: Yu Kuai <yukuai3@huawei.com>
Commit fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
make a mess how blk_get_queue() is called, blk_get_queue() returns true
on success while the caller expects it returns 0 on success.
Fix this problem and also add a corresponding error message on failure.
Fixes: fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Closes: https://lore.kernel.org/all/87lefv622n.fsf@linux.ibm.com/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/scsi/sg.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 89fa046c7158..0d8afffd1683 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1497,9 +1497,10 @@ sg_add_device(struct device *cl_dev)
int error;
unsigned long iflags;
- error = blk_get_queue(scsidp->request_queue);
- if (error)
- return error;
+ if (!blk_get_queue(scsidp->request_queue)) {
+ pr_warn("%s: get scsi_device queue failed\n", __func__);
+ return -ENODEV;
+ }
error = -ENOMEM;
cdev = cdev_alloc();
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi/sg: fix checking return value of blk_get_queue()
2023-07-05 2:40 [PATCH] scsi/sg: fix checking return value of blk_get_queue() Yu Kuai
@ 2023-07-05 6:13 ` Marc Hartmayer
2023-07-06 12:52 ` Christoph Hellwig
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Marc Hartmayer @ 2023-07-05 6:13 UTC (permalink / raw)
To: Yu Kuai, bblock, bvanassche, hch, axboe, yukuai3
Cc: linux-scsi, linux-kernel, yukuai1
On Wed, Jul 05, 2023 at 10:40 AM +0800, Yu Kuai <yukuai1@huaweicloud.com> wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Commit fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> make a mess how blk_get_queue() is called, blk_get_queue() returns true
> on success while the caller expects it returns 0 on success.
>
> Fix this problem and also add a corresponding error message on failure.
>
> Fixes: fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Closes: https://lore.kernel.org/all/87lefv622n.fsf@linux.ibm.com/
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/scsi/sg.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 89fa046c7158..0d8afffd1683 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -1497,9 +1497,10 @@ sg_add_device(struct device *cl_dev)
> int error;
> unsigned long iflags;
>
> - error = blk_get_queue(scsidp->request_queue);
> - if (error)
> - return error;
> + if (!blk_get_queue(scsidp->request_queue)) {
> + pr_warn("%s: get scsi_device queue failed\n", __func__);
> + return -ENODEV;
> + }
>
> error = -ENOMEM;
> cdev = cdev_alloc();
> --
> 2.39.2
Thanks.
Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi/sg: fix checking return value of blk_get_queue()
2023-07-05 2:40 [PATCH] scsi/sg: fix checking return value of blk_get_queue() Yu Kuai
2023-07-05 6:13 ` Marc Hartmayer
@ 2023-07-06 12:52 ` Christoph Hellwig
2023-07-07 7:07 ` Marc Hartmayer
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2023-07-06 12:52 UTC (permalink / raw)
To: Yu Kuai
Cc: mhartmay, bblock, bvanassche, hch, axboe, yukuai3, linux-scsi,
linux-kernel
Ooops, yes:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi/sg: fix checking return value of blk_get_queue()
2023-07-05 2:40 [PATCH] scsi/sg: fix checking return value of blk_get_queue() Yu Kuai
2023-07-05 6:13 ` Marc Hartmayer
2023-07-06 12:52 ` Christoph Hellwig
@ 2023-07-07 7:07 ` Marc Hartmayer
2023-07-13 12:21 ` Shinichiro Kawasaki
2023-07-19 1:09 ` Yu Kuai
4 siblings, 0 replies; 8+ messages in thread
From: Marc Hartmayer @ 2023-07-07 7:07 UTC (permalink / raw)
To: Yu Kuai, bblock, bvanassche, hch, axboe, yukuai3
Cc: linux-scsi, linux-kernel, yukuai1
On Wed, Jul 05, 2023 at 10:40 AM +0800, Yu Kuai <yukuai1@huaweicloud.com> wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Commit fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> make a mess how blk_get_queue() is called, blk_get_queue() returns true
> on success while the caller expects it returns 0 on success.
>
> Fix this problem and also add a corresponding error message on failure.
>
> Fixes: fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Closes: https://lore.kernel.org/all/87lefv622n.fsf@linux.ibm.com/
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/scsi/sg.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 89fa046c7158..0d8afffd1683 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -1497,9 +1497,10 @@ sg_add_device(struct device *cl_dev)
> int error;
> unsigned long iflags;
>
> - error = blk_get_queue(scsidp->request_queue);
> - if (error)
> - return error;
> + if (!blk_get_queue(scsidp->request_queue)) {
> + pr_warn("%s: get scsi_device queue failed\n", __func__);
> + return -ENODEV;
> + }
>
> error = -ENOMEM;
> cdev = cdev_alloc();
> --
> 2.39.2
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi/sg: fix checking return value of blk_get_queue()
2023-07-05 2:40 [PATCH] scsi/sg: fix checking return value of blk_get_queue() Yu Kuai
` (2 preceding siblings ...)
2023-07-07 7:07 ` Marc Hartmayer
@ 2023-07-13 12:21 ` Shinichiro Kawasaki
2023-07-19 1:09 ` Yu Kuai
4 siblings, 0 replies; 8+ messages in thread
From: Shinichiro Kawasaki @ 2023-07-13 12:21 UTC (permalink / raw)
To: Yu Kuai
Cc: mhartmay@linux.ibm.com, bblock@linux.ibm.com, bvanassche@acm.org,
hch@lst.de, axboe@kernel.dk, yukuai3@huawei.com,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
On Jul 05, 2023 / 10:40, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Commit fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> make a mess how blk_get_queue() is called, blk_get_queue() returns true
> on success while the caller expects it returns 0 on success.
>
> Fix this problem and also add a corresponding error message on failure.
>
> Fixes: fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Closes: https://lore.kernel.org/all/87lefv622n.fsf@linux.ibm.com/
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
I observed that /dev/sg* files are not created with kernel v6.5-rc1, and it
causes blktests scsi/002 failure. I confirmed this patch fixes it. Thanks.
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi/sg: fix checking return value of blk_get_queue()
2023-07-05 2:40 [PATCH] scsi/sg: fix checking return value of blk_get_queue() Yu Kuai
` (3 preceding siblings ...)
2023-07-13 12:21 ` Shinichiro Kawasaki
@ 2023-07-19 1:09 ` Yu Kuai
2023-07-19 16:34 ` Jens Axboe
4 siblings, 1 reply; 8+ messages in thread
From: Yu Kuai @ 2023-07-19 1:09 UTC (permalink / raw)
To: Yu Kuai, mhartmay, bblock, bvanassche, hch, axboe
Cc: linux-scsi, linux-kernel, yukuai (C)
Hi, Jens
在 2023/07/05 10:40, Yu Kuai 写道:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Commit fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> make a mess how blk_get_queue() is called, blk_get_queue() returns true
> on success while the caller expects it returns 0 on success.
>
> Fix this problem and also add a corresponding error message on failure.
>
> Fixes: fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Closes: https://lore.kernel.org/all/87lefv622n.fsf@linux.ibm.com/
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Sorry about the trouble... Can you apply this patch? I notice that the
original patch is applied to stable.
Thanks,
Kuai
> ---
> drivers/scsi/sg.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 89fa046c7158..0d8afffd1683 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -1497,9 +1497,10 @@ sg_add_device(struct device *cl_dev)
> int error;
> unsigned long iflags;
>
> - error = blk_get_queue(scsidp->request_queue);
> - if (error)
> - return error;
> + if (!blk_get_queue(scsidp->request_queue)) {
> + pr_warn("%s: get scsi_device queue failed\n", __func__);
> + return -ENODEV;
> + }
>
> error = -ENOMEM;
> cdev = cdev_alloc();
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi/sg: fix checking return value of blk_get_queue()
2023-07-19 1:09 ` Yu Kuai
@ 2023-07-19 16:34 ` Jens Axboe
2023-07-20 3:13 ` Martin K. Petersen
0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2023-07-19 16:34 UTC (permalink / raw)
To: Yu Kuai, mhartmay, bblock, bvanassche, hch
Cc: linux-scsi, linux-kernel, yukuai (C), Martin K. Petersen
On 7/18/23 7:09?PM, Yu Kuai wrote:
> Hi, Jens
>
> ? 2023/07/05 10:40, Yu Kuai ??:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> Commit fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
>> make a mess how blk_get_queue() is called, blk_get_queue() returns true
>> on success while the caller expects it returns 0 on success.
>>
>> Fix this problem and also add a corresponding error message on failure.
>>
>> Fixes: fcaa174a9c99 ("scsi/sg: don't grab scsi host module reference")
>> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
>> Closes: https://lore.kernel.org/all/87lefv622n.fsf@linux.ibm.com/
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>
> Sorry about the trouble... Can you apply this patch? I notice that the
> original patch is applied to stable.
I can, I had assumed that Martin would pick it up on the SCSI side?
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi/sg: fix checking return value of blk_get_queue()
2023-07-19 16:34 ` Jens Axboe
@ 2023-07-20 3:13 ` Martin K. Petersen
0 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2023-07-20 3:13 UTC (permalink / raw)
To: Jens Axboe
Cc: Yu Kuai, mhartmay, bblock, bvanassche, hch, linux-scsi,
linux-kernel, yukuai (C), Martin K. Petersen
Jens,
>> Sorry about the trouble... Can you apply this patch? I notice that the
>> original patch is applied to stable.
>
> I can, I had assumed that Martin would pick it up on the SCSI side?
Ah, but since the offending commit went through block I didn't have it
in SCSI until I set up the new trees. Now applied to 6.5/scsi-fixes.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-07-20 3:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05 2:40 [PATCH] scsi/sg: fix checking return value of blk_get_queue() Yu Kuai
2023-07-05 6:13 ` Marc Hartmayer
2023-07-06 12:52 ` Christoph Hellwig
2023-07-07 7:07 ` Marc Hartmayer
2023-07-13 12:21 ` Shinichiro Kawasaki
2023-07-19 1:09 ` Yu Kuai
2023-07-19 16:34 ` Jens Axboe
2023-07-20 3:13 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).