summaryrefslogtreecommitdiffstats
path: root/xlators/performance
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/performance')
-rw-r--r--xlators/performance/quick-read/src/quick-read-mem-types.h34
-rw-r--r--xlators/performance/quick-read/src/quick-read.c623
-rw-r--r--xlators/performance/quick-read/src/quick-read.h12
3 files changed, 328 insertions, 341 deletions
diff --git a/xlators/performance/quick-read/src/quick-read-mem-types.h b/xlators/performance/quick-read/src/quick-read-mem-types.h
index 32591125fe0..972fdb0d8c1 100644
--- a/xlators/performance/quick-read/src/quick-read-mem-types.h
+++ b/xlators/performance/quick-read/src/quick-read-mem-types.h
@@ -1,23 +1,22 @@
/*
- Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.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 Affero 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2008-2010 Gluster, Inc. <http://www.gluster.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 Affero 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
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
*/
-
#ifndef __QR_MEM_TYPES_H__
#define __QR_MEM_TYPES_H__
@@ -34,4 +33,3 @@ enum gf_qr_mem_types_ {
gf_qr_mt_end
};
#endif
-
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index cc83772a55e..04b57ab082c 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -79,7 +79,7 @@ out:
static int32_t
qr_loc_fill (loc_t *loc, inode_t *inode, char *path)
{
- int32_t ret = -1;
+ int32_t ret = -1;
char *parent = NULL;
if ((loc == NULL) || (inode == NULL) || (path == NULL)
@@ -126,8 +126,8 @@ out:
void
qr_resume_pending_ops (qr_fd_ctx_t *qr_fd_ctx)
{
- struct list_head waiting_ops;
- call_stub_t *stub = NULL, *tmp = NULL;
+ call_stub_t *stub = NULL, *tmp = NULL;
+ struct list_head waiting_ops = {0, };
if (qr_fd_ctx == NULL) {
goto out;
@@ -173,25 +173,25 @@ out:
static inline uint32_t
is_match (const char *path, const char *pattern)
{
- int32_t ret = 0;
+ int32_t ret = 0;
- ret = fnmatch (pattern, path, FNM_NOESCAPE);
+ ret = fnmatch (pattern, path, FNM_NOESCAPE);
- return (ret == 0);
+ return (ret == 0);
}
uint32_t
qr_get_priority (qr_conf_t *conf, const char *path)
{
- uint32_t priority = 0;
- struct qr_priority *curr = NULL;
+ uint32_t priority = 0;
+ struct qr_priority *curr = NULL;
list_for_each_entry (curr, &conf->priority_list, list) {
if (is_match (path, curr->pattern))
priority = curr->priority;
}
- return priority;
+ return priority;
}
@@ -199,7 +199,7 @@ qr_get_priority (qr_conf_t *conf, const char *path)
qr_inode_t *
__qr_inode_alloc (xlator_t *this, char *path, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
+ qr_inode_t *qr_inode = NULL;
qr_private_t *priv = NULL;
int priority = 0;
@@ -247,13 +247,13 @@ out:
void
__qr_cache_prune (xlator_t *this)
{
- qr_private_t *priv = NULL;
- qr_conf_t *conf = NULL;
- qr_inode_table_t *table = NULL;
- qr_inode_t *curr = NULL, *next = NULL;
- int32_t index = 0;
- uint64_t size_to_prune = 0;
- uint64_t size_pruned = 0;
+ qr_private_t *priv = NULL;
+ qr_conf_t *conf = NULL;
+ qr_inode_table_t *table = NULL;
+ qr_inode_t *curr = NULL, *next = NULL;
+ int32_t index = 0;
+ uint64_t size_to_prune = 0;
+ uint64_t size_pruned = 0;
priv = this->private;
table = &priv->table;
@@ -273,7 +273,7 @@ __qr_cache_prune (xlator_t *this)
done:
table->cache_used -= size_pruned;
- return;
+ return;
}
/* To be called with table->lock held */
@@ -374,7 +374,6 @@ qr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
unlock:
UNLOCK (&table->lock);
-
out:
/*
* FIXME: content size in dict can be greater than the size application
@@ -390,16 +389,16 @@ out:
int32_t
qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
{
- qr_conf_t *conf = NULL;
- dict_t *new_req_dict = NULL;
- int32_t op_ret = -1, op_errno = -1;
- data_t *content = NULL;
+ qr_conf_t *conf = NULL;
+ dict_t *new_req_dict = NULL;
+ int32_t op_ret = -1, op_errno = -1;
+ data_t *content = NULL;
uint64_t requested_size = 0, size = 0, value = 0;
- char cached = 0;
- qr_inode_t *qr_inode = NULL;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
- qr_local_t *local = NULL;
+ char cached = 0;
+ qr_inode_t *qr_inode = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ qr_local_t *local = NULL;
priv = this->private;
conf = &priv->conf;
@@ -466,7 +465,7 @@ qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
}
}
- STACK_WIND (frame, qr_lookup_cbk, FIRST_CHILD(this),
+ STACK_WIND (frame, qr_lookup_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->lookup, loc, xattr_req);
if (new_req_dict) {
@@ -491,16 +490,16 @@ int32_t
qr_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
int32_t op_errno, fd_t *fd)
{
- uint64_t value = 0;
- int32_t ret = -1;
- struct list_head waiting_ops;
- qr_local_t *local = NULL;
+ uint64_t value = 0;
+ int32_t ret = -1;
+ qr_local_t *local = NULL;
qr_inode_t *qr_inode = NULL;
qr_fd_ctx_t *qr_fd_ctx = NULL;
- call_stub_t *stub = NULL, *tmp = NULL;
- char is_open = 0;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
+ call_stub_t *stub = NULL, *tmp = NULL;
+ char is_open = 0;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ struct list_head waiting_ops;
priv = this->private;
table = &priv->table;
@@ -575,15 +574,15 @@ int32_t
qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
fd_t *fd, int32_t wbflags)
{
- qr_inode_t *qr_inode = NULL;
- int32_t ret = -1;
- uint64_t filep = 0;
+ qr_inode_t *qr_inode = NULL;
+ int32_t ret = -1;
+ uint64_t filep = 0;
char content_cached = 0;
- qr_fd_ctx_t *qr_fd_ctx = NULL, *tmp_fd_ctx = NULL;
- int32_t op_ret = -1, op_errno = -1;
- qr_local_t *local = NULL;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
+ qr_fd_ctx_t *qr_fd_ctx = NULL, *tmp_fd_ctx = NULL;
+ int32_t op_ret = -1, op_errno = -1;
+ qr_local_t *local = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
priv = this->private;
table = &priv->table;
@@ -612,8 +611,7 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
}
tmp_fd_ctx = NULL;
- local = GF_CALLOC (1, sizeof (*local),
- gf_qr_mt_qr_local_t);
+ local = GF_CALLOC (1, sizeof (*local), gf_qr_mt_qr_local_t);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -694,7 +692,7 @@ qr_time_elapsed (struct timeval *now, struct timeval *then)
static inline char
qr_need_validation (qr_conf_t *conf, qr_inode_t *qr_inode)
{
- struct timeval now = {0, };
+ struct timeval now = {0, };
char need_validation = 0;
gettimeofday (&now, NULL);
@@ -710,7 +708,7 @@ static int32_t
qr_validate_cache_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *buf)
{
- qr_inode_t *qr_inode = NULL;
+ qr_inode_t *qr_inode = NULL;
qr_local_t *local = NULL;
uint64_t value = 0;
int32_t ret = 0;
@@ -771,7 +769,7 @@ unwind:
int32_t
qr_validate_cache_helper (call_frame_t *frame, xlator_t *this, fd_t *fd)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
int32_t op_ret = -1, op_errno = -1;
local = frame->local;
@@ -799,20 +797,23 @@ int
qr_validate_cache (call_frame_t *frame, xlator_t *this, fd_t *fd,
call_stub_t *stub)
{
- int ret = -1;
- int flags = 0;
- uint64_t value = 0;
- loc_t loc = {0, };
- char *path = NULL;
- qr_local_t *local = NULL;
- qr_fd_ctx_t *qr_fd_ctx = NULL;
+ int ret = -1;
+ int flags = 0;
+ uint64_t value = 0;
+ loc_t loc = {0, };
+ char *path = NULL;
+ qr_local_t *local = NULL;
+ qr_fd_ctx_t *qr_fd_ctx = NULL;
call_stub_t *validate_stub = NULL;
- char need_open = 0, can_wind = 0;
+ char need_open = 0, can_wind = 0;
- local = GF_CALLOC (1, sizeof (*local),
- gf_qr_mt_qr_local_t);
- if (local == NULL) {
- goto out;
+ if (frame->local == NULL) {
+ local = GF_CALLOC (1, sizeof (*local), gf_qr_mt_qr_local_t);
+ if (local == NULL) {
+ goto out;
+ }
+ } else {
+ local = frame->local;
}
local->fd = fd;
@@ -875,8 +876,7 @@ qr_validate_cache (call_frame_t *frame, xlator_t *this, fd_t *fd,
qr_loc_wipe (&loc);
} else if (can_wind) {
- STACK_WIND (frame, qr_validate_cache_cbk,
- FIRST_CHILD (this),
+ STACK_WIND (frame, qr_validate_cache_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->fstat, fd);
}
@@ -891,9 +891,9 @@ qr_readv_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 iatt *stbuf, struct iobref *iobref)
{
- QR_STACK_UNWIND (readv, frame, op_ret, op_errno, vector, count,
+ QR_STACK_UNWIND (readv, frame, op_ret, op_errno, vector, count,
stbuf, iobref);
- return 0;
+ return 0;
}
@@ -911,29 +911,29 @@ int32_t
qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
off_t offset)
{
- qr_inode_t *qr_inode = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
- uint64_t value = 0;
- int count = -1, flags = 0, i = 0;
+ qr_inode_t *qr_inode = NULL;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
+ uint64_t value = 0;
+ int count = -1, flags = 0, i = 0;
char content_cached = 0, need_validation = 0;
- char need_open = 0, can_wind = 0, need_unwind = 0;
- struct iobuf *iobuf = NULL;
- struct iobref *iobref = NULL;
- struct iatt stbuf = {0, };
- data_t *content = NULL;
- qr_fd_ctx_t *qr_fd_ctx = NULL;
- call_stub_t *stub = NULL;
- loc_t loc = {0, };
- qr_conf_t *conf = NULL;
- struct iovec *vector = NULL;
- char *path = NULL;
- off_t start = 0, end = 0;
- size_t len = 0;
- struct iobuf_pool *iobuf_pool = NULL;
- qr_local_t *local = NULL;
+ char need_open = 0, can_wind = 0, need_unwind = 0;
+ struct iobuf *iobuf = NULL;
+ struct iobref *iobref = NULL;
+ struct iatt stbuf = {0, };
+ data_t *content = NULL;
+ qr_fd_ctx_t *qr_fd_ctx = NULL;
+ call_stub_t *stub = NULL;
+ loc_t loc = {0, };
+ qr_conf_t *conf = NULL;
+ struct iovec *vector = NULL;
+ char *path = NULL;
+ off_t start = 0, end = 0;
+ size_t len = 0;
+ struct iobuf_pool *iobuf_pool = NULL;
+ qr_local_t *local = NULL;
char just_validated = 0;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
op_ret = 0;
@@ -976,7 +976,6 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
content = dict_get (qr_inode->xattr,
GF_CONTENT_KEY);
-
stbuf = qr_inode->stbuf;
content_cached = 1;
list_move_tail (&qr_inode->lru,
@@ -1034,7 +1033,11 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
goto unlock;
}
- start = offset + (iobuf_pool->page_size * i);
+ start = offset
+ +
+ (iobuf_pool->page_size
+ * i);
+
if (start > end) {
len = 0;
} else {
@@ -1064,7 +1067,7 @@ unlock:
out:
if (content_cached || need_unwind) {
QR_STACK_UNWIND (readv, frame, op_ret, op_errno, vector,
- count, &stbuf, iobref);
+ count, &stbuf, iobref);
} else if (need_validation) {
stub = fop_readv_stub (frame, qr_readv, fd, size, offset);
@@ -1137,8 +1140,7 @@ out:
qr_loc_wipe (&loc);
} else if (can_wind) {
- STACK_WIND (frame, qr_readv_cbk,
- FIRST_CHILD (this),
+ STACK_WIND (frame, qr_readv_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->readv, fd, size,
offset);
}
@@ -1163,8 +1165,8 @@ qr_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
struct iatt *postbuf)
{
- QR_STACK_UNWIND (writev, frame, op_ret, op_errno, prebuf, postbuf);
- return 0;
+ QR_STACK_UNWIND (writev, frame, op_ret, op_errno, prebuf, postbuf);
+ return 0;
}
@@ -1184,17 +1186,17 @@ int32_t
qr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
int32_t count, off_t off, struct iobref *iobref)
{
- uint64_t value = 0;
- int flags = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
- qr_inode_t *qr_inode = NULL;
+ uint64_t value = 0;
+ int flags = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
+ qr_inode_t *qr_inode = NULL;
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t op_ret = -1, op_errno = -1, ret = -1;
- char can_wind = 0, need_unwind = 0, need_open = 0;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
+ int32_t op_ret = -1, op_errno = -1, ret = -1;
+ char can_wind = 0, need_unwind = 0, need_open = 0;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
priv = this->private;
table = &priv->table;
@@ -1255,8 +1257,7 @@ qr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
}
if (need_unwind) {
- QR_STACK_UNWIND (writev, frame, op_ret, op_errno, NULL,
- NULL);
+ QR_STACK_UNWIND (writev, frame, op_ret, op_errno, NULL, NULL);
} else if (can_wind) {
STACK_WIND (frame, qr_writev_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->writev, fd, vector, count,
@@ -1282,10 +1283,10 @@ ret:
int32_t
qr_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, struct iatt *buf)
+ int32_t op_errno, struct iatt *buf)
{
- QR_STACK_UNWIND (fstat, frame, op_ret, op_errno, buf);
- return 0;
+ QR_STACK_UNWIND (fstat, frame, op_ret, op_errno, buf);
+ return 0;
}
@@ -1303,12 +1304,12 @@ qr_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
{
qr_fd_ctx_t *qr_fd_ctx = NULL;
char need_open = 0, can_wind = 0, need_unwind = 0;
- uint64_t value = 0;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
- call_stub_t *stub = NULL;
- loc_t loc = {0, };
- char *path = NULL;
- int flags = 0;
+ uint64_t value = 0;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
+ call_stub_t *stub = NULL;
+ loc_t loc = {0, };
+ char *path = NULL;
+ int flags = 0;
ret = fd_ctx_get (fd, this, &value);
if (ret == 0) {
@@ -1374,15 +1375,13 @@ ret:
}
-
-
int32_t
qr_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno,
struct iatt *preop, struct iatt *postop)
{
- QR_STACK_UNWIND (fsetattr, frame, op_ret, op_errno, preop, postop);
- return 0;
+ QR_STACK_UNWIND (fsetattr, frame, op_ret, op_errno, preop, postop);
+ return 0;
}
@@ -1401,13 +1400,13 @@ int32_t
qr_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
struct iatt *stbuf, int32_t valid)
{
- uint64_t value = 0;
- int flags = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
+ uint64_t value = 0;
+ int flags = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
char need_open = 0, can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
@@ -1451,8 +1450,7 @@ qr_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
if (need_unwind) {
- QR_STACK_UNWIND (fsetattr, frame, op_ret, op_errno, NULL,
- NULL);
+ QR_STACK_UNWIND (fsetattr, frame, op_ret, op_errno, NULL, NULL);
} else if (can_wind) {
STACK_WIND (frame, qr_fsetattr_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->fsetattr, fd, stbuf,
@@ -1480,8 +1478,8 @@ int32_t
qr_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno)
{
- QR_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno);
- return 0;
+ QR_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno);
+ return 0;
}
@@ -1499,14 +1497,14 @@ int32_t
qr_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
int32_t flags)
{
- uint64_t value = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
int open_flags = 0;
- qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
- char need_open = 0, can_wind = 0, need_unwind = 0;
+ qr_fd_ctx_t *qr_fd_ctx = NULL;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
+ char need_open = 0, can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
if (ret == 0) {
@@ -1576,10 +1574,10 @@ ret:
int32_t
qr_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict)
+ int32_t op_ret, int32_t op_errno, dict_t *dict)
{
- QR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict);
- return 0;
+ QR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict);
+ return 0;
}
@@ -1596,13 +1594,13 @@ qr_fgetxattr_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
int32_t
qr_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name)
{
- int flags = 0;
- uint64_t value = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
+ int flags = 0;
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
char need_open = 0, can_wind = 0, need_unwind = 0;
/*
@@ -1679,8 +1677,8 @@ int32_t
qr_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
int32_t op_errno)
{
- QR_STACK_UNWIND (flush, frame, op_ret, op_errno);
- return 0;
+ QR_STACK_UNWIND (flush, frame, op_ret, op_errno);
+ return 0;
}
@@ -1696,11 +1694,11 @@ qr_flush_helper (call_frame_t *frame, xlator_t *this, fd_t *fd)
int32_t
qr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
{
- uint64_t value = 0;
- call_stub_t *stub = NULL;
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
- char can_wind = 0, need_unwind = 0;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
+ char can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
if (ret == 0) {
@@ -1751,8 +1749,8 @@ int32_t
qr_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno)
{
- QR_STACK_UNWIND (fentrylk, frame, op_ret, op_errno);
- return 0;
+ QR_STACK_UNWIND (fentrylk, frame, op_ret, op_errno);
+ return 0;
}
int32_t
@@ -1771,13 +1769,13 @@ int32_t
qr_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
const char *basename, entrylk_cmd cmd, entrylk_type type)
{
- int flags = 0;
- uint64_t value = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
+ int flags = 0;
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
char need_open = 0, can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
@@ -1852,8 +1850,8 @@ qr_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno)
{
- QR_STACK_UNWIND (finodelk, frame, op_ret, op_errno);
- return 0;
+ QR_STACK_UNWIND (finodelk, frame, op_ret, op_errno);
+ return 0;
}
@@ -1871,13 +1869,13 @@ int32_t
qr_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
int32_t cmd, struct gf_flock *lock)
{
- int flags = 0;
- uint64_t value = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
+ int flags = 0;
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
char need_open = 0, can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
@@ -1951,8 +1949,8 @@ int32_t
qr_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf)
{
- QR_STACK_UNWIND (fsync, frame, op_ret, op_errno, prebuf, postbuf);
- return 0;
+ QR_STACK_UNWIND (fsync, frame, op_ret, op_errno, prebuf, postbuf);
+ return 0;
}
@@ -1967,14 +1965,14 @@ qr_fsync_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
int32_t
qr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
{
- uint64_t value = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
int open_flags = 0;
- qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
- char need_open = 0, can_wind = 0, need_unwind = 0;
+ qr_fd_ctx_t *qr_fd_ctx = NULL;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
+ char need_open = 0, can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
if (ret == 0) {
@@ -2017,8 +2015,7 @@ qr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
}
if (need_unwind) {
- QR_STACK_UNWIND (fsync, frame, op_ret, op_errno, NULL,
- NULL);
+ QR_STACK_UNWIND (fsync, frame, op_ret, op_errno, NULL, NULL);
} else if (can_wind) {
STACK_WIND (frame, qr_fsync_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->fsync, fd, flags);
@@ -2046,12 +2043,12 @@ qr_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
struct iatt *postbuf)
{
- int32_t ret = 0;
- uint64_t value = 0;
- qr_inode_t *qr_inode = NULL;
- qr_local_t *local = NULL;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
+ int32_t ret = 0;
+ uint64_t value = 0;
+ qr_inode_t *qr_inode = NULL;
+ qr_local_t *local = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
if (op_ret == -1) {
goto out;
@@ -2106,14 +2103,14 @@ qr_ftruncate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
int32_t
qr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
{
- int flags = 0;
- uint64_t value = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
- qr_local_t *local = NULL;
+ int flags = 0;
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
+ qr_local_t *local = NULL;
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
char need_open = 0, can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
@@ -2121,8 +2118,7 @@ qr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
qr_fd_ctx = (qr_fd_ctx_t *)(long)value;
}
- local = GF_CALLOC (1, sizeof (*local),
- gf_qr_mt_qr_local_t);
+ local = GF_CALLOC (1, sizeof (*local), gf_qr_mt_qr_local_t);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2172,7 +2168,7 @@ qr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
out:
if (need_unwind) {
QR_STACK_UNWIND (ftruncate, frame, op_ret, op_errno, NULL,
- NULL);
+ NULL);
} else if (can_wind) {
STACK_WIND (frame, qr_ftruncate_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->ftruncate, fd, offset);
@@ -2196,11 +2192,11 @@ ret:
int32_t
-qr_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+qr_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
int32_t op_errno, struct gf_flock *lock)
{
- QR_STACK_UNWIND (lk, frame, op_ret, op_errno, lock);
- return 0;
+ QR_STACK_UNWIND (lk, frame, op_ret, op_errno, lock);
+ return 0;
}
@@ -2208,7 +2204,7 @@ int32_t
qr_lk_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
struct gf_flock *lock)
{
- STACK_WIND (frame, qr_lk_cbk, FIRST_CHILD(this),
+ STACK_WIND (frame, qr_lk_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->lk, fd, cmd, lock);
return 0;
@@ -2219,13 +2215,13 @@ int32_t
qr_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
struct gf_flock *lock)
{
- int flags = 0;
- uint64_t value = 0;
- call_stub_t *stub = NULL;
- char *path = NULL;
- loc_t loc = {0, };
+ int flags = 0;
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ char *path = NULL;
+ loc_t loc = {0, };
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = -1, op_ret = -1, op_errno = -1;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
char need_open = 0, can_wind = 0, need_unwind = 0;
ret = fd_ctx_get (fd, this, &value);
@@ -2296,8 +2292,8 @@ int32_t
qr_release (xlator_t *this, fd_t *fd)
{
qr_fd_ctx_t *qr_fd_ctx = NULL;
- int32_t ret = 0;
- uint64_t value = 0;
+ int32_t ret = 0;
+ uint64_t value = 0;
ret = fd_ctx_del (fd, this, &value);
if (ret == 0) {
@@ -2314,10 +2310,10 @@ qr_release (xlator_t *this, fd_t *fd)
int32_t
qr_forget (xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
- uint64_t value = 0;
- int32_t ret = -1;
- qr_private_t *priv = NULL;
+ qr_inode_t *qr_inode = NULL;
+ uint64_t value = 0;
+ int32_t ret = -1;
+ qr_private_t *priv = NULL;
priv = this->private;
@@ -2334,21 +2330,23 @@ qr_forget (xlator_t *this, inode_t *inode)
return 0;
}
+
int
qr_priv_dump (xlator_t *this)
{
- qr_conf_t *conf = NULL;
- char key[GF_DUMP_MAX_BUF_LEN];
- char key_prefix[GF_DUMP_MAX_BUF_LEN];
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
- uint32_t file_count = 0;
- uint32_t i = 0;
- qr_inode_t *curr = NULL;
- uint64_t total_size = 0;
-
- if (!this)
+ qr_conf_t *conf = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ uint32_t file_count = 0;
+ uint32_t i = 0;
+ qr_inode_t *curr = NULL;
+ uint64_t total_size = 0;
+ char key[GF_DUMP_MAX_BUF_LEN];
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
+
+ if (!this) {
return -1;
+ }
priv = this->private;
conf = &priv->conf;
@@ -2374,8 +2372,7 @@ qr_priv_dump (xlator_t *this)
gf_proc_dump_write (key, "%d", conf->cache_timeout);
if (!table) {
- gf_log (this->name, GF_LOG_WARNING,
- "table is NULL");
+ gf_log (this->name, GF_LOG_WARNING, "table is NULL");
goto out;
} else {
for (i = 0; i < conf->max_pri; i++) {
@@ -2407,7 +2404,7 @@ mem_acct_init (xlator_t *this)
if (ret != 0) {
gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
- "failed");
+ "failed");
return ret;
}
@@ -2418,15 +2415,14 @@ mem_acct_init (xlator_t *this)
int
validate_options (xlator_t *this, dict_t *options, char **op_errstr)
{
- char *str = NULL;
- int32_t ret = -1;
- int32_t cache_timeout;
- uint64_t cache_size;
+ char *str = NULL;
+ int32_t ret = -1;
+ int32_t cache_timeout = 0;
+ uint64_t cache_size = 0;
- if (!this)
+ if (!this) {
goto out;
-
-
+ }
ret = dict_get_str (this->options, "cache-timeout", &str);
if (ret == 0) {
@@ -2443,7 +2439,7 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr)
gf_log (this->name, GF_LOG_ERROR,
"invalid cache-timeout value %s", str);
*op_errstr = "Range 1 <= value <= 60";
- ret = -1;
+ ret = -1;
goto out;
}
}
@@ -2474,36 +2470,34 @@ validate_options (xlator_t *this, dict_t *options, char **op_errstr)
}
-
ret =0;
out:
- return ret;
-
+ return ret;
}
int
reconfigure (xlator_t *this, dict_t *options)
{
+ char *str = NULL;
+ int32_t ret = -1;
+ qr_private_t *priv = NULL;
+ qr_conf_t *conf = NULL;
+ int32_t cache_timeout = 0;
+ uint64_t cache_size = 0;
-
-
- char *str = NULL;
- int32_t ret = -1;
- qr_private_t *priv = NULL;
- qr_conf_t *conf = NULL;
- int32_t cache_timeout;
- uint64_t cache_size;
-
- if (!this)
+ if (!this) {
goto out;
+ }
priv = this->private;
- if (!priv)
+ if (!priv) {
goto out;
+ }
conf = &priv->conf;
- if (!conf)
+ if (!conf) {
goto out;
+ }
cache_timeout = conf->cache_timeout;
ret = dict_get_str (options, "cache-timeout", &str);
@@ -2517,9 +2511,9 @@ reconfigure (xlator_t *this, dict_t *options)
goto out;
}
conf->cache_timeout = cache_timeout;
- }
- else
+ } else {
conf->cache_timeout = 1;
+ }
cache_size = conf->cache_size;
ret = dict_get_str (options, "cache-size", &str);
@@ -2532,33 +2526,33 @@ reconfigure (xlator_t *this, dict_t *options)
ret = -1;
goto out;
}
+
gf_log (this->name, GF_LOG_DEBUG,
"Reconfiguring cache-siz to %"PRIu64, cache_size);
conf->cache_size = cache_size;
- }
- else
+ } else {
conf->cache_size = QR_DEFAULT_CACHE_SIZE;
+ }
ret = 0;
out:
return ret;
-
}
int32_t
qr_get_priority_list (const char *opt_str, struct list_head *first)
{
- int32_t max_pri = 1;
- char *tmp_str = NULL;
- char *tmp_str1 = NULL;
- char *tmp_str2 = NULL;
- char *dup_str = NULL;
- char *priority_str = NULL;
- char *pattern = NULL;
- char *priority = NULL;
- char *string = NULL;
- struct qr_priority *curr = NULL, *tmp = NULL;
+ int32_t max_pri = 1;
+ char *tmp_str = NULL;
+ char *tmp_str1 = NULL;
+ char *tmp_str2 = NULL;
+ char *dup_str = NULL;
+ char *priority_str = NULL;
+ char *pattern = NULL;
+ char *priority = NULL;
+ char *string = NULL;
+ struct qr_priority *curr = NULL, *tmp = NULL;
string = gf_strdup (opt_str);
if (string == NULL) {
@@ -2566,64 +2560,64 @@ qr_get_priority_list (const char *opt_str, struct list_head *first)
goto out;
}
- /* Get the pattern for cache priority.
- * "option priority *.jpg:1,abc*:2" etc
- */
- /* TODO: inode_lru in table is statically hard-coded to 5,
- * should be changed to run-time configuration
- */
- priority_str = strtok_r (string, ",", &tmp_str);
- while (priority_str) {
- curr = GF_CALLOC (1, sizeof (*curr), gf_qr_mt_qr_priority_t);
+ /* Get the pattern for cache priority.
+ * "option priority *.jpg:1,abc*:2" etc
+ */
+ /* TODO: inode_lru in table is statically hard-coded to 5,
+ * should be changed to run-time configuration
+ */
+ priority_str = strtok_r (string, ",", &tmp_str);
+ while (priority_str) {
+ curr = GF_CALLOC (1, sizeof (*curr), gf_qr_mt_qr_priority_t);
if (curr == NULL) {
max_pri = -1;
goto out;
}
- list_add_tail (&curr->list, first);
+ list_add_tail (&curr->list, first);
- dup_str = gf_strdup (priority_str);
+ dup_str = gf_strdup (priority_str);
if (dup_str == NULL) {
max_pri = -1;
goto out;
}
- pattern = strtok_r (dup_str, ":", &tmp_str1);
- if (!pattern) {
+ pattern = strtok_r (dup_str, ":", &tmp_str1);
+ if (!pattern) {
max_pri = -1;
goto out;
}
- priority = strtok_r (NULL, ":", &tmp_str1);
- if (!priority) {
+ priority = strtok_r (NULL, ":", &tmp_str1);
+ if (!priority) {
max_pri = -1;
goto out;
}
- gf_log ("quick-read", GF_LOG_TRACE,
- "quick-read priority : pattern %s : priority %s",
- pattern,
- priority);
+ gf_log ("quick-read", GF_LOG_TRACE,
+ "quick-read priority : pattern %s : priority %s",
+ pattern,
+ priority);
- curr->pattern = gf_strdup (pattern);
+ curr->pattern = gf_strdup (pattern);
if (curr->pattern == NULL) {
max_pri = -1;
goto out;
}
- curr->priority = strtol (priority, &tmp_str2, 0);
- if (tmp_str2 && (*tmp_str2)) {
+ curr->priority = strtol (priority, &tmp_str2, 0);
+ if (tmp_str2 && (*tmp_str2)) {
max_pri = -1;
goto out;
} else {
- max_pri = max (max_pri, curr->priority);
+ max_pri = max (max_pri, curr->priority);
}
GF_FREE (dup_str);
dup_str = NULL;
- priority_str = strtok_r (NULL, ",", &tmp_str);
- }
+ priority_str = strtok_r (NULL, ",", &tmp_str);
+ }
out:
if (string != NULL) {
GF_FREE (string);
@@ -2641,14 +2635,14 @@ out:
}
}
- return max_pri;
+ return max_pri;
}
int32_t
init (xlator_t *this)
{
- char *str = NULL;
+ char *str = NULL;
int32_t ret = -1, i = 0;
qr_private_t *priv = NULL;
qr_conf_t *conf = NULL;
@@ -2656,17 +2650,16 @@ init (xlator_t *this)
if (!this->children || this->children->next) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: volume (%s) not configured with exactly one "
- "child", this->name);
+ "child", this->name);
return -1;
}
- if (!this->parents) {
- gf_log (this->name, GF_LOG_WARNING,
- "dangling volume. check volfile ");
- }
+ if (!this->parents) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "dangling volume. check volfile ");
+ }
- priv = GF_CALLOC (1, sizeof (*priv),
- gf_qr_mt_qr_private_t);
+ priv = GF_CALLOC (1, sizeof (*priv), gf_qr_mt_qr_private_t);
if (priv == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"out of memory");
@@ -2716,25 +2709,24 @@ init (xlator_t *this)
}
}
- INIT_LIST_HEAD (&conf->priority_list);
- conf->max_pri = 1;
- if (dict_get (this->options, "priority")) {
- char *option_list = data_to_str (dict_get (this->options,
- "priority"));
- gf_log (this->name, GF_LOG_TRACE,
- "option path %s", option_list);
- /* parse the list of pattern:priority */
- conf->max_pri = qr_get_priority_list (option_list,
- &conf->priority_list);
+ INIT_LIST_HEAD (&conf->priority_list);
+ conf->max_pri = 1;
+ if (dict_get (this->options, "priority")) {
+ char *option_list = data_to_str (dict_get (this->options,
+ "priority"));
+ gf_log (this->name, GF_LOG_TRACE,
+ "option path %s", option_list);
+ /* parse the list of pattern:priority */
+ conf->max_pri = qr_get_priority_list (option_list,
+ &conf->priority_list);
- if (conf->max_pri == -1) {
+ if (conf->max_pri == -1) {
goto out;
}
conf->max_pri ++;
- }
+ }
- priv->table.lru = GF_CALLOC (conf->max_pri,
- sizeof (*priv->table.lru),
+ priv->table.lru = GF_CALLOC (conf->max_pri, sizeof (*priv->table.lru),
gf_common_mt_list_head);
if (priv->table.lru == NULL) {
ret = -1;
@@ -2764,9 +2756,8 @@ fini (xlator_t *this)
return;
}
-
struct xlator_fops fops = {
- .lookup = qr_lookup,
+ .lookup = qr_lookup,
.open = qr_open,
.readv = qr_readv,
.writev = qr_writev,
@@ -2782,8 +2773,6 @@ struct xlator_fops fops = {
.fsetattr = qr_fsetattr,
};
-
-
struct xlator_cbks cbks = {
.forget = qr_forget,
.release = qr_release,
@@ -2794,9 +2783,9 @@ struct xlator_dumpops dumpops = {
};
struct volume_options options[] = {
- { .key = {"priority"},
- .type = GF_OPTION_TYPE_ANY
- },
+ { .key = {"priority"},
+ .type = GF_OPTION_TYPE_ANY
+ },
{ .key = {"cache-size"},
.type = GF_OPTION_TYPE_SIZET,
.min = 0,
diff --git a/xlators/performance/quick-read/src/quick-read.h b/xlators/performance/quick-read/src/quick-read.h
index 0b2a5ae30e5..3b5c900943b 100644
--- a/xlators/performance/quick-read/src/quick-read.h
+++ b/xlators/performance/quick-read/src/quick-read.h
@@ -108,11 +108,11 @@ typedef struct qr_private qr_private_t;
void qr_local_free (qr_local_t *local);
-#define QR_STACK_UNWIND(op, frame, params ...) do { \
- qr_local_t *__local = frame->local; \
- frame->local = NULL; \
- STACK_UNWIND_STRICT (op, frame, params); \
- qr_local_free (__local); \
-} while (0)
+#define QR_STACK_UNWIND(op, frame, params ...) do { \
+ qr_local_t *__local = frame->local; \
+ frame->local = NULL; \
+ STACK_UNWIND_STRICT (op, frame, params); \
+ qr_local_free (__local); \
+ } while (0)
#endif /* #ifndef __QUICK_READ_H */