diff options
Diffstat (limited to 'fs/afs/vlocation.c')
-rw-r--r-- | fs/afs/vlocation.c | 102 |
1 files changed, 36 insertions, 66 deletions
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c index 782ee7c600ca..e48728c92175 100644 --- a/fs/afs/vlocation.c +++ b/fs/afs/vlocation.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* vlocation.c: volume location management | 1 | /* volume location management |
2 | * | 2 | * |
3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. | 3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 4 | * Written by David Howells (dhowells@redhat.com) |
@@ -73,7 +73,6 @@ struct cachefs_index_def afs_vlocation_cache_index_def = { | |||
73 | }; | 73 | }; |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | /*****************************************************************************/ | ||
77 | /* | 76 | /* |
78 | * iterate through the VL servers in a cell until one of them admits knowing | 77 | * iterate through the VL servers in a cell until one of them admits knowing |
79 | * about the volume in question | 78 | * about the volume in question |
@@ -146,13 +145,11 @@ static int afs_vlocation_access_vl_by_name(struct afs_vlocation *vlocation, | |||
146 | cell->vl_curr_svix %= cell->vl_naddrs; | 145 | cell->vl_curr_svix %= cell->vl_naddrs; |
147 | } | 146 | } |
148 | 147 | ||
149 | out: | 148 | out: |
150 | _leave(" = %d", ret); | 149 | _leave(" = %d", ret); |
151 | return ret; | 150 | return ret; |
151 | } | ||
152 | 152 | ||
153 | } /* end afs_vlocation_access_vl_by_name() */ | ||
154 | |||
155 | /*****************************************************************************/ | ||
156 | /* | 153 | /* |
157 | * iterate through the VL servers in a cell until one of them admits knowing | 154 | * iterate through the VL servers in a cell until one of them admits knowing |
158 | * about the volume in question | 155 | * about the volume in question |
@@ -225,13 +222,11 @@ static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vlocation, | |||
225 | cell->vl_curr_svix %= cell->vl_naddrs; | 222 | cell->vl_curr_svix %= cell->vl_naddrs; |
226 | } | 223 | } |
227 | 224 | ||
228 | out: | 225 | out: |
229 | _leave(" = %d", ret); | 226 | _leave(" = %d", ret); |
230 | return ret; | 227 | return ret; |
228 | } | ||
231 | 229 | ||
232 | } /* end afs_vlocation_access_vl_by_id() */ | ||
233 | |||
234 | /*****************************************************************************/ | ||
235 | /* | 230 | /* |
236 | * lookup volume location | 231 | * lookup volume location |
237 | * - caller must have cell->vol_sem write-locked | 232 | * - caller must have cell->vol_sem write-locked |
@@ -321,7 +316,7 @@ int afs_vlocation_lookup(struct afs_cell *cell, | |||
321 | 316 | ||
322 | goto found_on_vlserver; | 317 | goto found_on_vlserver; |
323 | 318 | ||
324 | found_in_graveyard: | 319 | found_in_graveyard: |
325 | /* found in the graveyard - resurrect */ | 320 | /* found in the graveyard - resurrect */ |
326 | _debug("found in graveyard"); | 321 | _debug("found in graveyard"); |
327 | atomic_inc(&vlocation->usage); | 322 | atomic_inc(&vlocation->usage); |
@@ -331,16 +326,16 @@ int afs_vlocation_lookup(struct afs_cell *cell, | |||
331 | afs_kafstimod_del_timer(&vlocation->timeout); | 326 | afs_kafstimod_del_timer(&vlocation->timeout); |
332 | goto active; | 327 | goto active; |
333 | 328 | ||
334 | found_in_memory: | 329 | found_in_memory: |
335 | /* found in memory - check to see if it's active */ | 330 | /* found in memory - check to see if it's active */ |
336 | _debug("found in memory"); | 331 | _debug("found in memory"); |
337 | atomic_inc(&vlocation->usage); | 332 | atomic_inc(&vlocation->usage); |
338 | 333 | ||
339 | active: | 334 | active: |
340 | active = 1; | 335 | active = 1; |
341 | 336 | ||
342 | #ifdef AFS_CACHING_SUPPORT | 337 | #ifdef AFS_CACHING_SUPPORT |
343 | found_in_cache: | 338 | found_in_cache: |
344 | #endif | 339 | #endif |
345 | /* try to look up a cached volume in the cell VL databases by ID */ | 340 | /* try to look up a cached volume in the cell VL databases by ID */ |
346 | _debug("found in cache"); | 341 | _debug("found in cache"); |
@@ -364,16 +359,13 @@ int afs_vlocation_lookup(struct afs_cell *cell, | |||
364 | if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) { | 359 | if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) { |
365 | vid = vlocation->vldb.vid[0]; | 360 | vid = vlocation->vldb.vid[0]; |
366 | voltype = AFSVL_RWVOL; | 361 | voltype = AFSVL_RWVOL; |
367 | } | 362 | } else if (vlocation->vldb.vidmask & AFS_VOL_VTM_RO) { |
368 | else if (vlocation->vldb.vidmask & AFS_VOL_VTM_RO) { | ||
369 | vid = vlocation->vldb.vid[1]; | 363 | vid = vlocation->vldb.vid[1]; |
370 | voltype = AFSVL_ROVOL; | 364 | voltype = AFSVL_ROVOL; |
371 | } | 365 | } else if (vlocation->vldb.vidmask & AFS_VOL_VTM_BAK) { |
372 | else if (vlocation->vldb.vidmask & AFS_VOL_VTM_BAK) { | ||
373 | vid = vlocation->vldb.vid[2]; | 366 | vid = vlocation->vldb.vid[2]; |
374 | voltype = AFSVL_BACKVOL; | 367 | voltype = AFSVL_BACKVOL; |
375 | } | 368 | } else { |
376 | else { | ||
377 | BUG(); | 369 | BUG(); |
378 | vid = 0; | 370 | vid = 0; |
379 | voltype = 0; | 371 | voltype = 0; |
@@ -400,7 +392,7 @@ int afs_vlocation_lookup(struct afs_cell *cell, | |||
400 | goto error; | 392 | goto error; |
401 | } | 393 | } |
402 | 394 | ||
403 | found_on_vlserver: | 395 | found_on_vlserver: |
404 | _debug("Done VL Lookup: %*.*s %02x { %08x(%x) %08x(%x) %08x(%x) }", | 396 | _debug("Done VL Lookup: %*.*s %02x { %08x(%x) %08x(%x) %08x(%x) }", |
405 | namesz, namesz, name, | 397 | namesz, namesz, name, |
406 | vldb.vidmask, | 398 | vldb.vidmask, |
@@ -430,12 +422,11 @@ int afs_vlocation_lookup(struct afs_cell *cell, | |||
430 | _leave(" = 0 (%p)",vlocation); | 422 | _leave(" = 0 (%p)",vlocation); |
431 | return 0; | 423 | return 0; |
432 | 424 | ||
433 | error: | 425 | error: |
434 | if (vlocation) { | 426 | if (vlocation) { |
435 | if (active) { | 427 | if (active) { |
436 | __afs_put_vlocation(vlocation); | 428 | __afs_put_vlocation(vlocation); |
437 | } | 429 | } else { |
438 | else { | ||
439 | list_del(&vlocation->link); | 430 | list_del(&vlocation->link); |
440 | #ifdef AFS_CACHING_SUPPORT | 431 | #ifdef AFS_CACHING_SUPPORT |
441 | cachefs_relinquish_cookie(vlocation->cache, 0); | 432 | cachefs_relinquish_cookie(vlocation->cache, 0); |
@@ -447,9 +438,8 @@ int afs_vlocation_lookup(struct afs_cell *cell, | |||
447 | 438 | ||
448 | _leave(" = %d", ret); | 439 | _leave(" = %d", ret); |
449 | return ret; | 440 | return ret; |
450 | } /* end afs_vlocation_lookup() */ | 441 | } |
451 | 442 | ||
452 | /*****************************************************************************/ | ||
453 | /* | 443 | /* |
454 | * finish using a volume location record | 444 | * finish using a volume location record |
455 | * - caller must have cell->vol_sem write-locked | 445 | * - caller must have cell->vol_sem write-locked |
@@ -489,9 +479,8 @@ static void __afs_put_vlocation(struct afs_vlocation *vlocation) | |||
489 | spin_unlock(&cell->vl_gylock); | 479 | spin_unlock(&cell->vl_gylock); |
490 | 480 | ||
491 | _leave(" [killed]"); | 481 | _leave(" [killed]"); |
492 | } /* end __afs_put_vlocation() */ | 482 | } |
493 | 483 | ||
494 | /*****************************************************************************/ | ||
495 | /* | 484 | /* |
496 | * finish using a volume location record | 485 | * finish using a volume location record |
497 | */ | 486 | */ |
@@ -504,9 +493,8 @@ void afs_put_vlocation(struct afs_vlocation *vlocation) | |||
504 | __afs_put_vlocation(vlocation); | 493 | __afs_put_vlocation(vlocation); |
505 | up_write(&cell->vl_sem); | 494 | up_write(&cell->vl_sem); |
506 | } | 495 | } |
507 | } /* end afs_put_vlocation() */ | 496 | } |
508 | 497 | ||
509 | /*****************************************************************************/ | ||
510 | /* | 498 | /* |
511 | * timeout vlocation record | 499 | * timeout vlocation record |
512 | * - removes from the cell's graveyard if the usage count is zero | 500 | * - removes from the cell's graveyard if the usage count is zero |
@@ -543,9 +531,8 @@ void afs_vlocation_do_timeout(struct afs_vlocation *vlocation) | |||
543 | kfree(vlocation); | 531 | kfree(vlocation); |
544 | 532 | ||
545 | _leave(" [destroyed]"); | 533 | _leave(" [destroyed]"); |
546 | } /* end afs_vlocation_do_timeout() */ | 534 | } |
547 | 535 | ||
548 | /*****************************************************************************/ | ||
549 | /* | 536 | /* |
550 | * send an update operation to the currently selected server | 537 | * send an update operation to the currently selected server |
551 | */ | 538 | */ |
@@ -564,16 +551,13 @@ static int afs_vlocation_update_begin(struct afs_vlocation *vlocation) | |||
564 | if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) { | 551 | if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) { |
565 | vid = vlocation->vldb.vid[0]; | 552 | vid = vlocation->vldb.vid[0]; |
566 | voltype = AFSVL_RWVOL; | 553 | voltype = AFSVL_RWVOL; |
567 | } | 554 | } else if (vlocation->vldb.vidmask & AFS_VOL_VTM_RO) { |
568 | else if (vlocation->vldb.vidmask & AFS_VOL_VTM_RO) { | ||
569 | vid = vlocation->vldb.vid[1]; | 555 | vid = vlocation->vldb.vid[1]; |
570 | voltype = AFSVL_ROVOL; | 556 | voltype = AFSVL_ROVOL; |
571 | } | 557 | } else if (vlocation->vldb.vidmask & AFS_VOL_VTM_BAK) { |
572 | else if (vlocation->vldb.vidmask & AFS_VOL_VTM_BAK) { | ||
573 | vid = vlocation->vldb.vid[2]; | 558 | vid = vlocation->vldb.vid[2]; |
574 | voltype = AFSVL_BACKVOL; | 559 | voltype = AFSVL_BACKVOL; |
575 | } | 560 | } else { |
576 | else { | ||
577 | BUG(); | 561 | BUG(); |
578 | vid = 0; | 562 | vid = 0; |
579 | voltype = 0; | 563 | voltype = 0; |
@@ -604,9 +588,8 @@ static int afs_vlocation_update_begin(struct afs_vlocation *vlocation) | |||
604 | 588 | ||
605 | _leave(" = %d", ret); | 589 | _leave(" = %d", ret); |
606 | return ret; | 590 | return ret; |
607 | } /* end afs_vlocation_update_begin() */ | 591 | } |
608 | 592 | ||
609 | /*****************************************************************************/ | ||
610 | /* | 593 | /* |
611 | * abandon updating a VL record | 594 | * abandon updating a VL record |
612 | * - does not restart the update timer | 595 | * - does not restart the update timer |
@@ -634,9 +617,8 @@ static void afs_vlocation_update_abandon(struct afs_vlocation *vlocation, | |||
634 | spin_unlock(&afs_vlocation_update_lock); | 617 | spin_unlock(&afs_vlocation_update_lock); |
635 | 618 | ||
636 | _leave(""); | 619 | _leave(""); |
637 | } /* end afs_vlocation_update_abandon() */ | 620 | } |
638 | 621 | ||
639 | /*****************************************************************************/ | ||
640 | /* | 622 | /* |
641 | * handle periodic update timeouts and busy retry timeouts | 623 | * handle periodic update timeouts and busy retry timeouts |
642 | * - called from kafstimod | 624 | * - called from kafstimod |
@@ -663,8 +645,7 @@ static void afs_vlocation_update_timer(struct afs_timer *timer) | |||
663 | if (afs_vlocation_update) { | 645 | if (afs_vlocation_update) { |
664 | list_add(&vlocation->upd_op.link, | 646 | list_add(&vlocation->upd_op.link, |
665 | &afs_vlocation_update_pendq); | 647 | &afs_vlocation_update_pendq); |
666 | } | 648 | } else { |
667 | else { | ||
668 | afs_get_vlocation(vlocation); | 649 | afs_get_vlocation(vlocation); |
669 | afs_vlocation_update = vlocation; | 650 | afs_vlocation_update = vlocation; |
670 | vlocation->upd_state = AFS_VLUPD_INPROGRESS; | 651 | vlocation->upd_state = AFS_VLUPD_INPROGRESS; |
@@ -706,16 +687,13 @@ static void afs_vlocation_update_timer(struct afs_timer *timer) | |||
706 | _leave(""); | 687 | _leave(""); |
707 | return; | 688 | return; |
708 | 689 | ||
709 | out_unlock2: | 690 | out_unlock2: |
710 | spin_unlock(&afs_vlocation_update_lock); | 691 | spin_unlock(&afs_vlocation_update_lock); |
711 | out_unlock1: | 692 | out_unlock1: |
712 | spin_unlock(&vlocation->cell->vl_gylock); | 693 | spin_unlock(&vlocation->cell->vl_gylock); |
713 | _leave(""); | 694 | _leave(""); |
714 | return; | 695 | } |
715 | |||
716 | } /* end afs_vlocation_update_timer() */ | ||
717 | 696 | ||
718 | /*****************************************************************************/ | ||
719 | /* | 697 | /* |
720 | * attend to an update operation upon which an event happened | 698 | * attend to an update operation upon which an event happened |
721 | * - called in kafsasyncd context | 699 | * - called in kafsasyncd context |
@@ -818,7 +796,7 @@ static void afs_vlocation_update_attend(struct afs_async_op *op) | |||
818 | } | 796 | } |
819 | 797 | ||
820 | /* try contacting the next server */ | 798 | /* try contacting the next server */ |
821 | try_next: | 799 | try_next: |
822 | vlocation->upd_busy_cnt = 0; | 800 | vlocation->upd_busy_cnt = 0; |
823 | 801 | ||
824 | /* discard the server record */ | 802 | /* discard the server record */ |
@@ -856,15 +834,13 @@ static void afs_vlocation_update_attend(struct afs_async_op *op) | |||
856 | } | 834 | } |
857 | 835 | ||
858 | /* abandon the update */ | 836 | /* abandon the update */ |
859 | abandon: | 837 | abandon: |
860 | afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, ret); | 838 | afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, ret); |
861 | afs_kafstimod_add_timer(&vlocation->upd_timer, HZ * 10); | 839 | afs_kafstimod_add_timer(&vlocation->upd_timer, HZ * 10); |
862 | afs_put_vlocation(vlocation); | 840 | afs_put_vlocation(vlocation); |
863 | _leave(" [abandoned]"); | 841 | _leave(" [abandoned]"); |
842 | } | ||
864 | 843 | ||
865 | } /* end afs_vlocation_update_attend() */ | ||
866 | |||
867 | /*****************************************************************************/ | ||
868 | /* | 844 | /* |
869 | * deal with an update operation being discarded | 845 | * deal with an update operation being discarded |
870 | * - called in kafsasyncd context when it's dying due to rmmod | 846 | * - called in kafsasyncd context when it's dying due to rmmod |
@@ -883,9 +859,8 @@ static void afs_vlocation_update_discard(struct afs_async_op *op) | |||
883 | afs_put_vlocation(vlocation); | 859 | afs_put_vlocation(vlocation); |
884 | 860 | ||
885 | _leave(""); | 861 | _leave(""); |
886 | } /* end afs_vlocation_update_discard() */ | 862 | } |
887 | 863 | ||
888 | /*****************************************************************************/ | ||
889 | /* | 864 | /* |
890 | * match a VLDB record stored in the cache | 865 | * match a VLDB record stored in the cache |
891 | * - may also load target from entry | 866 | * - may also load target from entry |
@@ -908,9 +883,7 @@ static cachefs_match_val_t afs_vlocation_cache_match(void *target, | |||
908 | vlocation->valid = 1; | 883 | vlocation->valid = 1; |
909 | _leave(" = SUCCESS [c->m]"); | 884 | _leave(" = SUCCESS [c->m]"); |
910 | return CACHEFS_MATCH_SUCCESS; | 885 | return CACHEFS_MATCH_SUCCESS; |
911 | } | 886 | } else if (memcmp(&vlocation->vldb, vldb, sizeof(*vldb)) != 0) { |
912 | /* need to update cache if cached info differs */ | ||
913 | else if (memcmp(&vlocation->vldb, vldb, sizeof(*vldb)) != 0) { | ||
914 | /* delete if VIDs for this name differ */ | 887 | /* delete if VIDs for this name differ */ |
915 | if (memcmp(&vlocation->vldb.vid, | 888 | if (memcmp(&vlocation->vldb.vid, |
916 | &vldb->vid, | 889 | &vldb->vid, |
@@ -921,8 +894,7 @@ static cachefs_match_val_t afs_vlocation_cache_match(void *target, | |||
921 | 894 | ||
922 | _leave(" = UPDATE"); | 895 | _leave(" = UPDATE"); |
923 | return CACHEFS_MATCH_SUCCESS_UPDATE; | 896 | return CACHEFS_MATCH_SUCCESS_UPDATE; |
924 | } | 897 | } else { |
925 | else { | ||
926 | _leave(" = SUCCESS"); | 898 | _leave(" = SUCCESS"); |
927 | return CACHEFS_MATCH_SUCCESS; | 899 | return CACHEFS_MATCH_SUCCESS; |
928 | } | 900 | } |
@@ -930,10 +902,9 @@ static cachefs_match_val_t afs_vlocation_cache_match(void *target, | |||
930 | 902 | ||
931 | _leave(" = FAILED"); | 903 | _leave(" = FAILED"); |
932 | return CACHEFS_MATCH_FAILED; | 904 | return CACHEFS_MATCH_FAILED; |
933 | } /* end afs_vlocation_cache_match() */ | 905 | } |
934 | #endif | 906 | #endif |
935 | 907 | ||
936 | /*****************************************************************************/ | ||
937 | /* | 908 | /* |
938 | * update a VLDB record stored in the cache | 909 | * update a VLDB record stored in the cache |
939 | */ | 910 | */ |
@@ -946,6 +917,5 @@ static void afs_vlocation_cache_update(void *source, void *entry) | |||
946 | _enter(""); | 917 | _enter(""); |
947 | 918 | ||
948 | *vldb = vlocation->vldb; | 919 | *vldb = vlocation->vldb; |
949 | 920 | } | |
950 | } /* end afs_vlocation_cache_update() */ | ||
951 | #endif | 921 | #endif |