summaryrefslogtreecommitdiffstats
path: root/include/linux/blk-mq.h
diff options
context:
space:
mode:
authorKeith Busch <kbusch@kernel.org>2022-01-05 09:05:16 -0800
committerJens Axboe <axboe@kernel.dk>2022-01-05 12:25:42 -0700
commit3764fd05e1f89530e2ee5cbff0b638f2b1141b90 (patch)
tree12008145c3422e06143814d4242f7a853def1713 /include/linux/blk-mq.h
parentedce22e19bfa86efa2522d041d6367f2f099e8ed (diff)
downloadlinux-stable-3764fd05e1f89530e2ee5cbff0b638f2b1141b90.tar.gz
linux-stable-3764fd05e1f89530e2ee5cbff0b638f2b1141b90.tar.bz2
linux-stable-3764fd05e1f89530e2ee5cbff0b638f2b1141b90.zip
block: introduce rq_list_for_each_safe macro
While iterating a list, a particular request may need to be removed for special handling. Provide an iterator that can safely handle that. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org> Link: https://lore.kernel.org/r/20220105170518.3181469-3-kbusch@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/blk-mq.h')
-rw-r--r--include/linux/blk-mq.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index bf64b94cd64e..1467f0fa2142 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -242,6 +242,10 @@ static inline unsigned short req_get_ioprio(struct request *req)
#define rq_list_for_each(listptr, pos) \
for (pos = rq_list_peek((listptr)); pos; pos = rq_list_next(pos))
+#define rq_list_for_each_safe(listptr, pos, nxt) \
+ for (pos = rq_list_peek((listptr)), nxt = rq_list_next(pos); \
+ pos; pos = nxt, nxt = pos ? rq_list_next(pos) : NULL)
+
#define rq_list_next(rq) (rq)->rq_next
#define rq_list_empty(list) ((list) == (struct request *) NULL)