]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
s390/dasd: Return BLK_STS_INVAL for EINVAL from do_dasd_request
authorJaehoon Kim <jhkim@linux.ibm.com>
Thu, 25 Sep 2025 15:47:07 +0000 (17:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Oct 2025 14:33:57 +0000 (16:33 +0200)
commit 8f4ed0ce4857ceb444174503fc9058720d4faaa1 upstream.

Currently, if CCW request creation fails with -EINVAL, the DASD driver
returns BLK_STS_IOERR to the block layer.

This can happen, for example, when a user-space application such as QEMU
passes a misaligned buffer, but the original cause of the error is
masked as a generic I/O error.

This patch changes the behavior so that -EINVAL is returned as
BLK_STS_INVAL, allowing user space to properly detect alignment issues
instead of interpreting them as I/O errors.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Cc: stable@vger.kernel.org #6.11+
Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/s390/block/dasd.c

index b80595414e6351c9fdb4bb1f6d06c3752bc52d0c..93f346d313e98225925881f48d198fd8803526a5 100644 (file)
@@ -3117,12 +3117,14 @@ static blk_status_t do_dasd_request(struct blk_mq_hw_ctx *hctx,
                    PTR_ERR(cqr) == -ENOMEM ||
                    PTR_ERR(cqr) == -EAGAIN) {
                        rc = BLK_STS_RESOURCE;
-                       goto out;
+               } else if (PTR_ERR(cqr) == -EINVAL) {
+                       rc = BLK_STS_INVAL;
+               } else {
+                       DBF_DEV_EVENT(DBF_ERR, basedev,
+                                     "CCW creation failed (rc=%ld) on request %p",
+                                     PTR_ERR(cqr), req);
+                       rc = BLK_STS_IOERR;
                }
-               DBF_DEV_EVENT(DBF_ERR, basedev,
-                             "CCW creation failed (rc=%ld) on request %p",
-                             PTR_ERR(cqr), req);
-               rc = BLK_STS_IOERR;
                goto out;
        }
        /*