diff options
Diffstat (limited to 'include/linux/blkdev.h')
| -rw-r--r-- | include/linux/blkdev.h | 164 |
1 files changed, 13 insertions, 151 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 6980014357d4..61207560e826 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -108,7 +108,7 @@ typedef __u32 __bitwise req_flags_t; | |||
| 108 | #define RQF_QUIET ((__force req_flags_t)(1 << 11)) | 108 | #define RQF_QUIET ((__force req_flags_t)(1 << 11)) |
| 109 | /* elevator private data attached */ | 109 | /* elevator private data attached */ |
| 110 | #define RQF_ELVPRIV ((__force req_flags_t)(1 << 12)) | 110 | #define RQF_ELVPRIV ((__force req_flags_t)(1 << 12)) |
| 111 | /* account I/O stat */ | 111 | /* account into disk and partition IO statistics */ |
| 112 | #define RQF_IO_STAT ((__force req_flags_t)(1 << 13)) | 112 | #define RQF_IO_STAT ((__force req_flags_t)(1 << 13)) |
| 113 | /* request came from our alloc pool */ | 113 | /* request came from our alloc pool */ |
| 114 | #define RQF_ALLOCED ((__force req_flags_t)(1 << 14)) | 114 | #define RQF_ALLOCED ((__force req_flags_t)(1 << 14)) |
| @@ -116,7 +116,7 @@ typedef __u32 __bitwise req_flags_t; | |||
| 116 | #define RQF_PM ((__force req_flags_t)(1 << 15)) | 116 | #define RQF_PM ((__force req_flags_t)(1 << 15)) |
| 117 | /* on IO scheduler merge hash */ | 117 | /* on IO scheduler merge hash */ |
| 118 | #define RQF_HASHED ((__force req_flags_t)(1 << 16)) | 118 | #define RQF_HASHED ((__force req_flags_t)(1 << 16)) |
| 119 | /* IO stats tracking on */ | 119 | /* track IO completion time */ |
| 120 | #define RQF_STATS ((__force req_flags_t)(1 << 17)) | 120 | #define RQF_STATS ((__force req_flags_t)(1 << 17)) |
| 121 | /* Look at ->special_vec for the actual data payload instead of the | 121 | /* Look at ->special_vec for the actual data payload instead of the |
| 122 | bio chain. */ | 122 | bio chain. */ |
| @@ -504,6 +504,12 @@ struct request_queue { | |||
| 504 | * various queue flags, see QUEUE_* below | 504 | * various queue flags, see QUEUE_* below |
| 505 | */ | 505 | */ |
| 506 | unsigned long queue_flags; | 506 | unsigned long queue_flags; |
| 507 | /* | ||
| 508 | * Number of contexts that have called blk_set_pm_only(). If this | ||
| 509 | * counter is above zero then only RQF_PM and RQF_PREEMPT requests are | ||
| 510 | * processed. | ||
| 511 | */ | ||
| 512 | atomic_t pm_only; | ||
| 507 | 513 | ||
| 508 | /* | 514 | /* |
| 509 | * ida allocated id for this queue. Used to index queues from | 515 | * ida allocated id for this queue. Used to index queues from |
| @@ -679,7 +685,7 @@ struct request_queue { | |||
| 679 | #define QUEUE_FLAG_FAIL_IO 7 /* fake timeout */ | 685 | #define QUEUE_FLAG_FAIL_IO 7 /* fake timeout */ |
| 680 | #define QUEUE_FLAG_NONROT 9 /* non-rotational device (SSD) */ | 686 | #define QUEUE_FLAG_NONROT 9 /* non-rotational device (SSD) */ |
| 681 | #define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */ | 687 | #define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */ |
| 682 | #define QUEUE_FLAG_IO_STAT 10 /* do IO stats */ | 688 | #define QUEUE_FLAG_IO_STAT 10 /* do disk/partitions IO accounting */ |
| 683 | #define QUEUE_FLAG_DISCARD 11 /* supports DISCARD */ | 689 | #define QUEUE_FLAG_DISCARD 11 /* supports DISCARD */ |
| 684 | #define QUEUE_FLAG_NOXMERGES 12 /* No extended merges */ | 690 | #define QUEUE_FLAG_NOXMERGES 12 /* No extended merges */ |
| 685 | #define QUEUE_FLAG_ADD_RANDOM 13 /* Contributes to random pool */ | 691 | #define QUEUE_FLAG_ADD_RANDOM 13 /* Contributes to random pool */ |
| @@ -693,12 +699,11 @@ struct request_queue { | |||
| 693 | #define QUEUE_FLAG_FUA 21 /* device supports FUA writes */ | 699 | #define QUEUE_FLAG_FUA 21 /* device supports FUA writes */ |
| 694 | #define QUEUE_FLAG_FLUSH_NQ 22 /* flush not queueuable */ | 700 | #define QUEUE_FLAG_FLUSH_NQ 22 /* flush not queueuable */ |
| 695 | #define QUEUE_FLAG_DAX 23 /* device supports DAX */ | 701 | #define QUEUE_FLAG_DAX 23 /* device supports DAX */ |
| 696 | #define QUEUE_FLAG_STATS 24 /* track rq completion times */ | 702 | #define QUEUE_FLAG_STATS 24 /* track IO start and completion times */ |
| 697 | #define QUEUE_FLAG_POLL_STATS 25 /* collecting stats for hybrid polling */ | 703 | #define QUEUE_FLAG_POLL_STATS 25 /* collecting stats for hybrid polling */ |
| 698 | #define QUEUE_FLAG_REGISTERED 26 /* queue has been registered to a disk */ | 704 | #define QUEUE_FLAG_REGISTERED 26 /* queue has been registered to a disk */ |
| 699 | #define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */ | 705 | #define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */ |
| 700 | #define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */ | 706 | #define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */ |
| 701 | #define QUEUE_FLAG_PREEMPT_ONLY 29 /* only process REQ_PREEMPT requests */ | ||
| 702 | 707 | ||
| 703 | #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ | 708 | #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ |
| 704 | (1 << QUEUE_FLAG_SAME_COMP) | \ | 709 | (1 << QUEUE_FLAG_SAME_COMP) | \ |
| @@ -736,12 +741,11 @@ bool blk_queue_flag_test_and_clear(unsigned int flag, struct request_queue *q); | |||
| 736 | ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ | 741 | ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ |
| 737 | REQ_FAILFAST_DRIVER)) | 742 | REQ_FAILFAST_DRIVER)) |
| 738 | #define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags) | 743 | #define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags) |
| 739 | #define blk_queue_preempt_only(q) \ | 744 | #define blk_queue_pm_only(q) atomic_read(&(q)->pm_only) |
| 740 | test_bit(QUEUE_FLAG_PREEMPT_ONLY, &(q)->queue_flags) | ||
| 741 | #define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags) | 745 | #define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags) |
| 742 | 746 | ||
| 743 | extern int blk_set_preempt_only(struct request_queue *q); | 747 | extern void blk_set_pm_only(struct request_queue *q); |
| 744 | extern void blk_clear_preempt_only(struct request_queue *q); | 748 | extern void blk_clear_pm_only(struct request_queue *q); |
| 745 | 749 | ||
| 746 | static inline int queue_in_flight(struct request_queue *q) | 750 | static inline int queue_in_flight(struct request_queue *q) |
| 747 | { | 751 | { |
| @@ -1281,29 +1285,6 @@ extern void blk_put_queue(struct request_queue *); | |||
| 1281 | extern void blk_set_queue_dying(struct request_queue *); | 1285 | extern void blk_set_queue_dying(struct request_queue *); |
| 1282 | 1286 | ||
| 1283 | /* | 1287 | /* |
| 1284 | * block layer runtime pm functions | ||
| 1285 | */ | ||
| 1286 | #ifdef CONFIG_PM | ||
| 1287 | extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev); | ||
| 1288 | extern int blk_pre_runtime_suspend(struct request_queue *q); | ||
| 1289 | extern void blk_post_runtime_suspend(struct request_queue *q, int err); | ||
| 1290 | extern void blk_pre_runtime_resume(struct request_queue *q); | ||
| 1291 | extern void blk_post_runtime_resume(struct request_queue *q, int err); | ||
| 1292 | extern void blk_set_runtime_active(struct request_queue *q); | ||
| 1293 | #else | ||
| 1294 | static inline void blk_pm_runtime_init(struct request_queue *q, | ||
| 1295 | struct device *dev) {} | ||
| 1296 | static inline int blk_pre_runtime_suspend(struct request_queue *q) | ||
| 1297 | { | ||
| 1298 | return -ENOSYS; | ||
| 1299 | } | ||
| 1300 | static inline void blk_post_runtime_suspend(struct request_queue *q, int err) {} | ||
| 1301 | static inline void blk_pre_runtime_resume(struct request_queue *q) {} | ||
| 1302 | static inline void blk_post_runtime_resume(struct request_queue *q, int err) {} | ||
| 1303 | static inline void blk_set_runtime_active(struct request_queue *q) {} | ||
| 1304 | #endif | ||
| 1305 | |||
| 1306 | /* | ||
| 1307 | * blk_plug permits building a queue of related requests by holding the I/O | 1288 | * blk_plug permits building a queue of related requests by holding the I/O |
| 1308 | * fragments for a short period. This allows merging of sequential requests | 1289 | * fragments for a short period. This allows merging of sequential requests |
| 1309 | * into single larger request. As the requests are moved from a per-task list to | 1290 | * into single larger request. As the requests are moved from a per-task list to |
| @@ -1676,94 +1657,6 @@ static inline void put_dev_sector(Sector p) | |||
| 1676 | put_page(p.v); | 1657 | put_page(p.v); |
| 1677 | } | 1658 | } |
| 1678 | 1659 | ||
| 1679 | static inline bool __bvec_gap_to_prev(struct request_queue *q, | ||
| 1680 | struct bio_vec *bprv, unsigned int offset) | ||
| 1681 | { | ||
| 1682 | return offset || | ||
| 1683 | ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q)); | ||
| 1684 | } | ||
| 1685 | |||
| 1686 | /* | ||
| 1687 | * Check if adding a bio_vec after bprv with offset would create a gap in | ||
| 1688 | * the SG list. Most drivers don't care about this, but some do. | ||
| 1689 | */ | ||
| 1690 | static inline bool bvec_gap_to_prev(struct request_queue *q, | ||
| 1691 | struct bio_vec *bprv, unsigned int offset) | ||
| 1692 | { | ||
| 1693 | if (!queue_virt_boundary(q)) | ||
| 1694 | return false; | ||
| 1695 | return __bvec_gap_to_prev(q, bprv, offset); | ||
| 1696 | } | ||
| 1697 | |||
| 1698 | /* | ||
| 1699 | * Check if the two bvecs from two bios can be merged to one segment. | ||
| 1700 | * If yes, no need to check gap between the two bios since the 1st bio | ||
| 1701 | * and the 1st bvec in the 2nd bio can be handled in one segment. | ||
| 1702 | */ | ||
| 1703 | static inline bool bios_segs_mergeable(struct request_queue *q, | ||
| 1704 | struct bio *prev, struct bio_vec *prev_last_bv, | ||
| 1705 | struct bio_vec *next_first_bv) | ||
| 1706 | { | ||
| 1707 | if (!BIOVEC_PHYS_MERGEABLE(prev_last_bv, next_first_bv)) | ||
| 1708 | return false; | ||
| 1709 | if (!BIOVEC_SEG_BOUNDARY(q, prev_last_bv, next_first_bv)) | ||
| 1710 | return false; | ||
| 1711 | if (prev->bi_seg_back_size + next_first_bv->bv_len > | ||
| 1712 | queue_max_segment_size(q)) | ||
| 1713 | return false; | ||
| 1714 | return true; | ||
| 1715 | } | ||
| 1716 | |||
| 1717 | static inline bool bio_will_gap(struct request_queue *q, | ||
| 1718 | struct request *prev_rq, | ||
| 1719 | struct bio *prev, | ||
| 1720 | struct bio *next) | ||
| 1721 | { | ||
| 1722 | if (bio_has_data(prev) && queue_virt_boundary(q)) { | ||
| 1723 | struct bio_vec pb, nb; | ||
| 1724 | |||
| 1725 | /* | ||
| 1726 | * don't merge if the 1st bio starts with non-zero | ||
| 1727 | * offset, otherwise it is quite difficult to respect | ||
| 1728 | * sg gap limit. We work hard to merge a huge number of small | ||
| 1729 | * single bios in case of mkfs. | ||
| 1730 | */ | ||
| 1731 | if (prev_rq) | ||
| 1732 | bio_get_first_bvec(prev_rq->bio, &pb); | ||
| 1733 | else | ||
| 1734 | bio_get_first_bvec(prev, &pb); | ||
| 1735 | if (pb.bv_offset) | ||
| 1736 | return true; | ||
| 1737 | |||
| 1738 | /* | ||
| 1739 | * We don't need to worry about the situation that the | ||
| 1740 | * merged segment ends in unaligned virt boundary: | ||
| 1741 | * | ||
| 1742 | * - if 'pb' ends aligned, the merged segment ends aligned | ||
| 1743 | * - if 'pb' ends unaligned, the next bio must include | ||
| 1744 | * one single bvec of 'nb', otherwise the 'nb' can't | ||
| 1745 | * merge with 'pb' | ||
| 1746 | */ | ||
| 1747 | bio_get_last_bvec(prev, &pb); | ||
| 1748 | bio_get_first_bvec(next, &nb); | ||
| 1749 | |||
| 1750 | if (!bios_segs_mergeable(q, prev, &pb, &nb)) | ||
| 1751 | return __bvec_gap_to_prev(q, &pb, nb.bv_offset); | ||
| 1752 | } | ||
| 1753 | |||
| 1754 | return false; | ||
| 1755 | } | ||
| 1756 | |||
| 1757 | static inline bool req_gap_back_merge(struct request *req, struct bio *bio) | ||
| 1758 | { | ||
| 1759 | return bio_will_gap(req->q, req, req->biotail, bio); | ||
| 1760 | } | ||
| 1761 | |||
| 1762 | static inline bool req_gap_front_merge(struct request *req, struct bio *bio) | ||
| 1763 | { | ||
| 1764 | return bio_will_gap(req->q, NULL, bio, req->bio); | ||
| 1765 | } | ||
| 1766 | |||
| 1767 | int kblockd_schedule_work(struct work_struct *work); | 1660 | int kblockd_schedule_work(struct work_struct *work); |
| 1768 | int kblockd_schedule_work_on(int cpu, struct work_struct *work); | 1661 | int kblockd_schedule_work_on(int cpu, struct work_struct *work); |
| 1769 | int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); | 1662 | int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); |
| @@ -1843,26 +1736,6 @@ queue_max_integrity_segments(struct request_queue *q) | |||
| 1843 | return q->limits.max_integrity_segments; | 1736 | return q->limits.max_integrity_segments; |
| 1844 | } | 1737 | } |
| 1845 | 1738 | ||
| 1846 | static inline bool integrity_req_gap_back_merge(struct request *req, | ||
| 1847 | struct bio *next) | ||
| 1848 | { | ||
| 1849 | struct bio_integrity_payload *bip = bio_integrity(req->bio); | ||
| 1850 | struct bio_integrity_payload *bip_next = bio_integrity(next); | ||
| 1851 | |||
| 1852 | return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1], | ||
| 1853 | bip_next->bip_vec[0].bv_offset); | ||
| 1854 | } | ||
| 1855 | |||
| 1856 | static inline bool integrity_req_gap_front_merge(struct request *req, | ||
| 1857 | struct bio *bio) | ||
| 1858 | { | ||
| 1859 | struct bio_integrity_payload *bip = bio_integrity(bio); | ||
| 1860 | struct bio_integrity_payload *bip_next = bio_integrity(req->bio); | ||
| 1861 | |||
| 1862 | return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1], | ||
| 1863 | bip_next->bip_vec[0].bv_offset); | ||
| 1864 | } | ||
| 1865 | |||
| 1866 | /** | 1739 | /** |
| 1867 | * bio_integrity_intervals - Return number of integrity intervals for a bio | 1740 | * bio_integrity_intervals - Return number of integrity intervals for a bio |
| 1868 | * @bi: blk_integrity profile for device | 1741 | * @bi: blk_integrity profile for device |
| @@ -1947,17 +1820,6 @@ static inline bool blk_integrity_merge_bio(struct request_queue *rq, | |||
| 1947 | return true; | 1820 | return true; |
| 1948 | } | 1821 | } |
| 1949 | 1822 | ||
| 1950 | static inline bool integrity_req_gap_back_merge(struct request *req, | ||
| 1951 | struct bio *next) | ||
| 1952 | { | ||
| 1953 | return false; | ||
| 1954 | } | ||
| 1955 | static inline bool integrity_req_gap_front_merge(struct request *req, | ||
| 1956 | struct bio *bio) | ||
| 1957 | { | ||
| 1958 | return false; | ||
| 1959 | } | ||
| 1960 | |||
| 1961 | static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi, | 1823 | static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi, |
| 1962 | unsigned int sectors) | 1824 | unsigned int sectors) |
| 1963 | { | 1825 | { |
