]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - block/blk-flush.c
nbd: use dev_err_ratelimited in io path
[karo-tx-linux.git] / block / blk-flush.c
index 6a14b68b91358bdd28d90fb5ab23100a77af31dd..1bdbb3d3e5f579b296f2831f14de7c2787e0f5de 100644 (file)
@@ -56,7 +56,7 @@
  * Once while executing DATA and again after the whole sequence is
  * complete.  The first completion updates the contained bio but doesn't
  * finish it so that the bio submitter is notified only after the whole
- * sequence is complete.  This is implemented by testing REQ_FLUSH_SEQ in
+ * sequence is complete.  This is implemented by testing RQF_FLUSH_SEQ in
  * req_bio_endio().
  *
  * The above peculiarity requires that each FLUSH/FUA request has only one
@@ -127,17 +127,14 @@ static void blk_flush_restore_request(struct request *rq)
        rq->bio = rq->biotail;
 
        /* make @rq a normal request */
-       rq->cmd_flags &= ~REQ_FLUSH_SEQ;
+       rq->rq_flags &= ~RQF_FLUSH_SEQ;
        rq->end_io = rq->flush.saved_end_io;
 }
 
 static bool blk_flush_queue_rq(struct request *rq, bool add_front)
 {
        if (rq->q->mq_ops) {
-               struct request_queue *q = rq->q;
-
-               blk_mq_add_to_requeue_list(rq, add_front);
-               blk_mq_kick_requeue_list(q);
+               blk_mq_add_to_requeue_list(rq, add_front, true);
                return false;
        } else {
                if (add_front)
@@ -330,7 +327,8 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq)
        }
 
        flush_rq->cmd_type = REQ_TYPE_FS;
-       req_set_op_attrs(flush_rq, REQ_OP_FLUSH, WRITE_FLUSH | REQ_FLUSH_SEQ);
+       flush_rq->cmd_flags = REQ_OP_FLUSH | REQ_PREFLUSH;
+       flush_rq->rq_flags |= RQF_FLUSH_SEQ;
        flush_rq->rq_disk = first_rq->rq_disk;
        flush_rq->end_io = flush_end_io;
 
@@ -397,6 +395,13 @@ void blk_insert_flush(struct request *rq)
        if (!(fflags & (1UL << QUEUE_FLAG_FUA)))
                rq->cmd_flags &= ~REQ_FUA;
 
+       /*
+        * REQ_PREFLUSH|REQ_FUA implies REQ_SYNC, so if we clear any
+        * of those flags, we have to set REQ_SYNC to avoid skewing
+        * the request accounting.
+        */
+       rq->cmd_flags |= REQ_SYNC;
+
        /*
         * An empty flush handed down from a stacking driver may
         * translate into nothing if the underlying device does not
@@ -433,7 +438,7 @@ void blk_insert_flush(struct request *rq)
         */
        memset(&rq->flush, 0, sizeof(rq->flush));
        INIT_LIST_HEAD(&rq->flush.list);
-       rq->cmd_flags |= REQ_FLUSH_SEQ;
+       rq->rq_flags |= RQF_FLUSH_SEQ;
        rq->flush.saved_end_io = rq->end_io; /* Usually NULL */
        if (q->mq_ops) {
                rq->end_io = mq_flush_data_end_io;
@@ -485,7 +490,7 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
 
        bio = bio_alloc(gfp_mask, 0);
        bio->bi_bdev = bdev;
-       bio_set_op_attrs(bio, REQ_OP_WRITE, WRITE_FLUSH);
+       bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
 
        ret = submit_bio_wait(bio);