Commit fd2d3326 authored by Jens Axboe's avatar Jens Axboe

blk-mq: add support for carrying internal tag information in blk_qc_t

No functional change in this patch, just in preparation for having
two types of tags available to the block layer for a single request.
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
Reviewed-by: default avatarOmar Sandoval <osandov@fb.com>
parent cc71a6f4
...@@ -1308,6 +1308,11 @@ static struct request *blk_mq_map_request(struct request_queue *q, ...@@ -1308,6 +1308,11 @@ static struct request *blk_mq_map_request(struct request_queue *q,
return rq; return rq;
} }
static blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx, struct request *rq)
{
return blk_tag_to_qc_t(rq->tag, hctx->queue_num, false);
}
static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie) static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie)
{ {
int ret; int ret;
...@@ -1318,7 +1323,7 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie) ...@@ -1318,7 +1323,7 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie)
.list = NULL, .list = NULL,
.last = 1 .last = 1
}; };
blk_qc_t new_cookie = blk_tag_to_qc_t(rq->tag, hctx->queue_num); blk_qc_t new_cookie = request_to_qc_t(hctx, rq);
if (blk_mq_hctx_stopped(hctx)) if (blk_mq_hctx_stopped(hctx))
goto insert; goto insert;
...@@ -1387,7 +1392,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) ...@@ -1387,7 +1392,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
wbt_track(&rq->issue_stat, wb_acct); wbt_track(&rq->issue_stat, wb_acct);
cookie = blk_tag_to_qc_t(rq->tag, data.hctx->queue_num); cookie = request_to_qc_t(data.hctx, rq);
if (unlikely(is_flush_fua)) { if (unlikely(is_flush_fua)) {
blk_mq_bio_to_request(rq, bio); blk_mq_bio_to_request(rq, bio);
...@@ -1496,7 +1501,7 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio) ...@@ -1496,7 +1501,7 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio)
wbt_track(&rq->issue_stat, wb_acct); wbt_track(&rq->issue_stat, wb_acct);
cookie = blk_tag_to_qc_t(rq->tag, data.hctx->queue_num); cookie = request_to_qc_t(data.hctx, rq);
if (unlikely(is_flush_fua)) { if (unlikely(is_flush_fua)) {
blk_mq_bio_to_request(rq, bio); blk_mq_bio_to_request(rq, bio);
......
...@@ -232,22 +232,29 @@ static inline bool op_is_sync(unsigned int op) ...@@ -232,22 +232,29 @@ static inline bool op_is_sync(unsigned int op)
} }
typedef unsigned int blk_qc_t; typedef unsigned int blk_qc_t;
#define BLK_QC_T_NONE -1U #define BLK_QC_T_NONE -1U
#define BLK_QC_T_SHIFT 16 #define BLK_QC_T_SHIFT 16
#define BLK_QC_T_INTERNAL (1U << 31)
static inline bool blk_qc_t_valid(blk_qc_t cookie) static inline bool blk_qc_t_valid(blk_qc_t cookie)
{ {
return cookie != BLK_QC_T_NONE; return cookie != BLK_QC_T_NONE;
} }
static inline blk_qc_t blk_tag_to_qc_t(unsigned int tag, unsigned int queue_num) static inline blk_qc_t blk_tag_to_qc_t(unsigned int tag, unsigned int queue_num,
bool internal)
{ {
return tag | (queue_num << BLK_QC_T_SHIFT); blk_qc_t ret = tag | (queue_num << BLK_QC_T_SHIFT);
if (internal)
ret |= BLK_QC_T_INTERNAL;
return ret;
} }
static inline unsigned int blk_qc_t_to_queue_num(blk_qc_t cookie) static inline unsigned int blk_qc_t_to_queue_num(blk_qc_t cookie)
{ {
return cookie >> BLK_QC_T_SHIFT; return (cookie & ~BLK_QC_T_INTERNAL) >> BLK_QC_T_SHIFT;
} }
static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie) static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie)
...@@ -255,6 +262,11 @@ static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie) ...@@ -255,6 +262,11 @@ static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie)
return cookie & ((1u << BLK_QC_T_SHIFT) - 1); return cookie & ((1u << BLK_QC_T_SHIFT) - 1);
} }
static inline bool blk_qc_t_is_internal(blk_qc_t cookie)
{
return (cookie & BLK_QC_T_INTERNAL) != 0;
}
struct blk_issue_stat { struct blk_issue_stat {
u64 time; u64 time;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment