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>
21 #include <stdlib.h> /* for malloc() */
22 #include <time.h> /* ANSI standard location for time stuff */
31 #include <afs/afs_assert.h>
39 #include <afs/afsint.h>
40 #include <afs/rxgen_consts.h>
42 #include <afs/errors.h>
43 #include <afs/ihandle.h>
44 #include <afs/vnode.h>
45 #include <afs/volume.h>
47 #include <afs/ptclient.h>
48 #include <afs/prs_fs.h>
49 #include <afs/afsutil.h>
51 #include <afs/cellconfig.h>
54 #include "../viced/viced_prototypes.h"
55 #include "../viced/viced.h"
56 #include "../viced/host.h"
57 #include "../viced/callback.h"
58 #include "serialize_state.h"
60 /*@+fcnmacros +macrofcndecl@*/
63 extern off64_t afs_lseek(int FD, off64_t O, int F);
64 #endif /*S_SPLINT_S */
65 #define afs_lseek(FD, O, F) lseek64(FD, (off64_t)(O), F)
66 #define afs_stat stat64
67 #define afs_fstat fstat64
68 #define afs_open open64
69 #define afs_fopen fopen64
70 #define afs_ftruncate ftruncate64
71 #define afs_mmap mmap64
73 extern void * mmap64(); /* ugly hack since aix build env appears to be somewhat broken */
75 #else /* !O_LARGEFILE */
77 extern off_t afs_lseek(int FD, off_t O, int F);
78 #endif /*S_SPLINT_S */
79 #define afs_lseek(FD, O, F) lseek(FD, (off_t)(O), F)
81 #define afs_fstat fstat
83 #define afs_fopen fopen
84 #define afs_ftruncate ftruncate
86 #endif /* !O_LARGEFILE */
87 /*@=fcnmacros =macrofcndecl@*/
90 #ifdef AFS_DEMAND_ATTACH_FS
96 * in order to make state dump/restore as fast as possible,
97 * we use memory mapped files
99 * if this causes problems on certain platforms, the APIs
100 * have been written so that it will be very simple to go
101 * back to standard I/O for just those poorly written platforms
104 #define FS_STATE_USE_MMAP 1
107 #ifdef FS_STATE_USE_MMAP
108 #define FS_STATE_INIT_FILESIZE (8 * 1024 * 1024) /* truncate to 8MB initially */
110 #include <sys/mman.h>
114 static int fs_stateCreateDump(struct fs_dump_state * state);
115 static int fs_stateLoadDump(struct fs_dump_state * state);
116 static int fs_stateInvalidateDump(struct fs_dump_state * state);
117 static int fs_stateCommitDump(struct fs_dump_state * state);
118 static int fs_stateCloseDump(struct fs_dump_state * state);
120 #ifdef FS_STATE_USE_MMAP
121 static int fs_stateSizeFile(struct fs_dump_state * state);
122 static int fs_stateResizeFile(struct fs_dump_state * state, size_t min_add);
123 static int fs_stateTruncateFile(struct fs_dump_state * state);
125 static int fs_stateMapFile(struct fs_dump_state * state);
126 static int fs_stateUnmapFile(struct fs_dump_state * state);
128 static int fs_stateIncCursor(struct fs_dump_state * state, size_t len);
129 static int fs_stateCheckIOSafety(struct fs_dump_state * state,
133 static int fs_stateFillHeader(struct fs_state_header * hdr);
134 static int fs_stateCheckHeader(struct fs_state_header * hdr);
136 static int fs_stateAlloc(struct fs_dump_state * state);
137 static int fs_stateFree(struct fs_dump_state * state);
139 extern afsUUID FS_HostUUID;
140 extern char cml_version_number[];
143 fs_stateFileOpen(struct fs_dump_state *state)
146 return(state->fd != -1);
148 return(state->fd >= 0);
155 * save all fileserver state
160 int ret = 0, verified = 1;
161 struct fs_dump_state state;
163 /* save and restore need to be atomic wrt other host package operations */
166 ViceLog(0, ("fs_stateSave: commencing fileserver state dump\n"));
168 if (fs_stateAlloc(&state)) {
169 ViceLog(0, ("fs_stateSave: memory allocation failed; dump aborted\n"));
175 * on busy servers, these checks will inevitably fail since stuff drops H_LOCK
176 * all over the place (with structs left in inconsistent states) while RPCs to
177 * clients happen (grumble, grumble, the host package needs to be rewritten...)
179 * the current hack is to force the background threads that deal with host and
180 * callback state offline early in the shutdown process, do VShutdown, come
181 * back and wait for those threads to die, THEN do the state dump
183 * BUT, this still has one flaw -- what do we do about rx worker threads that
184 * are blocked in the host package making an RPC call to a cm???
186 * perhaps we need a refcounter that keeps track of threads blocked in rpc calls
187 * with H_LOCK dropped (and the host struct likely left in an inconsistent state)
189 * or better yet, we need to associate a state machine with each host object
190 * (kind of like demand attach Volume structures).
192 * sigh. I suspect we'll need to revisit this issue
195 if (fs_state.options.fs_state_verify_before_save) {
196 ViceLog(0, ("fs_stateSave: performing internal consistency checks before proceeding with state dump\n"));
198 if (h_stateVerify(&state)) {
199 ViceLog(0, ("fs_stateSave: error: host table consistency checks failed; state dump will not be marked clean\n"));
204 if (cb_stateVerify(&state)) {
205 ViceLog(0, ("fs_stateSave: error: callback table consistency checks failed; state dump will not be marked clean\n"));
210 /* if a consistency check asserted the bail flag, reset it */
213 ViceLog(0, ("fs_stateSave: proceeding with dump\n"));
216 if (fs_stateCreateDump(&state)) {
217 ViceLog(0, ("fs_stateSave: error: dump create failed\n"));
222 if (h_stateSave(&state)) {
223 ViceLog(0, ("fs_stateSave: error: host state dump failed\n"));
228 if (cb_stateSave(&state)) {
229 ViceLog(0, ("fs_stateSave: error: callback state dump failed\n"));
238 if (fs_stateCommitDump(&state)) {
239 ViceLog(0, ("fs_stateSave: error: dump commit failed\n"));
245 ViceLog(0, ("fs_stateSave: fileserver state dump completed successfully\n"));
247 ViceLog(0, ("fs_stateSave: fileserver state dump completed, but not marked clean.\n"));
248 ViceLog(0, ("fs_stateSave: please save a copy of '%s' for use by technical support\n",
253 if (fs_stateFileOpen(&state))
254 fs_stateCloseDump(&state);
255 fs_stateFree(&state);
262 * restore all fileserver state
264 * this function must appear as one atomic operation to the host and callback
265 * packages, hence H_LOCK is held for the entirety of the process.
268 fs_stateRestore(void)
271 struct fs_dump_state state;
273 /* save and restore need to be atomic wrt other host package operations */
276 ViceLog(0, ("fs_stateRestore: commencing fileserver state restore\n"));
278 if (fs_stateAlloc(&state)) {
279 ViceLog(0, ("fs_stateRestore: memory allocation failed\n"));
284 if (fs_stateLoadDump(&state)) {
285 ViceLog(0, ("fs_stateRestore: failed to load dump file '%s'\n", state.fn));
290 if (fs_stateInvalidateDump(&state)) {
291 ViceLog(0, ("fs_stateRestore: failed to invalidate dump file '%s'\n", state.fn));
297 if (state.flags.do_host_restore) {
298 if (h_stateRestore(&state)) {
299 ViceLog(0, ("fs_stateRestore: error: host state restore failed. exiting avoid further corruption\n"));
302 ViceLog(0, ("fs_stateRestore: host table restored\n"));
304 if (cb_stateRestore(&state)) {
305 ViceLog(0, ("fs_stateRestore: error: callback state restore failed. exiting to avoid further corruption\n"));
308 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack tables restored\n"));
310 if (h_stateRestoreIndices(&state)) {
311 ViceLog(0, ("fs_stateRestore: error: host index remapping failed. exiting to avoid further corruption\n"));
314 ViceLog(0, ("fs_stateRestore: host table indices remapped\n"));
316 if (cb_stateRestoreIndices(&state)) {
317 ViceLog(0, ("fs_stateRestore: error: callback index remapping failed. exiting to avoid further corruption\n"));
320 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack indices remapped\n"));
323 ViceLog(0, ("fs_stateRestore: restore phase complete\n"));
325 if (fs_state.options.fs_state_verify_after_restore) {
326 ViceLog(0, ("fs_stateRestore: beginning state verification phase\n"));
328 if (state.flags.do_host_restore) {
329 if (h_stateVerify(&state)) {
330 ViceLog(0, ("fs_stateRestore: error: host table consistency checks failed; exiting to avoid further corruption\n"));
334 if (cb_stateVerify(&state)) {
335 ViceLog(0, ("fs_stateRestore: error: callback table consistency checks failed; exiting to avoid further corruption\n"));
340 ViceLog(0, ("fs_stateRestore: fileserver state verification complete\n"));
343 ViceLog(0, ("fs_stateRestore: restore was successful\n"));
347 fs_stateInvalidateDump(&state);
348 fs_stateCloseDump(&state);
350 fs_stateFree(&state);
356 fs_stateCreateDump(struct fs_dump_state * state)
359 char savedump[MAXPATHLEN];
360 struct afs_stat status;
362 afs_snprintf(savedump, sizeof(savedump), "%s.old", state->fn);
364 if (afs_stat(state->fn, &status) == 0) {
365 renamefile(state->fn, savedump);
368 if (((fd = afs_open(state->fn,
369 O_RDWR | O_CREAT | O_TRUNC,
370 S_IRUSR | S_IWUSR)) == -1) ||
371 (afs_fstat(fd, &status) == -1)) {
372 ViceLog(0, ("fs_stateCreateDump: failed to create state dump file '%s'\n",
379 state->mode = FS_STATE_DUMP_MODE;
380 memset(state->hdr, 0, sizeof(struct fs_state_header));
381 fs_stateIncEOF(state, sizeof(struct fs_state_header));
383 #ifdef FS_STATE_USE_MMAP
384 if (fs_stateSizeFile(state)) {
385 ViceLog(0, ("fs_stateCreateDump: failed to resize state dump file '%s'\n",
391 if (fs_stateMapFile(state)) {
392 ViceLog(0, ("fs_stateCreateDump: failed to memory map state dump file '%s'\n",
399 ret = fs_stateInvalidateDump(state);
406 fs_stateInvalidateDump(struct fs_dump_state * state)
410 struct fs_state_header hdr;
412 #ifdef FS_STATE_USE_MMAP
413 if (state->mmap.map == NULL) {
418 memcpy(&hdr, state->hdr, sizeof(hdr));
422 /* write a bogus header to flag dump in progress */
423 if (fs_stateWriteHeader(state, &z, &hdr, sizeof(hdr))) {
424 ViceLog(0, ("fs_stateInvalidateDump: failed to invalidate old dump file header '%s'\n",
429 if (fs_stateSync(state)) {
430 ViceLog(0, ("fs_stateInvalidateDump: failed to sync changes to disk\n"));
440 fs_stateCommitDump(struct fs_dump_state * state)
447 #ifdef FS_STATE_USE_MMAP
448 if (fs_stateTruncateFile(state)) {
449 ViceLog(0, ("fs_stateCommitDump: failed to truncate dump file to proper size\n"));
455 /* ensure that all pending data I/Os for the state file have been committed
456 * _before_ we make the metadata I/Os */
457 if (fs_stateSync(state)) {
458 ViceLog(0, ("fs_stateCommitDump: failed to sync changes to disk\n"));
463 #ifdef FS_STATE_USE_MMAP
464 /* XXX madvise may not exist on all platforms, so
465 * we may need to add some ifdefs at some point... */
467 madvise((((char *)state->mmap.map) + sizeof(struct fs_state_header)),
468 state->mmap.size - sizeof(struct fs_state_header),
473 /* build the header, and write it to disk */
474 fs_stateFillHeader(state->hdr);
476 state->hdr->valid = 0;
478 if (fs_stateWriteHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
479 ViceLog(0, ("fs_stateCommitDump: failed to write header to dump file '%s'\n",
484 if (fs_stateSync(state)) {
485 ViceLog(0, ("fs_stateCommitDump: failed to sync new header to disk\n"));
495 fs_stateLoadDump(struct fs_dump_state * state)
499 struct afs_stat status;
500 afs_int32 now = FT_ApproxTime();
504 if ((fd = afs_open(state->fn, O_RDWR)) == -1 ||
505 (afs_fstat(fd, &status) == -1)) {
506 ViceLog(0, ("fs_stateLoadDump: failed to load state dump file '%s'\n",
512 state->mode = FS_STATE_LOAD_MODE;
513 state->file_len = status.st_size;
515 #ifdef FS_STATE_USE_MMAP
516 if (fs_stateMapFile(state)) {
517 ViceLog(0, ("fs_stateLoadDump: failed to memory map state dump file '%s'\n",
524 if (fs_stateReadHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
525 ViceLog(0, ("fs_stateLoadDump: failed to read header from dump file '%s'\n",
531 /* check the validity of the header */
532 if (fs_stateCheckHeader(state->hdr)) {
533 ViceLog(1, ("fs_stateLoadDump: header failed validity checks; not restoring '%s'\n",
539 if ((state->hdr->timestamp + HOST_STATE_VALID_WINDOW) >= now) {
540 state->flags.do_host_restore = 1;
542 ViceLog(0, ("fs_stateLoadDump: warning: dump is too old for host and callback restore; skipping those steps\n"));
550 fs_stateCloseDump(struct fs_dump_state * state)
552 #ifdef FS_STATE_USE_MMAP
553 fs_stateUnmapFile(state);
560 fs_stateWrite(struct fs_dump_state * state,
561 void * buf, size_t len)
565 #ifdef FS_STATE_USE_MMAP
566 if (fs_stateCheckIOSafety(state, len)) {
567 if (fs_stateResizeFile(state, len)) {
568 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
575 memcpy(state->mmap.cursor, buf, len);
576 fs_stateIncCursor(state, len);
578 if (write(state->fd, buf, len) != len) {
579 ViceLog(0, ("fs_stateWrite: write failed\n"));
590 fs_stateRead(struct fs_dump_state * state,
591 void * buf, size_t len)
595 #ifdef FS_STATE_USE_MMAP
596 if (fs_stateCheckIOSafety(state, len)) {
597 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
603 memcpy(buf, state->mmap.cursor, len);
604 fs_stateIncCursor(state, len);
606 if (read(state->fd, buf, len) != len) {
607 ViceLog(0, ("fs_stateRead: read failed\n"));
618 fs_stateWriteV(struct fs_dump_state * state,
619 struct iovec * iov, int niov)
624 for (i=0; i < niov; i++) {
625 len += iov[i].iov_len;
628 #ifdef FS_STATE_USE_MMAP
629 if (fs_stateCheckIOSafety(state, len)) {
630 if (fs_stateResizeFile(state, len)) {
631 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
638 for (i=0; i < niov; i++) {
639 memcpy(state->mmap.cursor, iov[i].iov_base, iov[i].iov_len);
640 fs_stateIncCursor(state, iov[i].iov_len);
644 if (writev(state->fd, iov, niov) != len) {
645 ViceLog(0, ("fs_stateWriteV: write failed\n"));
649 #else /* AFS_NT40_ENV */
650 for (i=0; i < niov; i++) {
651 if (write(state->fd, iov[i].iov_base, iov[i].iov_len) != iov[i].iov_len) {
652 ViceLog(0, ("fs_stateWriteV: write failed\n"));
657 #endif /* AFS_NT40_ENV */
665 fs_stateReadV(struct fs_dump_state * state,
666 struct iovec * iov, int niov)
671 for (i=0; i < niov; i++) {
672 len += iov[i].iov_len;
675 #ifdef FS_STATE_USE_MMAP
676 if (fs_stateCheckIOSafety(state, len)) {
677 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
683 for (i=0; i < niov; i++) {
684 memcpy(iov[i].iov_base, state->mmap.cursor, iov[i].iov_len);
685 fs_stateIncCursor(state, iov[i].iov_len);
689 if (readv(state->fd, iov, niov) != len) {
690 ViceLog(0, ("fs_stateReadV: read failed\n"));
695 for (i=0; i < niov; i++) {
696 if (read(state->fd, iov[i].iov_base, iov[i].iov_len) != iov[i].iov_len) {
697 ViceLog(0, ("fs_stateReadV: read failed\n"));
702 #endif /* AFS_NT40_ENV */
710 fs_stateWriteHeader(struct fs_dump_state * state,
712 void * hdr, size_t len)
716 if (fs_stateSeek(state, offset)) {
717 ViceLog(0, ("fs_stateWriteHeader: could not seek to correct position in dump file '%s'\n",
723 if (fs_stateWrite(state, hdr, len)) {
724 ViceLog(0, ("fs_stateWriteHeader: write failed\n"));
734 fs_stateReadHeader(struct fs_dump_state * state,
736 void * hdr, size_t len)
740 if (fs_stateSeek(state, offset)) {
741 ViceLog(0, ("fs_stateReadHeader: could not seek to correct position in dump file '%s'\n",
747 if (fs_stateRead(state, hdr,len)) {
748 ViceLog(0, ("fs_stateReadHeader: read failed\n"));
757 #ifdef FS_STATE_USE_MMAP
759 fs_stateSizeFile(struct fs_dump_state * state)
762 state->file_len = FS_STATE_INIT_FILESIZE;
763 if (afs_ftruncate(state->fd, state->file_len) != 0)
769 fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
774 fs_stateUnmapFile(state);
776 inc = ((min_add / FS_STATE_INIT_FILESIZE)+1) * FS_STATE_INIT_FILESIZE;
777 state->file_len += inc;
779 if (afs_ftruncate(state->fd, state->file_len) != 0) {
780 ViceLog(0, ("fs_stateResizeFile: truncate failed\n"));
785 if (fs_stateMapFile(state)) {
786 ViceLog(0, ("fs_stateResizeFile: remapping memory mapped file failed\n"));
796 fs_stateTruncateFile(struct fs_dump_state * state)
800 if (afs_ftruncate(state->fd, state->eof_offset) != 0) {
808 fs_stateMapFile(struct fs_dump_state * state)
812 switch(state->mode) {
813 case FS_STATE_LOAD_MODE:
814 flags = PROT_READ | PROT_WRITE; /* loading involves a header invalidation */
816 case FS_STATE_DUMP_MODE:
820 ViceLog(0, ("fs_stateMapFile: invalid dump state mode\n"));
824 state->mmap.map = afs_mmap(NULL,
831 if (state->mmap.map == MAP_FAILED) {
832 state->mmap.size = 0;
833 state->mmap.map = NULL;
834 ViceLog(0, ("fs_stateMapFile: failed to memory map file '%s'\n",
840 state->mmap.size = state->file_len;
841 state->mmap.cursor = state->mmap.map;
842 state->mmap.offset = 0;
844 /* for state loading, accesses will be sequential, so let's give
845 * the VM subsystem a heads up */
846 if (state->mode == FS_STATE_LOAD_MODE) {
847 /* XXX madvise may not exist on all platforms, so
848 * we may need to add some ifdefs at some point... */
849 flags = MADV_SEQUENTIAL | MADV_WILLNEED;
850 #ifdef AFS_SUN510_ENV
851 flags |= MADV_ACCESS_LWP; /* added in solaris 9 12/02 */
853 madvise(state->mmap.map, state->mmap.size, flags);
861 fs_stateUnmapFile(struct fs_dump_state * state)
865 if (munmap(state->mmap.map, state->mmap.size) == -1) {
866 ViceLog(0, ("fs_stateUnmapFile: failed to unmap dump file '%s'\n",
877 fs_stateSync(struct fs_dump_state * state)
881 msync(state->mmap.map, state->mmap.size, MS_SYNC);
885 #else /* !FS_STATE_USE_MMAP */
887 fs_stateSync(struct fs_dump_state * state)
891 if (fsync(state->fd) == -1)
896 #endif /* !FS_STATE_USE_MMAP */
899 fs_stateIncEOF(struct fs_dump_state * state, afs_int32 len)
902 FillInt64(temp, 0, len);
903 AddUInt64(state->eof_offset, temp, &state->eof_offset);
907 #ifdef FS_STATE_USE_MMAP
909 fs_stateIncCursor(struct fs_dump_state * state, size_t len)
913 state->mmap.offset += len;
915 p = (char *) state->mmap.cursor;
917 state->mmap.cursor = (void *) p;
923 fs_stateCheckIOSafety(struct fs_dump_state * state, size_t len)
927 if ((state->mmap.offset + len) > state->mmap.size) {
932 #endif /* FS_STATE_USE_MMAP */
934 #ifdef FS_STATE_USE_MMAP
936 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
942 p = (char *) state->mmap.map;
944 state->mmap.cursor = (void *) p;
947 state->mmap.offset = *offset;
951 #else /* !FS_STATE_USE_MMAP */
953 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
957 if (afs_lseek(state->fd, *offset, SEEK_SET) == -1)
962 #endif /* !FS_STATE_USE_MMAP */
965 fs_stateFillHeader(struct fs_state_header * hdr)
967 hdr->stamp.magic = FS_STATE_MAGIC;
968 hdr->stamp.version = FS_STATE_VERSION;
970 hdr->sys_name = SYS_NAME_ID;
972 hdr->sys_name = 0xFFFFFFFF;
974 hdr->timestamp = FT_ApproxTime();
975 hdr->server_uuid = FS_HostUUID;
977 #ifdef WORDS_BIGENDIAN
982 #ifdef FS_STATS_DETAILED
983 hdr->stats_detailed = 1;
985 hdr->stats_detailed = 0;
987 if (strlcpy(hdr->server_version_string, cml_version_number, sizeof(hdr->server_version_string))
988 >= sizeof(hdr->server_version_string)) {
989 ViceLog(0, ("fs_stateFillHeader: WARNING -- cml_version_number field truncated\n"));
995 fs_stateCheckHeader(struct fs_state_header * hdr)
1000 ViceLog(0, ("fs_stateCheckHeader: dump was previously flagged invalid\n"));
1003 #ifdef WORDS_BIGENDIAN
1004 else if (!hdr->endianness) {
1005 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1008 #else /* AFSLITTLE_ENDIAN */
1009 else if (hdr->endianness) {
1010 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1013 #endif /* AFSLITTLE_ENDIAN */
1015 else if (hdr->stamp.magic != FS_STATE_MAGIC) {
1016 ViceLog(0, ("fs_stateCheckHeader: invalid dump header\n"));
1019 else if (hdr->stamp.version != FS_STATE_VERSION) {
1020 ViceLog(0, ("fs_stateCheckHeader: unknown dump format version number\n"));
1024 #ifdef FS_STATS_DETAILED
1025 else if (!hdr->stats_detailed) {
1026 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1029 #else /* FS_STATS_DETAILED */
1030 else if (hdr->stats_detailed) {
1031 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1034 #endif /* FS_STATS_DETAILED */
1036 else if (!afs_uuid_equal(&hdr->server_uuid, &FS_HostUUID)) {
1037 ViceLog(0, ("fs_stateCheckHeader: server UUID does not match this server's UUID\n"));
1041 /* the cml_version_string is included for informational purposes only. If someone ever
1042 * wants to limit state dump reloading based upon the contents of this string, just
1043 * uncomment the following code. uncommenting this code is _strongly discouraged_ because
1044 * we already make use of the version stamps in the various dump headers to deal with
1045 * data structure version incompatabilities.
1046 else if (strncmp(hdr->server_version_string, cml_version_number,
1047 sizeof(hdr->server_version_string)) != 0) {
1048 ViceLog(0, ("fs_stateCheckHeader: dump from different server version\n"));
1053 else if (strncmp(hdr->server_version_string, cml_version_number,
1054 sizeof(hdr->server_version_string)) != 0) {
1055 ViceLog(0, ("fs_stateCheckHeader: dump from different server version ; attempting state reload anyway\n"));
1063 fs_stateAlloc(struct fs_dump_state * state)
1066 memset(state, 0, sizeof(struct fs_dump_state));
1068 state->fn = (char *)AFSDIR_SERVER_FSSTATE_FILEPATH;
1069 state->hdr = (struct fs_state_header *)malloc(sizeof(struct fs_state_header));
1070 state->h_hdr = (struct host_state_header *)malloc(sizeof(struct host_state_header));
1071 state->cb_hdr = (struct callback_state_header *)malloc(sizeof(struct callback_state_header));
1072 state->cb_timeout_hdr = (struct callback_state_timeout_header *)
1073 malloc(sizeof(struct callback_state_timeout_header));
1074 state->cb_fehash_hdr = (struct callback_state_fehash_header *)
1075 malloc(sizeof(struct callback_state_fehash_header));
1076 if ((state->hdr == NULL) || (state->h_hdr == NULL) || (state->cb_hdr == NULL) ||
1077 (state->cb_timeout_hdr == NULL) || (state->cb_fehash_hdr == NULL))
1083 fs_stateFree(struct fs_dump_state * state)
1090 free(state->cb_hdr);
1091 if (state->cb_timeout_hdr)
1092 free(state->cb_timeout_hdr);
1093 if (state->cb_fehash_hdr)
1094 free(state->cb_fehash_hdr);
1095 if (state->h_map.entries)
1096 free(state->h_map.entries);
1097 if (state->fe_map.entries)
1098 free(state->fe_map.entries);
1099 if (state->cb_map.entries)
1100 free(state->cb_map.entries);
1104 #endif /* AFS_DEMAND_ATTACH_FS */