Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 1 | /* |
Jens Axboe | da751ca | 2007-03-14 10:59:33 +0100 | [diff] [blame] | 2 | * splice engine |
| 3 | * |
| 4 | * IO engine that transfers data by doing splices to/from pipes and |
| 5 | * the files. |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 6 | * |
| 7 | */ |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | #include <unistd.h> |
| 11 | #include <errno.h> |
| 12 | #include <assert.h> |
| 13 | #include <sys/poll.h> |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 14 | #include <sys/mman.h> |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 15 | |
| 16 | #include "../fio.h" |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 17 | |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 18 | #ifdef FIO_HAVE_SPLICE |
| 19 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 20 | struct spliceio_data { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 21 | int pipe[2]; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 22 | int vmsplice_to_user; |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 23 | int vmsplice_to_user_map; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 24 | }; |
| 25 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 26 | /* |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 27 | * vmsplice didn't use to support splicing to user space, this is the old |
| 28 | * variant of getting that job done. Doesn't make a lot of sense, but it |
| 29 | * uses splices to move data from the source into a pipe. |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 30 | */ |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 31 | static int fio_splice_read_old(struct thread_data *td, struct io_u *io_u) |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 32 | { |
| 33 | struct spliceio_data *sd = td->io_ops->data; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 34 | struct fio_file *f = io_u->file; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 35 | int ret, ret2, buflen; |
| 36 | off_t offset; |
| 37 | void *p; |
| 38 | |
| 39 | offset = io_u->offset; |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 40 | buflen = io_u->xfer_buflen; |
| 41 | p = io_u->xfer_buf; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 42 | while (buflen) { |
| 43 | int this_len = buflen; |
| 44 | |
| 45 | if (this_len > SPLICE_DEF_SIZE) |
| 46 | this_len = SPLICE_DEF_SIZE; |
| 47 | |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 48 | ret = splice(f->fd, &offset, sd->pipe[1], NULL, this_len, SPLICE_F_MORE); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 49 | if (ret < 0) { |
| 50 | if (errno == ENODATA || errno == EAGAIN) |
| 51 | continue; |
| 52 | |
Jens Axboe | b4ba5f3 | 2007-04-02 10:36:59 +0200 | [diff] [blame] | 53 | return -errno; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | buflen -= ret; |
| 57 | |
| 58 | while (ret) { |
| 59 | ret2 = read(sd->pipe[0], p, ret); |
| 60 | if (ret2 < 0) |
Jens Axboe | b4ba5f3 | 2007-04-02 10:36:59 +0200 | [diff] [blame] | 61 | return -errno; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 62 | |
| 63 | ret -= ret2; |
| 64 | p += ret2; |
| 65 | } |
| 66 | } |
| 67 | |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 68 | return io_u->xfer_buflen; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /* |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 72 | * We can now vmsplice into userspace, so do the transfer by splicing into |
| 73 | * a pipe and vmsplicing that into userspace. |
| 74 | */ |
| 75 | static int fio_splice_read(struct thread_data *td, struct io_u *io_u) |
| 76 | { |
| 77 | struct spliceio_data *sd = td->io_ops->data; |
| 78 | struct fio_file *f = io_u->file; |
| 79 | struct iovec iov; |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 80 | int ret , buflen, mmap_len; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 81 | off_t offset; |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 82 | void *p, *map; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 83 | |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 84 | ret = 0; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 85 | offset = io_u->offset; |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 86 | mmap_len = buflen = io_u->xfer_buflen; |
| 87 | |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 88 | if (sd->vmsplice_to_user_map) { |
| 89 | map = mmap(io_u->xfer_buf, buflen, PROT_READ, MAP_PRIVATE|OS_MAP_ANON, 0, 0); |
| 90 | if (map == MAP_FAILED) { |
| 91 | td_verror(td, errno, "mmap io_u"); |
| 92 | return -1; |
| 93 | } |
| 94 | |
| 95 | p = map; |
| 96 | } else { |
| 97 | map = NULL; |
| 98 | p = io_u->xfer_buf; |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 99 | } |
| 100 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 101 | while (buflen) { |
| 102 | int this_len = buflen; |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 103 | int flags = 0; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 104 | |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 105 | if (this_len > SPLICE_DEF_SIZE) { |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 106 | this_len = SPLICE_DEF_SIZE; |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 107 | flags = SPLICE_F_MORE; |
| 108 | } |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 109 | |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 110 | ret = splice(f->fd, &offset, sd->pipe[1], NULL, this_len,flags); |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 111 | if (ret < 0) { |
| 112 | if (errno == ENODATA || errno == EAGAIN) |
| 113 | continue; |
| 114 | |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 115 | td_verror(td, errno, "splice-from-fd"); |
| 116 | break; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | buflen -= ret; |
| 120 | iov.iov_base = p; |
| 121 | iov.iov_len = ret; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 122 | |
| 123 | while (iov.iov_len) { |
| 124 | ret = vmsplice(sd->pipe[0], &iov, 1, SPLICE_F_MOVE); |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 125 | if (ret < 0) { |
Jens Axboe | cd98801 | 2009-04-20 12:39:17 +0200 | [diff] [blame] | 126 | if (errno == EFAULT && |
| 127 | sd->vmsplice_to_user_map) { |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 128 | sd->vmsplice_to_user_map = 0; |
| 129 | munmap(map, mmap_len); |
Jens Axboe | cd98801 | 2009-04-20 12:39:17 +0200 | [diff] [blame] | 130 | map = NULL; |
| 131 | p = io_u->xfer_buf; |
| 132 | iov.iov_base = p; |
| 133 | continue; |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 134 | } |
Jens Axboe | 3a6d267 | 2007-10-16 09:44:47 +0200 | [diff] [blame] | 135 | if (errno == EBADF) { |
| 136 | ret = -EBADF; |
| 137 | break; |
| 138 | } |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 139 | td_verror(td, errno, "vmsplice"); |
| 140 | break; |
| 141 | } else if (!ret) { |
| 142 | td_verror(td, ENODATA, "vmsplice"); |
| 143 | ret = -1; |
| 144 | break; |
| 145 | } |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 146 | |
| 147 | iov.iov_len -= ret; |
| 148 | iov.iov_base += ret; |
Jens Axboe | cd98801 | 2009-04-20 12:39:17 +0200 | [diff] [blame] | 149 | p += ret; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 150 | } |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 151 | if (ret < 0) |
| 152 | break; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 153 | } |
| 154 | |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 155 | if (sd->vmsplice_to_user_map && munmap(map, mmap_len) < 0) { |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 156 | td_verror(td, errno, "munnap io_u"); |
| 157 | return -1; |
| 158 | } |
| 159 | if (ret < 0) |
| 160 | return ret; |
| 161 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 162 | return io_u->xfer_buflen; |
| 163 | } |
| 164 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 165 | /* |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 166 | * For splice writing, we can vmsplice our data buffer directly into a |
| 167 | * pipe and then splice that to a file. |
| 168 | */ |
| 169 | static int fio_splice_write(struct thread_data *td, struct io_u *io_u) |
| 170 | { |
| 171 | struct spliceio_data *sd = td->io_ops->data; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 172 | struct iovec iov = { |
| 173 | .iov_base = io_u->xfer_buf, |
| 174 | .iov_len = io_u->xfer_buflen, |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 175 | }; |
| 176 | struct pollfd pfd = { .fd = sd->pipe[1], .events = POLLOUT, }; |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 177 | struct fio_file *f = io_u->file; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 178 | off_t off = io_u->offset; |
| 179 | int ret, ret2; |
| 180 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 181 | while (iov.iov_len) { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 182 | if (poll(&pfd, 1, -1) < 0) |
| 183 | return errno; |
| 184 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 185 | ret = vmsplice(sd->pipe[1], &iov, 1, SPLICE_F_NONBLOCK); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 186 | if (ret < 0) |
Jens Axboe | b4ba5f3 | 2007-04-02 10:36:59 +0200 | [diff] [blame] | 187 | return -errno; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 188 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 189 | iov.iov_len -= ret; |
| 190 | iov.iov_base += ret; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 191 | |
| 192 | while (ret) { |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 193 | ret2 = splice(sd->pipe[0], NULL, f->fd, &off, ret, 0); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 194 | if (ret2 < 0) |
Jens Axboe | b4ba5f3 | 2007-04-02 10:36:59 +0200 | [diff] [blame] | 195 | return -errno; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 196 | |
| 197 | ret -= ret2; |
| 198 | } |
| 199 | } |
| 200 | |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 201 | return io_u->xfer_buflen; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static int fio_spliceio_queue(struct thread_data *td, struct io_u *io_u) |
| 205 | { |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 206 | struct spliceio_data *sd = td->io_ops->data; |
Jens Axboe | f3f552b | 2008-06-13 10:27:05 +0200 | [diff] [blame] | 207 | int uninitialized_var(ret); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 208 | |
Jens Axboe | 7101d9c | 2007-09-12 13:12:39 +0200 | [diff] [blame] | 209 | fio_ro_check(td, io_u); |
| 210 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 211 | if (io_u->ddir == DDIR_READ) { |
Jens Axboe | 4368857 | 2007-08-14 13:43:05 +0200 | [diff] [blame] | 212 | if (sd->vmsplice_to_user) { |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 213 | ret = fio_splice_read(td, io_u); |
Jens Axboe | 4368857 | 2007-08-14 13:43:05 +0200 | [diff] [blame] | 214 | /* |
| 215 | * This kernel doesn't support vmsplice to user |
| 216 | * space. Reset the vmsplice_to_user flag, so that |
| 217 | * we retry below and don't hit this path again. |
| 218 | */ |
| 219 | if (ret == -EBADF) |
| 220 | sd->vmsplice_to_user = 0; |
| 221 | } |
| 222 | if (!sd->vmsplice_to_user) |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 223 | ret = fio_splice_read_old(td, io_u); |
| 224 | } else if (io_u->ddir == DDIR_WRITE) |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 225 | ret = fio_splice_write(td, io_u); |
Jens Axboe | a5f3027 | 2010-07-19 16:19:55 -0600 | [diff] [blame] | 226 | else if (io_u->ddir == DDIR_TRIM) |
| 227 | ret = do_io_u_trim(td, io_u); |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 228 | else |
Jens Axboe | f011531 | 2010-03-09 21:47:15 +0100 | [diff] [blame] | 229 | ret = do_io_u_sync(td, io_u); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 230 | |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 231 | if (ret != (int) io_u->xfer_buflen) { |
Jens Axboe | 22819ec | 2007-02-18 07:47:14 +0100 | [diff] [blame] | 232 | if (ret >= 0) { |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 233 | io_u->resid = io_u->xfer_buflen - ret; |
| 234 | io_u->error = 0; |
Jens Axboe | 36167d8 | 2007-02-18 05:41:31 +0100 | [diff] [blame] | 235 | return FIO_Q_COMPLETED; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 236 | } else |
| 237 | io_u->error = errno; |
| 238 | } |
| 239 | |
Jens Axboe | 0aa417a | 2008-06-09 19:25:49 +0200 | [diff] [blame] | 240 | if (io_u->error) { |
Jens Axboe | e1161c3 | 2007-02-22 19:36:48 +0100 | [diff] [blame] | 241 | td_verror(td, io_u->error, "xfer"); |
Jens Axboe | 0aa417a | 2008-06-09 19:25:49 +0200 | [diff] [blame] | 242 | if (io_u->error == EINVAL) |
| 243 | log_err("fio: looks like splice doesn't work on this" |
| 244 | " file system\n"); |
| 245 | } |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 246 | |
Jens Axboe | 36167d8 | 2007-02-18 05:41:31 +0100 | [diff] [blame] | 247 | return FIO_Q_COMPLETED; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | static void fio_spliceio_cleanup(struct thread_data *td) |
| 251 | { |
| 252 | struct spliceio_data *sd = td->io_ops->data; |
| 253 | |
| 254 | if (sd) { |
| 255 | close(sd->pipe[0]); |
| 256 | close(sd->pipe[1]); |
| 257 | free(sd); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
| 261 | static int fio_spliceio_init(struct thread_data *td) |
| 262 | { |
| 263 | struct spliceio_data *sd = malloc(sizeof(*sd)); |
| 264 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 265 | if (pipe(sd->pipe) < 0) { |
Jens Axboe | e1161c3 | 2007-02-22 19:36:48 +0100 | [diff] [blame] | 266 | td_verror(td, errno, "pipe"); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 267 | free(sd); |
| 268 | return 1; |
| 269 | } |
| 270 | |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 271 | /* |
Jens Axboe | 4368857 | 2007-08-14 13:43:05 +0200 | [diff] [blame] | 272 | * Assume this work, we'll reset this if it doesn't |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 273 | */ |
Jens Axboe | 4368857 | 2007-08-14 13:43:05 +0200 | [diff] [blame] | 274 | sd->vmsplice_to_user = 1; |
Jens Axboe | f24254e | 2007-06-13 19:04:16 +0200 | [diff] [blame] | 275 | |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 276 | /* |
Jens Axboe | 8b85024 | 2007-10-16 09:42:40 +0200 | [diff] [blame] | 277 | * Works with "real" vmsplice to user, eg mapping pages directly. |
| 278 | * Reset if we fail. |
| 279 | */ |
| 280 | sd->vmsplice_to_user_map = 1; |
| 281 | |
| 282 | /* |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 283 | * And if vmsplice_to_user works, we definitely need aligned |
| 284 | * buffers. Just set ->odirect to force that. |
| 285 | */ |
| 286 | if (td_read(td)) |
Jens Axboe | 76a3179 | 2011-05-13 21:19:25 +0200 | [diff] [blame] | 287 | td->o.mem_align = 1; |
Jens Axboe | 81887d5 | 2007-09-07 20:36:08 +0200 | [diff] [blame] | 288 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 289 | td->io_ops->data = sd; |
| 290 | return 0; |
| 291 | } |
| 292 | |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 293 | static struct ioengine_ops ioengine = { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 294 | .name = "splice", |
| 295 | .version = FIO_IOOPS_VERSION, |
| 296 | .init = fio_spliceio_init, |
| 297 | .queue = fio_spliceio_queue, |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 298 | .cleanup = fio_spliceio_cleanup, |
Jens Axboe | b5af829 | 2007-03-08 12:43:13 +0100 | [diff] [blame] | 299 | .open_file = generic_open_file, |
| 300 | .close_file = generic_close_file, |
Jens Axboe | df9c26b | 2009-03-05 10:13:58 +0100 | [diff] [blame] | 301 | .get_file_size = generic_get_file_size, |
Jens Axboe | 9c0d224 | 2009-07-01 12:26:28 +0200 | [diff] [blame] | 302 | .flags = FIO_SYNCIO | FIO_PIPEIO, |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 303 | }; |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 304 | |
| 305 | #else /* FIO_HAVE_SPLICE */ |
| 306 | |
| 307 | /* |
| 308 | * When we have a proper configure system in place, we simply wont build |
| 309 | * and install this io engine. For now install a crippled version that |
| 310 | * just complains and fails to load. |
| 311 | */ |
| 312 | static int fio_spliceio_init(struct thread_data fio_unused *td) |
| 313 | { |
Jens Axboe | a3edaf7 | 2010-09-26 10:53:40 +0900 | [diff] [blame] | 314 | log_err("fio: splice not available\n"); |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 315 | return 1; |
| 316 | } |
| 317 | |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 318 | static struct ioengine_ops ioengine = { |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 319 | .name = "splice", |
| 320 | .version = FIO_IOOPS_VERSION, |
| 321 | .init = fio_spliceio_init, |
| 322 | }; |
| 323 | |
| 324 | #endif |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 325 | |
| 326 | static void fio_init fio_spliceio_register(void) |
| 327 | { |
| 328 | register_ioengine(&ioengine); |
| 329 | } |
| 330 | |
| 331 | static void fio_exit fio_spliceio_unregister(void) |
| 332 | { |
| 333 | unregister_ioengine(&ioengine); |
| 334 | } |