]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/blobdiff - include/linux/blkdev.h
Merge tag 'pci-v4.20-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaa...
[mirror_ubuntu-disco-kernel.git] / include / linux / blkdev.h
index c32f7171899be46fb82edae93c6ab78ed19c2a26..7d423721b3278358717584a7c9cb01f9949f73d7 100644 (file)
@@ -108,7 +108,7 @@ typedef __u32 __bitwise req_flags_t;
 #define RQF_QUIET              ((__force req_flags_t)(1 << 11))
 /* elevator private data attached */
 #define RQF_ELVPRIV            ((__force req_flags_t)(1 << 12))
-/* account I/O stat */
+/* account into disk and partition IO statistics */
 #define RQF_IO_STAT            ((__force req_flags_t)(1 << 13))
 /* request came from our alloc pool */
 #define RQF_ALLOCED            ((__force req_flags_t)(1 << 14))
@@ -116,7 +116,7 @@ typedef __u32 __bitwise req_flags_t;
 #define RQF_PM                 ((__force req_flags_t)(1 << 15))
 /* on IO scheduler merge hash */
 #define RQF_HASHED             ((__force req_flags_t)(1 << 16))
-/* IO stats tracking on */
+/* track IO completion time */
 #define RQF_STATS              ((__force req_flags_t)(1 << 17))
 /* Look at ->special_vec for the actual data payload instead of the
    bio chain. */
@@ -504,6 +504,12 @@ struct request_queue {
         * various queue flags, see QUEUE_* below
         */
        unsigned long           queue_flags;
+       /*
+        * Number of contexts that have called blk_set_pm_only(). If this
+        * counter is above zero then only RQF_PM and RQF_PREEMPT requests are
+        * processed.
+        */
+       atomic_t                pm_only;
 
        /*
         * ida allocated id for this queue.  Used to index queues from
@@ -679,7 +685,7 @@ struct request_queue {
 #define QUEUE_FLAG_FAIL_IO     7       /* fake timeout */
 #define QUEUE_FLAG_NONROT      9       /* non-rotational device (SSD) */
 #define QUEUE_FLAG_VIRT        QUEUE_FLAG_NONROT /* paravirt device */
-#define QUEUE_FLAG_IO_STAT     10      /* do IO stats */
+#define QUEUE_FLAG_IO_STAT     10      /* do disk/partitions IO accounting */
 #define QUEUE_FLAG_DISCARD     11      /* supports DISCARD */
 #define QUEUE_FLAG_NOXMERGES   12      /* No extended merges */
 #define QUEUE_FLAG_ADD_RANDOM  13      /* Contributes to random pool */
@@ -693,13 +699,12 @@ struct request_queue {
 #define QUEUE_FLAG_FUA        21       /* device supports FUA writes */
 #define QUEUE_FLAG_FLUSH_NQ    22      /* flush not queueuable */
 #define QUEUE_FLAG_DAX         23      /* device supports DAX */
-#define QUEUE_FLAG_STATS       24      /* track rq completion times */
+#define QUEUE_FLAG_STATS       24      /* track IO start and completion times */
 #define QUEUE_FLAG_POLL_STATS  25      /* collecting stats for hybrid polling */
 #define QUEUE_FLAG_REGISTERED  26      /* queue has been registered to a disk */
 #define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */
 #define QUEUE_FLAG_QUIESCED    28      /* queue has been quiesced */
-#define QUEUE_FLAG_PREEMPT_ONLY        29      /* only process REQ_PREEMPT requests */
-#define QUEUE_FLAG_PCI_P2PDMA  30      /* device supports PCI p2p requests */
+#define QUEUE_FLAG_PCI_P2PDMA  29      /* device supports PCI p2p requests */
 
 #define QUEUE_FLAG_DEFAULT     ((1 << QUEUE_FLAG_IO_STAT) |            \
                                 (1 << QUEUE_FLAG_SAME_COMP)    |       \
@@ -739,12 +744,11 @@ bool blk_queue_flag_test_and_clear(unsigned int flag, struct request_queue *q);
        ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
                             REQ_FAILFAST_DRIVER))
 #define blk_queue_quiesced(q)  test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags)
-#define blk_queue_preempt_only(q)                              \
-       test_bit(QUEUE_FLAG_PREEMPT_ONLY, &(q)->queue_flags)
+#define blk_queue_pm_only(q)   atomic_read(&(q)->pm_only)
 #define blk_queue_fua(q)       test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)
 
