Re: [RESEND PATCH 1/2] loop: Report EOPNOTSUPP properly

From: Bart Van Assche
Date: Thu Jan 31 2019 - 18:31:24 EST


On Thu, 2019-01-31 at 14:13 -0800, Evan Green wrote:
+AD4 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
+AD4 index cf5538942834..a1ba555e3b92 100644
+AD4 --- a/drivers/block/loop.c
+AD4 +-+-+- b/drivers/block/loop.c
+AD4 +AEAAQA -458,8 +-458,13 +AEAAQA static void lo+AF8-complete+AF8-rq(struct request +ACo-rq)
+AD4
+AD4 if (+ACE-cmd-+AD4-use+AF8-aio +AHwAfA cmd-+AD4-ret +ADw 0 +AHwAfA cmd-+AD4-ret +AD0APQ blk+AF8-rq+AF8-bytes(rq) +AHwAfA
+AD4 req+AF8-op(rq) +ACEAPQ REQ+AF8-OP+AF8-READ) +AHs
+AD4 - if (cmd-+AD4-ret +ADw 0)
+AD4 - ret +AD0 BLK+AF8-STS+AF8-IOERR+ADs
+AD4 +- if (cmd-+AD4-ret +ADw 0) +AHs
+AD4 +- if (cmd-+AD4-ret +AD0APQ -EOPNOTSUPP)
+AD4 +- ret +AD0 BLK+AF8-STS+AF8-NOTSUPP+ADs
+AD4 +- else
+AD4 +- ret +AD0 BLK+AF8-STS+AF8-IOERR+ADs
+AD4 +- +AH0

Please do not nest if-conditions if that is not necessary. I think the
above code can be written more clearly as follows:

if (cmd-+AD4-ret +AD0APQ -ENOTSUPP)
ret +AD0 BLK+AF8-STS+AF8-NOTSUPP+ADs
else if (cmd-+AD4-ret +ADw 0)
ret +AD0 BLK+AF8-STS+AF8-IOERR+ADs

Thanks,

Bart.