diff options
author | dormando <dormando@rydia.net> | 2017-10-14 01:53:24 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-11-28 14:18:05 -0800 |
commit | 889938405df7e46f31ab0bbafee1fd210372f249 (patch) | |
tree | 9250c8de7433e6abdf824e7b1f4610d8bee74fd0 /extstore.c | |
parent | b95f9751d135ec25a8331f5691235f4ae40322be (diff) | |
download | memcached-889938405df7e46f31ab0bbafee1fd210372f249.tar.gz |
extstore: support chunked items.
item size max must be <= wbuf_size.
reads into iovecs, writes out of same iovecs.
Diffstat (limited to 'extstore.c')
-rw-r--r-- | extstore.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -9,6 +9,7 @@ #include <pthread.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/uio.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> @@ -584,7 +585,18 @@ static inline int _read_from_wbuf(store_page *p, obj_io *io) { _store_wbuf *wbuf = p->wbuf; assert(wbuf != NULL); assert(io->offset < p->written + wbuf->size); - memcpy(io->buf, wbuf->buf + (io->offset - wbuf->offset), io->len); + if (io->iov == NULL) { + memcpy(io->buf, wbuf->buf + (io->offset - wbuf->offset), io->len); + } else { + int x; + unsigned int off = io->offset - wbuf->offset; + // need to loop fill iovecs + for (x = 0; x < io->iovcnt; x++) { + struct iovec *iov = &io->iov[x]; + memcpy(iov->iov_base, wbuf->buf + off, iov->iov_len); + off += iov->iov_len; + } + } return io->len; } @@ -650,8 +662,13 @@ static void *extstore_io_thread(void *arg) { ret = -2; // TODO: enum in IO for status? } pthread_mutex_unlock(&p->mutex); - if (do_op) - ret = pread(p->fd, cur_io->buf, cur_io->len, p->offset + cur_io->offset); + if (do_op) { + if (cur_io->iov == NULL) { + ret = pread(p->fd, cur_io->buf, cur_io->len, p->offset + cur_io->offset); + } else { + ret = preadv(p->fd, cur_io->iov, cur_io->iovcnt, p->offset + cur_io->offset); + } + } break; case OBJ_IO_WRITE: do_op = 0; |