Пример #1
0
/**
 * Wait for all queues to be empty
 * and all current DB request to be done.
 */
int handlemap_db_flush()
{
	unsigned int i;
	struct timeval t1;
	struct timeval t2;
	struct timeval tdiff;
	unsigned int to_sync = 0;

	for (i = 0; i < nb_db_threads; i++)
		to_sync += db_thread[i].work_queue.nb_waiting;

	LogEvent(COMPONENT_FSAL,
		 "Waiting for database synchronization (%u operations pending)",
		 to_sync);

	gettimeofday(&t1, NULL);

	/* wait for all threads to finish their job */

	for (i = 0; i < nb_db_threads; i++)
		wait_thread_jobs_finished(&db_thread[i]);

	gettimeofday(&t2, NULL);

	timersub(&t2, &t1, &tdiff);

	LogEvent(COMPONENT_FSAL, "Database synchronized in %d.%06ds",
		 (int)tdiff.tv_sec, (int)tdiff.tv_usec);

	return HANDLEMAP_SUCCESS;

}
Пример #2
0
/**
 * Gives the order to each DB thread to reload
 * the content of its database and insert it
 * to the hash table.
 * The function blocks until all threads have loaded their data.
 */
int handlemap_db_reaload_all(hash_table_t * target_hash)
{
  unsigned int i;
  db_op_item_t *new_task;
  int rc;

  /* give the job to all threads */
  for(i = 0; i < nb_db_threads; i++)
    {
      /* get a new db operation  */
      P(db_thread[i].pool_mutex);

      new_task = pool_alloc(&db_thread[i].dbop_pool, NULL);

      V(db_thread[i].pool_mutex);

      if(!new_task)
        return HANDLEMAP_SYSTEM_ERROR;

      /* can you fill it ? */
      new_task->op_type = LOAD;
      new_task->op_arg.hash = target_hash;

      rc = dbop_push(&db_thread[i].work_queue, new_task);

      if(rc)
        return rc;
    }

  /* wait for all threads to finish their job */

  for(i = 0; i < nb_db_threads; i++)
    {
      wait_thread_jobs_finished(&db_thread[i]);
    }

  return HANDLEMAP_SUCCESS;

}                               /* handlemap_db_reaload_all */