summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-05-04 10:33:11 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-05-05 12:06:58 +0530
commit80c30634da16f7b333d07eeff9839b70d577e39f (patch)
tree3e0273450b20d166714f5efd5e47b78dfdf8c2b6 /xlators
parent5d417f0f8853e4f17caf25255f98c559f3670434 (diff)
io-cache: indentation and logging fixes
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/io-cache/src/io-cache.c488
-rw-r--r--xlators/performance/io-cache/src/io-cache.h202
-rw-r--r--xlators/performance/io-cache/src/ioc-inode.c33
-rw-r--r--xlators/performance/io-cache/src/page.c212
4 files changed, 426 insertions, 509 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 3082242..8b36d2a 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -30,15 +30,13 @@
#include <assert.h>
#include <sys/time.h>
-static uint32_t
-ioc_get_priority (ioc_table_t *table,
- const char *path);
+uint32_t
+ioc_get_priority (ioc_table_t *table, const char *path);
-static uint32_t
-ioc_get_priority (ioc_table_t *table,
- const char *path);
+uint32_t
+ioc_get_priority (ioc_table_t *table, const char *path);
-static inline ioc_inode_t *
+inline ioc_inode_t *
ioc_inode_reupdate (ioc_inode_t *ioc_inode)
{
ioc_table_t *table = ioc_inode->table;
@@ -49,12 +47,11 @@ ioc_inode_reupdate (ioc_inode_t *ioc_inode)
return ioc_inode;
}
-static inline ioc_inode_t *
-ioc_get_inode (dict_t *dict,
- char *name)
+inline ioc_inode_t *
+ioc_get_inode (dict_t *dict, char *name)
{
ioc_inode_t *ioc_inode = NULL;
- data_t *ioc_inode_data = dict_get (dict, name);
+ data_t *ioc_inode_data = dict_get (dict, name);
ioc_table_t *table = NULL;
if (ioc_inode_data) {
@@ -76,10 +73,10 @@ ioc_get_inode (dict_t *dict,
int32_t
ioc_inode_need_revalidate (ioc_inode_t *ioc_inode)
{
- int8_t need_revalidate = 0;
+ int8_t need_revalidate = 0;
struct timeval tv = {0,};
- int32_t ret = -1;
- ioc_table_t *table = ioc_inode->table;
+ int32_t ret = -1;
+ ioc_table_t *table = ioc_inode->table;
ret = gettimeofday (&tv, NULL);
@@ -100,8 +97,8 @@ int32_t
__ioc_inode_flush (ioc_inode_t *ioc_inode)
{
ioc_page_t *curr = NULL, *next = NULL;
- int32_t destroy_size = 0;
- int32_t ret = 0;
+ int32_t destroy_size = 0;
+ int32_t ret = 0;
list_for_each_entry_safe (curr, next, &ioc_inode->pages, pages) {
ret = ioc_page_destroy (curr);
@@ -147,12 +144,8 @@ ioc_inode_flush (ioc_inode_t *ioc_inode)
*
*/
int32_t
-ioc_utimens_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct stat *stbuf)
+ioc_utimens_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct stat *stbuf)
{
STACK_UNWIND (frame, op_ret, op_errno, stbuf);
return 0;
@@ -168,10 +161,8 @@ ioc_utimens_cbk (call_frame_t *frame,
*
*/
int32_t
-ioc_utimens (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- struct timespec *tv)
+ioc_utimens (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ struct timespec *tv)
{
uint64_t ioc_inode = 0;
inode_ctx_get (loc->inode, this, &ioc_inode);
@@ -179,36 +170,30 @@ ioc_utimens (call_frame_t *frame,
if (ioc_inode)
ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame, ioc_utimens_cbk,
- FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->utimens,
- loc, tv);
+ STACK_WIND (frame, ioc_utimens_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->utimens, loc, tv);
+
return 0;
}
int32_t
-ioc_lookup_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- inode_t *inode,
- struct stat *stbuf,
- dict_t *dict)
+ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct stat *stbuf, dict_t *dict)
{
- ioc_inode_t *ioc_inode = NULL;
- ioc_local_t *local = frame->local;
- ioc_table_t *table = this->private;
- ioc_page_t *page = NULL;
- data_t *content_data = NULL;
- char *src = NULL;
- char need_unref = 0;
- uint8_t cache_still_valid = 0;
- uint32_t weight = 0;
- uint64_t tmp_ioc_inode = 0;
- char *buf = NULL;
- char *tmp = NULL;
- int i;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_local_t *local = frame->local;
+ ioc_table_t *table = this->private;
+ ioc_page_t *page = NULL;
+ data_t *content_data = NULL;
+ char *src = NULL;
+ char need_unref = 0;
+ uint8_t cache_still_valid = 0;
+ uint32_t weight = 0;
+ uint64_t tmp_ioc_inode = 0;
+ char *buf = NULL;
+ char *tmp = NULL;
+ int i;
struct iobref *iobref = NULL;
struct iobuf *iobuf = NULL;
@@ -302,12 +287,11 @@ ioc_lookup_cbk (call_frame_t *frame,
"page not present");
ioc_inode_unlock (ioc_inode);
- STACK_WIND (frame,
- ioc_lookup_cbk,
- FIRST_CHILD (this),
+ STACK_WIND (frame, ioc_lookup_cbk,
+ FIRST_CHILD (this),
FIRST_CHILD (this)->fops->lookup,
&local->file_loc,
- local->xattr_req);
+ local->xattr_req);
return 0;
}
buf = CALLOC (1, stbuf->st_size);
@@ -344,7 +328,7 @@ ioc_lookup_cbk (call_frame_t *frame,
}
}
- out:
+out:
STACK_UNWIND (frame, op_ret, op_errno, inode, stbuf, dict);
if (need_unref) {
@@ -360,19 +344,17 @@ ioc_lookup_cbk (call_frame_t *frame,
}
int32_t
-ioc_lookup (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
+ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
dict_t *xattr_req)
{
- uint64_t content_limit = 0;
+ uint64_t content_limit = 0;
+ uint64_t tmp_ioc_inode = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_page_t *page = NULL;
+ ioc_local_t *local = NULL;
if (GF_FILE_CONTENT_REQUESTED(xattr_req, &content_limit)) {
- uint64_t tmp_ioc_inode = 0;
- ioc_inode_t *ioc_inode = NULL;
- ioc_page_t *page = NULL;
- ioc_local_t *local = CALLOC (1, sizeof (*local));
-
+ local = CALLOC (1, sizeof (*local));
local->need_xattr = content_limit;
local->file_loc.path = loc->path;
local->file_loc.inode = loc->inode;
@@ -395,12 +377,9 @@ ioc_lookup (call_frame_t *frame,
}
}
- STACK_WIND (frame,
- ioc_lookup_cbk,
- FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->lookup,
- loc,
- xattr_req);
+ STACK_WIND (frame, ioc_lookup_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->lookup, loc, xattr_req);
+
return 0;
}
@@ -413,8 +392,7 @@ ioc_lookup (call_frame_t *frame,
*
*/
int32_t
-ioc_forget (xlator_t *this,
- inode_t *inode)
+ioc_forget (xlator_t *this, inode_t *inode)
{
uint64_t ioc_inode = 0;
@@ -439,19 +417,17 @@ ioc_forget (xlator_t *this,
*
*/
int32_t
-ioc_cache_validate_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct stat *stbuf)
+ioc_cache_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct stat *stbuf)
{
- ioc_local_t *local = frame->local;
+ ioc_local_t *local = NULL;
ioc_inode_t *ioc_inode = NULL;
- size_t destroy_size = 0;
- struct stat *local_stbuf = stbuf;
+ size_t destroy_size = 0;
+ struct stat *local_stbuf = NULL;
+ local = frame->local;
ioc_inode = local->inode;
+ local_stbuf = stbuf;
if ((op_ret == -1) ||
((op_ret >= 0) && !ioc_cache_still_valid(ioc_inode, stbuf))) {
@@ -501,12 +477,11 @@ ioc_cache_validate_cbk (call_frame_t *frame,
return 0;
}
-static int32_t
-ioc_wait_on_inode (ioc_inode_t *ioc_inode,
- ioc_page_t *page)
+int32_t
+ioc_wait_on_inode (ioc_inode_t *ioc_inode, ioc_page_t *page)
{
ioc_waitq_t *waiter = NULL, *trav = NULL;
- uint32_t page_found = 0;
+ uint32_t page_found = 0;
trav = ioc_inode->waitq;
@@ -537,14 +512,12 @@ ioc_wait_on_inode (ioc_inode_t *ioc_inode,
* @fd:
*
*/
-static int32_t
-ioc_cache_validate (call_frame_t *frame,
- ioc_inode_t *ioc_inode,
- fd_t *fd,
+int32_t
+ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
ioc_page_t *page)
{
call_frame_t *validate_frame = NULL;
- ioc_local_t *validate_local = NULL;
+ ioc_local_t *validate_local = NULL;
validate_local = CALLOC (1, sizeof (ioc_local_t));
ERR_ABORT (validate_local);
@@ -553,22 +526,20 @@ ioc_cache_validate (call_frame_t *frame,
validate_local->inode = ioc_inode;
validate_frame->local = validate_local;
- STACK_WIND (validate_frame,
- ioc_cache_validate_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->fstat,
- fd);
+ STACK_WIND (validate_frame, ioc_cache_validate_cbk,
+ FIRST_CHILD (frame->this),
+ FIRST_CHILD (frame->this)->fops->fstat, fd);
return 0;
}
-static inline uint32_t
-is_match (const char *path,
- const char *pattern)
+inline uint32_t
+is_match (const char *path, const char *pattern)
{
- char *pathname = strdup (path);
+ char *pathname = NULL;
int32_t ret = 0;
+ pathname = strdup (path);
ret = fnmatch (pattern, path, FNM_NOESCAPE);
free (pathname);
@@ -576,11 +547,10 @@ is_match (const char *path,
return (ret == 0);
}
-static uint32_t
-ioc_get_priority (ioc_table_t *table,
- const char *path)
+uint32_t
+ioc_get_priority (ioc_table_t *table, const char *path)
{
- uint32_t priority = 0;
+ uint32_t priority = 0;
struct ioc_priority *curr = NULL;
list_for_each_entry (curr, &table->priority_list, list) {
@@ -603,20 +573,21 @@ ioc_get_priority (ioc_table_t *table,
*
*/
int32_t
-ioc_open_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- fd_t *fd)
+ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, fd_t *fd)
{
- uint64_t tmp_ioc_inode = 0;
- ioc_local_t *local = frame->local;
- ioc_table_t *table = this->private;
+ uint64_t tmp_ioc_inode = 0;
+ ioc_local_t *local = NULL;
+ ioc_table_t *table = NULL;
ioc_inode_t *ioc_inode = NULL;
- inode_t *inode = local->file_loc.inode;
- uint32_t weight = 0;
- const char *path = local->file_loc.path;
+ inode_t *inode = NULL;
+ uint32_t weight = 0;
+ const char *path = NULL;
+
+ local = frame->local;
+ table = this->private;
+ inode = local->file_loc.inode;
+ path = local->file_loc.path;
if (op_ret != -1) {
/* look for ioc_inode corresponding to this fd */
@@ -626,12 +597,14 @@ ioc_open_cbk (call_frame_t *frame,
ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
if (!ioc_inode) {
- /* this is the first time someone is opening this
- file, assign weight
+ /*
+ this is the first time someone is opening
+ this file, assign weight
*/
weight = ioc_get_priority (table, path);
- ioc_inode = ioc_inode_update (table, inode, weight);
+ ioc_inode = ioc_inode_update (table, inode,
+ weight);
__inode_ctx_put (fd->inode, this,
(uint64_t)(long)ioc_inode);
} else {
@@ -648,8 +621,8 @@ ioc_open_cbk (call_frame_t *frame,
/* If mandatory locking has been enabled on this file,
we disable caching on it */
- if (((inode->st_mode & S_ISGID) &&
- !(inode->st_mode & S_IXGRP))) {
+ if (((inode->st_mode & S_ISGID)
+ && !(inode->st_mode & S_IXGRP))) {
fd_ctx_set (fd, this, 1);
}
@@ -684,20 +657,19 @@ ioc_open_cbk (call_frame_t *frame,
*
*/
int32_t
-ioc_create_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- fd_t *fd,
- inode_t *inode,
- struct stat *buf)
+ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, fd_t *fd,
+ inode_t *inode, struct stat *buf)
{
- ioc_local_t *local = frame->local;
- ioc_table_t *table = this->private;
+ ioc_local_t *local = NULL;
+ ioc_table_t *table = NULL;
ioc_inode_t *ioc_inode = NULL;
- uint32_t weight = 0;
- const char *path = local->file_loc.path;
+ uint32_t weight = 0;
+ const char *path = NULL;
+
+ local = frame->local;
+ table = this->private;
+ path = local->file_loc.path;
if (op_ret != -1) {
{
@@ -709,8 +681,10 @@ ioc_create_cbk (call_frame_t *frame,
inode_ctx_put (fd->inode, this,
(uint64_t)(long)ioc_inode);
}
- /* If mandatory locking has been enabled on this file,
- we disable caching on it */
+ /*
+ * If mandatory locking has been enabled on this file,
+ * we disable caching on it
+ */
if ((inode->st_mode & S_ISGID) &&
!(inode->st_mode & S_IXGRP)) {
fd_ctx_set (fd, this, 1);
@@ -718,7 +692,8 @@ ioc_create_cbk (call_frame_t *frame,
/* If O_DIRECT open, we disable caching on it */
if (local->flags & O_DIRECT){
- /* O_DIRECT is only for one fd, not the inode
+ /*
+ * O_DIRECT is only for one fd, not the inode
* as a whole
*/
fd_ctx_set (fd, this, 1);
@@ -743,14 +718,13 @@ ioc_create_cbk (call_frame_t *frame,
*
*/
int32_t
-ioc_open (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- int32_t flags,
+ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
fd_t *fd)
{
- ioc_local_t *local = CALLOC (1, sizeof (ioc_local_t));
+ ioc_local_t *local = NULL;
+
+ local = CALLOC (1, sizeof (ioc_local_t));
ERR_ABORT (local);
local->flags = flags;
@@ -759,13 +733,8 @@ ioc_open (call_frame_t *frame,
frame->local = local;
- STACK_WIND (frame,
- ioc_open_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->open,
- loc,
- flags,
- fd);
+ STACK_WIND (frame, ioc_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, loc, flags, fd);
return 0;
}
@@ -781,24 +750,21 @@ ioc_open (call_frame_t *frame,
*
*/
int32_t
-ioc_create (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- int32_t flags,
- mode_t mode,
- fd_t *fd)
+ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ mode_t mode, fd_t *fd)
{
- ioc_local_t *local = CALLOC (1, sizeof (ioc_local_t));
+ ioc_local_t *local = NULL;
+
+ local = CALLOC (1, sizeof (ioc_local_t));
ERR_ABORT (local);
local->flags = flags;
local->file_loc.path = loc->path;
frame->local = local;
- STACK_WIND (frame, ioc_create_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->create,
- loc, flags, mode, fd);
+ STACK_WIND (frame, ioc_create_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->create, loc, flags, mode, fd);
+
return 0;
}
@@ -814,8 +780,7 @@ ioc_create (call_frame_t *frame,
*
*/
int32_t
-ioc_release (xlator_t *this,
- fd_t *fd)
+ioc_release (xlator_t *this, fd_t *fd)
{
return 0;
}
@@ -832,14 +797,9 @@ ioc_release (xlator_t *this,
*
*/
int32_t
-ioc_readv_disabled_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct iovec *vector,
- int32_t count,
- struct stat *stbuf,
+ioc_readv_disabled_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iovec *vector,
+ int32_t count, struct stat *stbuf,
struct iobref *iobref)
{
STACK_UNWIND (frame, op_ret, op_errno, vector, count, stbuf, iobref);
@@ -865,31 +825,34 @@ ioc_need_prune (ioc_table_t *table)
}
/*
- * dispatch_requests -
+ * ioc_dispatch_requests -
*
* @frame:
* @inode:
*
*
*/
-static void
-dispatch_requests (call_frame_t *frame,
- ioc_inode_t *ioc_inode,
- fd_t *fd,
- off_t offset,
- size_t size)
+void
+ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
+ off_t offset, size_t size)
{
- ioc_local_t *local = frame->local;
- ioc_table_t *table = ioc_inode->table;
+ ioc_local_t *local = NULL;
+ ioc_table_t *table = NULL;
ioc_page_t *trav = NULL;
ioc_waitq_t *waitq = NULL;
- off_t rounded_offset = 0;
- off_t rounded_end = 0;
- off_t trav_offset = 0;
- int32_t fault = 0;
- int8_t need_validate = 0;
- int8_t might_need_validate = 0; /* if a page exists, do we need
- to validate it? */
+ off_t rounded_offset = 0;
+ off_t rounded_end = 0;
+ off_t trav_offset = 0;
+ int32_t fault = 0;
+ size_t trav_size = 0;
+ off_t local_offset = 0;
+ int8_t need_validate = 0;
+ int8_t might_need_validate = 0; /*
+ * if a page exists, do we need
+ * to validate it?
+ */
+ local = frame->local;
+ table = ioc_inode->table;
rounded_offset = floor (offset, table->page_size);
rounded_end = roof (offset + size, table->page_size);
@@ -908,9 +871,6 @@ dispatch_requests (call_frame_t *frame,
might_need_validate = ioc_inode_need_revalidate (ioc_inode);
while (trav_offset < rounded_end) {
- size_t trav_size = 0;
- off_t local_offset = 0;
-
ioc_inode_lock (ioc_inode);
//{
@@ -927,7 +887,7 @@ dispatch_requests (call_frame_t *frame,
fault = 1;
if (!trav) {
gf_log (frame->this->name, GF_LOG_CRITICAL,
- "ioc_page_create returned NULL");
+ "out of memory");
}
}
@@ -997,40 +957,31 @@ dispatch_requests (call_frame_t *frame,
*
*/
int32_t
-ioc_readv (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- size_t size,
- off_t offset)
+ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ size_t size, off_t offset)
{
uint64_t tmp_ioc_inode = 0;
- ioc_inode_t *ioc_inode = NULL;
- ioc_local_t *local = NULL;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_local_t *local = NULL;
uint32_t weight = 0;
inode_ctx_get (fd->inode, this, &tmp_ioc_inode);
ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
if (!ioc_inode) {
/* caching disabled, go ahead with normal readv */
- STACK_WIND (frame,
- ioc_readv_disabled_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->readv,
- fd,
- size,
- offset);
+ STACK_WIND (frame, ioc_readv_disabled_cbk,
+ FIRST_CHILD (frame->this),
+ FIRST_CHILD (frame->this)->fops->readv, fd, size,
+ offset);
return 0;
}
if (!fd_ctx_get (fd, this, NULL)) {
/* disable caching for this fd, go ahead with normal readv */
- STACK_WIND (frame,
- ioc_readv_disabled_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->readv,
- fd,
- size,
- offset);
+ STACK_WIND (frame, ioc_readv_disabled_cbk,
+ FIRST_CHILD (frame->this),
+ FIRST_CHILD (frame->this)->fops->readv, fd, size,
+ offset);
return 0;
}
@@ -1058,7 +1009,7 @@ ioc_readv (call_frame_t *frame,
}
ioc_table_unlock (ioc_inode->table);
- dispatch_requests (frame, ioc_inode, fd, offset, size);
+ ioc_dispatch_requests (frame, ioc_inode, fd, offset, size);
return 0;
}
@@ -1074,16 +1025,13 @@ ioc_readv (call_frame_t *frame,
*
*/
int32_t
-ioc_writev_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct stat *stbuf)
+ioc_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct stat *stbuf)
{
- ioc_local_t *local = frame->local;
- uint64_t ioc_inode = 0;
+ ioc_local_t *local = NULL;
+ uint64_t ioc_inode = 0;
+ local = frame->local;
inode_ctx_get (local->fd->inode, this, &ioc_inode);
if (ioc_inode)
@@ -1105,16 +1053,12 @@ ioc_writev_cbk (call_frame_t *frame,
*
*/
int32_t
-ioc_writev (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- struct iovec *vector,
- int32_t count,
- off_t offset,
+ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ struct iovec *vector, int32_t count, off_t offset,
struct iobref *iobref)
{
ioc_local_t *local = NULL;
- uint64_t ioc_inode = 0;
+ uint64_t ioc_inode = 0;
local = CALLOC (1, sizeof (ioc_local_t));
ERR_ABORT (local);
@@ -1127,14 +1071,8 @@ ioc_writev (call_frame_t *frame,
if (ioc_inode)
ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame,
- ioc_writev_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->writev,
- fd,
- vector,
- count,
- offset,
+ STACK_WIND (frame, ioc_writev_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, fd, vector, count, offset,
iobref);
return 0;
@@ -1152,12 +1090,8 @@ ioc_writev (call_frame_t *frame,
*
*/
int32_t
-ioc_truncate_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct stat *buf)
+ioc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct stat *buf)
{
STACK_UNWIND (frame, op_ret, op_errno, buf);
@@ -1174,10 +1108,7 @@ ioc_truncate_cbk (call_frame_t *frame,
*
*/
int32_t
-ioc_truncate (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- off_t offset)
+ioc_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
{
uint64_t ioc_inode = 0;
inode_ctx_get (loc->inode, this, &ioc_inode);
@@ -1185,12 +1116,8 @@ ioc_truncate (call_frame_t *frame,
if (ioc_inode)
ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame,
- ioc_truncate_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->truncate,
- loc,
- offset);
+ STACK_WIND (frame, ioc_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset);
return 0;
}
@@ -1204,10 +1131,7 @@ ioc_truncate (call_frame_t *frame,
*
*/
int32_t
-ioc_ftruncate (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- off_t offset)
+ioc_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
{
uint64_t ioc_inode = 0;
inode_ctx_get (fd->inode, this, &ioc_inode);
@@ -1215,41 +1139,30 @@ ioc_ftruncate (call_frame_t *frame,
if (ioc_inode)
ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame,
- ioc_truncate_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->ftruncate,
- fd,
- offset);
+ STACK_WIND (frame, ioc_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, fd, offset);
return 0;
}
int32_t
-ioc_lk_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct flock *lock)
+ioc_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct flock *lock)
{
STACK_UNWIND (frame, op_ret, op_errno, lock);
return 0;
}
int32_t
-ioc_lk (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- int32_t cmd,
- struct flock *lock)
+ioc_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
+ struct flock *lock)
{
- ioc_inode_t *ioc_inode = NULL;
+ ioc_inode_t *ioc_inode = NULL;
uint64_t tmp_inode = 0;
inode_ctx_get (fd->inode, this, &tmp_inode);
ioc_inode = (ioc_inode_t *)(long)tmp_inode;
if (!ioc_inode) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_DEBUG,
"inode context is NULL: returning EBADFD");
STACK_UNWIND (frame, -1, EBADFD, NULL);
return 0;
@@ -1261,26 +1174,27 @@ ioc_lk (call_frame_t *frame,
}
ioc_inode_unlock (ioc_inode);
- STACK_WIND (frame, ioc_lk_cbk,
- FIRST_CHILD (this),
+ STACK_WIND (frame, ioc_lk_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->lk, fd, cmd, lock);
+
return 0;
}
int32_t
ioc_get_priority_list (const char *opt_str, struct list_head *first)
{
- int32_t max_pri = 0;
- char *tmp_str = NULL;
- char *tmp_str1 = NULL;
- char *tmp_str2 = NULL;
- char *dup_str = NULL;
- char *stripe_str = NULL;
- char *pattern = NULL;
- char *priority = NULL;
- char *string = strdup (opt_str);
+ int32_t max_pri = 0;
+ char *tmp_str = NULL;
+ char *tmp_str1 = NULL;
+ char *tmp_str2 = NULL;
+ char *dup_str = NULL;
+ char *stripe_str = NULL;
+ char *pattern = NULL;
+ char *priority = NULL;
+ char *string = NULL;
struct ioc_priority *curr = NULL;
+ string = strdup (opt_str);
/* Get the pattern for cache priority.
* "option priority *.jpg:1,abc*:2" etc
*/
@@ -1326,9 +1240,9 @@ int32_t
init (xlator_t *this)
{
ioc_table_t *table;
- dict_t *options = this->options;
- uint32_t index = 0;
- char *cache_size_string = NULL;
+ dict_t *options = this->options;
+ uint32_t index = 0;
+ char *cache_size_string = NULL;
if (!this->children || this->children->next) {
gf_log (this->name, GF_LOG_ERROR,
diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h
index ffa7d7d..954b3fe 100644
--- a/xlators/performance/io-cache/src/io-cache.h
+++ b/xlators/performance/io-cache/src/io-cache.h
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2007-2009 Z RESEARCH, Inc. <http://www.zresearch.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2007-2009 Z RESEARCH, Inc. <http://www.zresearch.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
#ifndef __IO_CACHE_H
@@ -47,8 +47,8 @@ struct ioc_inode;
struct ioc_priority {
struct list_head list;
- char *pattern;
- uint32_t priority;
+ char *pattern;
+ uint32_t priority;
};
/*
@@ -60,9 +60,9 @@ struct ioc_priority {
*/
struct ioc_waitq {
struct ioc_waitq *next;
- void *data;
- off_t pending_offset;
- size_t pending_size;
+ void *data;
+ off_t pending_offset;
+ size_t pending_size;
};
/*
@@ -71,32 +71,38 @@ struct ioc_waitq {
*/
struct ioc_fill {
struct list_head list; /* list of ioc_fill structures of a frame */
- off_t offset;
- size_t size;
- struct iovec *vector;
- int32_t count;
- struct iobref *iobref;
+ off_t offset;
+ size_t size;
+ struct iovec *vector;
+ int32_t count;
+ struct iobref *iobref;
};
struct ioc_local {
- mode_t mode;
- int32_t flags;
- loc_t file_loc;
- off_t offset;
- size_t size;
- int32_t op_ret;
- int32_t op_errno;
+ mode_t mode;
+ int32_t flags;
+ loc_t file_loc;
+ off_t offset;
+ size_t size;
+ int32_t op_ret;
+ int32_t op_errno;
struct list_head fill_list; /* list of ioc_fill structures */
- off_t pending_offset; /* offset from this frame should continue */
- size_t pending_size; /* size of data this frame is waiting on */
+ off_t pending_offset; /*
+ * offset from this frame should
+ * continue
+ */
+ size_t pending_size; /*
+ * size of data this frame is waiting
+ * on
+ */
struct ioc_inode *inode;
- int32_t wait_count;
- pthread_mutex_t local_lock;
+ int32_t wait_count;
+ pthread_mutex_t local_lock;
struct ioc_waitq *waitq;
- void *stub;
- fd_t *fd;
- int32_t need_xattr;
- dict_t *xattr_req;
+ void *stub;
+ fd_t *fd;
+ int32_t need_xattr;
+ dict_t *xattr_req;
};
/*
@@ -104,48 +110,59 @@ struct ioc_local {
*
*/
struct ioc_page {
- struct list_head pages;
- struct list_head page_lru;
- struct ioc_inode *inode; /* inode this page belongs to */
+ struct list_head pages;
+ struct list_head page_lru;
+ struct ioc_inode *inode; /* inode this page belongs to */
struct ioc_priority *priority;
- char dirty;
- char ready;
- struct iovec *vector;
- int32_t count;
- off_t offset;
- size_t size;
- struct ioc_waitq *waitq;
- struct iobref *iobref;
- pthread_mutex_t page_lock;
+ char dirty;
+ char ready;
+ struct iovec *vector;
+ int32_t count;
+ off_t offset;
+ size_t size;
+ struct ioc_waitq *waitq;
+ struct iobref *iobref;
+ pthread_mutex_t page_lock;
};
struct ioc_inode {
struct ioc_table *table;
struct list_head pages; /* list of pages of this inode */
- struct list_head inode_list; /* list of inodes, maintained by io-cache translator */
+ struct list_head inode_list; /*
+ * list of inodes, maintained by io-cache
+ * translator
+ */
struct list_head inode_lru;
struct list_head page_lru;
struct ioc_waitq *waitq;
- pthread_mutex_t inode_lock;
- uint32_t weight; /* weight of the inode, increases on each read */
- time_t mtime; /* mtime of the server file when last cached */
- struct timeval tv; /* time-stamp at last re-validate */
+ pthread_mutex_t inode_lock;
+ uint32_t weight; /*
+ * weight of the inode, increases on each
+ * read
+ */
+ time_t mtime; /*
+ * mtime of the server file when last
+ * cached
+ */
+ struct timeval tv; /*
+ * time-stamp at last re-validate
+ */
};
struct ioc_table {
- uint64_t page_size;
- uint64_t cache_size;
- uint64_t cache_used;
+ uint64_t page_size;
+ uint64_t cache_size;
+ uint64_t cache_used;
struct list_head inodes; /* list of inodes cached */
struct list_head active;
struct list_head *inode_lru;
struct list_head priority_list;
- int32_t readv_count;
- pthread_mutex_t table_lock;
- xlator_t *xl;
- uint32_t inode_count;
- int32_t cache_timeout;
- int32_t max_pri;
+ int32_t readv_count;
+ pthread_mutex_t table_lock;
+ xlator_t *xl;
+ uint32_t inode_count;
+ int32_t cache_timeout;
+ int32_t max_pri;
};
typedef struct ioc_table ioc_table_t;
@@ -162,33 +179,22 @@ char *
ptr_to_str (void *ptr);
int32_t
-ioc_readv_disabled_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct iovec *vector,
- int32_t count,
- struct stat *stbuf,
+ioc_readv_disabled_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iovec *vector,
+ int32_t count, struct stat *stbuf,
struct iobref *iobref);
ioc_page_t *
-ioc_page_get (ioc_inode_t *ioc_inode,
- off_t offset);
+ioc_page_get (ioc_inode_t *ioc_inode, off_t offset);
ioc_page_t *
-ioc_page_create (ioc_inode_t *ioc_inode,
- off_t offset);
+ioc_page_create (ioc_inode_t *ioc_inode, off_t offset);
void
-ioc_page_fault (ioc_inode_t *ioc_inode,
- call_frame_t *frame,
- fd_t *fd,
+ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
off_t offset);
void
-ioc_wait_on_page (ioc_page_t *page,
- call_frame_t *frame,
- off_t offset,
+ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset,
size_t size);
ioc_waitq_t *
@@ -198,9 +204,8 @@ void
ioc_page_flush (ioc_page_t *page);
ioc_waitq_t *
-ioc_page_error (ioc_page_t *page,
- int32_t op_ret,
- int32_t op_errno);
+ioc_page_error (ioc_page_t *page, int32_t op_ret, int32_t op_errno);
+
void
ioc_page_purge (ioc_page_t *page);
@@ -211,9 +216,7 @@ void
ioc_waitq_return (ioc_waitq_t *waitq);
void
-ioc_frame_fill (ioc_page_t *page,
- call_frame_t *frame,
- off_t offset,
+ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,
size_t size);
#define ioc_inode_lock(ioc_inode) \
@@ -293,16 +296,13 @@ time_elapsed (struct timeval *now,
}
ioc_inode_t *
-ioc_inode_search (ioc_table_t *table,
- inode_t *inode);
+ioc_inode_search (ioc_table_t *table, inode_t *inode);
void
ioc_inode_destroy (ioc_inode_t *ioc_inode);
ioc_inode_t *
-ioc_inode_update (ioc_table_t *table,
- inode_t *inode,
- uint32_t weight);
+ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight);
int64_t
ioc_page_destroy (ioc_page_t *page);
@@ -314,13 +314,11 @@ void
ioc_inode_flush (ioc_inode_t *ioc_inode);
void
-ioc_inode_wakeup (call_frame_t *frame,
- ioc_inode_t *ioc_inode,
- struct stat *stbuf);
+ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode,
+ struct stat *stbuf);
int8_t
-ioc_cache_still_valid (ioc_inode_t *ioc_inode,
- struct stat *stbuf);
+ioc_cache_still_valid (ioc_inode_t *ioc_inode, struct stat *stbuf);
int32_t
ioc_prune (ioc_table_t *table);
@@ -328,4 +326,4 @@ ioc_prune (ioc_table_t *table);
int32_t
ioc_need_prune (ioc_table_t *table);
-#endif /* __READ_AHEAD_H */
+#endif /* __IO_CACHE_H */
diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c
index 917391d..c984ce1 100644
--- a/xlators/performance/io-cache/src/ioc-inode.c
+++ b/xlators/performance/io-cache/src/ioc-inode.c
@@ -33,7 +33,9 @@
void *
str_to_ptr (char *string)
{
- void *ptr = (void *)strtoul (string, NULL, 16);
+ void *ptr = NULL;
+
+ ptr = (void *)strtoul (string, NULL, 16);
return ptr;
}
@@ -46,23 +48,23 @@ str_to_ptr (char *string)
char *
ptr_to_str (void *ptr)
{
- char *str;
+ char *str = NULL;
asprintf (&str, "%p", ptr);
return str;
}
void
-ioc_inode_wakeup (call_frame_t *frame,
- ioc_inode_t *ioc_inode,
- struct stat *stbuf)
+ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode,
+ struct stat *stbuf)
{
ioc_waitq_t *waiter = NULL, *waited = NULL;
ioc_waitq_t *page_waitq = NULL;
- int8_t cache_still_valid = 1;
- ioc_local_t *local = frame->local;
- int8_t need_fault = 0;
- ioc_page_t *waiter_page = NULL;
+ int8_t cache_still_valid = 1;
+ ioc_local_t *local = NULL;
+ int8_t need_fault = 0;
+ ioc_page_t *waiter_page = NULL;
+ local = frame->local;
ioc_inode_lock (ioc_inode);
{
waiter = ioc_inode->waitq;
@@ -143,11 +145,11 @@ ioc_inode_wakeup (call_frame_t *frame,
* not for external reference
*/
ioc_inode_t *
-ioc_inode_update (ioc_table_t *table,
- inode_t *inode,
- uint32_t weight)
+ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight)
{
- ioc_inode_t *ioc_inode = CALLOC (1, sizeof (ioc_inode_t));
+ ioc_inode_t *ioc_inode = NULL;
+
+ ioc_inode = CALLOC (1, sizeof (ioc_inode_t));
ERR_ABORT (ioc_inode);
ioc_inode->table = table;
@@ -185,7 +187,9 @@ ioc_inode_update (ioc_table_t *table,
void
ioc_inode_destroy (ioc_inode_t *ioc_inode)
{
- ioc_table_t *table = ioc_inode->table;
+ ioc_table_t *table = NULL;
+
+ table = ioc_inode->table;
ioc_table_lock (table);
table->inode_count--;
@@ -198,4 +202,3 @@ ioc_inode_destroy (ioc_inode_t *ioc_inode)
pthread_mutex_destroy (&ioc_inode->inode_lock);
free (ioc_inode);
}
-
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index 73db26d..87a6e1a 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -1,20 +1,20 @@
/*
- Copyright (c) 2007-2009 Z RESEARCH, Inc. <http://www.zresearch.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2007-2009 Z RESEARCH, Inc. <http://www.zresearch.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
#ifndef _CONFIG_H
@@ -31,14 +31,16 @@
#include <sys/time.h>
ioc_page_t *
-ioc_page_get (ioc_inode_t *ioc_inode,
- off_t offset)
+ioc_page_get (ioc_inode_t *ioc_inode, off_t offset)
{
int8_t found = 0;
- ioc_page_t *page = NULL;
- ioc_table_t *table = ioc_inode->table;
- off_t rounded_offset = floor (offset, table->page_size);
+ ioc_page_t *page = NULL;
+ ioc_table_t *table = NULL;
+ off_t rounded_offset = 0;
+ table = ioc_inode->table;
+ rounded_offset = floor (offset, table->page_size);
+
if (list_empty (&ioc_inode->pages)) {
return NULL;
}
@@ -118,11 +120,11 @@ int32_t
ioc_prune (ioc_table_t *table)
{
ioc_inode_t *curr = NULL, *next_ioc_inode = NULL;
- ioc_page_t *page = NULL, *next = NULL;
- int32_t ret = -1;
- int32_t index = 0;
- uint64_t size_to_prune = 0;
- uint64_t size_pruned = 0;
+ ioc_page_t *page = NULL, *next = NULL;
+ int32_t ret = -1;
+ int32_t index = 0;
+ uint64_t size_to_prune = 0;
+ uint64_t size_pruned = 0;
ioc_table_lock (table);
{
@@ -190,15 +192,19 @@ ioc_prune (ioc_table_t *table)
*
*/
ioc_page_t *
-ioc_page_create (ioc_inode_t *ioc_inode,
- off_t offset)
+ioc_page_create (ioc_inode_t *ioc_inode, off_t offset)
{
- ioc_table_t *table = ioc_inode->table;
- ioc_page_t *page = NULL;
- off_t rounded_offset = floor (offset, table->page_size);
- ioc_page_t *newpage = CALLOC (1, sizeof (*newpage));
- ERR_ABORT (newpage);
+ ioc_table_t *table = NULL;
+ ioc_page_t *page = NULL;
+ off_t rounded_offset = 0;
+ ioc_page_t *newpage = NULL;
+ table = ioc_inode->table;
+ rounded_offset = floor (offset, table->page_size);
+
+ newpage = CALLOC (1, sizeof (*newpage));
+ ERR_ABORT (newpage);
+
if (ioc_inode)
table = ioc_inode->table;
else {
@@ -229,9 +235,7 @@ ioc_page_create (ioc_inode_t *ioc_inode,
*
*/
void
-ioc_wait_on_page (ioc_page_t *page,
- call_frame_t *frame,
- off_t offset,
+ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset,
size_t size)
{
ioc_waitq_t *waitq = NULL;
@@ -270,8 +274,7 @@ ioc_wait_on_page (ioc_page_t *page,
* assumes ioc_inode is locked
*/
int8_t
-ioc_cache_still_valid (ioc_inode_t *ioc_inode,
- struct stat *stbuf)
+ioc_cache_still_valid (ioc_inode_t *ioc_inode, struct stat *stbuf)
{
int8_t cache_still_valid = 1;
@@ -316,27 +319,26 @@ ioc_waitq_return (ioc_waitq_t *waitq)
int
-ioc_fault_cbk (call_frame_t *frame,
- void *cookie,
- xlator_t *this,
- int32_t op_ret,
- int32_t op_errno,
- struct iovec *vector,
- int32_t count,
- struct stat *stbuf,
- struct iobref *iobref)
+ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iovec *vector,
+ int32_t count, struct stat *stbuf, struct iobref *iobref)
{
- ioc_local_t *local = frame->local;
- off_t offset = local->pending_offset;
- ioc_inode_t *ioc_inode = local->inode;
- ioc_table_t *table = ioc_inode->table;
- ioc_page_t *page = NULL;
- off_t trav_offset = 0;
- size_t payload_size = 0;
- int32_t destroy_size = 0;
- size_t page_size = 0;
+ ioc_local_t *local = NULL;
+ off_t offset = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_table_t *table = NULL;
+ ioc_page_t *page = NULL;
+ off_t trav_offset = 0;
+ size_t payload_size = 0;
+ int32_t destroy_size = 0;
+ size_t page_size = 0;
ioc_waitq_t *waitq = NULL;
- size_t iobref_page_size = 0;
+ size_t iobref_page_size = 0;
+
+ local = frame->local;
+ offset = local->pending_offset;
+ ioc_inode = local->inode;
+ table = ioc_inode->table;
trav_offset = offset;
payload_size = op_ret;
@@ -458,15 +460,17 @@ ioc_fault_cbk (call_frame_t *frame,
*
*/
void
-ioc_page_fault (ioc_inode_t *ioc_inode,
- call_frame_t *frame,
- fd_t *fd,
+ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
off_t offset)
{
- ioc_table_t *table = ioc_inode->table;
- call_frame_t *fault_frame = copy_frame (frame);
- ioc_local_t *fault_local = CALLOC (1, sizeof (ioc_local_t));
- ERR_ABORT (fault_local);
+ ioc_table_t *table = NULL;
+ call_frame_t *fault_frame = NULL;
+ ioc_local_t *fault_local = NULL;
+
+ table = ioc_inode->table;
+ fault_frame = copy_frame (frame);
+ fault_local = CALLOC (1, sizeof (ioc_local_t));
+ ERR_ABORT (fault_local);
/* NOTE: copy_frame() means, the frame the fop whose fd_ref we
* are using till now won't be valid till we get reply from server.
@@ -485,26 +489,28 @@ ioc_page_fault (ioc_inode_t *ioc_inode,
"stack winding page fault for offset = %"PRId64" with "
"frame %p", offset, fault_frame);
- STACK_WIND (fault_frame, ioc_fault_cbk,
- FIRST_CHILD(fault_frame->this),
- FIRST_CHILD(fault_frame->this)->fops->readv,
- fd, table->page_size, offset);
+ STACK_WIND (fault_frame, ioc_fault_cbk, FIRST_CHILD(fault_frame->this),
+ FIRST_CHILD(fault_frame->this)->fops->readv, fd,
+ table->page_size, offset);
return;
}
void
-ioc_frame_fill (ioc_page_t *page,
- call_frame_t *frame,
- off_t offset,
- size_t size)
+ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,
+ size_t size)
{
- ioc_local_t *local = frame->local;
- ioc_fill_t *fill = NULL;
- off_t src_offset = 0;
- off_t dst_offset = 0;
- ssize_t copy_size = 0;
- ioc_inode_t *ioc_inode = page->inode;
+ ioc_local_t *local = NULL;
+ ioc_fill_t *fill = NULL;
+ off_t src_offset = 0;
+ off_t dst_offset = 0;
+ ssize_t copy_size = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_fill_t *new = NULL;
+ int8_t found = 0;
+ local = frame->local;
+ ioc_inode = page->inode;
+
gf_log (frame->this->name, GF_LOG_DEBUG,
"frame (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET" "
"&& page->size = %"GF_PRI_SIZET" && wait_count = %d",
@@ -542,7 +548,7 @@ ioc_frame_fill (ioc_page_t *page,
copy_size, src_offset, dst_offset);
{
- ioc_fill_t *new = CALLOC (1, sizeof (*new));
+ new = CALLOC (1, sizeof (*new));
ERR_ABORT (new);
new->offset = page->offset;
new->size = copy_size;
@@ -570,7 +576,7 @@ ioc_frame_fill (ioc_page_t *page,
* ioc_fill_t to the end of list */
list_add_tail (&new->list, &local->fill_list);
} else {
- int8_t found = 0;
+ found = 0;
/* list is not empty, we need to look for
* where this offset fits in list */
list_for_each_entry (fill, &local->fill_list,
@@ -607,15 +613,16 @@ ioc_frame_fill (ioc_page_t *page,
static void
ioc_frame_unwind (call_frame_t *frame)
{
- ioc_local_t *local = frame->local;
- ioc_fill_t *fill = NULL, *next = NULL;
- int32_t count = 0;
- struct iovec *vector = NULL;
- int32_t copied = 0;
+ ioc_local_t *local = NULL;
+ ioc_fill_t *fill = NULL, *next = NULL;
+ int32_t count = 0;
+ struct iovec *vector = NULL;
+ int32_t copied = 0;
struct iobref *iobref = NULL;
- struct stat stbuf = {0,};
- int32_t op_ret = 0;
+ struct stat stbuf = {0,};
+ int32_t op_ret = 0;
+ local = frame->local;
// ioc_local_lock (local);
iobref = iobref_new ();
@@ -656,13 +663,8 @@ ioc_frame_unwind (call_frame_t *frame)
// ioc_local_unlock (local);
- STACK_UNWIND (frame,
- op_ret,
- local->op_errno,
- vector,
- count,
- &stbuf,
- iobref);
+ STACK_UNWIND (frame, op_ret, local->op_errno, vector, count,
+ &stbuf, iobref);
iobref_unref (iobref);
@@ -682,9 +684,11 @@ ioc_frame_unwind (call_frame_t *frame)
void
ioc_frame_return (call_frame_t *frame)
{
- ioc_local_t *local = frame->local;
- int32_t wait_count;
- assert (local->wait_count > 0);
+ ioc_local_t *local = NULL;
+ int32_t wait_count = 0;
+
+ local = frame->local;
+ assert (local->wait_count > 0);
ioc_local_lock (local);
{
@@ -708,7 +712,7 @@ ioc_frame_return (call_frame_t *frame)
ioc_waitq_t *
ioc_page_wakeup (ioc_page_t *page)
{
- ioc_waitq_t *waitq = NULL, *trav = NULL;
+ ioc_waitq_t *waitq = NULL, *trav = NULL;
call_frame_t *frame = NULL;
waitq = page->waitq;
@@ -738,15 +742,13 @@ ioc_page_wakeup (ioc_page_t *page)
*
*/
ioc_waitq_t *
-ioc_page_error (ioc_page_t *page,
- int32_t op_ret,
- int32_t op_errno)
+ioc_page_error (ioc_page_t *page, int32_t op_ret, int32_t op_errno)
{
- ioc_waitq_t *waitq = NULL, *trav = NULL;
+ ioc_waitq_t *waitq = NULL, *trav = NULL;
call_frame_t *frame = NULL;
- int64_t ret = 0;
- ioc_table_t *table = NULL;
- ioc_local_t *local = NULL;
+ int64_t ret = 0;
+ ioc_table_t *table = NULL;
+ ioc_local_t *local = NULL;
waitq = page->waitq;
page->waitq = NULL;