Index: trunk/kernel/fs/vfs.c
===================================================================
--- trunk/kernel/fs/vfs.c	(revision 430)
+++ trunk/kernel/fs/vfs.c	(revision 433)
@@ -157,6 +157,10 @@
     error_t            error;
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enter / dentry = %x in cluster %x\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, GET_PTR(dentry_xp), GET_CXY(dentry_xp) );
+#if CONFIG_DEBUG_VFS_INODE_CREATE
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_INODE_CREATE < cycle )
+printk("\n[DBG] %s : thread %x enter / dentry = %x in cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, GET_PTR(dentry_xp), GET_CXY(dentry_xp), cycle );
+#endif
  
     // check fs type and get pointer on context
@@ -230,6 +234,10 @@
     remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] exit / inode = %x in cluster %x\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy );
+#if CONFIG_DEBUG_VFS_INODE_CREATE
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_INODE_CREATE < cycle )
+printk("\n[DBG] %s : thread %x exit / inode = %x in cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, inode, local_cxy, cycle );
+#endif
  
     // return extended pointer on inode
@@ -263,6 +271,11 @@
                         xptr_t        child_xp )
 {
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
-__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
+
+#if CONFIG_DEBUG_VFS_INODE_LOAD
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_INODE_LOAD < cycle )
+printk("\n[DBG] %s : thread %x enter for <%s> / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD , name , cycle );
+#endif
 
     error_t error = 0;
@@ -293,6 +306,10 @@
     }
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / cycle %d\n",
-__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_INODE_LOAD
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_INODE_LOAD < cycle )
+printk("\n[DBG] %s : thread %x exit for <%s> / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD , name , cycle );
+#endif
 
     return error;
@@ -416,6 +433,10 @@
 	kmem_req_t       req;        // request to kernel memory allocator
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, parent, hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_DENTRY_CREATE
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_DENTRY_CREATE < cycle )
+printk("\n[DBG] %s : thread %x enter for <%s> / parent_inode %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD , name , parent , cycle );
+#endif
 
     // get pointer on context
@@ -465,6 +486,10 @@
     *dentry_xp = XPTR( local_cxy , dentry );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / dentry = %x in cluster %x / cycle %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, dentry, local_cxy , hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_DENTRY_CREATE
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_DENTRY_CREATE < cycle )
+printk("\n[DBG] %s : thread %x exit for <%s> / dentry %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD , name , dentry , cycle );
+#endif
 
     return 0;
@@ -584,6 +609,10 @@
     uint32_t      file_id;      // created file descriptor index in reference fd_array
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, (uint32_t)hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_OPEN
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_OPEN < cycle )
+printk("\n[DBG] %s :  thread %x enter for <%s> / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, path, cycle );
+#endif
 
     // compute lookup working mode
@@ -610,7 +639,4 @@
     inode_ptr = (vfs_inode_t *)GET_PTR( inode_xp );
     
-vfs_dmsg("\n[DBG] %s : core[%x,%d] found inode for <%s> in cluster %x / cycle %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, inode_cxy , (uint32_t)hal_time_stamp() );
-
     // create a new file descriptor in cluster containing inode
     if( inode_cxy == local_cxy )      // target cluster is local
@@ -630,7 +656,10 @@
     if( error ) return error;
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / file = %x in cluster %x / cycle %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path,
-GET_PTR(file_xp), GET_CXY(file_xp), hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_OPEN
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_OPEN < cycle )
+printk("\n[DBG] %s : thread %x exit for <%s> / file %x in cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, path, GET_PTR(file_xp), GET_CXY(file_xp), cycle );
+#endif
 
     // success
@@ -647,6 +676,5 @@
                    uint32_t size )
 {
-    assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , 
-    "file_xp == XPTR_NULL" );
+    assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" );
 
     cxy_t              file_cxy;     // remote file descriptor cluster 
@@ -1319,6 +1347,10 @@
     process = this->process;
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
-__FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_LOOKUP
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_LOOKUP < cycle )
+printk("\n[DBG] %s : thread %x enter for <%s> / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, path, cycle );
+#endif
 
     // get extended pointer on first inode to search
@@ -1343,6 +1375,8 @@
         vfs_get_name_from_path( current , name , &next , &last );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] look for <%s> / last = %d\n",
