block: introduce rq_list_for_each_safe macro

Bugzilla: http://bugzilla.redhat.com/2066146

commit 3764fd05e1f89530e2ee5cbff0b638f2b1141b90
Author: Keith Busch <kbusch@kernel.org>
Date:   Wed Jan 5 09:05:16 2022 -0800

    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>

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
This commit is contained in:
Gopal Tiwari 2022-03-27 11:58:23 +05:30
parent ff7a611d72
commit aabf7088c8
1 changed files with 4 additions and 0 deletions

View File

@ -244,6 +244,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)