Index: appl/fs/fs.c =================================================================== RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/appl/fs/fs.c,v retrieving revision 1.88 diff -u -w -r1.88 fs.c --- appl/fs/fs.c 2000/10/03 00:07:34 1.88 +++ appl/fs/fs.c 2000/10/11 23:56:17 @@ -48,6 +48,7 @@ static int arladebug_cmd (int argc, char **argv); static int calculate_cmd (int argc, char **argv); static int checkservers_cmd (int argc, char **argv); +static int checkvolumes_cmd (int argc, char **argv); static int copyacl_cmd (int argc, char **argv); static int diskfree_cmd (int argc, char **argv); static int examine_cmd (int argc, char **argv); @@ -96,7 +97,7 @@ {"arladebug", arladebug_cmd, "tweek arla-debugging flags"}, {"calculate cache", calculate_cmd, "calculate the usege of cache"}, {"checkservers", checkservers_cmd,"check if servers is up"}, - {"checkvolumes", empty_cmd, "lookup mappings between volume-Id's and names"}, + {"checkvolumes", checkvolumes_cmd, "lookup mappings between volume-Id's and names"}, {"cleanacl", empty_cmd, "clear out numeric acl-entries"}, {"copyacl", copyacl_cmd, "copy acl"}, {"diskfree", diskfree_cmd, "show free partition space"}, @@ -198,13 +199,6 @@ } static int -connect_usage(void) -{ - printf("connect [connected|fetch|disconnected]\n"); - return 0; -} - -static int checkservers_cmd (int argc, char **argv) { char *cell = NULL; @@ -267,6 +261,24 @@ } } printf("\n"); + return 0; +} + +static int +checkvolumes_cmd (int argc, char **argv) +{ + int ret; + + ret = fs_checkvolumes(); + if (ret) + fserr (PROGNAME, ret, NULL); + return 0; +} + +static int +connect_usage(void) +{ + printf("connect [connected|fetch|disconnected]\n"); return 0; } Index: appl/lib/arlalib.h =================================================================== RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/appl/lib/arlalib.h,v retrieving revision 1.36 diff -u -w -r1.36 arlalib.h --- appl/lib/arlalib.h 2000/10/03 00:07:56 1.36 +++ appl/lib/arlalib.h 2000/10/11 23:56:18 @@ -113,6 +113,8 @@ int fs_checkservers(char *cell, int32_t flags, u_int32_t *hosts, int numhosts); +int fs_checkvolumes (void); + int fs_set_sysname (const char *sys); Index: appl/lib/fs_lib.c =================================================================== RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/appl/lib/fs_lib.c,v retrieving revision 1.31 diff -u -w -r1.31 fs_lib.c --- appl/lib/fs_lib.c 2000/10/10 17:30:00 1.31 +++ appl/lib/fs_lib.c 2000/10/11 23:56:18 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -570,6 +570,26 @@ free(in); return ret; +} + +/* + * check validity of cachec volume information + */ + +int +fs_checkvolumes (void) +{ + struct ViceIoctl a_params; + + a_params.in = NULL; + a_params.in_size = 0; + a_params.out = NULL; + a_params.out_size = 0; + + if (k_pioctl (NULL, VIOCCKBACK, &a_params, 0) < 0) + return errno; + else + return 0; } /* Index: arlad/messages.c =================================================================== RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/arlad/messages.c,v retrieving revision 1.228 diff -u -w -r1.228 messages.c --- arlad/messages.c 2000/10/02 22:32:31 1.228 +++ arlad/messages.c 2000/10/11 23:56:18 @@ -3176,7 +3176,7 @@ } /* - * + * Break the callback of the specified fid */ static int @@ -3219,6 +3219,17 @@ } /* + * check volume mappings + */ + +static int +vioc_ckback(int fd, struct xfs_message_pioctl *h, u_int size) +{ + volcache_invalidate_all (); + return 0; +} + +/* * Handle a pioctl message in `h' */ @@ -3486,6 +3497,15 @@ #endif error = vioc_breakcallback (fd, h, size); break; +#ifdef VIOCCKBACK_32 + case VIOCCKBACK_32 : + case VIOCCKBACK_64 : +#else + case VIOCCKBACK : +#endif + error = vioc_ckback (fd, h, size); + break; + default: arla_warnx (ADEBMSG, "unknown pioctl call %d", h->opcode); error = EINVAL ; Index: volcache.c =================================================================== RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/arlad/volcache.c,v retrieving revision 1.94 diff -u -w -u -w -r1.94 volcache.c --- volcache.c 2000/10/02 22:33:14 1.94 +++ volcache.c 2000/10/12 00:28:46 @@ -855,20 +857,36 @@ return 0; } else { VolCacheEntry tmp_ve; + int stable; error = get_info_byname (&tmp_ve, volname, cell, ce); if (error) { - --(*e)->refcount; - try_reuse (*e); + volcache_free (*e); return error; } - (*e)->flags.stablep = cmp_nvldbentry (&tmp_ve.entry, - &(*e)->entry) == 0; + stable = cmp_nvldbentry (&tmp_ve.entry, &(*e)->entry) == 0; + if (stable) { + (*e)->flags.stablep = TRUE; (*e)->flags.validp = TRUE; (*e)->entry = tmp_ve.entry; + } else { + volcache_free (*e); + + *e = get_free_entry (); + + (*e)->cell = cell; + (*e)->refcount = 0; + (*e)->vol_refs = 0; + + (*e)->entry = tmp_ve.entry; + (*e)->last_fetch = tmp_ve.last_fetch; + (*e)->flags.validp = TRUE; + (*e)->flags.stablep = FALSE; + add_to_hashtab (*e); } } } +} /* * Retrieve the entry for (volume-id, cell). If it's not in the cache, @@ -895,17 +913,33 @@ return 0; } else { VolCacheEntry tmp_ve; + int stable; error = get_info_byid (&tmp_ve, volid, cell, ce); if (error) { - --(*e)->refcount; - try_reuse (*e); + volcache_free (*e); return error; } - (*e)->flags.stablep = cmp_nvldbentry (&tmp_ve.entry, - &(*e)->entry) == 0; + stable = cmp_nvldbentry (&tmp_ve.entry, &(*e)->entry) == 0; + if (stable) { + (*e)->flags.stablep = TRUE; (*e)->flags.validp = TRUE; (*e)->entry = tmp_ve.entry; + } else { + volcache_free (*e); + + *e = get_free_entry (); + + (*e)->cell = cell; + (*e)->refcount = 0; + (*e)->vol_refs = 0; + + (*e)->entry = tmp_ve.entry; + (*e)->last_fetch = tmp_ve.last_fetch; + (*e)->flags.validp = TRUE; + (*e)->flags.stablep = FALSE; + add_to_hashtab (*e); + } } } } @@ -921,6 +955,25 @@ ve->flags.stablep = FALSE; } +static Bool +inval (void *ptr, void *arg) +{ + struct num_ptr *n = (struct num_ptr *)ptr; + VolCacheEntry *e = n->ptr; + + volcache_invalidate_ve (e); + return FALSE; +} + +/* + * Invalidate all volume entries + */ + +void +volcache_invalidate_all (void) +{ + hashtabforeach (volidhashtab, inval, NULL); +} /* * invalidate this volume if id == data->id Index: arlad/volcache.h =================================================================== RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/arlad/volcache.h,v retrieving revision 1.28 diff -u -w -r1.28 volcache.h --- arlad/volcache.h 2000/10/02 22:33:20 1.28 +++ arlad/volcache.h 2000/10/11 23:56:19 @@ -135,6 +135,8 @@ void volcache_invalidate_ve (VolCacheEntry *ve); +void volcache_invalidate_all (void); + int volume_make_uptodate (VolCacheEntry *e, CredCacheEntry *ce); Bool volcache_reliable (u_int32_t id, int32_t cell);