@@ -55,6 +55,11 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
rq->rq_disk = bd_disk;
rq->end_io = done;
+ if (WARN_ON_ONCE(blk_rq_is_internal(rq))) {
+ blk_mq_end_request(rq, BLK_STS_NOTSUPP);
+ return;
+ }
+
blk_account_io_start(rq);
/*
@@ -424,6 +424,7 @@ enum req_flag_bits {
/* for driver use */
__REQ_DRV,
__REQ_SWAP, /* swapping request. */
+ __REQ_INTERNAL, /* driver-internal command */
__REQ_NR_BITS, /* stops here */
};
@@ -448,6 +449,7 @@ enum req_flag_bits {
#define REQ_DRV (1ULL << __REQ_DRV)
#define REQ_SWAP (1ULL << __REQ_SWAP)
+#define REQ_INTERNAL (1ULL << __REQ_INTERNAL)
#define REQ_FAILFAST_MASK \
(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
@@ -269,6 +269,11 @@ static inline bool blk_rq_is_passthrough(struct request *rq)
return blk_rq_is_scsi(rq) || blk_rq_is_private(rq);
}
+static inline bool blk_rq_is_internal(struct request *rq)
+{
+ return rq->cmd_flags & REQ_INTERNAL;
+}
+
static inline bool bio_is_passthrough(struct bio *bio)
{
unsigned op = bio_op(bio);
Some drivers require to allocate requests for internal command submission. These request will never be passed through the block layer, but nevertheless require a valid tag to avoid them clashing with normal I/O commands. This patch adds a new request flag REQ_INTERNAL to mark such requests and a terminates any such commands in blk_execute_rq_nowait() with a WARN_ON_ONCE to signal such an invalid usage. Signed-off-by: Hannes Reinecke <hare@suse.de> --- block/blk-exec.c | 5 +++++ include/linux/blk_types.h | 2 ++ include/linux/blkdev.h | 5 +++++ 3 files changed, 12 insertions(+)