Skip to content

Commit 8238b60

Browse files
committed
blk/aio: fix incomplete patch to get rid off aio_size
Signed-off-by: Igor Fedotov <[email protected]>
1 parent 7b52409 commit 8238b60

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/blk/aio/aio.cc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,25 @@ int aio_queue_t::submit_batch(aio_iter begin, aio_iter end,
2929
struct aio_t *piocb[max_iodepth];
3030
#endif
3131
int done = 0;
32-
while (cur != end) {
32+
int pushed = 0; //used for LIBAIO only
33+
int pulled = 0;
34+
while (cur != end || pushed < pulled) {
3335
#if defined(HAVE_LIBAIO)
34-
int itemCount = 0;
35-
while (cur != end && itemCount < max_iodepth) {
36+
while (cur != end && pulled < max_iodepth) {
3637
cur->priv = priv;
37-
piocb[itemCount] = &(*cur);
38-
++itemCount;
38+
piocb[pulled] = &(*cur);
39+
++pulled;
3940
++cur;
4041
}
41-
r = io_submit(ctx, itemCount, (struct iocb**)piocb);
42+
int toSubmit = pulled - pushed;
43+
r = io_submit(ctx, toSubmit, (struct iocb**)(piocb + pushed));
44+
if (r >= 0 && r < toSubmit) {
45+
pushed += r;
46+
done += r;
47+
r = -EAGAIN;
48+
}
4249
#elif defined(HAVE_POSIXAIO)
43-
cur->priv = priv
50+
cur->priv = priv;
4451
if ((cur->n_aiocb == 1) {
4552
// TODO: consider batching multiple reads together with lio_listio
4653
cur->aio.aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
@@ -69,6 +76,7 @@ int aio_queue_t::submit_batch(aio_iter begin, aio_iter end,
6976
done += r;
7077
attempts = 16;
7178
delay = 125;
79+
pushed = pulled = 0;
7280
}
7381
return done;
7482
}

src/blk/aio/aio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct io_queue_t {
100100

101101
virtual int init(std::vector<int> &fds) = 0;
102102
virtual void shutdown() = 0;
103-
virtual int submit_batch(aio_iter begin, aio_iter end,
103+
virtual int submit_batch(aio_iter begin, aio_iter end,
104104
void *priv, int *retries) = 0;
105105
virtual int get_next_completed(int timeout_ms, aio_t **paio, int max) = 0;
106106
};

0 commit comments

Comments
 (0)