mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-12 17:42:38 +00:00
block: provide helpers for rq_list manipulation
Instead of open-coding the list additions, traversal, and removal, provide a basic set of helpers. Suggested-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
afd7de03c5
commit
013a7f9543
2 changed files with 34 additions and 14 deletions
|
@ -1298,4 +1298,33 @@ int fsync_bdev(struct block_device *bdev);
|
|||
int freeze_bdev(struct block_device *bdev);
|
||||
int thaw_bdev(struct block_device *bdev);
|
||||
|
||||
#define rq_list_add(listptr, rq) do { \
|
||||
(rq)->rq_next = *(listptr); \
|
||||
*(listptr) = rq; \
|
||||
} while (0)
|
||||
|
||||
#define rq_list_pop(listptr) \
|
||||
({ \
|
||||
struct request *__req = NULL; \
|
||||
if ((listptr) && *(listptr)) { \
|
||||
__req = *(listptr); \
|
||||
*(listptr) = __req->rq_next; \
|
||||
} \
|
||||
__req; \
|
||||
})
|
||||
|
||||
#define rq_list_peek(listptr) \
|
||||
({ \
|
||||
struct request *__req = NULL; \
|
||||
if ((listptr) && *(listptr)) \
|
||||
__req = *(listptr); \
|
||||
__req; \
|
||||
})
|
||||
|
||||
#define rq_list_for_each(listptr, pos) \
|
||||
for (pos = rq_list_peek((listptr)); pos; pos = rq_list_next(pos)) \
|
||||
|
||||
#define rq_list_next(rq) (rq)->rq_next
|
||||
#define rq_list_empty(list) ((list) == (struct request *) NULL)
|
||||
|
||||
#endif /* _LINUX_BLKDEV_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue