Skip to content

Commit 8cd5508

Browse files
Evan Greenaxboe
authored andcommitted
loop: Report EOPNOTSUPP properly
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 <[email protected]> Reviewed-by: Gwendal Grignou <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Andrzej Pietrasiewicz <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 4308a43 commit 8cd5508

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/block/loop.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static void lo_complete_rq(struct request *rq)
463463
if (!cmd->use_aio || cmd->ret < 0 || cmd->ret == blk_rq_bytes(rq) ||
464464
req_op(rq) != REQ_OP_READ) {
465465
if (cmd->ret < 0)
466-
ret = BLK_STS_IOERR;
466+
ret = errno_to_blk_status(cmd->ret);
467467
goto end_io;
468468
}
469469

@@ -1955,7 +1955,10 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
19551955
failed:
19561956
/* complete non-aio request */
19571957
if (!cmd->use_aio || ret) {
1958-
cmd->ret = ret ? -EIO : 0;
1958+
if (ret == -EOPNOTSUPP)
1959+
cmd->ret = ret;
1960+
else
1961+
cmd->ret = ret ? -EIO : 0;
19591962
blk_mq_complete_request(rq);
19601963
}
19611964
}

0 commit comments

Comments
 (0)