Changeset 0ca7286 in mainline for uspace/srv/vfs/vfs_node.c
- Timestamp:
- 2012-07-21T11:19:27Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2732c94
- Parents:
- 1c1da4b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_node.c
r1c1da4b r0ca7286 58 58 #define KEY_INDEX 2 59 59 60 static hash_index_t nodes_hash(unsigned long []);61 static int nodes_compare(unsigned long [], hash_count_t,link_t *);62 static void nodes_remove_callback(link_t *);60 static size_t nodes_key_hash(unsigned long []); 61 static size_t nodes_hash(const link_t *); 62 static bool nodes_match(unsigned long [], size_t, const link_t *); 63 63 64 64 /** VFS node hash table operations. */ 65 hash_table_op erations_t nodes_ops = {65 hash_table_ops_t nodes_ops = { 66 66 .hash = nodes_hash, 67 .compare = nodes_compare, 68 .remove_callback = nodes_remove_callback 67 .key_hash = nodes_key_hash, 68 .match = nodes_match, 69 .equal = 0, 70 .remove_callback = 0, 69 71 }; 70 72 … … 75 77 bool vfs_nodes_init(void) 76 78 { 77 return hash_table_create(&nodes, NODES_BUCKETS, 3, &nodes_ops);79 return hash_table_create(&nodes, 0, 3, &nodes_ops); 78 80 } 79 81 … … 207 209 link_initialize(&node->nh_link); 208 210 fibril_rwlock_initialize(&node->contents_rwlock); 209 hash_table_insert(&nodes, key,&node->nh_link);211 hash_table_insert(&nodes, &node->nh_link); 210 212 } else { 211 213 node = hash_table_get_instance(tmp, vfs_node_t, nh_link); … … 240 242 } 241 243 242 hash_index_t nodes_hash(unsigned long key[]) 243 { 244 hash_index_t a = key[KEY_FS_HANDLE] << (NODES_BUCKETS_LOG / 4); 245 hash_index_t b = (a | key[KEY_DEV_HANDLE]) << (NODES_BUCKETS_LOG / 2); 246 247 return (b | key[KEY_INDEX]) & (NODES_BUCKETS - 1); 248 } 249 250 int nodes_compare(unsigned long key[], hash_count_t keys, link_t *item) 244 size_t nodes_key_hash(unsigned long key[]) 245 { 246 /* Combine into a hash like they do in Effective Java, 2nd edition. */ 247 size_t hash = 17; 248 hash = 37 * hash + key[KEY_FS_HANDLE]; 249 hash = 37 * hash + key[KEY_DEV_HANDLE]; 250 hash = 37 * hash + key[KEY_INDEX]; 251 return hash; 252 } 253 254 size_t nodes_hash(const link_t *item) 255 { 256 vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link); 257 258 unsigned long key[] = { 259 [KEY_FS_HANDLE] = node->fs_handle, 260 [KEY_DEV_HANDLE] = node->service_id, 261 [KEY_INDEX] = node->index 262 }; 263 264 return nodes_key_hash(key); 265 } 266 267 268 bool nodes_match(unsigned long key[], size_t keys, const link_t *item) 251 269 { 252 270 vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link); … … 256 274 } 257 275 258 void nodes_remove_callback(link_t *item)259 {260 }261 276 262 277 struct refcnt_data { … … 267 282 }; 268 283 269 static voidrefcnt_visitor(link_t *item, void *arg)284 static bool refcnt_visitor(link_t *item, void *arg) 270 285 { 271 286 vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link); … … 275 290 (node->service_id == rd->service_id)) 276 291 rd->refcnt += node->refcnt; 292 293 return true; 277 294 } 278 295
Note:
See TracChangeset
for help on using the changeset viewer.