Fork us on GitHub Follow us on Facebook Follow us on Twitter

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


Ignore:
Timestamp:
2010-01-27T20:35:49Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
fb6f1a5
Parents:
fccc236 (diff), 95e6c4f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    rfccc236 rb79d450  
    137137        if (free_vfs_node)
    138138                free(node);
     139}
     140
     141/** Forget node.
     142 *
     143 * This function will remove the node from the node hash table and deallocate
     144 * its memory, regardless of the node's reference count.
     145 *
     146 * @param node  Node to be forgotten.
     147 */
     148void vfs_node_forget(vfs_node_t *node)
     149{
     150        fibril_mutex_lock(&nodes_mutex);
     151        unsigned long key[] = {
     152                [KEY_FS_HANDLE] = node->fs_handle,
     153                [KEY_DEV_HANDLE] = node->dev_handle,
     154                [KEY_INDEX] = node->index
     155        };
     156        hash_table_remove(&nodes, key, 3);
     157        fibril_mutex_unlock(&nodes_mutex);
     158        free(node);
    139159}
    140160
     
    231251}
    232252
     253struct refcnt_data {
     254        /** Sum of all reference counts for this file system instance. */
     255        unsigned refcnt;
     256        fs_handle_t fs_handle;
     257        dev_handle_t dev_handle;
     258};
     259
     260static void refcnt_visitor(link_t *item, void *arg)
     261{
     262        vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link);
     263        struct refcnt_data *rd = (void *) arg;
     264
     265        if ((node->fs_handle == rd->fs_handle) &&
     266            (node->dev_handle == rd->dev_handle))
     267                rd->refcnt += node->refcnt;
     268}
     269
     270unsigned
     271vfs_nodes_refcount_sum_get(fs_handle_t fs_handle, dev_handle_t dev_handle)
     272{
     273        struct refcnt_data rd = {
     274                .refcnt = 0,
     275                .fs_handle = fs_handle,
     276                .dev_handle = dev_handle
     277        };
     278
     279        fibril_mutex_lock(&nodes_mutex);
     280        hash_table_apply(&nodes, refcnt_visitor, &rd);
     281        fibril_mutex_unlock(&nodes_mutex);
     282
     283        return rd.refcnt;
     284}
     285
    233286/**
    234287 * @}
Note: See TracChangeset for help on using the changeset viewer.