summaryrefslogtreecommitdiffstats
path: root/xlators/performance/io-cache/src/page.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/performance/io-cache/src/page.c')
-rw-r--r--xlators/performance/io-cache/src/page.c67
1 files changed, 31 insertions, 36 deletions
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index d2cbe2499a4..84b1ae6cb20 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -8,10 +8,10 @@
cases as published by the Free Software Foundation.
*/
-#include "glusterfs.h"
-#include "logging.h"
-#include "dict.h"
-#include "xlator.h"
+#include <glusterfs/glusterfs.h>
+#include <glusterfs/logging.h>
+#include <glusterfs/dict.h>
+#include <glusterfs/xlator.h>
#include "io-cache.h"
#include "ioc-mem-types.h"
#include <assert.h>
@@ -307,8 +307,8 @@ __ioc_wait_on_page(ioc_page_t *page, call_frame_t *frame, off_t offset,
if (page == NULL) {
local->op_ret = -1;
local->op_errno = ENOMEM;
- gf_msg(frame->this->name, GF_LOG_WARNING, 0, IO_CACHE_MSG_NO_MEMORY,
- "asked to wait on a NULL page");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, 0,
+ IO_CACHE_MSG_NULL_PAGE_WAIT, NULL);
goto out;
}
@@ -413,9 +413,6 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
ioc_waitq_t *waitq = NULL;
size_t iobref_page_size = 0;
char zero_filled = 0;
- struct timeval tv = {
- 0,
- };
GF_ASSERT(frame);
@@ -431,7 +428,6 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
zero_filled = ((op_ret >= 0) && (stbuf->ia_mtime == 0));
- gettimeofday(&tv, NULL);
ioc_inode_lock(ioc_inode);
{
if (op_ret == -1 ||
@@ -448,7 +444,7 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
ioc_inode->cache.mtime_nsec = stbuf->ia_mtime_nsec;
}
- memcpy(&ioc_inode->cache.tv, &tv, sizeof(struct timeval));
+ ioc_inode->cache.last_revalidate = gf_time();
if (op_ret < 0) {
/* error, readv returned -1 */
@@ -461,12 +457,10 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
if (!page) {
/* page was flushed */
/* some serious bug ? */
- gf_msg(frame->this->name, GF_LOG_WARNING, 0,
- IO_CACHE_MSG_WASTED_COPY,
- "wasted copy: %" PRId64 "[+%" PRId64
- "] "
- "ioc_inode=%p",
- offset, table->page_size, ioc_inode);
+ gf_smsg(frame->this->name, GF_LOG_WARNING, 0,
+ IO_CACHE_MSG_WASTED_COPY, "offset=%" PRId64, offset,
+ "page-size=%" PRId64, table->page_size, "ioc_inode=%p",
+ ioc_inode, NULL);
} else {
if (page->vector) {
iobref_unref(page->iobref);
@@ -490,9 +484,8 @@ ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
} else {
/* TODO: we have got a response to
* our request and no data */
- gf_msg(frame->this->name, GF_LOG_CRITICAL, ENOMEM,
- IO_CACHE_MSG_NO_MEMORY,
- "frame>root>rsp_refs is null");
+ gf_smsg(frame->this->name, GF_LOG_CRITICAL, ENOMEM,
+ IO_CACHE_MSG_FRAME_NULL, NULL);
} /* if(frame->root->rsp_refs) */
/* page->size should indicate exactly how
@@ -546,6 +539,8 @@ unlock:
pthread_mutex_destroy(&local->local_lock);
fd_unref(local->fd);
+ if (local->xattr_req)
+ dict_unref(local->xattr_req);
STACK_DESTROY(frame->root);
return 0;
@@ -567,6 +562,7 @@ ioc_page_fault(ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
ioc_table_t *table = NULL;
call_frame_t *fault_frame = NULL;
ioc_local_t *fault_local = NULL;
+ ioc_local_t *local = NULL;
int32_t op_ret = -1, op_errno = -1;
ioc_waitq_t *waitq = NULL;
ioc_page_t *page = NULL;
@@ -575,8 +571,8 @@ ioc_page_fault(ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
if (frame == NULL) {
op_ret = -1;
op_errno = EINVAL;
- gf_msg("io-cache", GF_LOG_WARNING, EINVAL,
- IO_CACHE_MSG_ENFORCEMENT_FAILED, "page fault on a NULL frame");
+ gf_smsg("io-cache", GF_LOG_WARNING, EINVAL, IO_CACHE_MSG_PAGE_FAULT,
+ NULL);
goto err;
}
@@ -588,6 +584,7 @@ ioc_page_fault(ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
goto err;
}
+ local = frame->local;
fault_local = mem_get0(THIS->local_pool);
if (fault_local == NULL) {
op_ret = -1;
@@ -609,6 +606,9 @@ ioc_page_fault(ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
fault_local->pending_size = table->page_size;
fault_local->inode = ioc_inode;
+ if (local && local->xattr_req)
+ fault_local->xattr_req = dict_ref(local->xattr_req);
+
gf_msg_trace(frame->this->name, 0,
"stack winding page fault for offset = %" PRId64
" with "
@@ -617,7 +617,7 @@ ioc_page_fault(ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
STACK_WIND(fault_frame, ioc_fault_cbk, FIRST_CHILD(fault_frame->this),
FIRST_CHILD(fault_frame->this)->fops->readv, fd,
- table->page_size, offset, 0, NULL);
+ table->page_size, offset, 0, fault_local->xattr_req);
return;
err:
@@ -655,9 +655,8 @@ __ioc_frame_fill(ioc_page_t *page, call_frame_t *frame, off_t offset,
GF_VALIDATE_OR_GOTO(frame->this->name, local, out);
if (page == NULL) {
- gf_msg(frame->this->name, GF_LOG_WARNING, 0,
- IO_CACHE_MSG_ENFORCEMENT_FAILED,
- "NULL page has been provided to serve read request");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, 0,
+ IO_CACHE_MSG_SERVE_READ_REQUEST, NULL);
local->op_ret = -1;
local->op_errno = EINVAL;
goto out;
@@ -720,11 +719,8 @@ __ioc_frame_fill(ioc_page_t *page, call_frame_t *frame, off_t offset,
new->size = copy_size;
new->iobref = iobref_ref(page->iobref);
new->count = iov_subset(page->vector, page->count, src_offset,
- src_offset + copy_size, NULL);
-
- new->vector = GF_CALLOC(new->count, sizeof(struct iovec),
- gf_ioc_mt_iovec);
- if (new->vector == NULL) {
+ copy_size, &new->vector, 0);
+ if (new->count < 0) {
local->op_ret = -1;
local->op_errno = ENOMEM;
@@ -733,9 +729,6 @@ __ioc_frame_fill(ioc_page_t *page, call_frame_t *frame, off_t offset,
goto out;
}
- new->count = iov_subset(page->vector, page->count, src_offset,
- src_offset + copy_size, new->vector);
-
/* add the ioc_fill to fill_list for this frame */
if (list_empty(&local->fill_list)) {
/* if list is empty, then this is the first
@@ -798,8 +791,8 @@ ioc_frame_unwind(call_frame_t *frame)
local = frame->local;
if (local == NULL) {
- gf_msg(frame->this->name, GF_LOG_WARNING, ENOMEM,
- IO_CACHE_MSG_NO_MEMORY, "local is NULL");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, ENOMEM,
+ IO_CACHE_MSG_LOCAL_NULL, NULL);
op_ret = -1;
op_errno = ENOMEM;
goto unwind;
@@ -878,6 +871,8 @@ unwind:
}
if (local) {
+ if (local->xattr_req)
+ dict_unref(local->xattr_req);
pthread_mutex_destroy(&local->local_lock);
mem_put(local);
}