summaryrefslogtreecommitdiff
path: root/extstore.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-10-14 01:53:24 -0700
committerdormando <dormando@rydia.net>2017-11-28 14:18:05 -0800
commit889938405df7e46f31ab0bbafee1fd210372f249 (patch)
tree9250c8de7433e6abdf824e7b1f4610d8bee74fd0 /extstore.c
parentb95f9751d135ec25a8331f5691235f4ae40322be (diff)
downloadmemcached-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.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/extstore.c b/extstore.c
index c42578d..2e26462 100644
--- a/extstore.c
+++ b/extstore.c
@@ -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;