-__FUNCTION__ , local_cxy , this->core->lid , name , last );
+#if (CONFIG_DEBUG_VFS_LOOKUP & 1)
+if( CONFIG_DEBUG_VFS_LOOKUP < cycle )
+printk("\n[DBG] %s : look for <%s> / last = %d\n", __FUNCTION__ , name , last );
+#endif
 
         // search a child dentry matching name in parent inode
@@ -1362,6 +1396,8 @@
         {
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] miss <%s> => load it\n",
-__FUNCTION__ , local_cxy , this->core->lid , name );
+#if (CONFIG_DEBUG_VFS_LOOKUP & 1)
+if( CONFIG_DEBUG_VFS_LOOKUP < cycle )
+printk("\n[DBG] %s : miss <%s> => load it\n", __FUNCTION__ , name );
+#endif
 
             // release lock on parent inode
@@ -1446,11 +1482,16 @@
             vfs_inode_lock( parent_xp );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] created node <%s>\n",
-__FUNCTION__ , local_cxy , this->core->lid , name );
+#if (CONFIG_DEBUG_VFS_LOOKUP & 1)
+if( CONFIG_DEBUG_VFS_LOOKUP < cycle )
+printk("\n[DBG] %s : created node <%s>\n", __FUNCTION__ , name );
+#endif
 
         }
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] found <%s> / inode = %x in cluster %x\n",
-__FUNCTION__ , local_cxy , this->core->lid , name , GET_PTR(child_xp) , GET_CXY(child_xp) );
+#if (CONFIG_DEBUG_VFS_LOOKUP & 1)
+if( CONFIG_DEBUG_VFS_LOOKUP < cycle )
+printk("\n[DBG] %s : found <%s> / inode %x in cluster %x\n",
+__FUNCTION__ , name , GET_PTR(child_xp) , GET_CXY(child_xp) );
+#endif
 
         // TODO check access rights here [AG]
@@ -1477,6 +1518,10 @@
     vfs_inode_unlock( parent_xp );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / inode = %x in cluster %x\n",
-__FUNCTION__,local_cxy,this->core->lid,pathname,GET_PTR(child_xp),GET_CXY(child_xp) );
+#if CONFIG_DEBUG_VFS_LOOKUP
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_LOOKUP < cycle )
+printk("\n[DBG] %s : thread %x exit for <%s> / inode %x in cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, path, GET_PTR(child_xp), GET_CXY(child_xp), cycle );
+#endif
 
     // return searched pointer
@@ -1502,6 +1547,6 @@
     // we use two variables "index" and "count" because the buffer
     // is written in decreasing index order (from leaf to root) 
-    // TODO : handle conflict with a concurrent rename [AG]
-    // TODO : handle synchro in the loop  [AG]
+    // TODO  : handle conflict with a concurrent rename [AG]
+    // FIXME : handle synchro in the loop  [AG]
 
 	// set the NUL character in buffer / initialise buffer index and count
@@ -1576,6 +1621,10 @@
     parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / child_cxy = %x / parent_cxy = %x\n",
-__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , child_cxy , parent_cxy );
+#if CONFIG_DEBUG_VFS_ADD_CHILD
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_ADD_CHILD < cycle )
+printk("\n[DBG] %s : thread %x enter for <%s> / child_cxy = %x / parent_cxy = %x\n",
+__FUNCTION__ , CURRENT_THREAD , name , child_cxy , parent_cxy );
+#endif
 
     // 1. create dentry
@@ -1587,6 +1636,8 @@
                                    &dentry_xp );
 
-vfs_dmsg("\n[DBG] %s : dentry <%s> created in local cluster %x\n",
-__FUNCTION__ , name , local_cxy );
+#if (CONFIG_DEBUG_VFS_ADD_CHILD & 1)
+if( CONFIG_DEBUG_VFS_ADD_CHILD < cycle )
+printk("\n[DBG] %s : dentry <%s> created in cluster %x\n", __FUNCTION__, name, local_cxy );
+#endif
 
     }
