diff options
Diffstat (limited to 'block/blk-mq.h')
-rw-r--r-- | block/blk-mq.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/block/blk-mq.h b/block/blk-mq.h index de7b3bbd5bd6..57a7968e47b3 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -69,4 +69,26 @@ struct blk_align_bitmap { unsigned long depth; } ____cacheline_aligned_in_smp; +static inline struct blk_mq_ctx *__blk_mq_get_ctx(struct request_queue *q, + unsigned int cpu) +{ + return per_cpu_ptr(q->queue_ctx, cpu); +} + +/* + * This assumes per-cpu software queueing queues. They could be per-node + * as well, for instance. For now this is hardcoded as-is. Note that we don't + * care about preemption, since we know the ctx's are persistent. This does + * mean that we can't rely on ctx always matching the currently running CPU. + */ +static inline struct blk_mq_ctx *blk_mq_get_ctx(struct request_queue *q) +{ + return __blk_mq_get_ctx(q, get_cpu()); +} + +static inline void blk_mq_put_ctx(struct blk_mq_ctx *ctx) +{ + put_cpu(); +} + #endif |