Exemplo n.º 1
0
/**
*  Thread that will build the list of FID to re synchronize

   @param ctx_p : pointer to replication context
   
   @retval 0 on success
   @retval -1 on error (see errno for details)
*/
static void *geo_rep_restart_from_scratch_thread(void *param) {
  char                name[32];
  geo_rep_srv_ctx_t * ctx_p = (geo_rep_srv_ctx_t *) param;
  int                 status=-1;

  sprintf(name,"geoScratch.eid%d.site%d", ctx_p->eid, ctx_p->site_id);
  uma_dbg_thread_add_self(name);
  
  info("%s started",name);
  
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
  status = geo_rep_restart_from_scratch(ctx_p);
  pthread_exit(&status);
}  
Exemplo n.º 2
0
static void *quota_wbcache_thread(void *v) {

    pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
    int quota_wbcache_thread_period_current_count = 0;
    quota_wbcache_thread_period_count = 1;
    // Set the frequency of calls
    struct timespec ts = {DIRENT_WBCACHE_PTHREAD_FREQUENCY_SEC, 0};
   quota_wbcache_entry_t  *cache_p;
   int i;

    uma_dbg_thread_add_self("Quota wr.back");
    
    quota_wbcache_thread_period_count = DIRENT_WBCACHE_PTHREAD_FREQUENCY_SEC;
    quota_wbcache_poll_stats[0] = 0;
    quota_wbcache_poll_stats[1] = 0;
    info("WriteBack cache thread started ");

    for (;;) {
        quota_wbcache_thread_period_current_count++;
	if (quota_wbcache_thread_period_current_count >= quota_wbcache_thread_period_count)
	{
          START_PROFILING_TH(quota_wbcache_poll_stats);
          cache_p = &quota_wbcache_cache_p[0];
          for (i = 0; i < QUOTA_CACHE_MAX_ENTRY;i++,cache_p++)
	  {
	     if (cache_p->state == 0) continue;
	     if (quota_wbcache_check_write_pending(cache_p) == 0)
	     {
	        continue;
	     }
	     quota_wbcache_diskflush(cache_p);
	  
	  
	  }
	  STOP_PROFILING_TH(quota_wbcache_poll_stats);
	  quota_wbcache_thread_period_current_count = 0;
	}
        nanosleep(&ts, NULL);
    }
    return 0;
}
Exemplo n.º 3
0
static void *expt_thread(void *v) {

    pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
     uma_dbg_thread_add_self("Meta_trk");
    int expt_thread_period_current_count = 0;
    expt_thread_period_count = 10;
    // Set the frequency of calls
    struct timespec ts = {EXPT_PTHREAD_FREQUENCY_SEC, 0};
   expt_ctx_t  *entry_p;
   int i;
    
    expt_thread_period_count = EXPT_PTHREAD_FREQUENCY_SEC*30;
    expt_poll_stats[0] = 0;
    expt_poll_stats[1] = 0;
    info("inode export tracking thread started ");

    for (;;) {
        expt_thread_period_current_count++;
	if (expt_thread_period_current_count >= expt_thread_period_count)
	{
          START_PROFILING_TH(expt_poll_stats);
          
          for (i = 0; i < expt_thread_cur_context;i++)
	  {
	     entry_p = expt_thread_ctx_p[i];
	     if (entry_p == NULL) continue;
	     expt_disk_flush(entry_p);
	  
	  
	  }
	  STOP_PROFILING_TH(expt_poll_stats);
	  expt_thread_period_current_count = 0;
	}
        nanosleep(&ts, NULL);
    }
    return 0;
}
Exemplo n.º 4
0
/**
 *  This function is the entry point for setting rozofs in non-blocking mode

   @param args->ch: reference of the fuse channnel
   @param args->se: reference of the fuse session
   @param args->max_transactions: max number of transactions that can be handled in parallel
   
   @retval -1 on error
   @retval : no retval -> only on fatal error

 */
