diff options
Diffstat (limited to 'xlators/performance/io-cache/src/page.c')
| -rw-r--r-- | xlators/performance/io-cache/src/page.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c index dada4ebc55b..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> @@ -42,7 +42,7 @@ __ioc_page_get(ioc_inode_t *ioc_inode, off_t offset) table = ioc_inode->table; GF_VALIDATE_OR_GOTO("io-cache", ioc_inode, out); - rounded_offset = floor(offset, table->page_size); + rounded_offset = gf_floor(offset, table->page_size); page = rbthash_get(ioc_inode->cache.page_table, &rounded_offset, sizeof(rounded_offset)); @@ -253,7 +253,7 @@ __ioc_page_create(ioc_inode_t *ioc_inode, off_t offset) table = ioc_inode->table; GF_VALIDATE_OR_GOTO("io-cache", table, out); - rounded_offset = floor(offset, table->page_size); + rounded_offset = gf_floor(offset, table->page_size); newpage = GF_CALLOC(1, sizeof(*newpage), gf_ioc_mt_ioc_newpage_t); if (newpage == NULL) { @@ -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; } @@ -444,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; } - gettimeofday(&ioc_inode->cache.tv, NULL); + ioc_inode->cache.last_revalidate = gf_time(); if (op_ret < 0) { /* error, readv returned -1 */ @@ -457,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); @@ -486,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 @@ -542,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; @@ -563,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; @@ -571,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; } @@ -584,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; @@ -605,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 " @@ -613,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: @@ -651,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; @@ -716,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; @@ -729,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 @@ -794,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; @@ -874,6 +871,8 @@ unwind: } if (local) { + if (local->xattr_req) + dict_unref(local->xattr_req); pthread_mutex_destroy(&local->local_lock); mem_put(local); } |
