diff options
| author | Raghavendra G <raghavendra@gluster.com> | 2011-09-22 12:39:16 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2011-10-01 05:56:43 -0700 | 
| commit | 7e79dfe348e3da5cbfc7d1af0d193173689c3919 (patch) | |
| tree | 728dd9d1ed525d85c47048c6685c9e24ea7d7429 | |
| parent | 72cade6db5fd3f6f001295a5f4edeecf44e36045 (diff) | |
performance/io-cache: move mem-pool initialisation to init.
  - mem-pool is global structure which is stored in ioc-inode-table and hence
    can be initialised in init.
Change-Id: I215118d61e17805c9f3e78cb8e8297e17cc1117d
BUG: 3608
Reviewed-on: http://review.gluster.com/484
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amar@gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
| -rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 39 | 
1 files changed, 13 insertions, 26 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 230842389cc..830386e0206 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -1080,7 +1080,6 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,          ioc_local_t *local         = NULL;          uint32_t     weight        = 0;          ioc_table_t *table         = NULL; -        uint32_t     num_pages     = 0;          int32_t      op_errno      = -1;          if (!this) { @@ -1107,29 +1106,6 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,                  goto out;          } - -        ioc_table_lock (table); -        { -                if (!table->mem_pool) { - -                        num_pages = (table->cache_size / table->page_size) -                                + ((table->cache_size % table->page_size) -                                   ? 1 : 0); - -                        table->mem_pool -                                =  mem_pool_new (rbthash_entry_t, num_pages); - -                        if (!table->mem_pool) { -                                gf_log (this->name, GF_LOG_ERROR, -                                        "Unable to allocate mem_pool"); -                                op_errno = ENOMEM; -                                ioc_table_unlock (table); -                                goto out; -                        } -                } -        } -        ioc_table_unlock (table); -          ioc_inode_lock (ioc_inode);          {                  if (!ioc_inode->cache.page_table) { @@ -1727,6 +1703,7 @@ init (xlator_t *this)          glusterfs_ctx_t *ctx               = NULL;          data_t          *data              = 0;          char            *def_val           = NULL; +        uint32_t         num_pages         = 0;          xl_options = this->options; @@ -1800,7 +1777,6 @@ init (xlator_t *this)                  }          } -          data = dict_get (xl_options, "cache-timeout");          if (data) {                  table->cache_timeout = data_to_uint32 (data); @@ -1842,7 +1818,6 @@ init (xlator_t *this)                  }          } -          data = dict_get (xl_options, "min-file-size");          if (data)                  tmp = data_to_str (data); @@ -1918,6 +1893,18 @@ init (xlator_t *this)          pthread_mutex_init (&table->table_lock, NULL);          this->private = table; + +        num_pages = (table->cache_size / table->page_size) +                + ((table->cache_size % table->page_size) +                   ? 1 : 0); + +        table->mem_pool = mem_pool_new (rbthash_entry_t, num_pages); +        if (!table->mem_pool) { +                gf_log (this->name, GF_LOG_ERROR, +                        "Unable to allocate mem_pool"); +                goto out; +        } +          ret = 0;          ctx = this->ctx;  | 
