block: add a queue_has_disk helper
authorChristoph Hellwig <hch@lst.de>
Mon, 9 Aug 2021 14:17:42 +0000 (16:17 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Aug 2021 17:52:28 +0000 (11:52 -0600)
Add a helper to check if a gendisk is associated with a request_queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20210809141744.1203023-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/blkdev.h

index ac3642c..96f3d96 100644 (file)
@@ -664,6 +664,7 @@ extern void blk_clear_pm_only(struct request_queue *q);
        dma_map_page_attrs(dev, (bv)->bv_page, (bv)->bv_offset, (bv)->bv_len, \
        (dir), (attrs))
 
+#define queue_has_disk(q)      ((q)->kobj.parent != NULL)
 #define queue_to_disk(q)       (dev_to_disk(kobj_to_dev((q)->kobj.parent)))
 
 static inline bool queue_is_mq(struct request_queue *q)