Changeset b7c62a9 in mainline for uspace/srv/vfs/vfs_node.c


Ignore:
Timestamp:
2013-07-29T11:44:35Z (12 years ago)
Author:
Jiri Zarevucky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
677745a
Parents:
9e9b168
Message:

Make the server oblivious to the link count. It is just another source of potential problems. Also clean up some confusion with file types and node refcount.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_node.c

    r9e9b168 rb7c62a9  
    106106void vfs_node_delref(vfs_node_t *node)
    107107{
    108         bool free_vfs_node = false;
    109         bool free_fs_node = false;
    110        
    111         fibril_mutex_lock(&nodes_mutex);
    112        
    113         if (node->refcnt-- == 1) {
     108        bool free_node = false;
     109       
     110        fibril_mutex_lock(&nodes_mutex);
     111       
     112        node->refcnt--;
     113        if (node->refcnt == 0) {
    114114               
    115115                /*
     
    119119               
    120120                hash_table_remove_item(&nodes, &node->nh_link);
    121                 free_vfs_node = true;
    122                
    123                 if (!node->lnkcnt)
    124                         free_fs_node = true;
     121                free_node = true;
    125122        }
    126123       
    127124        fibril_mutex_unlock(&nodes_mutex);
    128125       
    129         if (free_fs_node) {
    130                
     126        if (free_node) {
    131127                /*
    132                  * The node is not visible in the file system namespace.
    133                  * Free up its resources.
     128                 * DESTROY will free up the file's resources if there are no more hard links.
    134129                 */
    135130               
    136131                async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
    137                 sysarg_t rc = async_req_2_0(exch, VFS_OUT_DESTROY,
    138                     (sysarg_t) node->service_id, (sysarg_t)node->index);
    139                
    140                 assert(rc == EOK);
     132                async_msg_2(exch, VFS_OUT_DESTROY,
     133                        (sysarg_t) node->service_id, (sysarg_t)node->index);
    141134                vfs_exchange_release(exch);
     135
     136                free(node);
    142137        }
    143        
    144         if (free_vfs_node)
    145                 free(node);
    146138}
    147139
     
    190182                node->index = result->triplet.index;
    191183                node->size = result->size;
    192                 node->lnkcnt = result->lnkcnt;
    193184                node->type = result->type;
    194185                fibril_rwlock_initialize(&node->contents_rwlock);
     
    196187        } else {
    197188                node = hash_table_get_inst(tmp, vfs_node_t, nh_link);
    198                 if (node->type == VFS_NODE_UNKNOWN &&
    199                     result->type != VFS_NODE_UNKNOWN) {
    200                         /* Upgrade the node type. */
    201                         node->type = result->type;
    202                 }
    203189        }
    204 
    205         assert(node->size == result->size || node->type != VFS_NODE_FILE);
    206         assert(node->lnkcnt == result->lnkcnt);
    207         assert(node->type == result->type || result->type == VFS_NODE_UNKNOWN);
    208190
    209191        _vfs_node_addref(node);
Note: See TracChangeset for help on using the changeset viewer.