-extern int blk_set_preempt_only(struct request_queue *q);
-extern void blk_clear_preempt_only(struct request_queue *q);
+extern void blk_set_pm_only(struct request_queue *q);
+extern void blk_clear_pm_only(struct request_queue *q);
 
 static inline int queue_in_flight(struct request_queue *q)
 {
@@ -1283,29 +1287,6 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id,
 extern void blk_put_queue(struct request_queue *);
 extern void blk_set_queue_dying(struct request_queue *);
 
-/*
- * block layer runtime pm functions
- */
-#ifdef CONFIG_PM
-extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev);
-extern int blk_pre_runtime_suspend(struct request_queue *q);
-extern void blk_post_runtime_suspend(struct request_queue *q, int err);
-extern void blk_pre_runtime_resume(struct request_queue *q);
-extern void blk_post_runtime_resume(struct request_queue *q, int err);
-extern void blk_set_runtime_active(struct request_queue *q);
-#else
-static inline void blk_pm_runtime_init(struct request_queue *q,
-       struct device *dev) {}
-static inline int blk_pre_runtime_suspend(struct request_queue *q)
-{
-       return -ENOSYS;
-}
-static inline void blk_post_runtime_suspend(struct request_queue *q, int err) {}
-static inline void blk_pre_runtime_resume(struct request_queue *q) {}
-static inline void blk_post_runtime_resume(struct request_queue *q, int err) {}
-static inline void blk_set_runtime_active(struct request_queue *q) {}
-#endif
-
 /*
  * blk_plug permits building a queue of related requests by holding the I/O
  * fragments for a short period. This allows merging of sequential requests
@@ -1679,94 +1660,6 @@ static inline void put_dev_sector(Sector p)
        put_page(p.v);
 }
 
-static inline bool __bvec_gap_to_prev(struct request_queue *q,
-                               struct bio_vec *bprv, unsigned int offset)
-{
-       return offset ||
-               ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q));
-}
-
-/*
- * Check if adding a bio_vec after bprv with offset would create a gap in
- * the SG list. Most drivers don't care about this, but some do.
- */
-static inline bool bvec_gap_to_prev(struct request_queue *q,
-                               struct bio_vec *bprv, unsigned int offset)
-{
-       if (!queue_virt_boundary(q))
-               return false;
-       return __bvec_gap_to_prev(q, bprv, offset);
-}
-
-/*
- * Check if the two bvecs from two bios can be merged to one segment.
- * If yes, no need to check gap between the two bios since the 1st bio
- * and the 1st bvec in the 2nd bio can be handled in one segment.
- */
-static inline bool bios_segs_mergeable(struct request_queue *q,
-               struct bio *prev, struct bio_vec *prev_last_bv,
-               struct bio_vec *next_first_bv)
-{
-       if (!BIOVEC_PHYS_MERGEABLE(prev_last_bv, next_first_bv))
-               return false;
-       if (!BIOVEC_SEG_BOUNDARY(q, prev_last_bv, next_first_bv))
-               return false;
-       if (prev->bi_seg_back_size + next_first_bv->bv_len >
-                       queue_max_segment_size(q))
-               return false;
-       return true;
-}
-
-static inline bool bio_will_gap(struct request_queue *q,
-                               struct request *prev_rq,
-                               struct bio *prev,
-                               struct bio *next)
-{
-       if (bio_has_data(prev) && queue_virt_boundary(q)) {
-               struct bio_vec pb, nb;
-
-               /*
-                * don't merge if the 1st bio starts with non-zero
-                * offset, otherwise it is quite difficult to respect
-                * sg gap limit. We work hard to merge a huge number of small
-                * single bios in case of mkfs.
-                */
-               if (prev_rq)
-                       bio_get_first_bvec(prev_rq->bio, &pb);
-               else
-                       bio_get_first_bvec(prev, &pb);
-               if (pb.bv_offset)
-                       return true;
-
-               /*
-                * We don't need to worry about the situation that the
-                * merged segment ends in unaligned virt boundary:
-                *
-                * - if 'pb' ends aligned, the merged segment ends aligned
-                * - if 'pb' ends unaligned, the next bio must include
-                *   one single bvec of 'nb', otherwise the 'nb' can't
-                *   merge with 'pb'
-                */
-               bio_get_last_bvec(prev, &pb);
-               bio_get_first_bvec(next, &nb);
-
-               if (!bios_segs_mergeable(q, prev, &pb, &nb))
-                       return __bvec_gap_to_prev(q, &pb, nb.bv_offset);
-       }
-
-       return false;
-}
-
-static inline bool req_gap_back_merge(struct request *req, struct bio *bio)
-{
-       return bio_will_gap(req->q, req, req->biotail, bio);
-}
-
-static inline bool req_gap_front_merge(struct request *req, struct bio *bio)
-{
-       return bio_will_gap(req->q, NULL, bio, req->bio);
-}
-
 int kblockd_schedule_work(struct work_struct *work);
 int kblockd_schedule_work_on(int cpu, struct work_struct *work);
 int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
@@ -1846,26 +1739,6 @@ queue_max_integrity_segments(struct request_queue *q)
        return q->limits.max_integrity_segments;
 }
 
-static inline bool integrity_req_gap_back_merge(struct request *req,
-                                               struct bio *next)
-{
-       struct bio_integrity_payload *bip = bio_integrity(req->bio);
-       struct bio_integrity_payload *bip_next = bio_integrity(next);
-
-       return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1],
-                               bip_next->bip_vec[0].bv_offset);
-}
-
-static inline bool integrity_req_gap_front_merge(struct request *req,
-                                                struct bio *bio)
-{
-       struct bio_integrity_payload *bip = bio_integrity(bio);
-       struct bio_integrity_payload *bip_next = bio_integrity(req->bio);
-
-       return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1],
-                               bip_next->bip_vec[0].bv_offset);
-}
-
 /**
  * bio_integrity_intervals - Return number of integrity intervals for a bio
  * @bi:                blk_integrity profile for device
@@ -1950,17 +1823,6 @@ static inline bool blk_integrity_merge_bio(struct request_queue *rq,
        return true;
 }
 
-static inline bool integrity_req_gap_back_merge(struct request *req,
-                                               struct bio *next)
-{
-       return false;
-}
-static inline bool integrity_req_gap_front_merge(struct request *req,
-                                                struct bio *bio)
-{
-       return false;
-}
-
 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
                                                   unsigned int sectors)
 {