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 | * |
| 12 | */ |
| 13 | |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 14 | #include <sys/ioctl.h> |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 15 | #include <sys/types.h> |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 16 | #include <pthread.h> |
| 17 | #include <unistd.h> |
| 18 | #include <errno.h> |
malc | 30525af | 2009-02-21 05:48:13 +0000 | [diff] [blame] | 19 | #include <time.h> |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 20 | #include <string.h> |
| 21 | #include <stdlib.h> |
| 22 | #include <stdio.h> |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 23 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 24 | #include "qemu-queue.h" |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 25 | #include "osdep.h" |
Jes Sorensen | dc786bc | 2010-10-26 10:39:23 +0200 | [diff] [blame] | 26 | #include "sysemu.h" |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 27 | #include "qemu-common.h" |
Stefan Hajnoczi | 6d519a5 | 2010-05-22 18:15:08 +0100 | [diff] [blame] | 28 | #include "trace.h" |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 29 | #include "block_int.h" |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 30 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 31 | #include "block/raw-posix-aio.h" |
| 32 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame^] | 33 | static void do_spawn_thread(void); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 34 | |
| 35 | struct qemu_paiocb { |
| 36 | BlockDriverAIOCB common; |
| 37 | int aio_fildes; |
| 38 | union { |
| 39 | struct iovec *aio_iov; |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 40 | void *aio_ioctl_buf; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 41 | }; |
| 42 | int aio_niov; |
| 43 | size_t aio_nbytes; |
| 44 | #define aio_ioctl_cmd aio_nbytes /* for QEMU_AIO_IOCTL */ |
| 45 | int ev_signo; |
| 46 | off_t aio_offset; |
| 47 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 48 | QTAILQ_ENTRY(qemu_paiocb) node; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 49 | int aio_type; |
| 50 | ssize_t ret; |
| 51 | int active; |
| 52 | struct qemu_paiocb *next; |
| 53 | }; |
| 54 | |
| 55 | typedef struct PosixAioState { |
| 56 | int rfd, wfd; |
| 57 | struct qemu_paiocb *first_aio; |
| 58 | } PosixAioState; |
| 59 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 60 | |
| 61 | static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; |
| 62 | static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
| 63 | static pthread_t thread_id; |
malc | a8227a5 | 2009-02-21 05:48:17 +0000 | [diff] [blame] | 64 | static pthread_attr_t attr; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 65 | static int max_threads = 64; |
| 66 | static int cur_threads = 0; |
| 67 | static int idle_threads = 0; |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame^] | 68 | static int new_threads = 0; /* backlog of threads we need to create */ |
| 69 | static int pending_threads = 0; /* threads created but not running yet */ |
| 70 | static QEMUBH *new_thread_bh; |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 71 | static QTAILQ_HEAD(, qemu_paiocb) request_list; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 72 | |
Juan Quintela | 2341f9a | 2009-07-27 16:12:58 +0200 | [diff] [blame] | 73 | #ifdef CONFIG_PREADV |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 74 | static int preadv_present = 1; |
| 75 | #else |
| 76 | static int preadv_present = 0; |
| 77 | #endif |
| 78 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 79 | static void die2(int err, const char *what) |
| 80 | { |
| 81 | fprintf(stderr, "%s failed: %s\n", what, strerror(err)); |
| 82 | abort(); |
| 83 | } |
| 84 | |
| 85 | static void die(const char *what) |
| 86 | { |
| 87 | die2(errno, what); |
| 88 | } |
| 89 | |
| 90 | static void mutex_lock(pthread_mutex_t *mutex) |
| 91 | { |
| 92 | int ret = pthread_mutex_lock(mutex); |
| 93 | if (ret) die2(ret, "pthread_mutex_lock"); |
| 94 | } |
| 95 | |
| 96 | static void mutex_unlock(pthread_mutex_t *mutex) |
| 97 | { |
| 98 | int ret = pthread_mutex_unlock(mutex); |
| 99 | if (ret) die2(ret, "pthread_mutex_unlock"); |
| 100 | } |
| 101 | |
| 102 | static int cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, |
| 103 | struct timespec *ts) |
| 104 | { |
| 105 | int ret = pthread_cond_timedwait(cond, mutex, ts); |
| 106 | if (ret && ret != ETIMEDOUT) die2(ret, "pthread_cond_timedwait"); |
| 107 | return ret; |
| 108 | } |
| 109 | |
malc | 5d47e37 | 2009-02-21 05:48:15 +0000 | [diff] [blame] | 110 | static void cond_signal(pthread_cond_t *cond) |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 111 | { |
malc | 5d47e37 | 2009-02-21 05:48:15 +0000 | [diff] [blame] | 112 | int ret = pthread_cond_signal(cond); |
| 113 | if (ret) die2(ret, "pthread_cond_signal"); |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static void thread_create(pthread_t *thread, pthread_attr_t *attr, |
| 117 | void *(*start_routine)(void*), void *arg) |
| 118 | { |
| 119 | int ret = pthread_create(thread, attr, start_routine, arg); |
| 120 | if (ret) die2(ret, "pthread_create"); |
| 121 | } |
| 122 | |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 123 | static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb) |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 124 | { |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 125 | int ret; |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 126 | |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 127 | ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf); |
| 128 | if (ret == -1) |
| 129 | return -errno; |
Christoph Hellwig | e7d54ae | 2009-04-28 11:57:02 +0200 | [diff] [blame] | 130 | |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 131 | /* |
| 132 | * This looks weird, but the aio code only consideres a request |
Stefan Weil | b0cd712 | 2010-08-06 21:53:45 +0200 | [diff] [blame] | 133 | * successful if it has written the number full number of bytes. |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 134 | * |
| 135 | * Now we overload aio_nbytes as aio_ioctl_cmd for the ioctl command, |
| 136 | * so in fact we return the ioctl command here to make posix_aio_read() |
| 137 | * happy.. |
| 138 | */ |
| 139 | return aiocb->aio_nbytes; |
aliguori | f141eaf | 2009-04-07 18:43:24 +0000 | [diff] [blame] | 140 | } |
| 141 | |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 142 | static ssize_t handle_aiocb_flush(struct qemu_paiocb *aiocb) |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 143 | { |
| 144 | int ret; |
| 145 | |
Blue Swirl | 47faadc | 2009-09-12 06:19:14 +0000 | [diff] [blame] | 146 | ret = qemu_fdatasync(aiocb->aio_fildes); |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 147 | if (ret == -1) |
| 148 | return -errno; |
| 149 | return 0; |
| 150 | } |
| 151 | |
Juan Quintela | 2341f9a | 2009-07-27 16:12:58 +0200 | [diff] [blame] | 152 | #ifdef CONFIG_PREADV |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 153 | |
| 154 | static ssize_t |
| 155 | qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 156 | { |
| 157 | return preadv(fd, iov, nr_iov, offset); |
| 158 | } |
| 159 | |
| 160 | static ssize_t |
| 161 | qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 162 | { |
| 163 | return pwritev(fd, iov, nr_iov, offset); |
| 164 | } |
| 165 | |
| 166 | #else |
| 167 | |
| 168 | static ssize_t |
| 169 | qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 170 | { |
| 171 | return -ENOSYS; |
| 172 | } |
| 173 | |
| 174 | static ssize_t |
| 175 | qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) |
| 176 | { |
| 177 | return -ENOSYS; |
| 178 | } |
| 179 | |
| 180 | #endif |
| 181 | |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 182 | static ssize_t handle_aiocb_rw_vector(struct qemu_paiocb *aiocb) |
aliguori | ceb42de | 2009-04-07 18:43:28 +0000 | [diff] [blame] | 183 | { |
| 184 | size_t offset = 0; |
| 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, |
| 192 | aiocb->aio_offset + offset); |
| 193 | else |
| 194 | len = qemu_preadv(aiocb->aio_fildes, |
| 195 | aiocb->aio_iov, |
| 196 | aiocb->aio_niov, |
| 197 | aiocb->aio_offset + offset); |
| 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 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 312 | static void *aio_thread(void *unused) |
| 313 | { |
malc | a8227a5 | 2009-02-21 05:48:17 +0000 | [diff] [blame] | 314 | pid_t pid; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 315 | |
malc | a8227a5 | 2009-02-21 05:48:17 +0000 | [diff] [blame] | 316 | pid = getpid(); |
| 317 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame^] | 318 | mutex_lock(&lock); |
| 319 | pending_threads--; |
| 320 | mutex_unlock(&lock); |
| 321 | do_spawn_thread(); |
| 322 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 323 | while (1) { |
| 324 | struct qemu_paiocb *aiocb; |
Kevin Wolf | 6769da2 | 2009-11-18 12:15:10 +0100 | [diff] [blame] | 325 | ssize_t ret = 0; |
malc | 30525af | 2009-02-21 05:48:13 +0000 | [diff] [blame] | 326 | qemu_timeval tv; |
| 327 | struct timespec ts; |
| 328 | |
| 329 | qemu_gettimeofday(&tv); |
| 330 | ts.tv_sec = tv.tv_sec + 10; |
| 331 | ts.tv_nsec = 0; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 332 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 333 | mutex_lock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 334 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 335 | while (QTAILQ_EMPTY(&request_list) && |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 336 | !(ret == ETIMEDOUT)) { |
Kevin Wolf | 5be4aab | 2011-05-02 17:32:54 +0200 | [diff] [blame] | 337 | idle_threads++; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 338 | ret = cond_timedwait(&cond, &lock, &ts); |
Kevin Wolf | 5be4aab | 2011-05-02 17:32:54 +0200 | [diff] [blame] | 339 | idle_threads--; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 340 | } |
| 341 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 342 | if (QTAILQ_EMPTY(&request_list)) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 343 | break; |
| 344 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 345 | aiocb = QTAILQ_FIRST(&request_list); |
| 346 | QTAILQ_REMOVE(&request_list, aiocb, node); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 347 | aiocb->active = 1; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 348 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 349 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 350 | switch (aiocb->aio_type & QEMU_AIO_TYPE_MASK) { |
| 351 | case QEMU_AIO_READ: |
Kevin Wolf | ba1d1af | 2011-07-25 19:42:37 +0200 | [diff] [blame] | 352 | ret = handle_aiocb_rw(aiocb); |
| 353 | if (ret >= 0 && ret < aiocb->aio_nbytes && aiocb->common.bs->growable) { |
| 354 | /* A short read means that we have reached EOF. Pad the buffer |
| 355 | * with zeros for bytes after EOF. */ |
| 356 | QEMUIOVector qiov; |
| 357 | |
| 358 | qemu_iovec_init_external(&qiov, aiocb->aio_iov, |
| 359 | aiocb->aio_niov); |
| 360 | qemu_iovec_memset_skip(&qiov, 0, aiocb->aio_nbytes - ret, ret); |
| 361 | |
| 362 | ret = aiocb->aio_nbytes; |
| 363 | } |
| 364 | break; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 365 | case QEMU_AIO_WRITE: |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 366 | ret = handle_aiocb_rw(aiocb); |
| 367 | break; |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 368 | case QEMU_AIO_FLUSH: |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 369 | ret = handle_aiocb_flush(aiocb); |
| 370 | break; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 371 | case QEMU_AIO_IOCTL: |
Stefan Hajnoczi | b587a52 | 2010-05-27 12:52:08 +0100 | [diff] [blame] | 372 | ret = handle_aiocb_ioctl(aiocb); |
| 373 | break; |
| 374 | default: |
| 375 | fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type); |
| 376 | ret = -EINVAL; |
| 377 | break; |
| 378 | } |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 379 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 380 | mutex_lock(&lock); |
aliguori | 221f715 | 2009-03-28 17:28:41 +0000 | [diff] [blame] | 381 | aiocb->ret = ret; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 382 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 383 | |
malc | a8227a5 | 2009-02-21 05:48:17 +0000 | [diff] [blame] | 384 | if (kill(pid, aiocb->ev_signo)) die("kill failed"); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 385 | } |
| 386 | |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 387 | cur_threads--; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 388 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 389 | |
| 390 | return NULL; |
| 391 | } |
| 392 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame^] | 393 | static void do_spawn_thread(void) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 394 | { |
malc | ee39930 | 2009-09-25 00:20:44 +0400 | [diff] [blame] | 395 | sigset_t set, oldset; |
| 396 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame^] | 397 | mutex_lock(&lock); |
| 398 | if (!new_threads) { |
| 399 | mutex_unlock(&lock); |
| 400 | return; |
| 401 | } |
| 402 | |
| 403 | new_threads--; |
| 404 | pending_threads++; |
| 405 | |
| 406 | mutex_unlock(&lock); |
malc | ee39930 | 2009-09-25 00:20:44 +0400 | [diff] [blame] | 407 | |
| 408 | /* block all signals */ |
| 409 | if (sigfillset(&set)) die("sigfillset"); |
| 410 | if (sigprocmask(SIG_SETMASK, &set, &oldset)) die("sigprocmask"); |
| 411 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 412 | thread_create(&thread_id, &attr, aio_thread, NULL); |
malc | ee39930 | 2009-09-25 00:20:44 +0400 | [diff] [blame] | 413 | |
| 414 | if (sigprocmask(SIG_SETMASK, &oldset, NULL)) die("sigprocmask restore"); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 415 | } |
| 416 | |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame^] | 417 | static void spawn_thread_bh_fn(void *opaque) |
| 418 | { |
| 419 | do_spawn_thread(); |
| 420 | } |
| 421 | |
| 422 | static void spawn_thread(void) |
| 423 | { |
| 424 | cur_threads++; |
| 425 | new_threads++; |
| 426 | /* If there are threads being created, they will spawn new workers, so |
| 427 | * we don't spend time creating many threads in a loop holding a mutex or |
| 428 | * starving the current vcpu. |
| 429 | * |
| 430 | * If there are no idle threads, ask the main thread to create one, so we |
| 431 | * inherit the correct affinity instead of the vcpu affinity. |
| 432 | */ |
| 433 | if (!pending_threads) { |
| 434 | qemu_bh_schedule(new_thread_bh); |
| 435 | } |
| 436 | } |
| 437 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 438 | static void qemu_paio_submit(struct qemu_paiocb *aiocb) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 439 | { |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 440 | aiocb->ret = -EINPROGRESS; |
| 441 | aiocb->active = 0; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 442 | mutex_lock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 443 | if (idle_threads == 0 && cur_threads < max_threads) |
| 444 | spawn_thread(); |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 445 | QTAILQ_INSERT_TAIL(&request_list, aiocb, node); |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 446 | mutex_unlock(&lock); |
malc | 5d47e37 | 2009-02-21 05:48:15 +0000 | [diff] [blame] | 447 | cond_signal(&cond); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 450 | static ssize_t qemu_paio_return(struct qemu_paiocb *aiocb) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 451 | { |
| 452 | ssize_t ret; |
| 453 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 454 | mutex_lock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 455 | ret = aiocb->ret; |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 456 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 457 | |
| 458 | return ret; |
| 459 | } |
| 460 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 461 | static int qemu_paio_error(struct qemu_paiocb *aiocb) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 462 | { |
| 463 | ssize_t ret = qemu_paio_return(aiocb); |
| 464 | |
| 465 | if (ret < 0) |
| 466 | ret = -ret; |
| 467 | else |
| 468 | ret = 0; |
| 469 | |
| 470 | return ret; |
| 471 | } |
| 472 | |
Kevin Wolf | 59c7b15 | 2009-10-22 17:54:35 +0200 | [diff] [blame] | 473 | static int posix_aio_process_queue(void *opaque) |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 474 | { |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 475 | PosixAioState *s = opaque; |
| 476 | struct qemu_paiocb *acb, **pacb; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 477 | int ret; |
Kevin Wolf | 59c7b15 | 2009-10-22 17:54:35 +0200 | [diff] [blame] | 478 | int result = 0; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 479 | |
| 480 | for(;;) { |
| 481 | pacb = &s->first_aio; |
| 482 | for(;;) { |
| 483 | acb = *pacb; |
| 484 | if (!acb) |
Kevin Wolf | 59c7b15 | 2009-10-22 17:54:35 +0200 | [diff] [blame] | 485 | return result; |
Kevin Wolf | e5f3764 | 2009-10-22 17:54:40 +0200 | [diff] [blame] | 486 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 487 | ret = qemu_paio_error(acb); |
| 488 | if (ret == ECANCELED) { |
| 489 | /* remove the request */ |
| 490 | *pacb = acb->next; |
| 491 | qemu_aio_release(acb); |
Kevin Wolf | 59c7b15 | 2009-10-22 17:54:35 +0200 | [diff] [blame] | 492 | result = 1; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 493 | } else if (ret != EINPROGRESS) { |
| 494 | /* end of aio */ |
| 495 | if (ret == 0) { |
| 496 | ret = qemu_paio_return(acb); |
| 497 | if (ret == acb->aio_nbytes) |
| 498 | ret = 0; |
| 499 | else |
| 500 | ret = -EINVAL; |
| 501 | } else { |
| 502 | ret = -ret; |
| 503 | } |
Stefan Hajnoczi | ddca9fb | 2011-03-07 08:06:10 +0000 | [diff] [blame] | 504 | |
| 505 | trace_paio_complete(acb, acb->common.opaque, ret); |
| 506 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 507 | /* remove the request */ |
| 508 | *pacb = acb->next; |
| 509 | /* call the callback */ |
| 510 | acb->common.cb(acb->common.opaque, ret); |
| 511 | qemu_aio_release(acb); |
Kevin Wolf | 59c7b15 | 2009-10-22 17:54:35 +0200 | [diff] [blame] | 512 | result = 1; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 513 | break; |
| 514 | } else { |
| 515 | pacb = &acb->next; |
| 516 | } |
| 517 | } |
| 518 | } |
Kevin Wolf | 59c7b15 | 2009-10-22 17:54:35 +0200 | [diff] [blame] | 519 | |
| 520 | return result; |
| 521 | } |
| 522 | |
| 523 | static void posix_aio_read(void *opaque) |
| 524 | { |
| 525 | PosixAioState *s = opaque; |
| 526 | ssize_t len; |
| 527 | |
| 528 | /* read all bytes from signal pipe */ |
| 529 | for (;;) { |
| 530 | char bytes[16]; |
| 531 | |
| 532 | len = read(s->rfd, bytes, sizeof(bytes)); |
| 533 | if (len == -1 && errno == EINTR) |
| 534 | continue; /* try again */ |
| 535 | if (len == sizeof(bytes)) |
| 536 | continue; /* more to read */ |
| 537 | break; |
| 538 | } |
| 539 | |
| 540 | posix_aio_process_queue(s); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | static int posix_aio_flush(void *opaque) |
| 544 | { |
| 545 | PosixAioState *s = opaque; |
| 546 | return !!s->first_aio; |
| 547 | } |
| 548 | |
| 549 | static PosixAioState *posix_aio_state; |
| 550 | |
| 551 | static void aio_signal_handler(int signum) |
| 552 | { |
| 553 | if (posix_aio_state) { |
| 554 | char byte = 0; |
Kirill A. Shutemov | 4817d32 | 2010-01-20 00:56:10 +0100 | [diff] [blame] | 555 | ssize_t ret; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 556 | |
Kirill A. Shutemov | 4817d32 | 2010-01-20 00:56:10 +0100 | [diff] [blame] | 557 | ret = write(posix_aio_state->wfd, &byte, sizeof(byte)); |
| 558 | if (ret < 0 && errno != EAGAIN) |
| 559 | die("write()"); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | qemu_service_io(); |
| 563 | } |
| 564 | |
| 565 | static void paio_remove(struct qemu_paiocb *acb) |
| 566 | { |
| 567 | struct qemu_paiocb **pacb; |
| 568 | |
| 569 | /* remove the callback from the queue */ |
| 570 | pacb = &posix_aio_state->first_aio; |
| 571 | for(;;) { |
| 572 | if (*pacb == NULL) { |
| 573 | fprintf(stderr, "paio_remove: aio request not found!\n"); |
| 574 | break; |
| 575 | } else if (*pacb == acb) { |
| 576 | *pacb = acb->next; |
| 577 | qemu_aio_release(acb); |
| 578 | break; |
| 579 | } |
| 580 | pacb = &(*pacb)->next; |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | static void paio_cancel(BlockDriverAIOCB *blockacb) |
| 585 | { |
| 586 | struct qemu_paiocb *acb = (struct qemu_paiocb *)blockacb; |
| 587 | int active = 0; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 588 | |
Stefan Hajnoczi | ddca9fb | 2011-03-07 08:06:10 +0000 | [diff] [blame] | 589 | trace_paio_cancel(acb, acb->common.opaque); |
| 590 | |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 591 | mutex_lock(&lock); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 592 | if (!acb->active) { |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 593 | QTAILQ_REMOVE(&request_list, acb, node); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 594 | acb->ret = -ECANCELED; |
| 595 | } else if (acb->ret == -EINPROGRESS) { |
| 596 | active = 1; |
| 597 | } |
malc | 8653c01 | 2009-02-21 05:48:11 +0000 | [diff] [blame] | 598 | mutex_unlock(&lock); |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 599 | |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 600 | if (active) { |
| 601 | /* fail safe: if the aio could not be canceled, we wait for |
| 602 | it */ |
| 603 | while (qemu_paio_error(acb) == EINPROGRESS) |
| 604 | ; |
| 605 | } |
| 606 | |
| 607 | paio_remove(acb); |
| 608 | } |
| 609 | |
| 610 | static AIOPool raw_aio_pool = { |
| 611 | .aiocb_size = sizeof(struct qemu_paiocb), |
| 612 | .cancel = paio_cancel, |
| 613 | }; |
| 614 | |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 615 | BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd, |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 616 | int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, |
| 617 | BlockDriverCompletionFunc *cb, void *opaque, int type) |
| 618 | { |
| 619 | struct qemu_paiocb *acb; |
| 620 | |
| 621 | acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque); |
| 622 | if (!acb) |
| 623 | return NULL; |
| 624 | acb->aio_type = type; |
| 625 | acb->aio_fildes = fd; |
| 626 | acb->ev_signo = SIGUSR2; |
Kevin Wolf | e5f3764 | 2009-10-22 17:54:40 +0200 | [diff] [blame] | 627 | |
Christoph Hellwig | b2e12bc | 2009-09-04 19:01:49 +0200 | [diff] [blame] | 628 | if (qiov) { |
| 629 | acb->aio_iov = qiov->iov; |
| 630 | acb->aio_niov = qiov->niov; |
| 631 | } |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 632 | acb->aio_nbytes = nb_sectors * 512; |
| 633 | acb->aio_offset = sector_num * 512; |
| 634 | |
| 635 | acb->next = posix_aio_state->first_aio; |
| 636 | posix_aio_state->first_aio = acb; |
| 637 | |
Stefan Hajnoczi | 6d519a5 | 2010-05-22 18:15:08 +0100 | [diff] [blame] | 638 | trace_paio_submit(acb, opaque, sector_num, nb_sectors, type); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 639 | qemu_paio_submit(acb); |
| 640 | return &acb->common; |
| 641 | } |
| 642 | |
| 643 | BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, |
| 644 | unsigned long int req, void *buf, |
| 645 | BlockDriverCompletionFunc *cb, void *opaque) |
| 646 | { |
| 647 | struct qemu_paiocb *acb; |
| 648 | |
| 649 | acb = qemu_aio_get(&raw_aio_pool, bs, cb, opaque); |
| 650 | if (!acb) |
| 651 | return NULL; |
| 652 | acb->aio_type = QEMU_AIO_IOCTL; |
| 653 | acb->aio_fildes = fd; |
| 654 | acb->ev_signo = SIGUSR2; |
| 655 | acb->aio_offset = 0; |
| 656 | acb->aio_ioctl_buf = buf; |
| 657 | acb->aio_ioctl_cmd = req; |
| 658 | |
| 659 | acb->next = posix_aio_state->first_aio; |
| 660 | posix_aio_state->first_aio = acb; |
| 661 | |
| 662 | qemu_paio_submit(acb); |
| 663 | return &acb->common; |
| 664 | } |
| 665 | |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 666 | int paio_init(void) |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 667 | { |
| 668 | struct sigaction act; |
| 669 | PosixAioState *s; |
| 670 | int fds[2]; |
| 671 | int ret; |
| 672 | |
| 673 | if (posix_aio_state) |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 674 | return 0; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 675 | |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 676 | s = g_malloc(sizeof(PosixAioState)); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 677 | |
| 678 | sigfillset(&act.sa_mask); |
| 679 | act.sa_flags = 0; /* do not restart syscalls to interrupt select() */ |
| 680 | act.sa_handler = aio_signal_handler; |
| 681 | sigaction(SIGUSR2, &act, NULL); |
| 682 | |
| 683 | s->first_aio = NULL; |
Kevin Wolf | 40ff6d7 | 2009-12-02 12:24:42 +0100 | [diff] [blame] | 684 | if (qemu_pipe(fds) == -1) { |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 685 | fprintf(stderr, "failed to create pipe\n"); |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 686 | return -1; |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | s->rfd = fds[0]; |
| 690 | s->wfd = fds[1]; |
| 691 | |
| 692 | fcntl(s->rfd, F_SETFL, O_NONBLOCK); |
| 693 | fcntl(s->wfd, F_SETFL, O_NONBLOCK); |
| 694 | |
Kevin Wolf | 8febfa2 | 2009-10-22 17:54:36 +0200 | [diff] [blame] | 695 | qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, |
| 696 | posix_aio_process_queue, s); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 697 | |
| 698 | ret = pthread_attr_init(&attr); |
| 699 | if (ret) |
| 700 | die2(ret, "pthread_attr_init"); |
| 701 | |
| 702 | ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| 703 | if (ret) |
| 704 | die2(ret, "pthread_attr_setdetachstate"); |
| 705 | |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 706 | QTAILQ_INIT(&request_list); |
Avi Kivity | e4ea78e | 2011-08-14 07:04:49 +0300 | [diff] [blame^] | 707 | new_thread_bh = qemu_bh_new(spawn_thread_bh_fn, NULL); |
Christoph Hellwig | 9ef91a6 | 2009-08-20 16:58:19 +0200 | [diff] [blame] | 708 | |
| 709 | posix_aio_state = s; |
Kevin Wolf | 1e5b9d2 | 2009-10-26 13:03:08 +0100 | [diff] [blame] | 710 | return 0; |
aliguori | 3c529d9 | 2008-12-12 16:41:40 +0000 | [diff] [blame] | 711 | } |