summaryrefslogtreecommitdiffstats
path: root/xlators/performance
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/performance')
-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 { \