linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
To: evgreen@chromium.org
Cc: asavery@chromium.org, axboe@kernel.dk, bvanassche@acm.org,
	darrick.wong@oracle.com, dianders@chromium.org,
	gwendal@chromium.org, hch@infradead.org,
	linux-block@vger.kernel.org, martin.petersen@oracle.com,
	ming.lei@redhat.com, kernel@collabora.com
Subject: [PATCH v8 1/2] loop: Report EOPNOTSUPP properly
Date: Thu,  2 Apr 2020 19:06:02 +0200	[thread overview]
Message-ID: <20200402170603.19649-2-andrzej.p@collabora.com> (raw)
In-Reply-To: <20200402170603.19649-1-andrzej.p@collabora.com>

From: Evan Green <evgreen@chromium.org>

Properly plumb out EOPNOTSUPP from loop driver operations, which may
get returned when for instance a discard operation is attempted but not
supported by the underlying block device. Before this change, everything
was reported in the log as an I/O error, which is scary and not
helpful in debugging.

Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
---
 drivers/block/loop.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 739b372a5112..6969be9a855a 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -461,7 +461,7 @@ static void lo_complete_rq(struct request *rq)
 	if (!cmd->use_aio || cmd->ret < 0 || cmd->ret == blk_rq_bytes(rq) ||
 	    req_op(rq) != REQ_OP_READ) {
 		if (cmd->ret < 0)
-			ret = BLK_STS_IOERR;
+			ret = errno_to_blk_status(cmd->ret);
 		goto end_io;
 	}
 
@@ -1953,7 +1953,10 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
  failed:
 	/* complete non-aio request */
 	if (!cmd->use_aio || ret) {
-		cmd->ret = ret ? -EIO : 0;
+		if (ret == -EOPNOTSUPP)
+			cmd->ret = ret;
+		else
+			cmd->ret = ret ? -EIO : 0;
 		blk_mq_complete_request(rq);
 	}
 }
-- 
2.17.1


  reply	other threads:[~2020-04-02 17:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02 17:06 [PATCH v8 0/2] Better discard support for block devices Andrzej Pietrasiewicz
2020-04-02 17:06 ` Andrzej Pietrasiewicz [this message]
2020-04-03  6:38   ` [PATCH v8 1/2] loop: Report EOPNOTSUPP properly Christoph Hellwig
2020-04-02 17:06 ` [PATCH v8 2/2] loop: Better discard support for block devices Andrzej Pietrasiewicz
2020-04-03  6:39   ` Christoph Hellwig
2020-04-03 10:27     ` Andrzej Pietrasiewicz
2020-04-03 11:15       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200402170603.19649-2-andrzej.p@collabora.com \
    --to=andrzej.p@collabora.com \
    --cc=asavery@chromium.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=darrick.wong@oracle.com \
    --cc=dianders@chromium.org \
    --cc=evgreen@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=hch@infradead.org \
    --cc=kernel@collabora.com \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).