Lines Matching defs:vol

42 	acquire_sem(vol->vcache.vc_sem)
45 acquire_sem_etc(vol->vcache.vc_sem, READERS, 0, 0)
48 release_sem(vol->vcache.vc_sem)
51 release_sem_etc(vol->vcache.vc_sem, READERS, 0)
72 void dump_vcache(nspace *vol)
78 vol->vcache.cache_size, vol->vcache.cur_vnid);
79 for (i=0;i<vol->vcache.cache_size;i++)
80 for (c = vol->vcache.by_vnid[i];c;c=c->next_vnid)
84 #define hash(v) ((v) & (vol->vcache.cache_size-1))
86 status_t init_vcache(nspace *vol)
91 vol->vcache.cur_vnid = ARTIFICIAL_VNID_BITS;
93 vol->vcache.cache_size = 1;
95 vol->vcache.cache_size = 512; /* must be power of 2 */
97 vol->vcache.by_vnid = calloc(sizeof(struct vache_entry *), vol->vcache.cache_size);
98 if (vol->vcache.by_vnid == NULL) {
102 vol->vcache.by_loc = calloc(sizeof(struct vache_entry *), vol->vcache.cache_size);
103 if (vol->vcache.by_loc == NULL) {
105 free(vol->vcache.by_vnid);
106 vol->vcache.by_vnid = NULL;
110 sprintf(name, "fat cache %lx", vol->id);
111 if ((vol->vcache.vc_sem = create_sem(READERS, name)) < 0) {
112 free(vol->vcache.by_vnid); vol->vcache.by_vnid = NULL;
113 free(vol->vcache.by_loc); vol->vcache.by_loc = NULL;
114 return vol->vcache.vc_sem;
117 DPRINTF(0, ("init_vcache: initialized vnid cache with %lx entries\n", vol->vcache.cache_size));
122 status_t uninit_vcache(nspace *vol)
131 for (i=0;i<vol->vcache.cache_size;i++) {
132 c = vol->vcache.by_vnid[i];
143 free(vol->vcache.by_vnid); vol->vcache.by_vnid = NULL;
144 free(vol->vcache.by_loc); vol->vcache.by_loc = NULL;
146 delete_sem(vol->vcache.vc_sem);
151 vnode_id generate_unique_vnid(nspace *vol)
156 return vol->vcache.cur_vnid++;
159 static status_t _add_to_vcache_(nspace *vol, vnode_id vnid, vnode_id loc)
174 c = p = vol->vcache.by_vnid[hash1];
186 vol->vcache.by_vnid[hash1] = e;
190 c = p = vol->vcache.by_loc[hash2];
202 vol->vcache.by_loc[hash2] = e;
209 static status_t _remove_from_vcache_(nspace *vol, vnode_id vnid)
216 c = p = vol->vcache.by_vnid[hash1];
228 vol->vcache.by_vnid[hash1] = c->next_vnid;
235 c = p = vol->vcache.by_loc[hash2];
247 vol->vcache.by_loc[hash2] = c->next_loc;
256 static struct vcache_entry *_find_vnid_in_vcache_(nspace *vol, vnode_id vnid)
260 c = vol->vcache.by_vnid[hash1];
272 static struct vcache_entry *_find_loc_in_vcache_(nspace *vol, vnode_id loc)
276 c = vol->vcache.by_loc[hash2];
288 status_t add_to_vcache(nspace *vol, vnode_id vnid, vnode_id loc)
293 result = _add_to_vcache_(vol,vnid,loc);
301 static status_t _update_loc_in_vcache_(nspace *vol, vnode_id vnid, vnode_id loc)
305 result = _remove_from_vcache_(vol, vnid);
307 result = _add_to_vcache_(vol, vnid, loc);
312 status_t remove_from_vcache(nspace *vol, vnode_id vnid)
317 result = _remove_from_vcache_(vol, vnid);
324 status_t vcache_vnid_to_loc(nspace *vol, vnode_id vnid, vnode_id *loc)
331 e = _find_vnid_in_vcache_(vol, vnid);
339 status_t vcache_loc_to_vnid(nspace *vol, vnode_id loc, vnode_id *vnid)
346 e = _find_loc_in_vcache_(vol, loc);
354 status_t vcache_set_entry(nspace *vol, vnode_id vnid, vnode_id loc)
361 if (is_vnode_removed(vol->id, vnid) > 0) {
365 ASSERT(is_vnode_removed(vol->id, vnid) == 0);
370 e = _find_vnid_in_vcache_(vol, vnid);
374 result = _remove_from_vcache_(vol, vnid);
376 result = _update_loc_in_vcache_(vol, vnid, loc);
379 result = _add_to_vcache_(vol,vnid,loc);
392 nspace *vol;
399 vol = (nspace *)strtoul(argv[1], NULL, 0);
400 if (vol == NULL)
406 if ((e = _find_vnid_in_vcache_(vol, vnid)) != NULL) {
419 nspace *vol;
426 vol = (nspace *)strtoul(argv[1], NULL, 0);
427 if (vol == NULL)
433 if ((e = _find_loc_in_vcache_(vol, loc)) != NULL) {