]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/block/loop.c
Merge branch 'for-4.8/core' of git://git.kernel.dk/linux-block
[karo-tx-linux.git] / drivers / block / loop.c
index 80cf8add46ff3667d896fca88aaea3fbf338ad27..364d491d4bdd4643d93329c57ea3589bc7840ddc 100644 (file)
@@ -447,7 +447,7 @@ static int lo_req_flush(struct loop_device *lo, struct request *rq)
 
 static inline void handle_partial_read(struct loop_cmd *cmd, long bytes)
 {
-       if (bytes < 0 || (cmd->rq->cmd_flags & REQ_WRITE))
+       if (bytes < 0 || op_is_write(req_op(cmd->rq)))
                return;
 
        if (unlikely(bytes < blk_rq_bytes(cmd->rq))) {
@@ -541,10 +541,10 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
 
        pos = ((loff_t) blk_rq_pos(rq) << 9) + lo->lo_offset;
 
-       if (rq->cmd_flags & REQ_WRITE) {
-               if (rq->cmd_flags & REQ_FLUSH)
+       if (op_is_write(req_op(rq))) {
+               if (req_op(rq) == REQ_OP_FLUSH)
                        ret = lo_req_flush(lo, rq);
-               else if (rq->cmd_flags & REQ_DISCARD)
+               else if (req_op(rq) == REQ_OP_DISCARD)
                        ret = lo_discard(lo, rq, pos);
                else if (lo->transfer)
                        ret = lo_write_transfer(lo, rq, pos);
@@ -943,7 +943,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
        mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
 
        if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
-               blk_queue_flush(lo->lo_queue, REQ_FLUSH);
+               blk_queue_write_cache(lo->lo_queue, true, false);
 
        loop_update_dio(lo);
        set_capacity(lo->lo_disk, size);
@@ -1659,8 +1659,8 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
        if (lo->lo_state != Lo_bound)
                return -EIO;
 
-       if (lo->use_dio && !(cmd->rq->cmd_flags & (REQ_FLUSH |
-                                       REQ_DISCARD)))
+       if (lo->use_dio && (req_op(cmd->rq) != REQ_OP_FLUSH ||
+           req_op(cmd->rq) == REQ_OP_DISCARD))
                cmd->use_aio = true;
        else
                cmd->use_aio = false;
@@ -1672,7 +1672,7 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 static void loop_handle_cmd(struct loop_cmd *cmd)
 {
-       const bool write = cmd->rq->cmd_flags & REQ_WRITE;
+       const bool write = op_is_write(req_op(cmd->rq));
        struct loop_device *lo = cmd->rq->q->queuedata;
        int ret = 0;