summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2009-11-26 13:36:34 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-26 11:29:58 -0800
commitff9944ff7910441a1f8b9784c153d5de5be62142 (patch)
tree18e8cb3bd4ab3007f99c05455aa714a90f9df4d7 /xlators
parent03949adaf0c7fcfe10f31a802723613b357ec191 (diff)
performance/stat-prefetch: Changed rbthash to make use of 1 bucket
rbthash makes use of 1 bucket and a common mem-pool is being used for all rbt entries. Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 221 (stat prefetch implementation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=221
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c76
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.h6
2 files changed, 66 insertions, 16 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index 566dd18094f..9a80f50781a 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.c
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c
@@ -19,7 +19,7 @@
#include "stat-prefetch.h"
-#define GF_SP_CACHE_BUCKETS 4096
+#define GF_SP_CACHE_BUCKETS 1
#define GF_SP_CACHE_ENTRIES_EXPECTED 1048576
@@ -165,18 +165,25 @@ sp_hashfn (void *data, int len)
}
sp_cache_t *
-sp_cache_init (void)
+sp_cache_init (xlator_t *this)
{
- sp_cache_t *cache = NULL;
+ sp_cache_t *cache = NULL;
+ sp_private_t *priv = NULL;
+
+ priv = this->private;
+
+ if (!priv)
+ goto out;
+
+ if (!priv->mem_pool)
+ goto out;
cache = CALLOC (1, sizeof (*cache));
if (cache) {
cache->table =
rbthash_table_init (GF_SP_CACHE_BUCKETS,
- sp_hashfn,
- free,
- GF_SP_CACHE_ENTRIES_EXPECTED,
- NULL);
+ sp_hashfn, free,
+ 0, priv->mem_pool);
if (cache->table == NULL) {
FREE (cache);
cache = NULL;
@@ -206,11 +213,23 @@ sp_cache_remove_entry (sp_cache_t *cache, char *name, char remove_all)
{
int32_t ret = -1;
rbthash_table_t *table = NULL;
+ xlator_t *this;
+ sp_private_t *priv = NULL;
if ((cache == NULL) || ((name == NULL) && !remove_all)) {
goto out;
}
+ this = THIS;
+
+ if (this == NULL)
+ goto out;
+
+ if (this->private == NULL)
+ goto out;
+
+ priv = this->private;
+
LOCK (&cache->lock);
{
if (remove_all) {
@@ -218,8 +237,8 @@ sp_cache_remove_entry (sp_cache_t *cache, char *name, char remove_all)
cache->table = rbthash_table_init (GF_SP_CACHE_BUCKETS,
sp_hashfn,
free,
- GF_SP_CACHE_ENTRIES_EXPECTED,
- NULL);
+ 0,
+ priv->mem_pool);
if (cache->table == NULL) {
cache->table = table;
} else {
@@ -916,16 +935,21 @@ int32_t
sp_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, gf_dirent_t *entries)
{
- sp_local_t *local = NULL;
- sp_cache_t *cache = NULL;
- fd_t *fd = NULL;
- int32_t ret = 0;
- char was_present = 1;
+ sp_local_t *local = NULL;
+ sp_cache_t *cache = NULL;
+ fd_t *fd = NULL;
+ int32_t ret = 0;
+ char was_present = 1;
+ sp_private_t *priv = NULL;
if (op_ret == -1) {
goto out;
}
+ if (!this->private) {
+ goto out;
+ }
+
local = frame->local;
if (local == NULL) {
goto out;
@@ -933,12 +957,25 @@ sp_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
fd = local->fd;
+ priv = this->private;
+
+ LOCK (&priv->lock);
+ {
+ if (!priv->mem_pool)
+ priv->mem_pool = mem_pool_new (rbthash_entry_t,
+ GF_SP_CACHE_ENTRIES_EXPECTED);
+ }
+ UNLOCK (&priv->lock);
+
+ if (!priv->mem_pool)
+ goto out;
+
LOCK (&fd->lock);
{
cache = __sp_get_cache_fd (this, fd);
if (cache == NULL) {
was_present = 0;
- cache = sp_cache_init ();
+ cache = sp_cache_init (this);
if (cache == NULL) {
goto unlock;
}
@@ -3750,7 +3787,9 @@ sp_release (xlator_t *this, fd_t *fd)
int32_t
init (xlator_t *this)
{
- int32_t ret = -1;
+ int32_t ret = -1;
+ sp_private_t *priv = NULL;
+
if (!this->children || this->children->next) {
gf_log ("stat-prefetch",
GF_LOG_ERROR,
@@ -3759,6 +3798,11 @@ init (xlator_t *this)
goto out;
}
+ priv = CALLOC (1, sizeof(sp_private_t));
+ LOCK_INIT (&priv->lock);
+
+ this->private = priv;
+
ret = 0;
out:
return ret;
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.h b/xlators/performance/stat-prefetch/src/stat-prefetch.h
index 6e329003e8a..51942acd960 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.h
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.h
@@ -78,6 +78,12 @@ struct sp_inode_ctx {
};
typedef struct sp_inode_ctx sp_inode_ctx_t;
+struct sp_private {
+ struct mem_pool *mem_pool;
+ gf_lock_t lock;
+};
+typedef struct sp_private sp_private_t;
+
void sp_local_free (sp_local_t *local);
#define SP_STACK_UNWIND(op, frame, params ...) do { \