Commit 907d5231 authored by Jeffle Xu's avatar Jeffle Xu Committed by Jens Axboe

block: add queue_to_disk() to get gendisk from request_queue

Sometimes we need to get the corresponding gendisk from request_queue.

It is preferred that block drivers store private data in
gendisk->private_data rather than request_queue->queuedata, e.g. see:
commit c4a59c4e ("dm: stop using ->queuedata").

So if only request_queue is given, we need to get its corresponding
gendisk to get the private data stored in that gendisk.
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarJeffle Xu <jefflexu@linux.alibaba.com>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent cbb749cf
......@@ -689,6 +689,8 @@ static inline bool blk_account_rq(struct request *rq)
dma_map_page_attrs(dev, (bv)->bv_page, (bv)->bv_offset, (bv)->bv_len, \
(dir), (attrs))
#define queue_to_disk(q) (dev_to_disk(kobj_to_dev((q)->kobj.parent)))
static inline bool queue_is_mq(struct request_queue *q)
{
return q->mq_ops;
......
......@@ -30,7 +30,7 @@ TRACE_EVENT(kyber_latency,
),
TP_fast_assign(
__entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
__entry->dev = disk_devt(queue_to_disk(q));
strlcpy(__entry->domain, domain, sizeof(__entry->domain));
strlcpy(__entry->type, type, sizeof(__entry->type));
__entry->percentile = percentile;
......@@ -59,7 +59,7 @@ TRACE_EVENT(kyber_adjust,
),
TP_fast_assign(
__entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
__entry->dev = disk_devt(queue_to_disk(q));
strlcpy(__entry->domain, domain, sizeof(__entry->domain));
__entry->depth = depth;
),
......@@ -81,7 +81,7 @@ TRACE_EVENT(kyber_throttled,
),
TP_fast_assign(
__entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
__entry->dev = disk_devt(queue_to_disk(q));
strlcpy(__entry->domain, domain, sizeof(__entry->domain));
),
......
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