void init_vars(hash_table_t **ht_ip_stats, struct prealloc_pool **ip_stats_pool)
{
    int rc;

    /* Get the FSAL functions */
    FSAL_LoadFunctions();

    /* Get the FSAL consts */
    FSAL_LoadConsts();

    /* Initialize buddy malloc */
    if((rc = BuddyInit(NULL)) != BUDDY_SUCCESS)
    {
        /* Failed init */
        LogTest("Memory manager could not be initialized");
        exit(1);
    }

    nfs_set_param_default(&nfs_param);

    /*ht_ip_stats*/
    return;
    *ht_ip_stats = nfs_Init_ip_stats(nfs_param.ip_stats_param);
    /*  if((*ht_ip_stats = HashTable_Init(nfs_param.ip_stats_param.hash_param)) == NULL)
      {
        LogCrit(COMPONENT_INIT, "NFS IP_STATS: Cannot init IP stats cache");
        return NULL;
        }*/

    if(*ht_ip_stats == NULL)
    {
        LogCrit(COMPONENT_INIT, "NFS_INIT: Error while initializing IP/stats cache");
        exit(1);
    }

    /*ip_stats_pool*/
    MakePool(*ip_stats_pool,
             100,//           nfs_param.worker_param.nb_ip_stats_prealloc,
             nfs_ip_stats_t, NULL, NULL);
    NamePool(*ip_stats_pool, "IP Stats Cache Pool");

    if(!IsPoolPreallocated(*ip_stats_pool))
    {
        LogCrit(COMPONENT_INIT, "NFS_INIT: Error while allocating IP stats cache pool");
        LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno);
        exit(1);
    }
}
Beispiel #2
0
/* One pool can be used for all FSAL_UP used for exports. */
void nfs_Init_FSAL_UP()
{
  memset(&nfs_param.fsal_up_param, 0, sizeof(nfs_param.fsal_up_param));
  nfs_param.fsal_up_param.nb_event_data_prealloc = 2;

  /* DEBUGGING */
  LogDebug(COMPONENT_INIT,
           "FSAL_UP: Initializing FSAL UP data pool");
  /* Allocation of the FSAL UP pool */
  MakePool(&nfs_param.fsal_up_param.event_pool,
           nfs_param.fsal_up_param.nb_event_data_prealloc,
           fsal_up_event_t,
           constructor_fsal_up_event_t, NULL);
  NamePool(&nfs_param.fsal_up_param.event_pool, "FSAL UP Data Pool");
  if(!IsPoolPreallocated(&nfs_param.fsal_up_param.event_pool))
    {
      LogCrit(COMPONENT_INIT,
              "Error while allocating FSAL UP data pool");
      LogError(COMPONENT_INIT, ERR_SYS, ERR_MALLOC, errno);
      Fatal();
    }

  return;
}
Beispiel #3
0
/**
 *
 * cache_inode_client_init: Init the ressource necessary for the cache inode management on the client handside.
 *
 * Init the ressource necessary for the cache inode management on the client handside.
 *
 * @param pclient      [OUT] the pointer to the client to be initiated.
 * @param param        [IN]  the parameter for this cache client.
 * @param thread_index [IN]  an integer related to the 'position' of the thread, from 0 to Nb_Workers -1
 *
 * @return 0 if successful, 1 if failed.
 *
 */
