summaryrefslogtreecommitdiffstats
path: root/xlators/performance/io-cache/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/performance/io-cache/src')
-rw-r--r--xlators/performance/io-cache/src/io-cache.c39
-rw-r--r--xlators/performance/io-cache/src/io-cache.h7
-rw-r--r--xlators/performance/io-cache/src/page.c29
3 files changed, 41 insertions, 34 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 4d5ffe292..9d6f35806 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -200,10 +200,8 @@ ioc_lookup_cbk (call_frame_t *frame,
ioc_local_t *local = frame->local;
ioc_table_t *table = this->private;
ioc_page_t *page = NULL;
- data_t *page_data = NULL;
data_t *content_data = NULL;
char *src = NULL;
- char *dst = NULL;
char need_unref = 0;
uint8_t cache_still_valid = 0;
uint32_t weight = 0;
@@ -211,6 +209,8 @@ ioc_lookup_cbk (call_frame_t *frame,
char *buf = NULL;
char *tmp = NULL;
int i;
+ struct iobref *iobref = NULL;
+ struct iobuf *iobuf = NULL;
if (op_ret != 0)
goto out;
@@ -257,7 +257,7 @@ ioc_lookup_cbk (call_frame_t *frame,
if (content_data) {
if (page) {
- dict_unref (page->ref);
+ iobref_unref (page->iobref);
free (page->vector);
page->vector = NULL;
@@ -270,19 +270,18 @@ ioc_lookup_cbk (call_frame_t *frame,
} else {
page = ioc_page_create (ioc_inode, 0);
}
-
- dst = CALLOC (1, stbuf->st_size);
- page->ref = dict_ref (get_new_dict ());
- page_data = data_from_dynptr (dst,
- stbuf->st_size);
- dict_set (page->ref, NULL, page_data);
-
+
src = data_to_ptr (content_data);
- memcpy (dst, src, stbuf->st_size);
+
+ iobuf = iobuf_get (this->ctx->iobuf_pool);
+ page->iobref = iobref_new ();
+ iobref_add (page->iobref, iobuf);
+
+ memcpy (iobuf->ptr, src, stbuf->st_size);
page->vector = CALLOC (1,
sizeof (*page->vector));
- page->vector->iov_base = dst;
+ page->vector->iov_base = iobuf->ptr;
page->vector->iov_len = stbuf->st_size;
page->count = 1;
@@ -351,6 +350,11 @@ ioc_lookup_cbk (call_frame_t *frame,
dict_unref (dict);
}
+ if (iobref)
+ iobref_unref (iobref);
+ if (iobuf)
+ iobuf_unref (iobuf);
+
return 0;
}
@@ -834,9 +838,10 @@ ioc_readv_disabled_cbk (call_frame_t *frame,
int32_t op_errno,
struct iovec *vector,
int32_t count,
- struct stat *stbuf)
+ struct stat *stbuf,
+ struct iobref *iobref)
{
- STACK_UNWIND (frame, op_ret, op_errno, vector, count, stbuf);
+ STACK_UNWIND (frame, op_ret, op_errno, vector, count, stbuf, iobref);
return 0;
}
@@ -1104,7 +1109,8 @@ ioc_writev (call_frame_t *frame,
fd_t *fd,
struct iovec *vector,
int32_t count,
- off_t offset)
+ off_t offset,
+ struct iobref *iobref)
{
ioc_local_t *local = NULL;
uint64_t ioc_inode = 0;
@@ -1127,7 +1133,8 @@ ioc_writev (call_frame_t *frame,
fd,
vector,
count,
- offset);
+ offset,
+ iobref);
return 0;
}
diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h
index 3cefca164..ffa7d7dcd 100644
--- a/xlators/performance/io-cache/src/io-cache.h
+++ b/xlators/performance/io-cache/src/io-cache.h
@@ -75,7 +75,7 @@ struct ioc_fill {
size_t size;
struct iovec *vector;
int32_t count;
- dict_t *refs;
+ struct iobref *iobref;
};
struct ioc_local {
@@ -115,7 +115,7 @@ struct ioc_page {
off_t offset;
size_t size;
struct ioc_waitq *waitq;
- dict_t *ref;
+ struct iobref *iobref;
pthread_mutex_t page_lock;
};
@@ -169,7 +169,8 @@ ioc_readv_disabled_cbk (call_frame_t *frame,
int32_t op_errno,
struct iovec *vector,
int32_t count,
- struct stat *stbuf);
+ struct stat *stbuf,
+ struct iobref *iobref);
ioc_page_t *
ioc_page_get (ioc_inode_t *ioc_inode,
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index 1acda2ce6..98897b7d9 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -90,7 +90,7 @@ ioc_page_destroy (ioc_page_t *page)
page, page->offset, page->inode);
if (page->vector){
- dict_unref (page->ref);
+ iobref_unref (page->iobref);
free (page->vector);
page->vector = NULL;
}
@@ -323,7 +323,8 @@ ioc_fault_cbk (call_frame_t *frame,
int32_t op_errno,
struct iovec *vector,
int32_t count,
- struct stat *stbuf)
+ struct stat *stbuf,
+ struct iobref *iobref)
{
ioc_local_t *local = frame->local;
off_t offset = local->pending_offset;
@@ -374,7 +375,7 @@ ioc_fault_cbk (call_frame_t *frame,
table->page_size, ioc_inode);
} else {
if (page->vector) {
- dict_unref (page->ref);
+ iobref_unref (page->iobref);
free (page->vector);
page->vector = NULL;
}
@@ -382,9 +383,8 @@ ioc_fault_cbk (call_frame_t *frame,
/* keep a copy of the page for our cache */
page->vector = iov_dup (vector, count);
page->count = count;
- if (frame->root->rsp_refs) {
- dict_ref (frame->root->rsp_refs);
- page->ref = frame->root->rsp_refs;
+ if (iobref) {
+ page->iobref = iobref_ref (iobref);
} else {
/* TODO: we have got a response to
* our request and no data */
@@ -543,7 +543,7 @@ ioc_frame_fill (ioc_page_t *page,
ERR_ABORT (new);
new->offset = page->offset;
new->size = copy_size;
- new->refs = dict_ref (page->ref);
+ new->iobref = iobref_ref (page->iobref);
new->count = iov_subset (page->vector,
page->count,
src_offset,
@@ -609,12 +609,12 @@ ioc_frame_unwind (call_frame_t *frame)
int32_t count = 0;
struct iovec *vector = NULL;
int32_t copied = 0;
- dict_t *refs = NULL;
+ struct iobref *iobref = NULL;
struct stat stbuf = {0,};
int32_t op_ret = 0;
// ioc_local_lock (local);
- refs = get_new_dict ();
+ iobref = iobref_new ();
frame->local = NULL;
@@ -639,16 +639,14 @@ ioc_frame_unwind (call_frame_t *frame)
copied += (fill->count * sizeof (*vector));
- dict_copy (fill->refs, refs);
+ iobref_merge (iobref, fill->iobref);
list_del (&fill->list);
- dict_unref (fill->refs);
+ iobref_unref (fill->iobref);
free (fill->vector);
free (fill);
}
- frame->root->rsp_refs = dict_ref (refs);
-
op_ret = iov_length (vector, count);
gf_log (frame->this->name, GF_LOG_DEBUG,
"frame(%p) unwinding with op_ret=%d", frame, op_ret);
@@ -660,9 +658,10 @@ ioc_frame_unwind (call_frame_t *frame)
local->op_errno,
vector,
count,
- &stbuf);
+ &stbuf,
+ iobref);
- dict_unref (refs);
+ iobref_unref (iobref);
pthread_mutex_destroy (&local->local_lock);
free (local);