root / drivers / tapdisk-queue.h @ abdb293f
History | View | Annotate | Download (2.6 kB)
1 |
/* Copyright (c) 2007, XenSource Inc.
|
---|---|
2 |
* All rights reserved.
|
3 |
*/
|
4 |
|
5 |
#ifndef TAPDISK_QUEUE_H
|
6 |
#define TAPDISK_QUEUE_H
|
7 |
|
8 |
#include <libaio.h> |
9 |
|
10 |
#include "io-optimize.h" |
11 |
#include "scheduler.h" |
12 |
|
13 |
struct tiocb;
|
14 |
struct tfilter;
|
15 |
|
16 |
typedef void (*td_queue_callback_t)(void *arg, struct tiocb *, int err); |
17 |
|
18 |
|
19 |
struct tiocb {
|
20 |
td_queue_callback_t cb; |
21 |
void *arg;
|
22 |
|
23 |
struct iocb iocb;
|
24 |
struct tiocb *next;
|
25 |
}; |
26 |
|
27 |
struct tlist {
|
28 |
struct tiocb *head;
|
29 |
struct tiocb *tail;
|
30 |
}; |
31 |
|
32 |
struct tqueue {
|
33 |
int size;
|
34 |
|
35 |
const struct tio *tio; |
36 |
void *tio_data;
|
37 |
|
38 |
struct opioctx opioctx;
|
39 |
|
40 |
int queued;
|
41 |
struct iocb **iocbs;
|
42 |
|
43 |
/* number of iocbs pending in the aio layer */
|
44 |
int iocbs_pending;
|
45 |
|
46 |
/* number of tiocbs pending in the queue --
|
47 |
* this is likely to be larger than iocbs_pending
|
48 |
* due to request coalescing */
|
49 |
int tiocbs_pending;
|
50 |
|
51 |
/* iocbs may be deferred if the aio ring is full.
|
52 |
* tapdisk_queue_complete will ensure deferred
|
53 |
* iocbs are queued as slots become available. */
|
54 |
struct tlist deferred;
|
55 |
int tiocbs_deferred;
|
56 |
|
57 |
/* optional tapdisk filter */
|
58 |
struct tfilter *filter;
|
59 |
|
60 |
uint64_t deferrals; |
61 |
}; |
62 |
|
63 |
struct tio {
|
64 |
const char *name; |
65 |
size_t data_size; |
66 |
|
67 |
int (*tio_setup) (struct tqueue *queue, int qlen); |
68 |
void (*tio_destroy) (struct tqueue *queue); |
69 |
int (*tio_submit) (struct tqueue *queue); |
70 |
}; |
71 |
|
72 |
enum {
|
73 |
TIO_DRV_LIO = 1,
|
74 |
TIO_DRV_RWIO = 2,
|
75 |
}; |
76 |
|
77 |
/*
|
78 |
* Interface for request producer (i.e., tapdisk)
|
79 |
* NB: the following functions may cause additional tiocbs to be queued:
|
80 |
* - tapdisk_submit_tiocbs
|
81 |
* - tapdisk_cancel_tiocbs
|
82 |
* - tapdisk_complete_tiocbs
|
83 |
* The *_all_tiocbs variants will handle the first two cases;
|
84 |
* be sure to call submit after calling complete in the third case.
|
85 |
*/
|
86 |
#define tapdisk_queue_count(q) ((q)->queued)
|
87 |
#define tapdisk_queue_empty(q) ((q)->queued == 0) |
88 |
#define tapdisk_queue_full(q) \
|
89 |
(((q)->tiocbs_pending + (q)->queued) >= (q)->size) |
90 |
int tapdisk_init_queue(struct tqueue *, int size, int drv, struct tfilter *); |
91 |
void tapdisk_free_queue(struct tqueue *); |
92 |
void tapdisk_debug_queue(struct tqueue *); |
93 |
void tapdisk_queue_tiocb(struct tqueue *, struct tiocb *); |
94 |
int tapdisk_submit_tiocbs(struct tqueue *); |
95 |
int tapdisk_submit_all_tiocbs(struct tqueue *); |
96 |
int tapdisk_cancel_tiocbs(struct tqueue *); |
97 |
int tapdisk_cancel_all_tiocbs(struct tqueue *); |
98 |
void tapdisk_prep_tiocb(struct tiocb *, int, int, char *, size_t, |
99 |
long long, td_queue_callback_t, void *); |
100 |
|
101 |
#endif
|