int cache_inode_client_init(cache_inode_client_t * pclient,
                            cache_inode_client_parameter_t param,
                            int thread_index, void *pworker_data)
{
  LRU_status_t lru_status;
  char name[256];

  if(thread_index < SMALL_CLIENT_INDEX)
    sprintf(name, "Cache Inode Worker #%d", thread_index);
  else if(thread_index == SMALL_CLIENT_INDEX)
    sprintf(name, "Cache Inode Small Client");
  else
    sprintf(name, "Cache Inode NLM Async #%d", thread_index - NLM_THREAD_INDEX);

  pclient->attrmask = param.attrmask;
  pclient->nb_prealloc = param.nb_prealloc_entry;
  pclient->nb_pre_dir_data = param.nb_pre_dir_data;
  pclient->nb_pre_parent = param.nb_pre_parent;
  pclient->nb_pre_state_v4 = param.nb_pre_state_v4;
  pclient->expire_type_attr = param.expire_type_attr;
  pclient->expire_type_link = param.expire_type_link;
  pclient->expire_type_dirent = param.expire_type_dirent;
  pclient->grace_period_attr = param.grace_period_attr;
  pclient->grace_period_link = param.grace_period_link;
  pclient->grace_period_dirent = param.grace_period_dirent;
  pclient->use_test_access = param.use_test_access;
  pclient->getattr_dir_invalidation = param.getattr_dir_invalidation;
  pclient->pworker = pworker_data;
  pclient->use_cache = param.use_cache;
  pclient->retention = param.retention;
  pclient->max_fd_per_thread = param.max_fd_per_thread;

  /* introducing desynchronisation for GC */
  pclient->time_of_last_gc = time(NULL) + thread_index * 20;
  pclient->call_since_last_gc = thread_index * 20;

  pclient->time_of_last_gc_fd = time(NULL);

  MakePool(&pclient->pool_entry, pclient->nb_prealloc, cache_entry_t, NULL, NULL);
  NamePool(&pclient->pool_entry, "%s Entry Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_entry))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Entry Pool", name);
      return 1;
    }

  MakePool(&pclient->pool_entry_symlink, pclient->nb_prealloc, cache_inode_symlink_t, NULL, NULL);
  NamePool(&pclient->pool_entry_symlink, "%s Entry Symlink Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_entry_symlink))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Entry Symlink Pool", name);
      return 1;
    }

  MakePool(&pclient->pool_dir_data, pclient->nb_pre_dir_data, cache_inode_dir_data_t, NULL, NULL);
  NamePool(&pclient->pool_dir_data, "%s Dir Data Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_dir_data))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Dir Data Pool", name);
      return 1;
    }

  MakePool(&pclient->pool_parent, pclient->nb_pre_parent, cache_inode_parent_entry_t, NULL, NULL);
  NamePool(&pclient->pool_parent, "%s Parent Link Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_parent))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Parent Link Pool", name);
      return 1;
    }

  MakePool(&pclient->pool_state_v4, pclient->nb_pre_state_v4, state_t, NULL, NULL);
  NamePool(&pclient->pool_state_v4, "%s State V4 Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_state_v4))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s State V4 Pool", name);
      return 1;
    }

  /* TODO: warning - entries in this pool are never released! */
  MakePool(&pclient->pool_state_owner, pclient->nb_pre_state_v4, state_owner_t, NULL, NULL);
  NamePool(&pclient->pool_state_owner, "%s Open Owner Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_state_owner))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Open Owner Pool", name);
      return 1;
    }

  /* TODO: warning - entries in this pool are never released! */
  MakePool(&pclient->pool_nfs4_owner_name, pclient->nb_pre_state_v4, state_nfs4_owner_name_t, NULL, NULL);
  NamePool(&pclient->pool_nfs4_owner_name, "%s Open Owner Name Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_nfs4_owner_name))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Open Owner Name Pool", name);
      return 1;
    }
#ifdef _USE_NFS4_1
  /* TODO: warning - entries in this pool are never released! */
  MakePool(&pclient->pool_session, pclient->nb_pre_state_v4, nfs41_session_t, NULL, NULL);
  NamePool(&pclient->pool_session, "%s Session Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_session))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Session Pool", name);
      return 1;
    }
#endif                          /* _USE_NFS4_1 */

  MakePool(&pclient->pool_key, pclient->nb_prealloc, cache_inode_fsal_data_t, NULL, NULL);
  NamePool(&pclient->pool_key, "%s Key Pool", name);
  if(!IsPoolPreallocated(&pclient->pool_key))
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s Key Pool", name);
      return 1;
    }

  param.lru_param.name = name;

  if((pclient->lru_gc = LRU_Init(param.lru_param, &lru_status)) == NULL)
    {
      LogCrit(COMPONENT_CACHE_INODE,
              "Can't init %s lru gc", name);
      return 1;
    }

  /* Everything was ok, return 0 */
  return 0;
}                               /* cache_inode_client_init */