Lines Matching refs:vl

37 static int afs_vlocation_access_vl_by_name(struct afs_vlocation *vl,  in afs_vlocation_access_vl_by_name()  argument
41 struct afs_cell *cell = vl->cell; in afs_vlocation_access_vl_by_name()
45 _enter("%s,%s", cell->name, vl->vldb.name); in afs_vlocation_access_vl_by_name()
47 down_write(&vl->cell->vl_sem); in afs_vlocation_access_vl_by_name()
55 ret = afs_vl_get_entry_by_name(&addr, key, vl->vldb.name, vldb, in afs_vlocation_access_vl_by_name()
84 up_write(&vl->cell->vl_sem); in afs_vlocation_access_vl_by_name()
93 static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vl, in afs_vlocation_access_vl_by_id() argument
99 struct afs_cell *cell = vl->cell; in afs_vlocation_access_vl_by_id()
105 down_write(&vl->cell->vl_sem); in afs_vlocation_access_vl_by_id()
127 vl->upd_busy_cnt++; in afs_vlocation_access_vl_by_id()
128 if (vl->upd_busy_cnt <= 3) { in afs_vlocation_access_vl_by_id()
129 if (vl->upd_busy_cnt > 1) { in afs_vlocation_access_vl_by_id()
138 vl->upd_rej_cnt++; in afs_vlocation_access_vl_by_id()
149 vl->upd_busy_cnt = 0; in afs_vlocation_access_vl_by_id()
153 if (ret < 0 && vl->upd_rej_cnt > 0) { in afs_vlocation_access_vl_by_id()
156 vl->vldb.name); in afs_vlocation_access_vl_by_id()
157 vl->valid = 0; in afs_vlocation_access_vl_by_id()
161 up_write(&vl->cell->vl_sem); in afs_vlocation_access_vl_by_id()
173 struct afs_vlocation *vl; in afs_vlocation_alloc() local
175 vl = kzalloc(sizeof(struct afs_vlocation), GFP_KERNEL); in afs_vlocation_alloc()
176 if (vl) { in afs_vlocation_alloc()
177 vl->cell = cell; in afs_vlocation_alloc()
178 vl->state = AFS_VL_NEW; in afs_vlocation_alloc()
179 atomic_set(&vl->usage, 1); in afs_vlocation_alloc()
180 INIT_LIST_HEAD(&vl->link); in afs_vlocation_alloc()
181 INIT_LIST_HEAD(&vl->grave); in afs_vlocation_alloc()
182 INIT_LIST_HEAD(&vl->update); in afs_vlocation_alloc()
183 init_waitqueue_head(&vl->waitq); in afs_vlocation_alloc()
184 spin_lock_init(&vl->lock); in afs_vlocation_alloc()
185 memcpy(vl->vldb.name, name, namesz); in afs_vlocation_alloc()
188 _leave(" = %p", vl); in afs_vlocation_alloc()
189 return vl; in afs_vlocation_alloc()
195 static int afs_vlocation_update_record(struct afs_vlocation *vl, in afs_vlocation_update_record() argument
205 vl->vldb.name, in afs_vlocation_update_record()
206 vl->vldb.vidmask, in afs_vlocation_update_record()
207 ntohl(vl->vldb.servers[0].s_addr), in afs_vlocation_update_record()
208 vl->vldb.srvtmask[0], in afs_vlocation_update_record()
209 ntohl(vl->vldb.servers[1].s_addr), in afs_vlocation_update_record()
210 vl->vldb.srvtmask[1], in afs_vlocation_update_record()
211 ntohl(vl->vldb.servers[2].s_addr), in afs_vlocation_update_record()
212 vl->vldb.srvtmask[2]); in afs_vlocation_update_record()
215 vl->vldb.vid[0], in afs_vlocation_update_record()
216 vl->vldb.vid[1], in afs_vlocation_update_record()
217 vl->vldb.vid[2]); in afs_vlocation_update_record()
219 if (vl->vldb.vidmask & AFS_VOL_VTM_RW) { in afs_vlocation_update_record()
220 vid = vl->vldb.vid[0]; in afs_vlocation_update_record()
222 } else if (vl->vldb.vidmask & AFS_VOL_VTM_RO) { in afs_vlocation_update_record()
223 vid = vl->vldb.vid[1]; in afs_vlocation_update_record()
225 } else if (vl->vldb.vidmask & AFS_VOL_VTM_BAK) { in afs_vlocation_update_record()
226 vid = vl->vldb.vid[2]; in afs_vlocation_update_record()
237 ret = afs_vlocation_access_vl_by_id(vl, key, vid, voltype, vldb); in afs_vlocation_update_record()
243 vl->vldb.name, vid, vl->cell->name, ret); in afs_vlocation_update_record()
256 vl->vldb.name, vid, vl->cell->name); in afs_vlocation_update_record()
267 static void afs_vlocation_apply_update(struct afs_vlocation *vl, in afs_vlocation_apply_update() argument
279 if (strcmp(vldb->name, vl->vldb.name) != 0) in afs_vlocation_apply_update()
282 vl->vldb.name, vldb->name); in afs_vlocation_apply_update()
284 vl->vldb = *vldb; in afs_vlocation_apply_update()
287 fscache_update_cookie(vl->cache); in afs_vlocation_apply_update()
295 static int afs_vlocation_fill_in_record(struct afs_vlocation *vl, in afs_vlocation_fill_in_record() argument
303 ASSERTCMP(vl->valid, ==, 0); in afs_vlocation_fill_in_record()
309 vl->cache = fscache_acquire_cookie(vl->cell->cache, in afs_vlocation_fill_in_record()
310 &afs_vlocation_cache_index_def, vl, in afs_vlocation_fill_in_record()
314 if (vl->valid) { in afs_vlocation_fill_in_record()
318 ret = afs_vlocation_update_record(vl, key, &vldb); in afs_vlocation_fill_in_record()
322 ret = afs_vlocation_access_vl_by_name(vl, key, &vldb); in afs_vlocation_fill_in_record()
325 vl->vldb.name, vl->cell->name); in afs_vlocation_fill_in_record()
330 afs_vlocation_apply_update(vl, &vldb); in afs_vlocation_fill_in_record()
338 static void afs_vlocation_queue_for_updates(struct afs_vlocation *vl) in afs_vlocation_queue_for_updates() argument
343 vl->update_at = get_seconds() + afs_vlocation_update_timeout; in afs_vlocation_queue_for_updates()
354 if (vl->update_at <= xvl->update_at) in afs_vlocation_queue_for_updates()
355 vl->update_at = xvl->update_at + 1; in afs_vlocation_queue_for_updates()
362 list_add_tail(&vl->update, &afs_vlocation_updates); in afs_vlocation_queue_for_updates()
378 struct afs_vlocation *vl; in afs_vlocation_lookup() local
385 if (namesz >= sizeof(vl->vldb.name)) { in afs_vlocation_lookup()
393 list_for_each_entry(vl, &cell->vl_list, link) { in afs_vlocation_lookup()
394 if (vl->vldb.name[namesz] != '\0') in afs_vlocation_lookup()
396 if (memcmp(vl->vldb.name, name, namesz) == 0) in afs_vlocation_lookup()
402 vl = afs_vlocation_alloc(cell, name, namesz); in afs_vlocation_lookup()
403 if (!vl) { in afs_vlocation_lookup()
410 list_add_tail(&vl->link, &cell->vl_list); in afs_vlocation_lookup()
411 vl->state = AFS_VL_CREATING; in afs_vlocation_lookup()
415 ret = afs_vlocation_fill_in_record(vl, key); in afs_vlocation_lookup()
418 spin_lock(&vl->lock); in afs_vlocation_lookup()
419 vl->state = AFS_VL_VALID; in afs_vlocation_lookup()
420 spin_unlock(&vl->lock); in afs_vlocation_lookup()
421 wake_up(&vl->waitq); in afs_vlocation_lookup()
425 fscache_update_cookie(vl->cache); in afs_vlocation_lookup()
429 afs_vlocation_queue_for_updates(vl); in afs_vlocation_lookup()
435 atomic_inc(&vl->usage); in afs_vlocation_lookup()
437 if (!list_empty(&vl->grave)) { in afs_vlocation_lookup()
439 list_del_init(&vl->grave); in afs_vlocation_lookup()
445 spin_lock(&vl->lock); in afs_vlocation_lookup()
446 while (vl->state != AFS_VL_VALID) { in afs_vlocation_lookup()
447 afs_vlocation_state_t state = vl->state; in afs_vlocation_lookup()
452 vl->state = AFS_VL_CREATING; in afs_vlocation_lookup()
453 spin_unlock(&vl->lock); in afs_vlocation_lookup()
461 spin_unlock(&vl->lock); in afs_vlocation_lookup()
462 ret = wait_event_interruptible(vl->waitq, in afs_vlocation_lookup()
463 vl->state == AFS_VL_NEW || in afs_vlocation_lookup()
464 vl->state == AFS_VL_VALID || in afs_vlocation_lookup()
465 vl->state == AFS_VL_NO_VOLUME); in afs_vlocation_lookup()
468 spin_lock(&vl->lock); in afs_vlocation_lookup()
470 spin_unlock(&vl->lock); in afs_vlocation_lookup()
473 _leave(" = %p", vl); in afs_vlocation_lookup()
474 return vl; in afs_vlocation_lookup()
477 spin_lock(&vl->lock); in afs_vlocation_lookup()
478 vl->state = AFS_VL_NEW; in afs_vlocation_lookup()
479 spin_unlock(&vl->lock); in afs_vlocation_lookup()
480 wake_up(&vl->waitq); in afs_vlocation_lookup()
482 ASSERT(vl != NULL); in afs_vlocation_lookup()
483 afs_put_vlocation(vl); in afs_vlocation_lookup()
491 void afs_put_vlocation(struct afs_vlocation *vl) in afs_put_vlocation() argument
493 if (!vl) in afs_put_vlocation()
496 _enter("%s", vl->vldb.name); in afs_put_vlocation()
498 ASSERTCMP(atomic_read(&vl->usage), >, 0); in afs_put_vlocation()
500 if (likely(!atomic_dec_and_test(&vl->usage))) { in afs_put_vlocation()
506 if (atomic_read(&vl->usage) == 0) { in afs_put_vlocation()
508 list_move_tail(&vl->grave, &afs_vlocation_graveyard); in afs_put_vlocation()
509 vl->time_of_death = get_seconds(); in afs_put_vlocation()
514 if (!list_empty(&vl->update)) { in afs_put_vlocation()
516 list_del_init(&vl->update); in afs_put_vlocation()
527 static void afs_vlocation_destroy(struct afs_vlocation *vl) in afs_vlocation_destroy() argument
529 _enter("%p", vl); in afs_vlocation_destroy()
532 fscache_relinquish_cookie(vl->cache, 0); in afs_vlocation_destroy()
534 afs_put_cell(vl->cell); in afs_vlocation_destroy()
535 kfree(vl); in afs_vlocation_destroy()
544 struct afs_vlocation *vl; in afs_vlocation_reaper() local
554 vl = list_entry(afs_vlocation_graveyard.next, in afs_vlocation_reaper()
557 _debug("check %p", vl); in afs_vlocation_reaper()
560 expiry = vl->time_of_death + afs_vlocation_timeout; in afs_vlocation_reaper()
568 spin_lock(&vl->cell->vl_lock); in afs_vlocation_reaper()
569 if (atomic_read(&vl->usage) > 0) { in afs_vlocation_reaper()
571 list_del_init(&vl->grave); in afs_vlocation_reaper()
574 list_move_tail(&vl->grave, &corpses); in afs_vlocation_reaper()
575 list_del_init(&vl->link); in afs_vlocation_reaper()
577 spin_unlock(&vl->cell->vl_lock); in afs_vlocation_reaper()
584 vl = list_entry(corpses.next, struct afs_vlocation, grave); in afs_vlocation_reaper()
585 list_del(&vl->grave); in afs_vlocation_reaper()
586 afs_vlocation_destroy(vl); in afs_vlocation_reaper()
624 struct afs_vlocation *vl, *xvl; in afs_vlocation_updater() local
642 vl = list_entry(afs_vlocation_updates.next, in afs_vlocation_updater()
644 if (atomic_read(&vl->usage) > 0) in afs_vlocation_updater()
646 list_del_init(&vl->update); in afs_vlocation_updater()
649 timeout = vl->update_at - now; in afs_vlocation_updater()
658 list_del_init(&vl->update); in afs_vlocation_updater()
659 atomic_inc(&vl->usage); in afs_vlocation_updater()
663 _debug("update %s", vl->vldb.name); in afs_vlocation_updater()
664 vl->state = AFS_VL_UPDATING; in afs_vlocation_updater()
665 vl->upd_rej_cnt = 0; in afs_vlocation_updater()
666 vl->upd_busy_cnt = 0; in afs_vlocation_updater()
668 ret = afs_vlocation_update_record(vl, NULL, &vldb); in afs_vlocation_updater()
669 spin_lock(&vl->lock); in afs_vlocation_updater()
672 afs_vlocation_apply_update(vl, &vldb); in afs_vlocation_updater()
673 vl->state = AFS_VL_VALID; in afs_vlocation_updater()
676 vl->state = AFS_VL_VOLUME_DELETED; in afs_vlocation_updater()
679 vl->state = AFS_VL_UNCERTAIN; in afs_vlocation_updater()
682 spin_unlock(&vl->lock); in afs_vlocation_updater()
683 wake_up(&vl->waitq); in afs_vlocation_updater()
687 vl->update_at = get_seconds() + afs_vlocation_update_timeout; in afs_vlocation_updater()
698 if (vl->update_at <= xvl->update_at) in afs_vlocation_updater()
699 vl->update_at = xvl->update_at + 1; in afs_vlocation_updater()
709 ASSERT(list_empty(&vl->update)); in afs_vlocation_updater()
711 list_add_tail(&vl->update, &afs_vlocation_updates); in afs_vlocation_updater()
717 afs_put_vlocation(vl); in afs_vlocation_updater()