@@ -1600,6 +1651,8 @@
                                       &error );
 
-vfs_dmsg("\n[DBG] %s : dentry <%s> created in remote cluster %x\n",
-__FUNCTION__ , name , parent_cxy );
+#if (CONFIG_DEBUG_VFS_ADD_CHILD & 1)
+if( CONFIG_DEBUG_VFS_ADD_CHILD < cycle )
+printk("\n[DBG] %s : dentry <%s> created in cluster %x\n", __FUNCTION__, name, parent_cxy );
+#endif
 
     }
@@ -1629,4 +1682,10 @@
                                   gid,
                                   &inode_xp );
+
+#if (CONFIG_DEBUG_VFS_ADD_CHILD & 1)
+if( CONFIG_DEBUG_VFS_ADD_CHILD < cycle )
+printk("\n[DBG] %s : inode <%x> created in cluster %x\n",
+__FUNCTION__ , GET_PTR(inode_xp) , local_cxy );
+#endif
 
 vfs_dmsg("\n[DBG] %s : inode %x created in local cluster %x\n",
@@ -1648,6 +1707,9 @@
                                      &error );
 
-vfs_dmsg("\n[DBG] %s : inode %x created in remote cluster %x\n",
+#if (CONFIG_DEBUG_VFS_ADD_CHILD & 1)
+if( CONFIG_DEBUG_VFS_ADD_CHILD < cycle )
+printk("\n[DBG] %s : inode <%s> created in cluster %x\n",
 __FUNCTION__ , GET_PTR(inode_xp) , child_cxy );
+#endif
 
     }
@@ -1669,6 +1731,10 @@
     hal_remote_swd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp );
 
-vfs_dmsg("\n[DBG] %s : exit in cluster %x for <%s>\n",
-__FUNCTION__ , local_cxy , name );
+#if CONFIG_DEBUG_VFS_ADD_CHILD
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_ADD_CHILD < cycle )
+printk("\n[DBG] %s : thread %x exit for <%s>\n",
+__FUNCTION__ , CURRENT_THREAD , name );
+#endif
 
     // success : return extended pointer on child inode
@@ -1694,6 +1760,10 @@
     assert( (mapper != NULL) , __FUNCTION__ , "no mapper for page\n" );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enters for page %d / mapper = %x / inode = %x\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid , page->index , mapper, mapper->inode );
+#if CONFIG_DEBUG_VFS_MAPPER_MOVE
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_MAPPER_MOVE < cycle )
+printk("\n[DBG] %s : thread %x enter for page %d / mapper %x / inode %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, page->index, mapper, mapper->inode, cycle );
+#endif
 
     // get FS type
@@ -1720,6 +1790,10 @@
     }
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / mapper = %x / inode = %x\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, page->index, mapper, mapper->inode );
+#if CONFIG_DEBUG_VFS_MAPPER_MOVE
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_MAPPER_MOVE < cycle )
+printk("\n[DBG] %s : thread %x exit for page %d / mapper %x / inode %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, page->index, mapper, mapper->inode, cycle );
+#endif
 
     return error;
@@ -1740,6 +1814,10 @@
     assert( (mapper != NULL) , __FUNCTION__ , "mapper pointer is NULL\n" );
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for inode %x in cluster %x/ cycle %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_MAPPER_LOAD
+uint32_t cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_MAPPER_MOVE < cycle )
+printk("\n[DBG] %s : thread %x enter for inode %x in cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, inode, local_cxy, cycle );
+#endif
 
     // compute number of pages
@@ -1757,6 +1835,10 @@
     }
 
-vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for inode %x in cluster %x / cycle %d\n",
-__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() );
+#if CONFIG_DEBUG_VFS_MAPPER_LOAD
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_VFS_MAPPER_MOVE < cycle )
+printk("\n[DBG] %s : thread %x exit for inode %x in cluster %x / cycle %d\n",
+__FUNCTION__, CURRENT_THREAD, inode, local_cxy, cycle );
+#endif
 
     return 0;
