2 * Copyright 2006, Sine Nomine Associates and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
12 * fileserver state serialization
15 #include <afsconfig.h>
16 #include <afs/param.h>
20 #include <stdlib.h> /* for malloc() */
21 #include <time.h> /* ANSI standard location for time stuff */
30 #include <afs/assert.h>
38 #include <afs/afsint.h>
39 #include <afs/rxgen_consts.h>
41 #include <afs/errors.h>
42 #include <afs/ihandle.h>
43 #include <afs/vnode.h>
44 #include <afs/volume.h>
46 #include <afs/ptclient.h>
47 #include <afs/prs_fs.h>
48 #include <afs/afsutil.h>
50 #include <afs/cellconfig.h>
53 #include "../viced/viced_prototypes.h"
54 #include "../viced/viced.h"
55 #include "../viced/host.h"
56 #include "../viced/callback.h"
57 #include "serialize_state.h"
59 /*@+fcnmacros +macrofcndecl@*/
62 extern off64_t afs_lseek(int FD, off64_t O, int F);
63 #endif /*S_SPLINT_S */
64 #define afs_lseek(FD, O, F) lseek64(FD, (off64_t)(O), F)
65 #define afs_stat stat64
66 #define afs_fstat fstat64
67 #define afs_open open64
68 #define afs_fopen fopen64
69 #define afs_ftruncate ftruncate64
70 #define afs_mmap mmap64
72 extern void * mmap64(); /* ugly hack since aix build env appears to be somewhat broken */
74 #else /* !O_LARGEFILE */
76 extern off_t afs_lseek(int FD, off_t O, int F);
77 #endif /*S_SPLINT_S */
78 #define afs_lseek(FD, O, F) lseek(FD, (off_t)(O), F)
80 #define afs_fstat fstat
82 #define afs_fopen fopen
83 #define afs_ftruncate ftruncate
85 #endif /* !O_LARGEFILE */
86 /*@=fcnmacros =macrofcndecl@*/
89 #ifdef AFS_DEMAND_ATTACH_FS
95 * in order to make state dump/restore as fast as possible,
96 * we use memory mapped files
98 * if this causes problems on certain platforms, the APIs
99 * have been written so that it will be very simple to go
100 * back to standard I/O for just those poorly written platforms
103 #define FS_STATE_USE_MMAP
106 #ifdef FS_STATE_USE_MMAP
107 #define FS_STATE_INIT_FILESIZE (8 * 1024 * 1024) /* truncate to 8MB initially */
108 #include <sys/mman.h>
111 static int fs_stateCreateDump(struct fs_dump_state * state);
112 static int fs_stateLoadDump(struct fs_dump_state * state);
113 static int fs_stateInvalidateDump(struct fs_dump_state * state);
114 static int fs_stateCommitDump(struct fs_dump_state * state);
115 static int fs_stateCloseDump(struct fs_dump_state * state);
117 #ifdef FS_STATE_USE_MMAP
118 static int fs_stateSizeFile(struct fs_dump_state * state);
119 static int fs_stateResizeFile(struct fs_dump_state * state, size_t min_add);
120 static int fs_stateTruncateFile(struct fs_dump_state * state);
122 static int fs_stateMapFile(struct fs_dump_state * state);
123 static int fs_stateUnmapFile(struct fs_dump_state * state);
125 static int fs_stateIncCursor(struct fs_dump_state * state, size_t len);
126 static int fs_stateCheckIOSafety(struct fs_dump_state * state,
130 static int fs_stateFillHeader(struct fs_state_header * hdr);
131 static int fs_stateCheckHeader(struct fs_state_header * hdr);
133 static int fs_stateAlloc(struct fs_dump_state * state);
134 static int fs_stateFree(struct fs_dump_state * state);
136 extern afsUUID FS_HostUUID;
137 extern char cml_version_number[];
141 * save all fileserver state
146 int ret = 0, verified = 1;
147 struct fs_dump_state state;
149 /* save and restore need to be atomic wrt other host package operations */
152 ViceLog(0, ("fs_stateSave: commencing fileserver state dump\n"));
154 if (fs_stateAlloc(&state)) {
155 ViceLog(0, ("fs_stateSave: memory allocation failed; dump aborted\n"));
161 * on busy servers, these checks will inevitably fail since stuff drops H_LOCK
162 * all over the place (with structs left in inconsistent states) while RPCs to
163 * clients happen (grumble, grumble, the host package needs to be rewritten...)
165 * the current hack is to force the background threads that deal with host and
166 * callback state offline early in the shutdown process, do VShutdown, come
167 * back and wait for those threads to die, THEN do the state dump
169 * BUT, this still has one flaw -- what do we do about rx worker threads that
170 * are blocked in the host package making an RPC call to a cm???
172 * perhaps we need a refcounter that keeps track of threads blocked in rpc calls
173 * with H_LOCK dropped (and the host struct likely left in an inconsistent state)
175 * or better yet, we need to associate a state machine with each host object
176 * (kind of like demand attach Volume structures).
178 * sigh. I suspect we'll need to revisit this issue
181 if (fs_state.options.fs_state_verify_before_save) {
182 ViceLog(0, ("fs_stateSave: performing internal consistency checks before proceeding with state dump\n"));
184 if (h_stateVerify(&state)) {
185 ViceLog(0, ("fs_stateSave: error: host table consistency checks failed; state dump will not be marked clean\n"));
190 if (cb_stateVerify(&state)) {
191 ViceLog(0, ("fs_stateSave: error: callback table consistency checks failed; state dump will not be marked clean\n"));
196 /* if a consistency check asserted the bail flag, reset it */
199 ViceLog(0, ("fs_stateSave: proceeding with dump\n"));
202 if (fs_stateCreateDump(&state)) {
203 ViceLog(0, ("fs_stateSave: error: dump create failed\n"));
208 if (h_stateSave(&state)) {
209 ViceLog(0, ("fs_stateSave: error: host state dump failed\n"));
214 if (cb_stateSave(&state)) {
215 ViceLog(0, ("fs_stateSave: error: callback state dump failed\n"));
224 if (fs_stateCommitDump(&state)) {
225 ViceLog(0, ("fs_stateSave: error: dump commit failed\n"));
231 ViceLog(0, ("fs_stateSave: fileserver state dump completed successfully\n"));
233 ViceLog(0, ("fs_stateSave: fileserver state dump completed, but not marked clean.\n"));
234 ViceLog(0, ("fs_stateSave: please save a copy of '%s' for use by technical support\n",
240 fs_stateCloseDump(&state);
241 fs_stateFree(&state);
248 * restore all fileserver state
250 * this function must appear as one atomic operation to the host and callback
251 * packages, hence H_LOCK is held for the entirety of the process.
254 fs_stateRestore(void)
257 struct fs_dump_state state;
259 /* save and restore need to be atomic wrt other host package operations */
262 ViceLog(0, ("fs_stateRestore: commencing fileserver state restore\n"));
264 if (fs_stateAlloc(&state)) {
265 ViceLog(0, ("fs_stateRestore: memory allocation failed\n"));
270 if (fs_stateLoadDump(&state)) {
271 ViceLog(0, ("fs_stateRestore: failed to load dump file '%s'\n", state.fn));
276 if (fs_stateInvalidateDump(&state)) {
277 ViceLog(0, ("fs_stateRestore: failed to invalidate dump file '%s'\n", state.fn));
283 if (state.flags.do_host_restore) {
284 if (h_stateRestore(&state)) {
285 ViceLog(0, ("fs_stateRestore: error: host state restore failed. exiting avoid further corruption\n"));
288 ViceLog(0, ("fs_stateRestore: host table restored\n"));
290 if (cb_stateRestore(&state)) {
291 ViceLog(0, ("fs_stateRestore: error: callback state restore failed. exiting to avoid further corruption\n"));
294 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack tables restored\n"));
296 if (h_stateRestoreIndices(&state)) {
297 ViceLog(0, ("fs_stateRestore: error: host index remapping failed. exiting to avoid further corruption\n"));
300 ViceLog(0, ("fs_stateRestore: host table indices remapped\n"));
302 if (cb_stateRestoreIndices(&state)) {
303 ViceLog(0, ("fs_stateRestore: error: callback index remapping failed. exiting to avoid further corruption\n"));
306 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack indices remapped\n"));
309 ViceLog(0, ("fs_stateRestore: restore phase complete\n"));
311 if (fs_state.options.fs_state_verify_after_restore) {
312 ViceLog(0, ("fs_stateRestore: beginning state verification phase\n"));
314 if (state.flags.do_host_restore) {
315 if (h_stateVerify(&state)) {
316 ViceLog(0, ("fs_stateRestore: error: host table consistency checks failed; exiting to avoid further corruption\n"));
320 if (cb_stateVerify(&state)) {
321 ViceLog(0, ("fs_stateRestore: error: callback table consistency checks failed; exiting to avoid further corruption\n"));
326 ViceLog(0, ("fs_stateRestore: fileserver state verification complete\n"));
329 ViceLog(0, ("fs_stateRestore: restore was successful\n"));
333 fs_stateInvalidateDump(&state);
334 fs_stateCloseDump(&state);
336 fs_stateFree(&state);
342 fs_stateCreateDump(struct fs_dump_state * state)
345 char savedump[MAXPATHLEN];
346 struct afs_stat status;
348 afs_snprintf(savedump, sizeof(savedump), "%s.old", state->fn);
350 if (afs_stat(state->fn, &status) == 0) {
351 renamefile(state->fn, savedump);
354 if (((fd = afs_open(state->fn,
355 O_RDWR | O_CREAT | O_TRUNC,
356 S_IRUSR | S_IWUSR)) == -1) ||
357 (afs_fstat(fd, &status) == -1)) {
358 ViceLog(0, ("fs_stateCreateDump: failed to create state dump file '%s'\n",
365 state->mode = FS_STATE_DUMP_MODE;
366 memset(state->hdr, 0, sizeof(struct fs_state_header));
367 fs_stateIncEOF(state, sizeof(struct fs_state_header));
369 #ifdef FS_STATE_USE_MMAP
370 if (fs_stateSizeFile(state)) {
371 ViceLog(0, ("fs_stateCreateDump: failed to resize state dump file '%s'\n",
377 if (fs_stateMapFile(state)) {
378 ViceLog(0, ("fs_stateCreateDump: failed to memory map state dump file '%s'\n",
385 ret = fs_stateInvalidateDump(state);
392 fs_stateInvalidateDump(struct fs_dump_state * state)
396 struct fs_state_header hdr;
398 #ifdef FS_STATE_USE_MMAP
399 if (state->mmap.map == NULL) {
404 memcpy(&hdr, state->hdr, sizeof(hdr));
408 /* write a bogus header to flag dump in progress */
409 if (fs_stateWriteHeader(state, &z, &hdr, sizeof(hdr))) {
410 ViceLog(0, ("fs_stateInvalidateDump: failed to invalidate old dump file header '%s'\n",
415 if (fs_stateSync(state)) {
416 ViceLog(0, ("fs_stateInvalidateDump: failed to sync changes to disk\n"));
426 fs_stateCommitDump(struct fs_dump_state * state)
433 #ifdef FS_STATE_USE_MMAP
434 if (fs_stateTruncateFile(state)) {
435 ViceLog(0, ("fs_stateCommitDump: failed to truncate dump file to proper size\n"));
441 /* ensure that all pending data I/Os for the state file have been committed
442 * _before_ we make the metadata I/Os */
443 if (fs_stateSync(state)) {
444 ViceLog(0, ("fs_stateCommitDump: failed to sync changes to disk\n"));
449 #ifdef FS_STATE_USE_MMAP
450 /* XXX madvise may not exist on all platforms, so
451 * we may need to add some ifdefs at some point... */
453 madvise((((char *)state->mmap.map) + sizeof(struct fs_state_header)),
454 state->mmap.size - sizeof(struct fs_state_header),
459 /* build the header, and write it to disk */
460 fs_stateFillHeader(state->hdr);
462 state->hdr->valid = 0;
464 if (fs_stateWriteHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
465 ViceLog(0, ("fs_stateCommitDump: failed to write header to dump file '%s'\n",
470 if (fs_stateSync(state)) {
471 ViceLog(0, ("fs_stateCommitDump: failed to sync new header to disk\n"));
481 fs_stateLoadDump(struct fs_dump_state * state)
485 struct afs_stat status;
486 afs_int32 now = FT_ApproxTime();
490 if ((fd = afs_open(state->fn, O_RDWR)) == -1 ||
491 (afs_fstat(fd, &status) == -1)) {
492 ViceLog(0, ("fs_stateLoadDump: failed to load state dump file '%s'\n",
498 state->mode = FS_STATE_LOAD_MODE;
499 state->file_len = status.st_size;
501 #ifdef FS_STATE_USE_MMAP
502 if (fs_stateMapFile(state)) {
503 ViceLog(0, ("fs_stateLoadDump: failed to memory map state dump file '%s'\n",
510 if (fs_stateReadHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
511 ViceLog(0, ("fs_stateLoadDump: failed to read header from dump file '%s'\n",
517 /* check the validity of the header */
518 if (fs_stateCheckHeader(state->hdr)) {
519 ViceLog(1, ("fs_stateLoadDump: header failed validity checks; not restoring '%s'\n",
525 if ((state->hdr->timestamp + HOST_STATE_VALID_WINDOW) >= now) {
526 state->flags.do_host_restore = 1;
528 ViceLog(0, ("fs_stateLoadDump: warning: dump is too old for host and callback restore; skipping those steps\n"));
536 fs_stateCloseDump(struct fs_dump_state * state)
538 #ifdef FS_STATE_USE_MMAP
539 fs_stateUnmapFile(state);
546 fs_stateWrite(struct fs_dump_state * state,
547 void * buf, size_t len)
551 #ifdef FS_STATE_USE_MMAP
552 if (fs_stateCheckIOSafety(state, len)) {
553 if (fs_stateResizeFile(state, len)) {
554 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
561 memcpy(state->mmap.cursor, buf, len);
562 fs_stateIncCursor(state, len);
564 if (write(state->fd, buf, len) != len) {
565 ViceLog(0, ("fs_stateWrite: write failed\n"));
576 fs_stateRead(struct fs_dump_state * state,
577 void * buf, size_t len)
581 #ifdef FS_STATE_USE_MMAP
582 if (fs_stateCheckIOSafety(state, len)) {
583 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
589 memcpy(buf, state->mmap.cursor, len);
590 fs_stateIncCursor(state, len);
592 if (read(state->fd, buf, len) != len) {
593 ViceLog(0, ("fs_stateRead: read failed\n"));
604 fs_stateWriteV(struct fs_dump_state * state,
605 struct iovec * iov, int niov)
610 for (i=0; i < niov; i++) {
611 len += iov[i].iov_len;
614 #ifdef FS_STATE_USE_MMAP
615 if (fs_stateCheckIOSafety(state, len)) {
616 if (fs_stateResizeFile(state, len)) {
617 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
624 for (i=0; i < niov; i++) {
625 memcpy(state->mmap.cursor, iov[i].iov_base, iov[i].iov_len);
626 fs_stateIncCursor(state, iov[i].iov_len);
629 if (writev(state->fd, iov, niov) != len) {
630 ViceLog(0, ("fs_stateWriteV: write failed\n"));
641 fs_stateReadV(struct fs_dump_state * state,
642 struct iovec * iov, int niov)
647 for (i=0; i < niov; i++) {
648 len += iov[i].iov_len;
651 #ifdef FS_STATE_USE_MMAP
652 if (fs_stateCheckIOSafety(state, len)) {
653 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
659 for (i=0; i < niov; i++) {
660 memcpy(iov[i].iov_base, state->mmap.cursor, iov[i].iov_len);
661 fs_stateIncCursor(state, iov[i].iov_len);
664 if (readv(state->fd, iov, niov) != len) {
665 ViceLog(0, ("fs_stateReadV: read failed\n"));
676 fs_stateWriteHeader(struct fs_dump_state * state,
678 void * hdr, size_t len)
682 if (fs_stateSeek(state, offset)) {
683 ViceLog(0, ("fs_stateWriteHeader: could not seek to correct position in dump file '%s'\n",
689 if (fs_stateWrite(state, hdr, len)) {
690 ViceLog(0, ("fs_stateWriteHeader: write failed\n"));
700 fs_stateReadHeader(struct fs_dump_state * state,
702 void * hdr, size_t len)
706 if (fs_stateSeek(state, offset)) {
707 ViceLog(0, ("fs_stateReadHeader: could not seek to correct position in dump file '%s'\n",
713 if (fs_stateRead(state, hdr,len)) {
714 ViceLog(0, ("fs_stateReadHeader: read failed\n"));
723 #ifdef FS_STATE_USE_MMAP
725 fs_stateSizeFile(struct fs_dump_state * state)
728 state->file_len = FS_STATE_INIT_FILESIZE;
729 if (afs_ftruncate(state->fd, state->file_len) != 0)
735 fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
740 #ifdef FS_STATE_USE_MMAP
741 fs_stateUnmapFile(state);
744 inc = ((min_add / FS_STATE_INIT_FILESIZE)+1) * FS_STATE_INIT_FILESIZE;
745 state->file_len += inc;
747 if (afs_ftruncate(state->fd, state->file_len) != 0) {
748 ViceLog(0, ("fs_stateResizeFile: truncate failed\n"));
753 #ifdef FS_STATE_USE_MMAP
754 if (fs_stateMapFile(state)) {
755 ViceLog(0, ("fs_stateResizeFile: remapping memory mapped file failed\n"));
766 fs_stateTruncateFile(struct fs_dump_state * state)
770 #ifdef AFS_LARGEFILE_ENV
771 if (afs_ftruncate(state->fd, state->eof_offset) != 0) {
776 SplitInt64(state->eof_offset, hi, lo);
777 if (afs_ftruncate(state->fd, lo) != 0) {
786 #ifdef FS_STATE_USE_MMAP
788 fs_stateMapFile(struct fs_dump_state * state)
792 switch(state->mode) {
793 case FS_STATE_LOAD_MODE:
794 flags = PROT_READ | PROT_WRITE; /* loading involves a header invalidation */
796 case FS_STATE_DUMP_MODE:
800 ViceLog(0, ("fs_stateMapFile: invalid dump state mode\n"));
804 state->mmap.map = afs_mmap(NULL,
811 if (state->mmap.map == MAP_FAILED) {
812 state->mmap.size = 0;
813 state->mmap.map = NULL;
814 ViceLog(0, ("fs_stateMapFile: failed to memory map file '%s'\n",
820 state->mmap.size = state->file_len;
821 state->mmap.cursor = state->mmap.map;
822 state->mmap.offset = 0;
824 /* for state loading, accesses will be sequential, so let's give
825 * the VM subsystem a heads up */
826 if (state->mode == FS_STATE_LOAD_MODE) {
827 /* XXX madvise may not exist on all platforms, so
828 * we may need to add some ifdefs at some point... */
829 flags = MADV_SEQUENTIAL | MADV_WILLNEED;
830 #ifdef AFS_SUN510_ENV
831 flags |= MADV_ACCESS_LWP; /* added in solaris 9 12/02 */
833 madvise(state->mmap.map, state->mmap.size, flags);
841 fs_stateUnmapFile(struct fs_dump_state * state)
845 if (munmap(state->mmap.map, state->mmap.size) == -1) {
846 ViceLog(0, ("fs_stateUnmapFile: failed to unmap dump file '%s'\n",
855 #endif /* FS_STATE_USE_MMAP */
857 #ifdef FS_STATE_USE_MMAP
859 fs_stateSync(struct fs_dump_state * state)
863 msync(state->mmap.map, state->mmap.size, MS_SYNC);
868 #else /* !FS_STATE_USE_MMAP */
870 fs_stateSync(struct fs_dump_state * state)
874 if (fsync(state->fd) == -1)
880 #endif /* !FS_STATE_USE_MMAP */
883 fs_stateIncEOF(struct fs_dump_state * state, afs_int32 len)
886 FillInt64(temp, 0, len);
887 AddUInt64(state->eof_offset, temp, &state->eof_offset);
891 #ifdef FS_STATE_USE_MMAP
893 fs_stateIncCursor(struct fs_dump_state * state, size_t len)
897 state->mmap.offset += len;
899 p = (char *) state->mmap.cursor;
901 state->mmap.cursor = (void *) p;
907 fs_stateCheckIOSafety(struct fs_dump_state * state, size_t len)
911 if ((state->mmap.offset + len) > state->mmap.size) {
916 #endif /* FS_STATE_USE_MMAP */
918 #ifdef FS_STATE_USE_MMAP
920 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
926 SplitInt64(*offset, hi, lo);
929 p = (char *) state->mmap.map;
935 state->mmap.cursor = (void *) p;
938 #ifdef AFS_LARGEFILE_ENV
939 state->mmap.offset = *offset;
943 state->mmap.offset = lo;
948 #else /* !FS_STATE_USE_MMAP */
950 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
953 #ifndef AFS_LARGEFILE_ENV
954 afs_uint32 high, low;
956 SplitInt64(*offset, high, low);
962 if (afs_lseek(state->fd, low, SEEK_SET) == -1)
965 if (afs_lseek(state->fd, *offset, SEEK_SET) == -1)
970 #endif /* !FS_STATE_USE_MMAP */
973 fs_stateFillHeader(struct fs_state_header * hdr)
975 hdr->stamp.magic = FS_STATE_MAGIC;
976 hdr->stamp.version = FS_STATE_VERSION;
978 hdr->sys_name = SYS_NAME_ID;
980 hdr->sys_name = 0xFFFFFFFF;
982 hdr->timestamp = FT_ApproxTime();
983 hdr->server_uuid = FS_HostUUID;
985 #ifdef WORDS_BIGENDIAN
990 #ifdef FS_STATS_DETAILED
991 hdr->stats_detailed = 1;
993 hdr->stats_detailed = 0;
995 if (strlcpy(hdr->server_version_string, cml_version_number, sizeof(hdr->server_version_string))
996 >= sizeof(hdr->server_version_string)) {
997 ViceLog(0, ("fs_stateFillHeader: WARNING -- cml_version_number field truncated\n"));
1003 fs_stateCheckHeader(struct fs_state_header * hdr)
1008 ViceLog(0, ("fs_stateCheckHeader: dump was previously flagged invalid\n"));
1011 #ifdef WORDS_BIGENDIAN
1012 else if (!hdr->endianness) {
1013 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1016 #else /* AFSLITTLE_ENDIAN */
1017 else if (hdr->endianness) {
1018 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1021 #endif /* AFSLITTLE_ENDIAN */
1023 else if (hdr->stamp.magic != FS_STATE_MAGIC) {
1024 ViceLog(0, ("fs_stateCheckHeader: invalid dump header\n"));
1027 else if (hdr->stamp.version != FS_STATE_VERSION) {
1028 ViceLog(0, ("fs_stateCheckHeader: unknown dump format version number\n"));
1032 #ifdef FS_STATS_DETAILED
1033 else if (!hdr->stats_detailed) {
1034 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1037 #else /* FS_STATS_DETAILED */
1038 else if (hdr->stats_detailed) {
1039 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1042 #endif /* FS_STATS_DETAILED */
1044 else if (!afs_uuid_equal(&hdr->server_uuid, &FS_HostUUID)) {
1045 ViceLog(0, ("fs_stateCheckHeader: server UUID does not match this server's UUID\n"));
1049 /* the cml_version_string is included for informational purposes only. If someone ever
1050 * wants to limit state dump reloading based upon the contents of this string, just
1051 * uncomment the following code. uncommenting this code is _strongly discouraged_ because
1052 * we already make use of the version stamps in the various dump headers to deal with
1053 * data structure version incompatabilities.
1054 else if (strncmp(hdr->server_version_string, cml_version_number,
1055 sizeof(hdr->server_version_string)) != 0) {
1056 ViceLog(0, ("fs_stateCheckHeader: dump from different server version\n"));
1061 else if (strncmp(hdr->server_version_string, cml_version_number,
1062 sizeof(hdr->server_version_string)) != 0) {
1063 ViceLog(0, ("fs_stateCheckHeader: dump from different server version ; attempting state reload anyway\n"));
1071 fs_stateAlloc(struct fs_dump_state * state)
1074 memset(state, 0, sizeof(struct fs_dump_state));
1076 state->fn = AFSDIR_SERVER_FSSTATE_FILEPATH;
1077 state->hdr = (struct fs_state_header *)malloc(sizeof(struct fs_state_header));
1078 state->h_hdr = (struct host_state_header *)malloc(sizeof(struct host_state_header));
1079 state->cb_hdr = (struct callback_state_header *)malloc(sizeof(struct callback_state_header));
1080 state->cb_timeout_hdr = (struct callback_state_timeout_header *)
1081 malloc(sizeof(struct callback_state_timeout_header));
1082 state->cb_fehash_hdr = (struct callback_state_fehash_header *)
1083 malloc(sizeof(struct callback_state_fehash_header));
1084 if ((state->hdr == NULL) || (state->h_hdr == NULL) || (state->cb_hdr == NULL) ||
1085 (state->cb_timeout_hdr == NULL) || (state->cb_fehash_hdr == NULL))
1091 fs_stateFree(struct fs_dump_state * state)
1098 free(state->cb_hdr);
1099 if (state->cb_timeout_hdr)
1100 free(state->cb_timeout_hdr);
1101 if (state->cb_fehash_hdr)
1102 free(state->cb_fehash_hdr);
1103 if (state->h_map.entries)
1104 free(state->h_map.entries);
1105 if (state->fe_map.entries)
1106 free(state->fe_map.entries);
1107 if (state->cb_map.entries)
1108 free(state->cb_map.entries);
1112 #endif /* AFS_DEMAND_ATTACH_FS */