Exemplo n.º 1
0
/**
*  Init of the pseudo fuse thread 

  @param ch : initial channel
  @param se : initial session
  @param rozofs_fuse_buffer_count : number of request buffers (corresponds to the number of fuse save context)  
  
  @retval 0 on success
  @retval -1 on error
*/
int rozofs_fuse_init(struct fuse_chan *ch,struct fuse_session *se,int rozofs_fuse_buffer_count)
{
  int status = 0;
  
//   return 0;
   
  int fileflags;
  rozofs_fuse_ctx_p = malloc(sizeof (rozofs_fuse_ctx_t));
  if (rozofs_fuse_ctx_p == NULL) 
  {
    /*
    ** cannot allocate memory for fuse rozofs context
    */
    return -1;
  }
  /*
  ** clear read/write merge stats table
  */
  memset(rozofs_write_merge_stats_tab,0,sizeof(uint64_t)*RZ_FUSE_WRITE_MAX);
  memset (rozofs_write_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset (rozofs_read_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset(&rozofs_fuse_read_write_stats_buf,0,sizeof(rozofs_fuse_read_write_stats));
  /*
  ** init of the context
  */
  rozofs_fuse_ctx_p->fuseReqPoolRef = NULL;
  rozofs_fuse_ctx_p->ch             = NULL;
  rozofs_fuse_ctx_p->se             = se;
  rozofs_fuse_ctx_p->bufsize        = 0; 
  rozofs_fuse_ctx_p->buf_fuse_req_p = NULL;
  rozofs_fuse_ctx_p->initBufCount   = rozofs_fuse_buffer_count;
  
  while (1)
  {
     /*
     ** get the receive buffer size for former channel in order to create the request distributor
     */
     int bufsize = fuse_chan_bufsize(ch);
     rozofs_fuse_ctx_p->bufsize = bufsize;
     /*
     ** create the pool
     */
     rozofs_fuse_ctx_p->fuseReqPoolRef = ruc_buf_poolCreate(rozofs_fuse_buffer_count,sizeof(rozofs_fuse_save_ctx_t));
     if (rozofs_fuse_ctx_p->fuseReqPoolRef == NULL)
     {
        severe( "rozofs_fuse_init buffer pool creation error(%d,%d)", (int)rozofs_fuse_buffer_count, (int)sizeof(rozofs_fuse_save_ctx_t) ) ;
        status = -1;
        break;
     }
     ruc_buffer_debug_register_pool("fuseCtx",  rozofs_fuse_ctx_p->fuseReqPoolRef);
     
     /*
     ** allocate a buffer for receiving the fuse request
     */
     rozofs_fuse_ctx_p->buf_fuse_req_p = malloc(bufsize);
     if (rozofs_fuse_ctx_p == NULL) 
     {     
        severe( "rozofs_fuse_init out of memory %d", bufsize ) ;
        status = -1;
        break;     
     }
     /*
     ** get the fd of the channel
     */
     rozofs_fuse_ctx_p->fd = fuse_chan_fd(ch);
     /*
     ** create a new channel with the specific operation for rozofs (non-blocking)
     */  
     rozofs_fuse_ctx_p->ch = fuse_chan_new(&rozofs_fuse_ch_ops,fuse_chan_fd(ch),fuse_chan_bufsize(ch),rozofs_fuse_ctx_p);  
     if (rozofs_fuse_ctx_p->ch == NULL)
     {
        severe( "rozofs_fuse_init fuse_chan_new error"  ) ;
        status = -1;
        break;          
     }
     /*
     ** remove the association between the initial session and channel
     */
     fuse_session_remove_chan(ch);  
     /*
     ** OK, now add the new channel
     */
     fuse_session_add_chan(se,rozofs_fuse_ctx_p->ch );  
     /*
     ** set the channel in non blocking mode
     */
     if((fileflags=fcntl(rozofs_fuse_ctx_p->fd,F_GETFL,0))==-1)
     {
       RUC_WARNING(errno);
       status = -1; 
       break;   
     }

     if((fcntl(rozofs_fuse_ctx_p->fd,F_SETFL,fileflags|O_NDELAY))==-1)
     {
       RUC_WARNING(errno);
       status = -1; 
       break;   
     }
     /*
     ** perform the connection with the socket controller
     */
   /*
   ** OK, we are almost done, just need to connect with the socket controller
   */
   rozofs_fuse_ctx_p->connectionId = ruc_sockctl_connect(rozofs_fuse_ctx_p->fd,  // Reference of the socket
                                              "rozofs_fuse",                 // name of the socket
                                              3,                             // Priority within the socket controller
                                              (void*)rozofs_fuse_ctx_p,      // user param for socketcontroller callback
                                              &rozofs_fuse_callBack_sock);   // Default callbacks
    if (rozofs_fuse_ctx_p->connectionId == NULL)
    {
       /*
       ** Fail to connect with the socket controller
       */
       RUC_WARNING(-1);
       status = -1; 
       break;   
    } 
    rozofs_fuse_get_ticker();

     status = 0;
     break;
  }
  /*
  ** attach the callback on socket controller
  */
  ruc_sockCtrl_attach_applicative_poller(rozofs_fuse_scheduler_entry_point); 
  
  uma_dbg_addTopic("fuse", rozofs_fuse_show);
  return status;
  
}
Exemplo n.º 2
0
void rozofs_fuse_show(char * argv[], uint32_t tcpRef, void *bufRef) {
  uint32_t            buffer_count=0;
  char                status[16];
  int   new_val; 
  int   ret;
  
  char *pChar = uma_dbg_get_buffer();

  if (argv[1] != NULL)
  {
      if (strcmp(argv[1],"kernel")==0) 
      {
	 if (rozofs_fuse_ctx_p->ioctl_supported)
	 {
	   ioctl(rozofs_fuse_ctx_p->fd,100,NULL);  
           pChar += sprintf(pChar, "check result in dmesg: ROZOFS_FUSE...\n");
	 } 
	 else
	 { 
           pChar += sprintf(pChar, "ioctl not supported with that fuse kernel version\n");
	 }

	 uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	 return;
      }
      if (strcmp(argv[1],"loop")==0) 
      {
	 errno = 0;
	 if (argv[2] == NULL)
	 {
           pChar += sprintf(pChar, "argument is missing\n");
	   rozofs_fuse_show_usage(pChar);
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;	  	  
	 }
	 new_val = (int) strtol(argv[2], (char **) NULL, 10);   
	 if (errno != 0) {
           pChar += sprintf(pChar, "bad value %s\n",argv[2]);
	   rozofs_fuse_show_usage(pChar);
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;
	 }
	 /*
	 ** 
	 */
	 if (new_val == 0) {
           pChar += sprintf(pChar, "unsupported value %s\n",argv[2]);
	   rozofs_fuse_show_usage(pChar);
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;
	 }	 
	 rozofs_fuse_loop_count = new_val;
         pChar += sprintf(pChar, "new polling request count %d\n",rozofs_fuse_loop_count);
	 uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	 return;
      }
      if (strcmp(argv[1],"dir")==0) 
      {
	 if (rozofs_fuse_ctx_p->ioctl_supported==0)
	 {
           pChar += sprintf(pChar, "ioctl not supported with that fuse kernel version\n");
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;
	 }
	 errno = 0;
	 if (argv[2] == NULL)
	 {
           pChar += sprintf(pChar, "argument is missing\n");
	   rozofs_fuse_show_usage(pChar);
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;	  	  
	 }
	 if (strcmp(argv[2],"enable")==0) 
	 {
	   ret = ioctl(rozofs_fuse_ctx_p->fd,4,NULL);  
	   if (ret < 0) 
	   {
            pChar += sprintf(pChar, "ioctl failed %s\n",strerror(errno));
	   }
	   else
	   {
             pChar += sprintf(pChar, "directory attributes are invalidated on mknod/rmdir/unlink...\n");
	     rozofs_fuse_ctx_p->dir_attr_invalidate = 1;
	   }
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;
         }
	 if (strcmp(argv[2],"disable")==0) 
	 {
	   ret = ioctl(rozofs_fuse_ctx_p->fd,3,NULL);  
	   if (ret < 0) 
	   {
            pChar += sprintf(pChar, "ioctl failed %s\n",strerror(errno));
	   }
	   else
	   {
             pChar += sprintf(pChar, "directory attributes are not invalidated on mknod/rmdir/unlink...\n");
	     rozofs_fuse_ctx_p->dir_attr_invalidate = 0;
	   }
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;
         }
         pChar += sprintf(pChar, "unsupported argument %s\n",argv[2]);
	 rozofs_fuse_show_usage(pChar);
	 uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	 return;
      }
      pChar += sprintf(pChar, "unsupported command %s\n",argv[1]);
      rozofs_fuse_show_usage(pChar);
      uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
      return;
  }
  uint64_t old_ticker = rozofs_fuse_req_tic;
  rozofs_fuse_get_ticker();  
  buffer_count      = ruc_buf_getFreeBufferCount(rozofs_fuse_ctx_p->fuseReqPoolRef);
  /*
  ** check if the session has been exited
  */
  if (fuse_session_exited(rozofs_fuse_ctx_p->se)) sprintf(status,"exited");
  else                                            sprintf(status,"running");
  
  pChar +=  sprintf(pChar,"FUSE %8s - %d/%d ctx remaining\n",
               status, buffer_count, rozofs_fuse_ctx_p->initBufCount);
  /*
  ** display the cache mode
  */
  pChar +=  sprintf(pChar,"buffer sz  : %d\n",rozofs_fuse_ctx_p->bufsize); 
  pChar +=  sprintf(pChar,"poll count : %d\n",rozofs_fuse_loop_count); 
  pChar +=  sprintf(pChar,"dir attr   : %s\n",(rozofs_fuse_ctx_p->dir_attr_invalidate)?"INVALIDATE":"KEEP"); 
  pChar +=  sprintf(pChar,"FS Mode    : "); 
  if (rozofs_mode== 0)
  {
    pChar +=  sprintf(pChar,"standard\n");    
  }
  else
  {
    pChar +=  sprintf(pChar,"Block\n");      
  }  
  pChar +=  sprintf(pChar,"FS Xattr   : %s\n",(rozofs_xattr_disable==1)?"Disabled":"Enabled");   
  pChar +=  sprintf(pChar,"cache Mode : ");      
    switch (rozofs_cache_mode)
  {
    default:
    case 0:
     pChar +=  sprintf(pChar,"default\n");  
     break;    
   case 1:
     pChar +=  sprintf(pChar,"direct_io\n");  
     break;    
   case 2:
     pChar +=  sprintf(pChar,"keep_cache\n");  
     break;    
  }
  int i;
  for (i = 0; i < RZ_FUSE_WRITE_MAX; i++)
  {
     pChar +=sprintf(pChar,"cpt_%d: %8llu\n",i,(long long unsigned int)rozofs_write_merge_stats_tab[i]);  
  }
  /**
  * clear the stats
  */
  uint64_t  delay = rozofs_fuse_req_tic-old_ticker;

  memset(rozofs_write_merge_stats_tab,0,sizeof(uint64_t)*RZ_FUSE_WRITE_MAX);
  pChar +=sprintf(pChar,"fuse req_in (count/bytes): %8llu/%llu\n",(long long unsigned int)rozofs_fuse_req_count,
                                                    (long long unsigned int)rozofs_fuse_req_byte_in);  
  pChar +=sprintf(pChar,"fuse time                :%8llu (%llu)\n",
          (long long unsigned int)(fuse_profile[P_COUNT]?fuse_profile[P_ELAPSE]/fuse_profile[P_COUNT]:0),
          (long long unsigned int)fuse_profile[P_COUNT]);

  if (delay)
  {
  pChar +=sprintf(pChar,"fuse req_in/s            : %8llu/%llu\n",(long long unsigned int)(rozofs_fuse_req_count*1000000/delay),
                                                   (long long unsigned int)(rozofs_fuse_req_byte_in*1000000/delay));
  }

  pChar +=sprintf(pChar,"fuse req_in EAGAIN/ENOENT: %8llu/%llu\n",(long long unsigned int)rozofs_fuse_req_eagain_count,
                                                     (long long unsigned int)rozofs_fuse_req_enoent_count);  

  pChar +=sprintf(pChar,"fuse buffer depletion    : %8llu\n",(long long unsigned int)rozofs_fuse_buffer_depletion_count);  
  pChar +=sprintf(pChar,"storcli buffer depletion : %8llu\n",(long long unsigned int)rozofs_storcli_buffer_depletion_count);
  pChar +=sprintf(pChar,"pending storcli requests : %8d\n",rozofs_storcli_pending_req_count);
  pChar +=sprintf(pChar,"fuse kernel xoff/xon     : %8llu/%llu\n",(long long unsigned int)rozofs_storcli_xoff_count,
                                                                   (long long unsigned int)rozofs_storcli_xon_count);

  rozofs_storcli_buffer_depletion_count =0;
  rozofs_fuse_buffer_depletion_count =0;
  rozofs_fuse_req_count = 0;
  rozofs_fuse_req_byte_in = 0;
  rozofs_fuse_req_eagain_count = 0;
  rozofs_fuse_req_enoent_count = 0;
  rozofs_storcli_xoff_count = 0;
  rozofs_storcli_xon_count = 0;
  /**
  *  read/write statistics
  */
  pChar +=sprintf(pChar,"big write count           : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.big_write_cpt);  
  pChar +=sprintf(pChar,"flush buf. count          : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.flush_buf_cpt);  
  pChar +=sprintf(pChar,"  start aligned/unaligned : %8llu/%llu\n",
                 (long long unsigned int)rozofs_aligned_write_start[0],
                 (long long unsigned int)rozofs_aligned_write_start[1]
		 );  
  pChar +=sprintf(pChar,"  end aligned/unaligned   : %8llu/%llu\n",
                (long long unsigned int)rozofs_aligned_write_end[0],
                (long long unsigned int)rozofs_aligned_write_end[1]
		);  
  pChar +=sprintf(pChar,"readahead count           : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.readahead_cpt);  
  pChar +=sprintf(pChar,"read req. count           : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.read_req_cpt);  
  pChar +=sprintf(pChar,"read fuse count           : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.read_fuse_cpt);  
  
  memset(&rozofs_fuse_read_write_stats_buf,0,sizeof(rozofs_fuse_read_write_stats));
  {
    int k;
    for (k= 0;k< 2;k++)
    {
      rozofs_aligned_write_start[k] = 0;
      rozofs_aligned_write_end[k] = 0;
    }
  }
  /*
  ** Per array statistics
  */
  pChar +=sprintf(pChar,"Per Read Array statitics:\n" );  
  for (i = 0; i < ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX; i++)
  {
     if (rozofs_read_buf_section_table[i]!= 0)
       pChar +=sprintf(pChar,"  %6d: %8llu\n",(i+1)*ROZOFS_PAGE_SZ,(long long unsigned int)rozofs_read_buf_section_table[i]);  
  }
  pChar +=sprintf(pChar,"Per Write Array statitics:\n" );  
  for (i = 0; i < ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX; i++)
  {
     if (rozofs_write_buf_section_table[i]!= 0)
       pChar +=sprintf(pChar,"  %6d: %8llu\n",(i+1)*ROZOFS_PAGE_SZ,(long long unsigned int)rozofs_write_buf_section_table[i]);  
  }
  memset (rozofs_write_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset (rozofs_read_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  
  uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
}
Exemplo n.º 3
0
void rozofs_fuse_show(char * argv[], uint32_t tcpRef, void *bufRef) {
  uint32_t            buffer_count=0;
  char                status[16];
  int   new_val;   
  
  char *pChar = uma_dbg_get_buffer();

  if (argv[1] != NULL)
  {
      if (strcmp(argv[1],"loop")==0) 
      {
	 errno = 0;
	 if (argv[2] == NULL)
	 {
           pChar += sprintf(pChar, "argument is missing\n");
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;	  	  
	 }
	 new_val = (int) strtol(argv[2], (char **) NULL, 10);   
	 if (errno != 0) {
           pChar += sprintf(pChar, "bad value %s\n",argv[2]);
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;
	 }
	 /*
	 ** 
	 */
	 if (new_val == 0) {
           pChar += sprintf(pChar, "unsupported value %s\n",argv[2]);
	   uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
	   return;
	 }	 
	 rozofs_fuse_loop_count = new_val;
      }
  }
  uint64_t old_ticker = rozofs_fuse_req_tic;
  rozofs_fuse_get_ticker();  
  buffer_count      = ruc_buf_getFreeBufferCount(rozofs_fuse_ctx_p->fuseReqPoolRef);
  /*
  ** check if the session has been exited
  */
  if (fuse_session_exited(rozofs_fuse_ctx_p->se)) sprintf(status,"exited");
  else                                            sprintf(status,"running");
  
  pChar +=  sprintf(pChar,"FUSE %8s - %d/%d ctx remaining\n",
               status, buffer_count, rozofs_fuse_ctx_p->initBufCount);
  /*
  ** display the cache mode
  */
  pChar +=  sprintf(pChar,"poll count : %d\n",rozofs_fuse_loop_count); 
  pChar +=  sprintf(pChar,"FS Mode    : "); 
  if (rozofs_mode== 0)
  {
    pChar +=  sprintf(pChar,"standard\n");    
  }
  else
  {
    pChar +=  sprintf(pChar,"Block\n");      
  }  
  pChar +=  sprintf(pChar,"FS Xattr   : %s\n",(rozofs_xattr_disable==1)?"Disabled":"Enabled");   
  pChar +=  sprintf(pChar,"cache Mode : ");      
    switch (rozofs_cache_mode)
  {
    default:
    case 0:
     pChar +=  sprintf(pChar,"default\n");  
     break;    
   case 1:
     pChar +=  sprintf(pChar,"direct_io\n");  
     break;    
   case 2:
     pChar +=  sprintf(pChar,"keep_cache\n");  
     break;    
  }
  int i;
  for (i = 0; i < RZ_FUSE_WRITE_MAX; i++)
  {
     pChar +=sprintf(pChar,"cpt_%d: %8llu\n",i,(long long unsigned int)rozofs_write_merge_stats_tab[i]);  
  }
  /**
  * clear the stats
  */
  uint64_t  delay = rozofs_fuse_req_tic-old_ticker;

  memset(rozofs_write_merge_stats_tab,0,sizeof(uint64_t)*RZ_FUSE_WRITE_MAX);
  pChar +=sprintf(pChar,"fuse req_in (count/bytes): %8llu/%llu\n",(long long unsigned int)rozofs_fuse_req_count,
                                                    (long long unsigned int)rozofs_fuse_req_byte_in);  
  if (delay)
  {
  pChar +=sprintf(pChar,"fuse req_in/s            : %8llu/%llu\n",(long long unsigned int)(rozofs_fuse_req_count*1000000/delay),
                                                   (long long unsigned int)(rozofs_fuse_req_byte_in*1000000/delay));
  }

  pChar +=sprintf(pChar,"fuse req_in EAGAIN/ENOENT: %8llu/%llu\n",(long long unsigned int)rozofs_fuse_req_eagain_count,
                                                     (long long unsigned int)rozofs_fuse_req_enoent_count);  

  pChar +=sprintf(pChar,"fuse buffer depletion    : %8llu\n",(long long unsigned int)rozofs_fuse_buffer_depletion_count);
  rozofs_fuse_buffer_depletion_count =0;
  rozofs_fuse_req_count = 0;
  rozofs_fuse_req_byte_in = 0;
  rozofs_fuse_req_eagain_count = 0;
  rozofs_fuse_req_enoent_count = 0;
  /**
  *  read/write statistics
  */
  pChar +=sprintf(pChar,"flush buf. count          : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.flush_buf_cpt);  
  pChar +=sprintf(pChar,"  start aligned/unaligned : %8llu/%llu\n",
                 (long long unsigned int)rozofs_aligned_write_start[0],
                 (long long unsigned int)rozofs_aligned_write_start[1]
		 );  
  pChar +=sprintf(pChar,"  end aligned/unaligned   : %8llu/%llu\n",
                (long long unsigned int)rozofs_aligned_write_end[0],
                (long long unsigned int)rozofs_aligned_write_end[1]
		);  
  pChar +=sprintf(pChar,"readahead count           : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.readahead_cpt);  
  pChar +=sprintf(pChar,"read req. count           : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.read_req_cpt);  
  pChar +=sprintf(pChar,"read fuse count           : %8llu\n",(long long unsigned int)rozofs_fuse_read_write_stats_buf.read_fuse_cpt);  
  
  memset(&rozofs_fuse_read_write_stats_buf,0,sizeof(rozofs_fuse_read_write_stats));
  {
    int k;
    for (k= 0;k< 2;k++)
    {
      rozofs_aligned_write_start[k] = 0;
      rozofs_aligned_write_end[k] = 0;
    }
  }
  /*
  ** Per array statistics
  */
  pChar +=sprintf(pChar,"Per Read Array statitics:\n" );  
  for (i = 0; i < 32; i++)
  {
     if (rozofs_read_buf_section_table[i]!= 0)
       pChar +=sprintf(pChar,"  %6d: %8llu\n",(i+1)*ROZOFS_PAGE_SZ,(long long unsigned int)rozofs_read_buf_section_table[i]);  
  }
  pChar +=sprintf(pChar,"Per Write Array statitics:\n" );  
  for (i = 0; i < 32; i++)
  {
     if (rozofs_write_buf_section_table[i]!= 0)
       pChar +=sprintf(pChar,"  %6d: %8llu\n",(i+1)*ROZOFS_PAGE_SZ,(long long unsigned int)rozofs_write_buf_section_table[i]);  
  }
  memset (rozofs_write_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset (rozofs_read_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  
  uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
}
Exemplo n.º 4
0
/**
*  Init of the pseudo fuse thread 

  @param ch : initial channel
  @param se : initial session
  @param rozofs_fuse_buffer_count : number of request buffers (corresponds to the number of fuse save context)  
  
  @retval 0 on success
  @retval -1 on error
*/
int rozofs_fuse_init(struct fuse_chan *ch,struct fuse_session *se,int rozofs_fuse_buffer_count)
{
  int status = 0;
  int i;
  
//   return 0;

  fuse_sharemem_init_done = 0;   
  
  int fileflags;
  rozofs_fuse_ctx_p = malloc(sizeof (rozofs_fuse_ctx_t));
  if (rozofs_fuse_ctx_p == NULL) 
  {
    /*
    ** cannot allocate memory for fuse rozofs context
    */
    return -1;
  }
  memset(rozofs_fuse_ctx_p,0,sizeof (rozofs_fuse_ctx_t));
  /*
  ** clear read/write merge stats table
  */
  memset(rozofs_write_merge_stats_tab,0,sizeof(uint64_t)*RZ_FUSE_WRITE_MAX);
  memset (rozofs_write_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset (rozofs_read_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset(&rozofs_fuse_read_write_stats_buf,0,sizeof(rozofs_fuse_read_write_stats));
  /*
  ** init of the context
  */
  rozofs_fuse_ctx_p->fuseReqPoolRef = NULL;
  rozofs_fuse_ctx_p->ch             = NULL;
  rozofs_fuse_ctx_p->se             = se;
  rozofs_fuse_ctx_p->bufsize        = 0; 
  rozofs_fuse_ctx_p->buf_fuse_req_p = NULL;
  rozofs_fuse_ctx_p->dir_attr_invalidate = 0;
  rozofs_fuse_ctx_p->initBufCount   = rozofs_fuse_buffer_count;
  
  while (1)
  {
     /*
     ** get the receive buffer size for former channel in order to create the request distributor:
     ** note: by default the fuse buffer is 4K+128K: for RozoFS the payload can reach 512K (x4)
     */
     int bufsize = fuse_chan_bufsize(ch)*4;
     rozofs_fuse_ctx_p->bufsize = bufsize;
     /*
     ** create the distributor fro receiving data from fuse kernel
     */
     status = rozofs_fuse_init_rcv_buffer_pool(ROZOFS_FUSE_RECV_BUF_COUNT,bufsize);
     if (status < 0)
     {
        severe( "rozofs_fuse_init fuse buffer pool creation error(%d,%d)", (int)ROZOFS_FUSE_RECV_BUF_COUNT, (int)bufsize ) ;
        status = -1;
        break;     
     
     }
     /*
     ** create the pool
     */
     rozofs_fuse_ctx_p->fuseReqPoolRef = ruc_buf_poolCreate(rozofs_fuse_buffer_count,sizeof(rozofs_fuse_save_ctx_t));
     if (rozofs_fuse_ctx_p->fuseReqPoolRef == NULL)
     {
        severe( "rozofs_fuse_init buffer pool creation error(%d,%d)", (int)rozofs_fuse_buffer_count, (int)sizeof(rozofs_fuse_save_ctx_t) ) ;
        status = -1;
        break;
     }
     ruc_buffer_debug_register_pool("fuseCtx",  rozofs_fuse_ctx_p->fuseReqPoolRef);
     /*
     ** Allocate a head of list for queueing pending lookup requests
     */
     for (i=0; i< ROZOFS_MAX_LKUP_QUEUE ; i++)
     {
       ruc_listHdrInit(&rozofs_lookup_queue[i]);
     }
     
     
     /*
     ** allocate a buffer for receiving the fuse request
     */
     rozofs_fuse_ctx_p->buf_fuse_req_p = malloc(bufsize);
     if (rozofs_fuse_ctx_p == NULL) 
     {     
        severe( "rozofs_fuse_init out of memory %d", bufsize ) ;
        status = -1;
        break;     
     }
     /*
     ** get the fd of the channel
     */
     rozofs_fuse_ctx_p->fd = fuse_chan_fd(ch);
     /*
     ** wait the end of the share memroy init prior providing it to fuse
     */
     while (rozofs_shared_mem_init_done == 0) sleep(1);  
     /*
     ** create a new channel with the specific operation for rozofs (non-blocking)
     */  
     rozofs_fuse_ctx_p->ch = fuse_chan_new(&rozofs_fuse_ch_ops,fuse_chan_fd(ch),bufsize,rozofs_fuse_ctx_p);  
     if (rozofs_fuse_ctx_p->ch == NULL)
     {
        severe( "rozofs_fuse_init fuse_chan_new error"  ) ;
        status = -1;
        break;          
     }
     /*
     ** remove the association between the initial session and channel
     */
     fuse_session_remove_chan(ch);  
     /*
     ** OK, now add the new channel
     */
     fuse_session_add_chan(se,rozofs_fuse_ctx_p->ch );  
     /*
     ** set the channel in non blocking mode
     */
     if((fileflags=fcntl(rozofs_fuse_ctx_p->fd,F_GETFL,0))==-1)
     {
       RUC_WARNING(errno);
       status = -1; 
       break;   
     }

     if((fcntl(rozofs_fuse_ctx_p->fd,F_SETFL,fileflags|O_NDELAY))==-1)
     {
       RUC_WARNING(errno);
       status = -1; 
       break;   
     }
     /*
     ** send XON to the fuse channel
     */
     {
        int ret;
	rozofs_fuse_ctx_p->ioctl_supported = 1;
	rozofs_fuse_ctx_p->data_xon        = 1;
     
        while(1)
	{	
	  ret = ioctl(rozofs_fuse_ctx_p->fd,1,NULL);
	  if (ret < 0) 
	  {
	     warning("ioctl error %s",strerror(errno));
	     rozofs_fuse_ctx_p->ioctl_supported = 0;
	     break;

	  }
          if (rozofs_fuse_ctx_p->dir_attr_invalidate == 0)
	  {
	    ret = ioctl(rozofs_fuse_ctx_p->fd,3,NULL);
	    if (ret < 0) 
	    {
	       warning("ioctl error %s",strerror(errno));
//	       rozofs_fuse_ctx_p->ioctl_supported = 0;
	       rozofs_fuse_ctx_p->dir_attr_invalidate = 1;
	       break;
	    }		
	  }
	  break;     
        }
     }
     /*
     ** perform the connection with the socket controller
     */
   /*
   ** OK, we are almost done, just need to connect with the socket controller
   */
   rozofs_fuse_ctx_p->connectionId = ruc_sockctl_connect(rozofs_fuse_ctx_p->fd,  // Reference of the socket
                                              "rozofs_fuse",                 // name of the socket
                                              3,                             // Priority within the socket controller
                                              (void*)rozofs_fuse_ctx_p,      // user param for socketcontroller callback
                                              &rozofs_fuse_callBack_sock);   // Default callbacks
    if (rozofs_fuse_ctx_p->connectionId == NULL)
    {
       /*
       ** Fail to connect with the socket controller
       */
       RUC_WARNING(-1);
       status = -1; 
       break;   
    } 
    rozofs_fuse_get_ticker();

     status = 0;
     break;
  }
  /*
  ** attach the callback on socket controller
  */
//#warning no poller
  ruc_sockCtrl_attach_applicative_poller(rozofs_fuse_scheduler_entry_point); 
  for(i = 0; i < 3;i++) fuse_profile[i] = 0;
  
  uma_dbg_addTopic("fuse", rozofs_fuse_show);
  return status;
  
}