1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ 2 #ifndef __BLK_TYPES_H 3 #define __BLK_TYPES_H 4 5 /* From include/linux/blk_types.h */ 6 7 /* 8 * Operations and flags common to the bio and request structures. 9 * We use 8 bits for encoding the operation, and the remaining 24 for flags. 10 * 11 * The least significant bit of the operation number indicates the data 12 * transfer direction: 13 * 14 * - if the least significant bit is set transfers are TO the device 15 * - if the least significant bit is not set transfers are FROM the device 16 * 17 * If a operation does not transfer data the least significant bit has no 18 * meaning. 19 */ 20 #define REQ_OP_BITS 8 21 #define REQ_OP_MASK ((1 << REQ_OP_BITS) - 1) 22 #define REQ_FLAG_BITS 24 23 24 enum req_opf { 25 /* read sectors from the device */ 26 REQ_OP_READ = 0, 27 /* write sectors to the device */ 28 REQ_OP_WRITE = 1, 29 /* flush the volatile write cache */ 30 REQ_OP_FLUSH = 2, 31 /* discard sectors */ 32 REQ_OP_DISCARD = 3, 33 /* securely erase sectors */ 34 REQ_OP_SECURE_ERASE = 5, 35 /* reset a zone write pointer */ 36 REQ_OP_ZONE_RESET = 6, 37 /* write the same sector many times */ 38 REQ_OP_WRITE_SAME = 7, 39 /* reset all the zone present on the device */ 40 REQ_OP_ZONE_RESET_ALL = 8, 41 /* write the zero filled sector many times */ 42 REQ_OP_WRITE_ZEROES = 9, 43 /* Open a zone */ 44 REQ_OP_ZONE_OPEN = 10, 45 /* Close a zone */ 46 REQ_OP_ZONE_CLOSE = 11, 47 /* Transition a zone to full */ 48 REQ_OP_ZONE_FINISH = 12, 49 50 /* SCSI passthrough using struct scsi_request */ 51 REQ_OP_SCSI_IN = 32, 52 REQ_OP_SCSI_OUT = 33, 53 /* Driver private requests */ 54 REQ_OP_DRV_IN = 34, 55 REQ_OP_DRV_OUT = 35, 56 57 REQ_OP_LAST, 58 }; 59 60 enum req_flag_bits { 61 __REQ_FAILFAST_DEV = /* no driver retries of device errors */ 62 REQ_OP_BITS, 63 __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */ 64 __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */ 65 __REQ_SYNC, /* request is sync (sync write or read) */ 66 __REQ_META, /* metadata io request */ 67 __REQ_PRIO, /* boost priority in cfq */ 68 __REQ_NOMERGE, /* don't touch this for merging */ 69 __REQ_IDLE, /* anticipate more IO after this one */ 70 __REQ_INTEGRITY, /* I/O includes block integrity payload */ 71 __REQ_FUA, /* forced unit access */ 72 __REQ_PREFLUSH, /* request for cache flush */ 73 __REQ_RAHEAD, /* read ahead, can fail anytime */ 74 __REQ_BACKGROUND, /* background IO */ 75 __REQ_NOWAIT, /* Don't wait if request will block */ 76 __REQ_NOWAIT_INLINE, /* Return would-block error inline */ 77 /* 78 * When a shared kthread needs to issue a bio for a cgroup, doing 79 * so synchronously can lead to priority inversions as the kthread 80 * can be trapped waiting for that cgroup. CGROUP_PUNT flag makes 81 * submit_bio() punt the actual issuing to a dedicated per-blkcg 82 * work item to avoid such priority inversions. 83 */ 84 __REQ_CGROUP_PUNT, 85 86 /* command specific flags for REQ_OP_WRITE_ZEROES: */ 87 __REQ_NOUNMAP, /* do not free blocks when zeroing */ 88 89 __REQ_HIPRI, 90 91 /* for driver use */ 92 __REQ_DRV, 93 __REQ_SWAP, /* swapping request. */ 94 __REQ_NR_BITS, /* stops here */ 95 }; 96 97 #define REQ_FAILFAST_DEV (1ULL << __REQ_FAILFAST_DEV) 98 #define REQ_FAILFAST_TRANSPORT (1ULL << __REQ_FAILFAST_TRANSPORT) 99 #define REQ_FAILFAST_DRIVER (1ULL << __REQ_FAILFAST_DRIVER) 100 #define REQ_SYNC (1ULL << __REQ_SYNC) 101 #define REQ_META (1ULL << __REQ_META) 102 #define REQ_PRIO (1ULL << __REQ_PRIO) 103 #define REQ_NOMERGE (1ULL << __REQ_NOMERGE) 104 #define REQ_IDLE (1ULL << __REQ_IDLE) 105 #define REQ_INTEGRITY (1ULL << __REQ_INTEGRITY) 106 #define REQ_FUA (1ULL << __REQ_FUA) 107 #define REQ_PREFLUSH (1ULL << __REQ_PREFLUSH) 108 #define REQ_RAHEAD (1ULL << __REQ_RAHEAD) 109 #define REQ_BACKGROUND (1ULL << __REQ_BACKGROUND) 110 #define REQ_NOWAIT (1ULL << __REQ_NOWAIT) 111 #define REQ_NOWAIT_INLINE (1ULL << __REQ_NOWAIT_INLINE) 112 #define REQ_CGROUP_PUNT (1ULL << __REQ_CGROUP_PUNT) 113 114 #define REQ_NOUNMAP (1ULL << __REQ_NOUNMAP) 115 #define REQ_HIPRI (1ULL << __REQ_HIPRI) 116 117 #define REQ_DRV (1ULL << __REQ_DRV) 118 #define REQ_SWAP (1ULL << __REQ_SWAP) 119 120 #define REQ_FAILFAST_MASK \ 121 (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) 122 123 #define REQ_NOMERGE_FLAGS \ 124 (REQ_NOMERGE | REQ_PREFLUSH | REQ_FUA) 125 126 #endif /* __BLK_TYPES_H */ 127