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>
22 #include <stdlib.h> /* for malloc() */
23 #include <time.h> /* ANSI standard location for time stuff */
38 #include <afs/assert.h>
46 #include <afs/afsint.h>
47 #include <afs/rxgen_consts.h>
49 #include <afs/errors.h>
50 #include <afs/ihandle.h>
51 #include <afs/vnode.h>
52 #include <afs/volume.h>
54 #include <afs/ptclient.h>
55 #include <afs/prs_fs.h>
56 #include <afs/afsutil.h>
58 #include <afs/cellconfig.h>
61 #include "../viced/viced_prototypes.h"
62 #include "../viced/viced.h"
63 #include "../viced/host.h"
64 #include "../viced/callback.h"
65 #include "serialize_state.h"
67 /*@+fcnmacros +macrofcndecl@*/
70 extern off64_t afs_lseek(int FD, off64_t O, int F);
71 #endif /*S_SPLINT_S */
72 #define afs_lseek(FD, O, F) lseek64(FD, (off64_t)(O), F)
73 #define afs_stat stat64
74 #define afs_fstat fstat64
75 #define afs_open open64
76 #define afs_fopen fopen64
77 #define afs_ftruncate ftruncate64
78 #define afs_mmap mmap64
80 extern void * mmap64(); /* ugly hack since aix build env appears to be somewhat broken */
82 #else /* !O_LARGEFILE */
84 extern off_t afs_lseek(int FD, off_t O, int F);
85 #endif /*S_SPLINT_S */
86 #define afs_lseek(FD, O, F) lseek(FD, (off_t)(O), F)
88 #define afs_fstat fstat
90 #define afs_fopen fopen
91 #define afs_ftruncate ftruncate
93 #endif /* !O_LARGEFILE */
94 /*@=fcnmacros =macrofcndecl@*/
97 #ifdef AFS_DEMAND_ATTACH_FS
101 * state dump routines
103 * in order to make state dump/restore as fast as possible,
104 * we use memory mapped files
106 * if this causes problems on certain platforms, the APIs
107 * have been written so that it will be very simple to go
108 * back to standard I/O for just those poorly written platforms
111 #define FS_STATE_USE_MMAP
114 #ifdef FS_STATE_USE_MMAP
115 #define FS_STATE_INIT_FILESIZE (8 * 1024 * 1024) /* truncate to 8MB initially */
116 #include <sys/mman.h>
119 static int fs_stateCreateDump(struct fs_dump_state * state);
120 static int fs_stateLoadDump(struct fs_dump_state * state);
121 static int fs_stateInvalidateDump(struct fs_dump_state * state);
122 static int fs_stateCommitDump(struct fs_dump_state * state);
123 static int fs_stateCloseDump(struct fs_dump_state * state);
125 #ifdef FS_STATE_USE_MMAP
126 static int fs_stateSizeFile(struct fs_dump_state * state);
127 static int fs_stateResizeFile(struct fs_dump_state * state, size_t min_add);
128 static int fs_stateTruncateFile(struct fs_dump_state * state);
130 static int fs_stateMapFile(struct fs_dump_state * state);
131 static int fs_stateUnmapFile(struct fs_dump_state * state);
133 static int fs_stateIncCursor(struct fs_dump_state * state, size_t len);
134 static int fs_stateCheckIOSafety(struct fs_dump_state * state,
138 static int fs_stateFillHeader(struct fs_state_header * hdr);
139 static int fs_stateCheckHeader(struct fs_state_header * hdr);
141 static int fs_stateAlloc(struct fs_dump_state * state);
142 static int fs_stateFree(struct fs_dump_state * state);
144 extern afsUUID FS_HostUUID;
145 extern char cml_version_number[];
149 * save all fileserver state
154 int ret = 0, verified = 1;
155 struct fs_dump_state state;
157 /* save and restore need to be atomic wrt other host package operations */
160 ViceLog(0, ("fs_stateSave: commencing fileserver state dump\n"));
162 if (fs_stateAlloc(&state)) {
163 ViceLog(0, ("fs_stateSave: memory allocation failed; dump aborted\n"));
169 * on busy servers, these checks will inevitably fail since stuff drops H_LOCK
170 * all over the place (with structs left in inconsistent states) while RPCs to
171 * clients happen (grumble, grumble, the host package needs to be rewritten...)
173 * the current hack is to force the background threads that deal with host and
174 * callback state offline early in the shutdown process, do VShutdown, come
175 * back and wait for those threads to die, THEN do the state dump
177 * BUT, this still has one flaw -- what do we do about rx worker threads that
178 * are blocked in the host package making an RPC call to a cm???
180 * perhaps we need a refcounter that keeps track of threads blocked in rpc calls
181 * with H_LOCK dropped (and the host struct likely left in an inconsistent state)
183 * or better yet, we need to associate a state machine with each host object
184 * (kind of like demand attach Volume structures).
186 * sigh. I suspect we'll need to revisit this issue
189 if (fs_state.options.fs_state_verify_before_save) {
190 ViceLog(0, ("fs_stateSave: performing internal consistency checks before proceeding with state dump\n"));
192 if (h_stateVerify(&state)) {
193 ViceLog(0, ("fs_stateSave: error: host table consistency checks failed; state dump will not be marked clean\n"));
198 if (cb_stateVerify(&state)) {
199 ViceLog(0, ("fs_stateSave: error: callback table consistency checks failed; state dump will not be marked clean\n"));
204 /* if a consistency check asserted the bail flag, reset it */
207 ViceLog(0, ("fs_stateSave: proceeding with dump\n"));
210 if (fs_stateCreateDump(&state)) {
211 ViceLog(0, ("fs_stateSave: error: dump create failed\n"));
216 if (h_stateSave(&state)) {
217 ViceLog(0, ("fs_stateSave: error: host state dump failed\n"));
222 if (cb_stateSave(&state)) {
223 ViceLog(0, ("fs_stateSave: error: callback state dump failed\n"));
232 if (fs_stateCommitDump(&state)) {
233 ViceLog(0, ("fs_stateSave: error: dump commit failed\n"));
239 ViceLog(0, ("fs_stateSave: fileserver state dump completed successfully\n"));
241 ViceLog(0, ("fs_stateSave: fileserver state dump completed, but not marked clean.\n"));
242 ViceLog(0, ("fs_stateSave: please save a copy of '%s' for use by technical support\n",
248 fs_stateCloseDump(&state);
249 fs_stateFree(&state);
256 * restore all fileserver state
258 * this function must appear as one atomic operation to the host and callback
259 * packages, hence H_LOCK is held for the entirety of the process.
262 fs_stateRestore(void)
265 struct fs_dump_state state;
267 /* save and restore need to be atomic wrt other host package operations */
270 ViceLog(0, ("fs_stateRestore: commencing fileserver state restore\n"));
272 if (fs_stateAlloc(&state)) {
273 ViceLog(0, ("fs_stateRestore: memory allocation failed\n"));
278 if (fs_stateLoadDump(&state)) {
279 ViceLog(0, ("fs_stateRestore: failed to load dump file '%s'\n", state.fn));
284 if (fs_stateInvalidateDump(&state)) {
285 ViceLog(0, ("fs_stateRestore: failed to invalidate dump file '%s'\n", state.fn));
291 if (state.flags.do_host_restore) {
292 if (h_stateRestore(&state)) {
293 ViceLog(0, ("fs_stateRestore: error: host state restore failed. exiting avoid further corruption\n"));
296 ViceLog(0, ("fs_stateRestore: host table restored\n"));
298 if (cb_stateRestore(&state)) {
299 ViceLog(0, ("fs_stateRestore: error: callback state restore failed. exiting to avoid further corruption\n"));
302 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack tables restored\n"));
304 if (h_stateRestoreIndices(&state)) {
305 ViceLog(0, ("fs_stateRestore: error: host index remapping failed. exiting to avoid further corruption\n"));
308 ViceLog(0, ("fs_stateRestore: host table indices remapped\n"));
310 if (cb_stateRestoreIndices(&state)) {
311 ViceLog(0, ("fs_stateRestore: error: callback index remapping failed. exiting to avoid further corruption\n"));
314 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack indices remapped\n"));
317 ViceLog(0, ("fs_stateRestore: restore phase complete\n"));
319 if (fs_state.options.fs_state_verify_after_restore) {
320 ViceLog(0, ("fs_stateRestore: beginning state verification phase\n"));
322 if (state.flags.do_host_restore) {
323 if (h_stateVerify(&state)) {
324 ViceLog(0, ("fs_stateRestore: error: host table consistency checks failed; exiting to avoid further corruption\n"));
328 if (cb_stateVerify(&state)) {
329 ViceLog(0, ("fs_stateRestore: error: callback table consistency checks failed; exiting to avoid further corruption\n"));
334 ViceLog(0, ("fs_stateRestore: fileserver state verification complete\n"));
337 ViceLog(0, ("fs_stateRestore: restore was successful\n"));
341 fs_stateInvalidateDump(&state);
342 fs_stateCloseDump(&state);
344 fs_stateFree(&state);
350 fs_stateCreateDump(struct fs_dump_state * state)
353 char savedump[MAXPATHLEN];
354 struct afs_stat status;
356 afs_snprintf(savedump, sizeof(savedump), "%s.old", state->fn);
358 if (afs_stat(state->fn, &status) == 0) {
359 renamefile(state->fn, savedump);
362 if (((fd = afs_open(state->fn,
363 O_RDWR | O_CREAT | O_TRUNC,
364 S_IRUSR | S_IWUSR)) == -1) ||
365 (afs_fstat(fd, &status) == -1)) {
366 ViceLog(0, ("fs_stateCreateDump: failed to create state dump file '%s'\n",
373 state->mode = FS_STATE_DUMP_MODE;
374 memset(state->hdr, 0, sizeof(struct fs_state_header));
375 fs_stateIncEOF(state, sizeof(struct fs_state_header));
377 #ifdef FS_STATE_USE_MMAP
378 if (fs_stateSizeFile(state)) {
379 ViceLog(0, ("fs_stateCreateDump: failed to resize state dump file '%s'\n",
385 if (fs_stateMapFile(state)) {
386 ViceLog(0, ("fs_stateCreateDump: failed to memory map state dump file '%s'\n",
393 ret = fs_stateInvalidateDump(state);
400 fs_stateInvalidateDump(struct fs_dump_state * state)
404 struct fs_state_header hdr;
406 #ifdef FS_STATE_USE_MMAP
407 if (state->mmap.map == NULL) {
412 memcpy(&hdr, state->hdr, sizeof(hdr));
416 /* write a bogus header to flag dump in progress */
417 if (fs_stateWriteHeader(state, &z, &hdr, sizeof(hdr))) {
418 ViceLog(0, ("fs_stateInvalidateDump: failed to invalidate old dump file header '%s'\n",
423 if (fs_stateSync(state)) {
424 ViceLog(0, ("fs_stateInvalidateDump: failed to sync changes to disk\n"));
434 fs_stateCommitDump(struct fs_dump_state * state)
441 #ifdef FS_STATE_USE_MMAP
442 if (fs_stateTruncateFile(state)) {
443 ViceLog(0, ("fs_stateCommitDump: failed to truncate dump file to proper size\n"));
449 /* ensure that all pending data I/Os for the state file have been committed
450 * _before_ we make the metadata I/Os */
451 if (fs_stateSync(state)) {
452 ViceLog(0, ("fs_stateCommitDump: failed to sync changes to disk\n"));
457 #ifdef FS_STATE_USE_MMAP
458 /* XXX madvise may not exist on all platforms, so
459 * we may need to add some ifdefs at some point... */
461 madvise((((char *)state->mmap.map) + sizeof(struct fs_state_header)),
462 state->mmap.size - sizeof(struct fs_state_header),
467 /* build the header, and write it to disk */
468 fs_stateFillHeader(state->hdr);
470 state->hdr->valid = 0;
472 if (fs_stateWriteHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
473 ViceLog(0, ("fs_stateCommitDump: failed to write header to dump file '%s'\n",
478 if (fs_stateSync(state)) {
479 ViceLog(0, ("fs_stateCommitDump: failed to sync new header to disk\n"));
489 fs_stateLoadDump(struct fs_dump_state * state)
493 struct afs_stat status;
494 afs_int32 now = FT_ApproxTime();
498 if ((fd = afs_open(state->fn, O_RDWR)) == -1 ||
499 (afs_fstat(fd, &status) == -1)) {
500 ViceLog(0, ("fs_stateLoadDump: failed to load state dump file '%s'\n",
506 state->mode = FS_STATE_LOAD_MODE;
507 state->file_len = status.st_size;
509 #ifdef FS_STATE_USE_MMAP
510 if (fs_stateMapFile(state)) {
511 ViceLog(0, ("fs_stateLoadDump: failed to memory map state dump file '%s'\n",
518 if (fs_stateReadHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
519 ViceLog(0, ("fs_stateLoadDump: failed to read header from dump file '%s'\n",
525 /* check the validity of the header */
526 if (fs_stateCheckHeader(state->hdr)) {
527 ViceLog(1, ("fs_stateLoadDump: header failed validity checks; not restoring '%s'\n",
533 if ((state->hdr->timestamp + HOST_STATE_VALID_WINDOW) >= now) {
534 state->flags.do_host_restore = 1;
536 ViceLog(0, ("fs_stateLoadDump: warning: dump is too old for host and callback restore; skipping those steps\n"));
544 fs_stateCloseDump(struct fs_dump_state * state)
546 #ifdef FS_STATE_USE_MMAP
547 fs_stateUnmapFile(state);
554 fs_stateWrite(struct fs_dump_state * state,
555 void * buf, size_t len)
559 #ifdef FS_STATE_USE_MMAP
560 if (fs_stateCheckIOSafety(state, len)) {
561 if (fs_stateResizeFile(state, len)) {
562 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
569 memcpy(state->mmap.cursor, buf, len);
570 fs_stateIncCursor(state, len);
572 if (write(state->fd, buf, len) != len) {
573 ViceLog(0, ("fs_stateWrite: write failed\n"));
584 fs_stateRead(struct fs_dump_state * state,
585 void * buf, size_t len)
589 #ifdef FS_STATE_USE_MMAP
590 if (fs_stateCheckIOSafety(state, len)) {
591 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
597 memcpy(buf, state->mmap.cursor, len);
598 fs_stateIncCursor(state, len);
600 if (read(state->fd, buf, len) != len) {
601 ViceLog(0, ("fs_stateRead: read failed\n"));
612 fs_stateWriteV(struct fs_dump_state * state,
613 struct iovec * iov, int niov)
618 for (i=0; i < niov; i++) {
619 len += iov[i].iov_len;
622 #ifdef FS_STATE_USE_MMAP
623 if (fs_stateCheckIOSafety(state, len)) {
624 if (fs_stateResizeFile(state, len)) {
625 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
632 for (i=0; i < niov; i++) {
633 memcpy(state->mmap.cursor, iov[i].iov_base, iov[i].iov_len);
634 fs_stateIncCursor(state, iov[i].iov_len);
637 if (writev(state->fd, iov, niov) != len) {
638 ViceLog(0, ("fs_stateWriteV: write failed\n"));
649 fs_stateReadV(struct fs_dump_state * state,
650 struct iovec * iov, int niov)
655 for (i=0; i < niov; i++) {
656 len += iov[i].iov_len;
659 #ifdef FS_STATE_USE_MMAP
660 if (fs_stateCheckIOSafety(state, len)) {
661 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
667 for (i=0; i < niov; i++) {
668 memcpy(iov[i].iov_base, state->mmap.cursor, iov[i].iov_len);
669 fs_stateIncCursor(state, iov[i].iov_len);
672 if (readv(state->fd, iov, niov) != len) {
673 ViceLog(0, ("fs_stateReadV: read failed\n"));
684 fs_stateWriteHeader(struct fs_dump_state * state,
686 void * hdr, size_t len)
690 if (fs_stateSeek(state, offset)) {
691 ViceLog(0, ("fs_stateWriteHeader: could not seek to correct position in dump file '%s'\n",
697 if (fs_stateWrite(state, hdr, len)) {
698 ViceLog(0, ("fs_stateWriteHeader: write failed\n"));
708 fs_stateReadHeader(struct fs_dump_state * state,
710 void * hdr, size_t len)
714 if (fs_stateSeek(state, offset)) {
715 ViceLog(0, ("fs_stateReadHeader: could not seek to correct position in dump file '%s'\n",
721 if (fs_stateRead(state, hdr,len)) {
722 ViceLog(0, ("fs_stateReadHeader: read failed\n"));
731 #ifdef FS_STATE_USE_MMAP
733 fs_stateSizeFile(struct fs_dump_state * state)
736 state->file_len = FS_STATE_INIT_FILESIZE;
737 if (afs_ftruncate(state->fd, state->file_len) != 0)
743 fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
748 #ifdef FS_STATE_USE_MMAP
749 fs_stateUnmapFile(state);
752 inc = ((min_add / FS_STATE_INIT_FILESIZE)+1) * FS_STATE_INIT_FILESIZE;
753 state->file_len += inc;
755 if (afs_ftruncate(state->fd, state->file_len) != 0) {
756 ViceLog(0, ("fs_stateResizeFile: truncate failed\n"));
761 #ifdef FS_STATE_USE_MMAP
762 if (fs_stateMapFile(state)) {
763 ViceLog(0, ("fs_stateResizeFile: remapping memory mapped file failed\n"));
774 fs_stateTruncateFile(struct fs_dump_state * state)
778 #ifdef AFS_LARGEFILE_ENV
779 if (afs_ftruncate(state->fd, state->eof_offset) != 0) {
784 SplitInt64(state->eof_offset, hi, lo);
785 if (afs_ftruncate(state->fd, lo) != 0) {
794 #ifdef FS_STATE_USE_MMAP
796 fs_stateMapFile(struct fs_dump_state * state)
800 switch(state->mode) {
801 case FS_STATE_LOAD_MODE:
802 flags = PROT_READ | PROT_WRITE; /* loading involves a header invalidation */
804 case FS_STATE_DUMP_MODE:
808 ViceLog(0, ("fs_stateMapFile: invalid dump state mode\n"));
812 state->mmap.map = afs_mmap(NULL,
819 if (state->mmap.map == MAP_FAILED) {
820 state->mmap.size = 0;
821 state->mmap.map = NULL;
822 ViceLog(0, ("fs_stateMapFile: failed to memory map file '%s'\n",
828 state->mmap.size = state->file_len;
829 state->mmap.cursor = state->mmap.map;
830 state->mmap.offset = 0;
832 /* for state loading, accesses will be sequential, so let's give
833 * the VM subsystem a heads up */
834 if (state->mode == FS_STATE_LOAD_MODE) {
835 /* XXX madvise may not exist on all platforms, so
836 * we may need to add some ifdefs at some point... */
837 flags = MADV_SEQUENTIAL | MADV_WILLNEED;
838 #ifdef AFS_SUN510_ENV
839 flags |= MADV_ACCESS_LWP; /* added in solaris 9 12/02 */
841 madvise(state->mmap.map, state->mmap.size, flags);
849 fs_stateUnmapFile(struct fs_dump_state * state)
853 if (munmap(state->mmap.map, state->mmap.size) == -1) {
854 ViceLog(0, ("fs_stateUnmapFile: failed to unmap dump file '%s'\n",
863 #endif /* FS_STATE_USE_MMAP */
865 #ifdef FS_STATE_USE_MMAP
867 fs_stateSync(struct fs_dump_state * state)
871 msync(state->mmap.map, state->mmap.size, MS_SYNC);
876 #else /* !FS_STATE_USE_MMAP */
878 fs_stateSync(struct fs_dump_state * state)
882 if (fsync(state->fd) == -1)
888 #endif /* !FS_STATE_USE_MMAP */
891 fs_stateIncEOF(struct fs_dump_state * state, afs_int32 len)
894 FillInt64(temp, 0, len);
895 AddUInt64(state->eof_offset, temp, &state->eof_offset);
899 #ifdef FS_STATE_USE_MMAP
901 fs_stateIncCursor(struct fs_dump_state * state, size_t len)
905 state->mmap.offset += len;
907 p = (char *) state->mmap.cursor;
909 state->mmap.cursor = (void *) p;
915 fs_stateCheckIOSafety(struct fs_dump_state * state, size_t len)
919 if ((state->mmap.offset + len) > state->mmap.size) {
924 #endif /* FS_STATE_USE_MMAP */
926 #ifdef FS_STATE_USE_MMAP
928 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
934 SplitInt64(*offset, hi, lo);
937 p = (char *) state->mmap.map;
943 state->mmap.cursor = (void *) p;
946 #ifdef AFS_LARGEFILE_ENV
947 state->mmap.offset = *offset;
951 state->mmap.offset = lo;
956 #else /* !FS_STATE_USE_MMAP */
958 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
961 #ifndef AFS_LARGEFILE_ENV
962 afs_uint32 high, low;
964 SplitInt64(*offset, high, low);
970 if (afs_lseek(state->fd, low, SEEK_SET) == -1)
973 if (afs_lseek(state->fd, *offset, SEEK_SET) == -1)
978 #endif /* !FS_STATE_USE_MMAP */
981 fs_stateFillHeader(struct fs_state_header * hdr)
983 hdr->stamp.magic = FS_STATE_MAGIC;
984 hdr->stamp.version = FS_STATE_VERSION;
986 hdr->sys_name = SYS_NAME_ID;
988 hdr->sys_name = 0xFFFFFFFF;
990 hdr->timestamp = FT_ApproxTime();
991 hdr->server_uuid = FS_HostUUID;
993 #ifdef WORDS_BIGENDIAN
998 #ifdef FS_STATS_DETAILED
999 hdr->stats_detailed = 1;
1001 hdr->stats_detailed = 0;
1003 if (strlcpy(hdr->server_version_string, cml_version_number, sizeof(hdr->server_version_string))
1004 >= sizeof(hdr->server_version_string)) {
1005 ViceLog(0, ("fs_stateFillHeader: WARNING -- cml_version_number field truncated\n"));
1011 fs_stateCheckHeader(struct fs_state_header * hdr)
1016 ViceLog(0, ("fs_stateCheckHeader: dump was previously flagged invalid\n"));
1019 #ifdef WORDS_BIGENDIAN
1020 else if (!hdr->endianness) {
1021 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1024 #else /* AFSLITTLE_ENDIAN */
1025 else if (hdr->endianness) {
1026 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1029 #endif /* AFSLITTLE_ENDIAN */
1031 else if (hdr->stamp.magic != FS_STATE_MAGIC) {
1032 ViceLog(0, ("fs_stateCheckHeader: invalid dump header\n"));
1035 else if (hdr->stamp.version != FS_STATE_VERSION) {
1036 ViceLog(0, ("fs_stateCheckHeader: unknown dump format version number\n"));
1040 #ifdef FS_STATS_DETAILED
1041 else if (!hdr->stats_detailed) {
1042 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1045 #else /* FS_STATS_DETAILED */
1046 else if (hdr->stats_detailed) {
1047 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1050 #endif /* FS_STATS_DETAILED */
1052 else if (!afs_uuid_equal(&hdr->server_uuid, &FS_HostUUID)) {
1053 ViceLog(0, ("fs_stateCheckHeader: server UUID does not match this server's UUID\n"));
1057 /* the cml_version_string is included for informational purposes only. If someone ever
1058 * wants to limit state dump reloading based upon the contents of this string, just
1059 * uncomment the following code. uncommenting this code is _strongly discouraged_ because
1060 * we already make use of the version stamps in the various dump headers to deal with
1061 * data structure version incompatabilities.
1062 else if (strncmp(hdr->server_version_string, cml_version_number,
1063 sizeof(hdr->server_version_string)) != 0) {
1064 ViceLog(0, ("fs_stateCheckHeader: dump from different server version\n"));
1069 else if (strncmp(hdr->server_version_string, cml_version_number,
1070 sizeof(hdr->server_version_string)) != 0) {
1071 ViceLog(0, ("fs_stateCheckHeader: dump from different server version ; attempting state reload anyway\n"));
1079 fs_stateAlloc(struct fs_dump_state * state)
1082 memset(state, 0, sizeof(struct fs_dump_state));
1084 state->fn = AFSDIR_SERVER_FSSTATE_FILEPATH;
1085 state->hdr = (struct fs_state_header *)malloc(sizeof(struct fs_state_header));
1086 state->h_hdr = (struct host_state_header *)malloc(sizeof(struct host_state_header));
1087 state->cb_hdr = (struct callback_state_header *)malloc(sizeof(struct callback_state_header));
1088 state->cb_timeout_hdr = (struct callback_state_timeout_header *)
1089 malloc(sizeof(struct callback_state_timeout_header));
1090 state->cb_fehash_hdr = (struct callback_state_fehash_header *)
1091 malloc(sizeof(struct callback_state_fehash_header));
1092 if ((state->hdr == NULL) || (state->h_hdr == NULL) || (state->cb_hdr == NULL) ||
1093 (state->cb_timeout_hdr == NULL) || (state->cb_fehash_hdr == NULL))
1099 fs_stateFree(struct fs_dump_state * state)
1106 free(state->cb_hdr);
1107 if (state->cb_timeout_hdr)
1108 free(state->cb_timeout_hdr);
1109 if (state->cb_fehash_hdr)
1110 free(state->cb_fehash_hdr);
1111 if (state->h_map.entries)
1112 free(state->h_map.entries);
1113 if (state->fe_map.entries)
1114 free(state->fe_map.entries);
1115 if (state->cb_map.entries)
1116 free(state->cb_map.entries);
1120 #endif /* AFS_DEMAND_ATTACH_FS */