OSDN Git Service

io_uring: add support for link with drain
authorJackie Liu <liuyun01@kylinos.cn>
Mon, 9 Sep 2019 12:50:40 +0000 (20:50 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Sep 2019 22:15:00 +0000 (16:15 -0600)
commit4fe2c963154c31227bec2f2d690e01f9cab383ea
tree7080d147d8eb4a3cd226208eca95424625b8c63d
parent8776f3fa15a5cd213c4dfab7ddaf557983374ea6
io_uring: add support for link with drain

To support the link with drain, we need to do two parts.

There is an sqes:

    0     1     2     3     4     5     6
 +-----+-----+-----+-----+-----+-----+-----+
 |  N  |  L  |  L  | L+D |  N  |  N  |  N  |
 +-----+-----+-----+-----+-----+-----+-----+

First, we need to ensure that the io before the link is completed,
there is a easy way is set drain flag to the link list's head, so
all subsequent io will be inserted into the defer_list.

+-----+
    (0) |  N  |
+-----+
           |          (2)         (3)         (4)
+-----+     +-----+     +-----+     +-----+
    (1) | L+D | --> |  L  | --> | L+D | --> |  N  |
+-----+     +-----+     +-----+     +-----+
           |
+-----+
    (5) |  N  |
+-----+
           |
+-----+
    (6) |  N  |
+-----+

Second, ensure that the following IO will not be completed first,
an easy way is to create a mirror of drain io and insert it into
defer_list, in this way, as long as drain io is not processed, the
following io in the defer_list will not be actively process.

+-----+
    (0) |  N  |
+-----+
           |          (2)         (3)         (4)
+-----+     +-----+     +-----+     +-----+
    (1) | L+D | --> |  L  | --> | L+D | --> |  N  |
+-----+     +-----+     +-----+     +-----+
           |
+-----+
   ('3) |  D  |   <== This is a shadow of (3)
+-----+
           |
+-----+
    (5) |  N  |
+-----+
           |
+-----+
    (6) |  N  |
+-----+

Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c