int rozofs_stat_start(void *args) {

    uma_dbg_thread_add_self("Main");

    int ret; 
    //sem_t semForEver;    /* semaphore for blocking the main thread doing nothing */
    args_p = args;
    exportclt_t *exportclt_p = (exportclt_t*)args_p->exportclt;
    uint16_t debug_port = args_p->debug_port;
    uint16_t export_listening_port = (uint16_t)exportclt_p->listen_port;
    
    info("exportd listening port %d",export_listening_port);
    /*
    ** allocate memory for bandwidth computation
    */
    rozofs_throughput_counter_init();
   
    ret = ruc_init(FALSE, debug_port,export_listening_port);
    if (ret != RUC_OK) {
        /*
         ** fatal error
         */
        return -1;
    }

    {
        char name[32];
        sprintf(name, "rozofsmount %d", args_p->instance);
        uma_dbg_set_name(name);
    }
    
    /*
    ** Send the file lock reset request to remove old locks
    ** (NB This is not actually a low level fuse API....)
    */
    rozofs_ll_clear_client_file_lock(exportclt.eid,rozofs_client_hash);

    /*
     ** init of the fuse part
     */
    ret = rozofs_fuse_init(args_p->ch, args_p->se, args_p->max_transactions);
    if (ret != RUC_OK) {
        /*
         ** fatal error
         */
        return -1;
    }
    
#if 0
    NO MORE LBG MASTER. USE ONLY LBG EXPORTD.
    /*
     ** Perform the init with exportd--> setup of the TCP connection associated with the load balancing group
     */
    uint16_t export_nb_port = rozofs_get_service_port_export_master_eproto(); 
    if (export_lbg_initialize((exportclt_t*) args_p->exportclt, EXPORT_PROGRAM, EXPORT_VERSION, export_nb_port,
                               (af_stream_poll_CBK_t) rozofs_export_lbg_cnx_polling) != 0) {
        severe("Cannot setup the load balancing group towards Exportd");
    }
#endif    
    
    //#warning storcli instances are hardcoded
    if (storcli_lbg_initialize((exportclt_t*) args_p->exportclt,"rozofsmount", args_p->instance, 1, 2) != 0) {
        severe("Cannot setup the load balancing group towards StorCli");
    }
    
    rozofs_signals_declare("rozofsmount",  common_config.nb_core_file);
    

  /*
  **  change the priority of the main thread
  */
#if 1
    {
      struct sched_param my_priority;
      int policy=-1;
      int ret= 0;

      pthread_getschedparam(pthread_self(),&policy,&my_priority);
          info("storio main thread Scheduling policy   = %s\n",
                    (policy == SCHED_OTHER) ? "SCHED_OTHER" :
                    (policy == SCHED_FIFO)  ? "SCHED_FIFO" :
                    (policy == SCHED_RR)    ? "SCHED_RR" :
                    "???");
 #if 1
      my_priority.sched_priority= 98;
      policy = SCHED_RR;
      ret = pthread_setschedparam(pthread_self(),policy,&my_priority);
      if (ret < 0) 
      {
	severe("error on sched_setscheduler: %s",strerror(errno));	
      }
      pthread_getschedparam(pthread_self(),&policy,&my_priority);
          DEBUG("RozoFS thread Scheduling policy (prio %d)  = %s\n",my_priority.sched_priority,
                    (policy == SCHED_OTHER) ? "SCHED_OTHER" :
                    (policy == SCHED_FIFO)  ? "SCHED_FIFO" :
                    (policy == SCHED_RR)    ? "SCHED_RR" :
                    "???");
 #endif        
     
    }  
#endif  
   /*
   ** start the file KPI service
   */
   rzkpi_file_service_init();

    /*
    ** create the fuse threads
    */
    info("FDL RozoFs Instance %d",args_p->instance);
    ret = rozofs_fuse_thread_intf_create("localhost",args_p->instance,3);
    if (ret < 0)
    {
       fatal("Cannot create fuse threads");
    }
    fuse_reply_thread_init();
    uma_dbg_addTopic("fuse_reply_thread", show_fuse_reply_thread);  
    
      
    /*
     ** main loop
     */
    while (1) {
        ruc_sockCtrl_selectWait();
    }
    fatal( "main() code is rotten" );
}
Exemplo n.º 5
0
void *rozofs_fuse_thread(void *arg) {
  rozofs_fuse_thread_msg_t   msg;
  rozofs_fuse_thread_ctx_t * ctx_p = (rozofs_fuse_thread_ctx_t*)arg;
  int                        bytesRcvd;

#if 1
    {
      struct sched_param my_priority;
      int policy=-1;
      int ret= 0;
      uma_dbg_thread_add_self("Fuse_Rsp");
      
      pthread_getschedparam(pthread_self(),&policy,&my_priority);
          info("storio main thread Scheduling policy   = %s\n",
                    (policy == SCHED_OTHER) ? "SCHED_OTHER" :
                    (policy == SCHED_FIFO)  ? "SCHED_FIFO" :
                    (policy == SCHED_RR)    ? "SCHED_RR" :
                    "???");
 #if 1
      my_priority.sched_priority= 98;
      policy = SCHED_FIFO;
      ret = pthread_setschedparam(pthread_self(),policy,&my_priority);
      if (ret < 0) 
      {
	severe("error on sched_setscheduler: %s",strerror(errno));	
      }
      pthread_getschedparam(pthread_self(),&policy,&my_priority);
          DEBUG("RozoFS thread Scheduling policy (prio %d)  = %s\n",my_priority.sched_priority,
                    (policy == SCHED_OTHER) ? "SCHED_OTHER" :
                    (policy == SCHED_FIFO)  ? "SCHED_FIFO" :
                    (policy == SCHED_RR)    ? "SCHED_RR" :
                    "???");
 #endif        

    }  
#endif     

  //info("Fuse Thread %d Started !!\n",ctx_p->thread_idx);
  
  while(1) {
  
    /*
    ** read the north disk socket
    */
    bytesRcvd = recvfrom(af_unix_fuse_socket_ref,
			 &msg,sizeof(msg), 
			 0,(struct sockaddr *)NULL,NULL);
    if (bytesRcvd == -1) {
      fatal("Disk Thread %d recvfrom %s !!\n",ctx_p->thread_idx,strerror(errno));
      exit(0);
    }
    if (bytesRcvd != sizeof(msg)) {
      fatal("Disk Thread %d socket is dead (%d/%d) %s !!\n",ctx_p->thread_idx,bytesRcvd,(int)sizeof(msg),strerror(errno));
      exit(0);    
    }
    
    switch (msg.opcode) {
    
      case ROZOFS_FUSE_REPLY_BUF:
        rozofs_fuse_th_fuse_reply_buf(ctx_p,&msg);
        break;
	
      default:
        fatal(" unexpected opcode : %d\n",msg.opcode);
        exit(0);       
    }
//    sched_yield();
  }
}