]> Git Repo - qemu.git/blame - hw/block/dataplane/ioq.h
dataplane/virtio-blk: drop flush_true() and flush_io()
[qemu.git] / hw / block / dataplane / ioq.h
CommitLineData
3e9ec521
SH
1/*
2 * Linux AIO request queue
3 *
4 * Copyright 2012 IBM, Corp.
5 * Copyright 2012 Red Hat, Inc. and/or its affiliates
6 *
7 * Authors:
8 * Stefan Hajnoczi <[email protected]>
9 *
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
12 *
13 */
14
15#ifndef IOQ_H
16#define IOQ_H
17
18#include <libaio.h>
19#include "qemu/event_notifier.h"
20
21typedef struct {
22 int fd; /* file descriptor */
23 unsigned int max_reqs; /* max length of freelist and queue */
24
25 io_context_t io_ctx; /* Linux AIO context */
26 EventNotifier io_notifier; /* Linux AIO eventfd */
27
28 /* Requests can complete in any order so a free list is necessary to manage
29 * available iocbs.
30 */
31 struct iocb **freelist; /* free iocbs */
32 unsigned int freelist_idx;
33
34 /* Multiple requests are queued up before submitting them all in one go */
35 struct iocb **queue; /* queued iocbs */
36 unsigned int queue_idx;
37} IOQueue;
38
39void ioq_init(IOQueue *ioq, int fd, unsigned int max_reqs);
40void ioq_cleanup(IOQueue *ioq);
41EventNotifier *ioq_get_notifier(IOQueue *ioq);
42struct iocb *ioq_get_iocb(IOQueue *ioq);
43void ioq_put_iocb(IOQueue *ioq, struct iocb *iocb);
44struct iocb *ioq_rdwr(IOQueue *ioq, bool read, struct iovec *iov,
45 unsigned int count, long long offset);
46int ioq_submit(IOQueue *ioq);
47
48static inline unsigned int ioq_num_queued(IOQueue *ioq)
49{
50 return ioq->queue_idx;
51}
52
53typedef void IOQueueCompletion(struct iocb *iocb, ssize_t ret, void *opaque);
54int ioq_run_completion(IOQueue *ioq, IOQueueCompletion *completion,
55 void *opaque);
56
57#endif /* IOQ_H */
This page took 0.112451 seconds and 4 git commands to generate.