loop: don't try to use AIO for discards
authorChristoph Hellwig <hch@lst.de>
Thu, 4 Aug 2016 14:10:00 +0000 (16:10 +0200)
committerJens Axboe <axboe@fb.com>
Thu, 4 Aug 2016 20:19:16 +0000 (14:19 -0600)
Fix a fat-fingered conversion to the req_op accessors, and also
use a switch statement to make it more obvious what is being checked.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Dave Chinner <david@fromorbit.com>
Fixes: c2df40 ("drivers: use req op accessor");
Reviewed-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/loop.c

index 075377eee0c0bcafed761e4034ab69e17ef9d5b8..91c2c881cb49807cf67516ff31aa60f066cb2cbe 100644 (file)
@@ -1659,11 +1659,15 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
        if (lo->lo_state != Lo_bound)
                return -EIO;
 
-       if (lo->use_dio && (req_op(cmd->rq) != REQ_OP_FLUSH ||
-           req_op(cmd->rq) == REQ_OP_DISCARD))
-               cmd->use_aio = true;
-       else
+       switch (req_op(cmd->rq)) {
+       case REQ_OP_FLUSH:
+       case REQ_OP_DISCARD:
                cmd->use_aio = false;
+               break;
+       default:
+               cmd->use_aio = lo->use_dio;
+               break;
+       }
 
        queue_kthread_work(&lo->worker, &cmd->work);