aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * QEMU posix-aio emulation |
| 3 | * |
| 4 | * Copyright IBM, Corp. 2008 |
| 5 | * |
| 6 | * Authors: |
| 7 | * Anthony Liguori <aliguori@us.ibm.com> |
| 8 | * |
| 9 | * This work is licensed under the terms of the GNU GPL, version 2. See |
| 10 | * the COPYING file in the top-level directory. |
| 11 | * |
Paolo Bonzini | 6b620ca | 2012-01-13 17:44:23 +0100 | [diff] [blame] | 12 | * Contributions after 2012-01-13 are licensed under the terms of the |
| 13 | * GNU GPL, version 2 or (at your option) any later version. |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 16 | #include <sys/ioctl.h> |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 17 | #include <sys/types.h> |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 18 | #include <pthread.h> |
| 19 | #include <unistd.h> |
| 20 | #include <errno.h> |
malc | 30525af | 2009-02-21 05:48:13 +0000 | [diff] [blame] | 21 | #include <time.h> |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 22 | #include <string.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <stdio.h> |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 25 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 26 | #include "qemu-queue.h" |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 27 | #include "osdep.h" |
Jes Sorensen | dc786bc | 2010-10-26 10:39:23 +0200 | [diff] [blame] | 28 | #include "sysemu.h" |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 29 | #include "qemu-common.h" |
Stefan Hajnoczi | 6d519a5 | 2010-05-22 18:15:08 +0100 | [diff] [blame] | 30 | #include "trace.h" |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 31 | #include "block_int.h" |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 32 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 33 | #include "block/raw-posix-aio.h" |
| 34 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame] | 35 | static void do_spawn_thread(void); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 36 | |
| 37 | struct qemu_paiocb { |
| 38 | BlockDriverAIOCB common; |
| 39 | int aio_fildes; |
| 40 | union { |
| 41 | struct iovec *aio_iov; |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 42 | void *aio_ioctl_buf; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 43 | }; |
| 44 | int aio_niov; |
| 45 | size_t aio_nbytes; |
| 46 | #define aio_ioctl_cmd aio_nbytes /* for QEMU_AIO_IOCTL */ |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 47 | off_t aio_offset; |
| 48 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 49 | QTAILQ_ENTRY(qemu_paiocb) node; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 50 | int aio_type; |
| 51 | ssize_t ret; |
| 52 | int active; |
| 53 | struct qemu_paiocb *next; |
| 54 | }; |
| 55 | |
| 56 | typedef struct PosixAioState { |
| 57 | int rfd, wfd; |
| 58 | struct qemu_paiocb *first_aio; |
| 59 | } PosixAioState; |
| 60 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 61 | |
| 62 | static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; |
| 63 | static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
| 64 | static pthread_t thread_id; |
malc | a8227a5 | 2009-02-21 05:48:17 +0000 | [diff] [blame] | 65 | static pthread_attr_t attr; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 66 | static int max_threads = 64; |
| 67 | static int cur_threads = 0; |
| 68 | static int idle_threads = 0; |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame] | 69 | static int new_threads = 0; /* backlog of threads we need to create */ |
| 70 | static int pending_threads = 0; /* threads created but not running yet */ |
| 71 | static QEMUBH *new_thread_bh; |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 72 | static QTAILQ_HEAD(, qemu_paiocb) request_list; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 73 | |
Juan Quintela | 2341f9a | 2009-07-27 16:12:58 +0200 | [diff] [blame] | 74 | #ifdef CONFIG_PREADV |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 75 | static int preadv_present = 1; |
| 76 | #else |
| 77 | static int preadv_present = 0; |
| 78 | #endif |
| 79 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 80 | static void die2(int err, const char *what) |
| 81 | { |
| 82 | fprintf(stderr, "%s failed: %s\n", what, strerror(err)); |
| 83 | abort(); |
| 84 | } |
| 85 | |
| 86 | static void die(const char *what) |
| 87 | { |
| 88 | die2(errno, what); |
| 89 | } |
| 90 | |
| 91 | static void mutex_lock(pthread_mutex_t *mutex) |
| 92 | { |
| 93 | int ret = pthread_mutex_lock(mutex); |
| 94 | if (ret) die2(ret, "pthread_mutex_lock"); |
| 95 | } |
| 96 | |
| 97 | static void mutex_unlock(pthread_mutex_t *mutex) |
| 98 | { |
| 99 | int ret = pthread_mutex_unlock(mutex); |
| 100 | if (ret) die2(ret, "pthread_mutex_unlock"); |
| 101 | } |
| 102 | |
| 103 | static int cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, |
| 104 | struct timespec *ts) |
| 105 | { |
| 106 | int ret = pthread_cond_timedwait(cond, mutex, ts); |
| 107 | if (ret && ret != ETIMEDOUT) die2(ret, "pthread_cond_timedwait"); |
| 108 | return ret; |
| 109 | } |
| 110 | |
malc | 5d47e37 | 2009-02-21 05:48:15 +0000 | [diff] [blame] | 111 | static void cond_signal(pthread_cond_t *cond) |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 112 | { |
malc | 5d47e37 | 2009-02-21 05:48:15 +0000 | [diff] [blame] | 113 | int ret = pthread_cond_signal(cond); |
| 114 | if (ret) die2(ret, "pthread_cond_signal"); |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static void thread_create(pthread_t *thread, pthread_attr_t *attr, |
| 118 | void *(*start_routine)(void*), void *arg) |
| 119 | { |
| 120 | int ret = pthread_create(thread, attr, start_routine, arg); |
| 121 | if (ret) die2(ret, "pthread_create"); |
| 122 | } |
| 123 | |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 124 | static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb) |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 125 | { |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 126 | int ret; |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 127 | |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 128 | ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf); |
| 129 | if (ret == -1) |
| 130 | return -errno; |
Christoph Hellwig | e7d54ae | 2009-04-28 11:57:02 +0200 | [diff] [blame] | 131 | |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 132 | /* |
Stefan Weil | e7d8100 | 2011-12-10 00:19:46 +0100 | [diff] [blame] | 133 | * This looks weird, but the aio code only considers a request |
| 134 | * successful if it has written the full number of bytes. |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 135 | * |
| 136 | * Now we overload aio_nbytes as aio_ioctl_cmd for the ioctl command, |
| 137 | * so in fact we return the ioctl command here to make posix_aio_read() |
| 138 | * happy.. |
| 139 | */ |
| 140 | return aiocb->aio_nbytes; |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 143 | static ssize_t handle_aiocb_flush(struct qemu_paiocb *aiocb) |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 144 | { |
| 145 | int ret; |
| 146 | |
Blue Swirl | 47faadc | 2009-09-12 06:19:14 +0000 | [diff] [blame] | 147 | ret = qemu_fdatasync(aiocb->aio_fildes); |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 148 | if (ret == -1) |
| 149 | return -errno; |
| 150 | return 0; |
| 151 | } |
| 152 | |
Juan Quintela | 2341f9a | 2009-07-27 16:12:58 +0200 | [diff] [blame] | 153 | #ifdef CONFIG_PREADV |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 154 | |
| 155 | static ssize_t |
| 156 | qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 157 | { |
| 158 | return preadv(fd, iov, nr_iov, offset); |
| 159 | } |
| 160 | |
| 161 | static ssize_t |
| 162 | qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 163 | { |
| 164 | return pwritev(fd, iov, nr_iov, offset); |
| 165 | } |
| 166 | |
| 167 | #else |
| 168 | |
| 169 | static ssize_t |
| 170 | qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 171 | { |
| 172 | return -ENOSYS; |
| 173 | } |
| 174 | |
| 175 | static ssize_t |
| 176 | qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 177 | { |
| 178 | return -ENOSYS; |
| 179 | } |
| 180 | |
| 181 | #endif |
| 182 | |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 183 | static ssize_t handle_aiocb_rw_vector(struct qemu_paiocb *aiocb) |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 184 | { |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 185 | ssize_t len; |
| 186 | |
| 187 | do { |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 188 | if (aiocb->aio_type & QEMU_AIO_WRITE) |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 189 | len = qemu_pwritev(aiocb->aio_fildes, |
| 190 | aiocb->aio_iov, |
| 191 | aiocb->aio_niov, |
Frediano Ziglio | 21cfa41 | 2011-09-16 13:34:46 +0200 | [diff] [blame] | 192 | aiocb->aio_offset); |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 193 | else |
| 194 | len = qemu_preadv(aiocb->aio_fildes, |
| 195 | aiocb->aio_iov, |
| 196 | aiocb->aio_niov, |
Frediano Ziglio | 21cfa41 | 2011-09-16 13:34:46 +0200 | [diff] [blame] | 197 | aiocb->aio_offset); |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 198 | } while (len == -1 && errno == EINTR); |
| 199 | |
| 200 | if (len == -1) |
| 201 | return -errno; |
| 202 | return len; |
| 203 | } |
| 204 | |
Kevin Wolf | ba1d1af | 2011-07-25 19:42:37 +0200 | [diff] [blame] | 205 | /* |
| 206 | * Read/writes the data to/from a given linear buffer. |
| 207 | * |
| 208 | * Returns the number of bytes handles or -errno in case of an error. Short |
| 209 | * reads are only returned if the end of the file is reached. |
| 210 | */ |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 211 | static ssize_t handle_aiocb_rw_linear(struct qemu_paiocb *aiocb, char *buf) |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 212 | { |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 213 | ssize_t offset = 0; |
| 214 | ssize_t len; |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 215 | |
| 216 | while (offset < aiocb->aio_nbytes) { |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 217 | if (aiocb->aio_type & QEMU_AIO_WRITE) |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 218 | len = pwrite(aiocb->aio_fildes, |
| 219 | (const char *)buf + offset, |
| 220 | aiocb->aio_nbytes - offset, |
| 221 | aiocb->aio_offset + offset); |
| 222 | else |
| 223 | len = pread(aiocb->aio_fildes, |
| 224 | buf + offset, |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 225 | aiocb->aio_nbytes - offset, |
| 226 | aiocb->aio_offset + offset); |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 227 | |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 228 | if (len == -1 && errno == EINTR) |
| 229 | continue; |
| 230 | else if (len == -1) { |
| 231 | offset = -errno; |
| 232 | break; |
| 233 | } else if (len == 0) |
| 234 | break; |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 235 | |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 236 | offset += len; |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | return offset; |
| 240 | } |
| 241 | |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 242 | static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb) |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 243 | { |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 244 | ssize_t nbytes; |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 245 | char *buf; |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 246 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 247 | if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) { |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 248 | /* |
| 249 | * If there is just a single buffer, and it is properly aligned |
| 250 | * we can just use plain pread/pwrite without any problems. |
| 251 | */ |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 252 | if (aiocb->aio_niov == 1) |
| 253 | return handle_aiocb_rw_linear(aiocb, aiocb->aio_iov->iov_base); |
| 254 | |
| 255 | /* |
| 256 | * We have more than one iovec, and all are properly aligned. |
| 257 | * |
| 258 | * Try preadv/pwritev first and fall back to linearizing the |
| 259 | * buffer if it's not supported. |
| 260 | */ |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 261 | if (preadv_present) { |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 262 | nbytes = handle_aiocb_rw_vector(aiocb); |
| 263 | if (nbytes == aiocb->aio_nbytes) |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 264 | return nbytes; |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 265 | if (nbytes < 0 && nbytes != -ENOSYS) |
| 266 | return nbytes; |
| 267 | preadv_present = 0; |
| 268 | } |
| 269 | |
| 270 | /* |
| 271 | * XXX(hch): short read/write. no easy way to handle the reminder |
| 272 | * using these interfaces. For now retry using plain |
| 273 | * pread/pwrite? |
| 274 | */ |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | /* |
| 278 | * Ok, we have to do it the hard way, copy all segments into |
| 279 | * a single aligned buffer. |
| 280 | */ |
Christoph Hellwig | 72aef73 | 2010-09-12 23:42:56 +0200 | [diff] [blame] | 281 | buf = qemu_blockalign(aiocb->common.bs, aiocb->aio_nbytes); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 282 | if (aiocb->aio_type & QEMU_AIO_WRITE) { |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 283 | char *p = buf; |
| 284 | int i; |
| 285 | |
| 286 | for (i = 0; i < aiocb->aio_niov; ++i) { |
| 287 | memcpy(p, aiocb->aio_iov[i].iov_base, aiocb->aio_iov[i].iov_len); |
| 288 | p += aiocb->aio_iov[i].iov_len; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | nbytes = handle_aiocb_rw_linear(aiocb, buf); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 293 | if (!(aiocb->aio_type & QEMU_AIO_WRITE)) { |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 294 | char *p = buf; |
| 295 | size_t count = aiocb->aio_nbytes, copy; |
| 296 | int i; |
| 297 | |
| 298 | for (i = 0; i < aiocb->aio_niov && count; ++i) { |
| 299 | copy = count; |
| 300 | if (copy > aiocb->aio_iov[i].iov_len) |
| 301 | copy = aiocb->aio_iov[i].iov_len; |
| 302 | memcpy(aiocb->aio_iov[i].iov_base, p, copy); |
| 303 | p += copy; |
| 304 | count -= copy; |
| 305 | } |
| 306 | } |
| 307 | qemu_vfree(buf); |
| 308 | |
| 309 | return nbytes; |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Frediano Ziglio | e1d3b25 | 2011-09-19 16:37:13 +0200 | [diff] [blame] | 312 | static void posix_aio_notify_event(void); |
| 313 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 314 | static void *aio_thread(void *unused) |
| 315 | { |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame] | 316 | mutex_lock(&lock); |
| 317 | pending_threads--; |
| 318 | mutex_unlock(&lock); |
| 319 | do_spawn_thread(); |
| 320 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 321 | while (1) { |
| 322 | struct qemu_paiocb *aiocb; |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 323 | ssize_t ret = 0; |
malc | 30525af | 2009-02-21 05:48:13 +0000 | [diff] [blame] | 324 | qemu_timeval tv; |
| 325 | struct timespec ts; |
| 326 | |
| 327 | qemu_gettimeofday(&tv); |
| 328 | ts.tv_sec = tv.tv_sec + 10; |
| 329 | ts.tv_nsec = 0; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 330 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 331 | mutex_lock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 332 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 333 | while (QTAILQ_EMPTY(&request_list) && |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 334 | !(ret == ETIMEDOUT)) { |
Kevin Wolf | 5be4aab | 2011-05-02 17:32:54 +0200 | [diff] [blame] | 335 | idle_threads++; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 336 | ret = cond_timedwait(&cond, &lock, &ts); |
Kevin Wolf | 5be4aab | 2011-05-02 17:32:54 +0200 | [diff] [blame] | 337 | idle_threads--; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 340 | if (QTAILQ_EMPTY(&request_list)) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 341 | break; |
| 342 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 343 | aiocb = QTAILQ_FIRST(&request_list); |
| 344 | QTAILQ_REMOVE(&request_list, aiocb, node); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 345 | aiocb->active = 1; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 346 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 347 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 348 | switch (aiocb->aio_type & QEMU_AIO_TYPE_MASK) { |
| 349 | case QEMU_AIO_READ: |
Kevin Wolf | ba1d1af | 2011-07-25 19:42:37 +0200 | [diff] [blame] | 350 | ret = handle_aiocb_rw(aiocb); |
| 351 | if (ret >= 0 && ret < aiocb->aio_nbytes && aiocb->common.bs->growable) { |
| 352 | /* A short read means that we have reached EOF. Pad the buffer |
| 353 | * with zeros for bytes after EOF. */ |
| 354 | QEMUIOVector qiov; |
| 355 | |
| 356 | qemu_iovec_init_external(&qiov, aiocb->aio_iov, |
| 357 | aiocb->aio_niov); |
| 358 | qemu_iovec_memset_skip(&qiov, 0, aiocb->aio_nbytes - ret, ret); |
| 359 | |
| 360 | ret = aiocb->aio_nbytes; |
| 361 | } |
| 362 | break; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 363 | case QEMU_AIO_WRITE: |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 364 | ret = handle_aiocb_rw(aiocb); |
| 365 | break; |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 366 | case QEMU_AIO_FLUSH: |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 367 | ret = handle_aiocb_flush(aiocb); |
| 368 | break; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 369 | case QEMU_AIO_IOCTL: |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 370 | ret = handle_aiocb_ioctl(aiocb); |
| 371 | break; |
| 372 | default: |
| 373 | fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type); |
| 374 | ret = -EINVAL; |
| 375 | break; |
| 376 | } |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 377 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 378 | mutex_lock(&lock); |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 379 | aiocb->ret = ret; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 380 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 381 | |
Frediano Ziglio | e1d3b25 | 2011-09-19 16:37:13 +0200 | [diff] [blame] | 382 | posix_aio_notify_event(); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 383 | } |
| 384 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 385 | cur_threads--; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 386 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 387 | |
| 388 | return NULL; |
| 389 | } |
| 390 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame] | 391 | static void do_spawn_thread(void) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 392 | { |
malc | ee39930 | 2009-09-25 00:20:44 +0400 | [diff] [blame] | 393 | sigset_t set, oldset; |
| 394 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame] | 395 | mutex_lock(&lock); |
| 396 | if (!new_threads) { |
| 397 | mutex_unlock(&lock); |
| 398 | return; |
| 399 | } |
| 400 | |
| 401 | new_threads--; |
| 402 | pending_threads++; |
| 403 | |
| 404 | mutex_unlock(&lock); |
malc | ee39930 | 2009-09-25 00:20:44 +0400 | [diff] [blame] | 405 | |
| 406 | /* block all signals */ |
| 407 | if (sigfillset(&set)) die("sigfillset"); |
| 408 | if (sigprocmask(SIG_SETMASK, &set, &oldset)) die("sigprocmask"); |
| 409 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 410 | thread_create(&thread_id, &attr, aio_thread, NULL); |
malc | ee39930 | 2009-09-25 00:20:44 +0400 | [diff] [blame] | 411 | |
| 412 | if (sigprocmask(SIG_SETMASK, &oldset, NULL)) die("sigprocmask restore"); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame] | 415 | static void spawn_thread_bh_fn(void *opaque) |
| 416 | { |
| 417 | do_spawn_thread(); |
| 418 | } |
| 419 | |
| 420 | static void spawn_thread(void) |
| 421 | { |
| 422 | cur_threads++; |
| 423 | new_threads++; |
| 424 | /* If there are threads being created, they will spawn new workers, so |
| 425 | * we don't spend time creating many threads in a loop holding a mutex or |
| 426 | * starving the current vcpu. |
| 427 | * |
| 428 | * If there are no idle threads, ask the main thread to create one, so we |
| 429 | * inherit the correct affinity instead of the vcpu affinity. |
| 430 | */ |
| 431 | if (!pending_threads) { |
| 432 | qemu_bh_schedule(new_thread_bh); |
| 433 | } |
| 434 | } |
| 435 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 436 | static void qemu_paio_submit(struct qemu_paiocb *aiocb) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 437 | { |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 438 | aiocb->ret = -EINPROGRESS; |
| 439 | aiocb->active = 0; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 440 | mutex_lock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 441 | if (idle_threads == 0 && cur_threads < max_threads) |
| 442 | spawn_thread(); |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 443 | QTAILQ_INSERT_TAIL(&request_list, aiocb, node); |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 444 | mutex_unlock(&lock); |
malc | 5d47e37 | 2009-02-21 05:48:15 +0000 | [diff] [blame] | 445 | cond_signal(&cond); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 446 | } |
| 447 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 448 | static ssize_t qemu_paio_return(struct qemu_paiocb *aiocb) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 449 | { |
| 450 | ssize_t ret; |
| 451 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 452 | mutex_lock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 453 | ret = aiocb->ret; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 454 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 455 | |
| 456 | return ret; |
| 457 | } |
| 458 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 459 | static int qemu_paio_error(struct qemu_paiocb *aiocb) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 460 | { |
| 461 | ssize_t ret = qemu_paio_return(aiocb); |
| 462 | |
| 463 | if (ret < 0) |
| 464 | ret = -ret; |
| 465 | else |
| 466 | ret = 0; |
| 467 | |
| 468 | return ret; |
| 469 | } |
| 470 | |
Paolo Bonzini | adfe92f | 2012-04-12 14:00:53 +0200 | [diff] [blame] | 471 | static void posix_aio_read(void *opaque) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 472 | { |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 473 | PosixAioState *s = opaque; |
| 474 | struct qemu_paiocb *acb, **pacb; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 475 | int ret; |
Paolo Bonzini | adfe92f | 2012-04-12 14:00:53 +0200 | [diff] [blame] | 476 | ssize_t len; |
| 477 | |
| 478 | /* read all bytes from signal pipe */ |
| 479 | for (;;) { |
| 480 | char bytes[16]; |
| 481 | |
| 482 | len = read(s->rfd, bytes, sizeof(bytes)); |
| 483 | if (len == -1 && errno == EINTR) |
| 484 | continue; /* try again */ |
| 485 | if (len == sizeof(bytes)) |
| 486 | continue; /* more to read */ |
| 487 | break; |
| 488 | } |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 489 | |
| 490 | for(;;) { |
| 491 | pacb = &s->first_aio; |
| 492 | for(;;) { |
| 493 | acb = *pacb; |
| 494 | if (!acb) |
Paolo Bonzini | adfe92f | 2012-04-12 14:00:53 +0200 | [diff] [blame] | 495 | return; |
Kevin Wolf | e5f3764 | 2009-10-22 17:54:40 +0200 | [diff] [blame] | 496 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 497 | ret = qemu_paio_error(acb); |
| 498 | if (ret == ECANCELED) { |
| 499 | /* remove the request */ |
| 500 | *pacb = acb->next; |
| 501 | qemu_aio_release(acb); |
| 502 | } else if (ret != EINPROGRESS) { |
| 503 | /* end of aio */ |
| 504 | if (ret == 0) { |
| 505 | ret = qemu_paio_return(acb); |
| 506 | if (ret == acb->aio_nbytes) |
| 507 | ret = 0; |
| 508 | else |
| 509 | ret = -EINVAL; |
| 510 | } else { |
| 511 | ret = -ret; |
| 512 | } |
Stefan Hajnoczi | ddca9fb | 2011-03-07 08:06:10 +0000 | [diff] [blame] | 513 | |
| 514 | trace_paio_complete(acb, acb->common.opaque, ret); |
| 515 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 516 | /* remove the request */ |
| 517 | *pacb = acb->next; |
| 518 | /* call the callback */ |
| 519 | acb->common.cb(acb->common.opaque, ret); |
| 520 | qemu_aio_release(acb); |
| 521 | break; |
| 522 | } else { |
| 523 | pacb = &acb->next; |
| 524 | } |
| 525 | } |
| 526 | } |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | static int posix_aio_flush(void *opaque) |
| 530 | { |
| 531 | PosixAioState *s = opaque; |
| 532 | return !!s->first_aio; |
| 533 | } |
| 534 | |
| 535 | static PosixAioState *posix_aio_state; |
| 536 | |
Frediano Ziglio | e1d3b25 | 2011-09-19 16:37:13 +0200 | [diff] [blame] | 537 | static void posix_aio_notify_event(void) |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 538 | { |
Frediano Ziglio | e1d3b25 | 2011-09-19 16:37:13 +0200 | [diff] [blame] | 539 | char byte = 0; |
| 540 | ssize_t ret; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 541 | |
Frediano Ziglio | e1d3b25 | 2011-09-19 16:37:13 +0200 | [diff] [blame] | 542 | ret = write(posix_aio_state->wfd, &byte, sizeof(byte)); |
| 543 | if (ret < 0 && errno != EAGAIN) |
| 544 | die("write()"); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | static void paio_remove(struct qemu_paiocb *acb) |
| 548 | { |
| 549 | struct qemu_paiocb **pacb; |
| 550 | |
| 551 | /* remove the callback from the queue */ |
| 552 | pacb = &posix_aio_state->first_aio; |
| 553 | for(;;) { |
| 554 | if (*pacb == NULL) { |
| 555 | fprintf(stderr, "paio_remove: aio request not found!\n"); |
| 556 | break; |
| 557 | } else if (*pacb == acb) { |
| 558 | *pacb = acb->next; |
| 559 | qemu_aio_release(acb); |
| 560 | break; |
| 561 | } |
| 562 | pacb = &(*pacb)->next; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | static void paio_cancel(BlockDriverAIOCB *blockacb) |
| 567 | { |
| 568 | struct qemu_paiocb *acb = (struct qemu_paiocb *)blockacb; |
| 569 | int active = 0; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 570 | |
Stefan Hajnoczi | ddca9fb | 2011-03-07 08:06:10 +0000 | [diff] [blame] | 571 | trace_paio_cancel(acb, acb->common.opaque); |
| 572 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 573 | mutex_lock(&lock); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 574 | if (!acb->active) { |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 575 | QTAILQ_REMOVE(&request_list, acb, node); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 576 | acb->ret = -ECANCELED; |
| 577 | } else if (acb->ret == -EINPROGRESS) { |
| 578 | active = 1; |
| 579 | } |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 580 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 581 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 582 | if (active) { |
| 583 | /* fail safe: if the aio could not be canceled, we wait for |
| 584 | it */ |
| 585 | while (qemu_paio_error(acb) == EINPROGRESS) |
| 586 | ; |
| 587 | } |
| 588 | |
| 589 | paio_remove(acb); |
| 590 | } |
| 591 | |
| 592 | static AIOPool raw_aio_pool = { |
| 593 | .aiocb_size = sizeof(struct qemu_paiocb), |
| 594 | .cancel = paio_cancel, |
| 595 | }; |
| 596 | |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 597 | BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd, |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 598 | int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, |
| 599 | BlockDriverCompletionFunc *cb, void *opaque, int type) |
| 600 | { |
| 601 | struct qemu_paiocb *acb; |
| 602 | |
| 603 | acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 604 | acb->aio_type = type; |
| 605 | acb->aio_fildes = fd; |
Kevin Wolf | e5f3764 | 2009-10-22 17:54:40 +0200 | [diff] [blame] | 606 | |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 607 | if (qiov) { |
| 608 | acb->aio_iov = qiov->iov; |
| 609 | acb->aio_niov = qiov->niov; |
| 610 | } |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 611 | acb->aio_nbytes = nb_sectors * 512; |
| 612 | acb->aio_offset = sector_num * 512; |
| 613 | |
| 614 | acb->next = posix_aio_state->first_aio; |
| 615 | posix_aio_state->first_aio = acb; |
| 616 | |
Stefan Hajnoczi | 6d519a5 | 2010-05-22 18:15:08 +0100 | [diff] [blame] | 617 | trace_paio_submit(acb, opaque, sector_num, nb_sectors, type); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 618 | qemu_paio_submit(acb); |
| 619 | return &acb->common; |
| 620 | } |
| 621 | |
| 622 | BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, |
| 623 | unsigned long int req, void *buf, |
| 624 | BlockDriverCompletionFunc *cb, void *opaque) |
| 625 | { |
| 626 | struct qemu_paiocb *acb; |
| 627 | |
| 628 | acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 629 | acb->aio_type = QEMU_AIO_IOCTL; |
| 630 | acb->aio_fildes = fd; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 631 | acb->aio_offset = 0; |
| 632 | acb->aio_ioctl_buf = buf; |
| 633 | acb->aio_ioctl_cmd = req; |
| 634 | |
| 635 | acb->next = posix_aio_state->first_aio; |
| 636 | posix_aio_state->first_aio = acb; |
| 637 | |
| 638 | qemu_paio_submit(acb); |
| 639 | return &acb->common; |
| 640 | } |
| 641 | |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 642 | int paio_init(void) |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 643 | { |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 644 | PosixAioState *s; |
| 645 | int fds[2]; |
| 646 | int ret; |
| 647 | |
| 648 | if (posix_aio_state) |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 649 | return 0; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 650 | |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 651 | s = g_malloc(sizeof(PosixAioState)); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 652 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 653 | s->first_aio = NULL; |
Kevin Wolf | 40ff6d7 | 2009-12-02 12:24:42 +0100 | [diff] [blame] | 654 | if (qemu_pipe(fds) == -1) { |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 655 | fprintf(stderr, "failed to create pipe\n"); |
Markus Armbruster | 095ed5b | 2011-11-11 10:40:08 +0100 | [diff] [blame] | 656 | g_free(s); |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 657 | return -1; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | s->rfd = fds[0]; |
| 661 | s->wfd = fds[1]; |
| 662 | |
| 663 | fcntl(s->rfd, F_SETFL, O_NONBLOCK); |
| 664 | fcntl(s->wfd, F_SETFL, O_NONBLOCK); |
| 665 | |
Paolo Bonzini | bafbd6a | 2012-04-12 14:00:54 +0200 | [diff] [blame] | 666 | qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 667 | |
| 668 | ret = pthread_attr_init(&attr); |
| 669 | if (ret) |
| 670 | die2(ret, "pthread_attr_init"); |
| 671 | |
| 672 | ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| 673 | if (ret) |
| 674 | die2(ret, "pthread_attr_setdetachstate"); |
| 675 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 676 | QTAILQ_INIT(&request_list); |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame] | 677 | new_thread_bh = qemu_bh_new(spawn_thread_bh_fn, NULL); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 678 | |
| 679 | posix_aio_state = s; |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 680 | return 0; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 681 | } |