kernel: bump 4.19 to 4.19.115
[oweals/openwrt.git] / target / linux / generic / hack-4.19 / 550-loop-Report-EOPNOTSUPP-properly.patch
1 From 2e864386e62e702a343be2507062ee08d5dfc810 Mon Sep 17 00:00:00 2001
2 From: Evan Green <evgreen@chromium.org>
3 Date: Thu, 14 Nov 2019 15:50:07 -0800
4 Subject: loop: Report EOPNOTSUPP properly
5
6 Properly plumb out EOPNOTSUPP from loop driver operations, which may
7 get returned when for instance a discard operation is attempted but not
8 supported by the underlying block device. Before this change, everything
9 was reported in the log as an I/O error, which is scary and not
10 helpful in debugging.
11
12 Signed-off-by: Evan Green <evgreen@chromium.org>
13 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
14 Reviewed-by: Bart Van Assche <bvanassche@acm.org>
15 ---
16  drivers/block/loop.c | 7 +++++--
17  1 file changed, 5 insertions(+), 2 deletions(-)
18
19 --- a/drivers/block/loop.c
20 +++ b/drivers/block/loop.c
21 @@ -460,7 +460,7 @@ static void lo_complete_rq(struct reques
22         if (!cmd->use_aio || cmd->ret < 0 || cmd->ret == blk_rq_bytes(rq) ||
23             req_op(rq) != REQ_OP_READ) {
24                 if (cmd->ret < 0)
25 -                       ret = BLK_STS_IOERR;
26 +                       ret = errno_to_blk_status(cmd->ret);
27                 goto end_io;
28         }
29  
30 @@ -1904,7 +1904,10 @@ static void loop_handle_cmd(struct loop_
31   failed:
32         /* complete non-aio request */
33         if (!cmd->use_aio || ret) {
34 -               cmd->ret = ret ? -EIO : 0;
35 +               if (ret == -EOPNOTSUPP)
36 +                       cmd->ret = ret;
37 +               else
38 +                       cmd->ret = ret ? -EIO : 0;
39                 blk_mq_complete_request(rq);
40         }
41  }