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 */
32 #include <afs/assert.h>
40 #include <afs/afsint.h>
41 #include <afs/rxgen_consts.h>
43 #include <afs/errors.h>
44 #include <afs/ihandle.h>
45 #include <afs/vnode.h>
46 #include <afs/volume.h>
48 #include <afs/ptclient.h>
49 #include <afs/prs_fs.h>
50 #include <afs/afsutil.h>
52 #include <afs/cellconfig.h>
55 #include "../viced/viced_prototypes.h"
56 #include "../viced/viced.h"
57 #include "../viced/host.h"
58 #include "../viced/callback.h"
59 #include "serialize_state.h"
61 /*@+fcnmacros +macrofcndecl@*/
64 extern off64_t afs_lseek(int FD, off64_t O, int F);
65 #endif /*S_SPLINT_S */
66 #define afs_lseek(FD, O, F) lseek64(FD, (off64_t)(O), F)
67 #define afs_stat stat64
68 #define afs_fstat fstat64
69 #define afs_open open64
70 #define afs_fopen fopen64
71 #define afs_ftruncate ftruncate64
72 #define afs_mmap mmap64
74 extern void * mmap64(); /* ugly hack since aix build env appears to be somewhat broken */
76 #else /* !O_LARGEFILE */
78 extern off_t afs_lseek(int FD, off_t O, int F);
79 #endif /*S_SPLINT_S */
80 #define afs_lseek(FD, O, F) lseek(FD, (off_t)(O), F)
82 #define afs_fstat fstat
84 #define afs_fopen fopen
85 #define afs_ftruncate ftruncate
87 #endif /* !O_LARGEFILE */
88 /*@=fcnmacros =macrofcndecl@*/
91 #ifdef AFS_DEMAND_ATTACH_FS
97 * in order to make state dump/restore as fast as possible,
98 * we use memory mapped files
100 * if this causes problems on certain platforms, the APIs
101 * have been written so that it will be very simple to go
102 * back to standard I/O for just those poorly written platforms
105 #define FS_STATE_USE_MMAP
108 #ifdef FS_STATE_USE_MMAP
109 #define FS_STATE_INIT_FILESIZE (8 * 1024 * 1024) /* truncate to 8MB initially */
110 #include <sys/mman.h>
113 static int fs_stateCreateDump(struct fs_dump_state * state);
114 static int fs_stateLoadDump(struct fs_dump_state * state);
115 static int fs_stateInvalidateDump(struct fs_dump_state * state);
116 static int fs_stateCommitDump(struct fs_dump_state * state);
117 static int fs_stateCloseDump(struct fs_dump_state * state);
119 #ifdef FS_STATE_USE_MMAP
120 static int fs_stateSizeFile(struct fs_dump_state * state);
121 static int fs_stateResizeFile(struct fs_dump_state * state, size_t min_add);
122 static int fs_stateTruncateFile(struct fs_dump_state * state);
124 static int fs_stateMapFile(struct fs_dump_state * state);
125 static int fs_stateUnmapFile(struct fs_dump_state * state);
127 static int fs_stateIncCursor(struct fs_dump_state * state, size_t len);
128 static int fs_stateCheckIOSafety(struct fs_dump_state * state,
132 static int fs_stateFillHeader(struct fs_state_header * hdr);
133 static int fs_stateCheckHeader(struct fs_state_header * hdr);
135 static int fs_stateAlloc(struct fs_dump_state * state);
136 static int fs_stateFree(struct fs_dump_state * state);
138 extern afsUUID FS_HostUUID;
139 extern char cml_version_number[];
143 * save all fileserver state
148 int ret = 0, verified = 1;
149 struct fs_dump_state state;
151 /* save and restore need to be atomic wrt other host package operations */
154 ViceLog(0, ("fs_stateSave: commencing fileserver state dump\n"));
156 if (fs_stateAlloc(&state)) {
157 ViceLog(0, ("fs_stateSave: memory allocation failed; dump aborted\n"));
163 * on busy servers, these checks will inevitably fail since stuff drops H_LOCK
164 * all over the place (with structs left in inconsistent states) while RPCs to
165 * clients happen (grumble, grumble, the host package needs to be rewritten...)
167 * the current hack is to force the background threads that deal with host and
168 * callback state offline early in the shutdown process, do VShutdown, come
169 * back and wait for those threads to die, THEN do the state dump
171 * BUT, this still has one flaw -- what do we do about rx worker threads that
172 * are blocked in the host package making an RPC call to a cm???
174 * perhaps we need a refcounter that keeps track of threads blocked in rpc calls
175 * with H_LOCK dropped (and the host struct likely left in an inconsistent state)
177 * or better yet, we need to associate a state machine with each host object
178 * (kind of like demand attach Volume structures).
180 * sigh. I suspect we'll need to revisit this issue
183 if (fs_state.options.fs_state_verify_before_save) {
184 ViceLog(0, ("fs_stateSave: performing internal consistency checks before proceeding with state dump\n"));
186 if (h_stateVerify(&state)) {
187 ViceLog(0, ("fs_stateSave: error: host table consistency checks failed; state dump will not be marked clean\n"));
192 if (cb_stateVerify(&state)) {
193 ViceLog(0, ("fs_stateSave: error: callback table consistency checks failed; state dump will not be marked clean\n"));
198 /* if a consistency check asserted the bail flag, reset it */
201 ViceLog(0, ("fs_stateSave: proceeding with dump\n"));
204 if (fs_stateCreateDump(&state)) {
205 ViceLog(0, ("fs_stateSave: error: dump create failed\n"));
210 if (h_stateSave(&state)) {
211 ViceLog(0, ("fs_stateSave: error: host state dump failed\n"));
216 if (cb_stateSave(&state)) {
217 ViceLog(0, ("fs_stateSave: error: callback state dump failed\n"));
226 if (fs_stateCommitDump(&state)) {
227 ViceLog(0, ("fs_stateSave: error: dump commit failed\n"));
233 ViceLog(0, ("fs_stateSave: fileserver state dump completed successfully\n"));
235 ViceLog(0, ("fs_stateSave: fileserver state dump completed, but not marked clean.\n"));
236 ViceLog(0, ("fs_stateSave: please save a copy of '%s' for use by technical support\n",
242 fs_stateCloseDump(&state);
243 fs_stateFree(&state);
250 * restore all fileserver state
252 * this function must appear as one atomic operation to the host and callback
253 * packages, hence H_LOCK is held for the entirety of the process.
256 fs_stateRestore(void)
259 struct fs_dump_state state;
261 /* save and restore need to be atomic wrt other host package operations */
264 ViceLog(0, ("fs_stateRestore: commencing fileserver state restore\n"));
266 if (fs_stateAlloc(&state)) {
267 ViceLog(0, ("fs_stateRestore: memory allocation failed\n"));
272 if (fs_stateLoadDump(&state)) {
273 ViceLog(0, ("fs_stateRestore: failed to load dump file '%s'\n", state.fn));
278 if (fs_stateInvalidateDump(&state)) {
279 ViceLog(0, ("fs_stateRestore: failed to invalidate dump file '%s'\n", state.fn));
285 if (state.flags.do_host_restore) {
286 if (h_stateRestore(&state)) {
287 ViceLog(0, ("fs_stateRestore: error: host state restore failed. exiting avoid further corruption\n"));
290 ViceLog(0, ("fs_stateRestore: host table restored\n"));
292 if (cb_stateRestore(&state)) {
293 ViceLog(0, ("fs_stateRestore: error: callback state restore failed. exiting to avoid further corruption\n"));
296 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack tables restored\n"));
298 if (h_stateRestoreIndices(&state)) {
299 ViceLog(0, ("fs_stateRestore: error: host index remapping failed. exiting to avoid further corruption\n"));
302 ViceLog(0, ("fs_stateRestore: host table indices remapped\n"));
304 if (cb_stateRestoreIndices(&state)) {
305 ViceLog(0, ("fs_stateRestore: error: callback index remapping failed. exiting to avoid further corruption\n"));
308 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack indices remapped\n"));
311 ViceLog(0, ("fs_stateRestore: restore phase complete\n"));
313 if (fs_state.options.fs_state_verify_after_restore) {
314 ViceLog(0, ("fs_stateRestore: beginning state verification phase\n"));
316 if (state.flags.do_host_restore) {
317 if (h_stateVerify(&state)) {
318 ViceLog(0, ("fs_stateRestore: error: host table consistency checks failed; exiting to avoid further corruption\n"));
322 if (cb_stateVerify(&state)) {
323 ViceLog(0, ("fs_stateRestore: error: callback table consistency checks failed; exiting to avoid further corruption\n"));
328 ViceLog(0, ("fs_stateRestore: fileserver state verification complete\n"));
331 ViceLog(0, ("fs_stateRestore: restore was successful\n"));
335 fs_stateInvalidateDump(&state);
336 fs_stateCloseDump(&state);
338 fs_stateFree(&state);
344 fs_stateCreateDump(struct fs_dump_state * state)
347 char savedump[MAXPATHLEN];
348 struct afs_stat status;
350 afs_snprintf(savedump, sizeof(savedump), "%s.old", state->fn);
352 if (afs_stat(state->fn, &status) == 0) {
353 renamefile(state->fn, savedump);
356 if (((fd = afs_open(state->fn,
357 O_RDWR | O_CREAT | O_TRUNC,
358 S_IRUSR | S_IWUSR)) == -1) ||
359 (afs_fstat(fd, &status) == -1)) {
360 ViceLog(0, ("fs_stateCreateDump: failed to create state dump file '%s'\n",
367 state->mode = FS_STATE_DUMP_MODE;
368 memset(state->hdr, 0, sizeof(struct fs_state_header));
369 fs_stateIncEOF(state, sizeof(struct fs_state_header));
371 #ifdef FS_STATE_USE_MMAP
372 if (fs_stateSizeFile(state)) {
373 ViceLog(0, ("fs_stateCreateDump: failed to resize state dump file '%s'\n",
379 if (fs_stateMapFile(state)) {
380 ViceLog(0, ("fs_stateCreateDump: failed to memory map state dump file '%s'\n",
387 ret = fs_stateInvalidateDump(state);
394 fs_stateInvalidateDump(struct fs_dump_state * state)
398 struct fs_state_header hdr;
400 #ifdef FS_STATE_USE_MMAP
401 if (state->mmap.map == NULL) {
406 memcpy(&hdr, state->hdr, sizeof(hdr));
410 /* write a bogus header to flag dump in progress */
411 if (fs_stateWriteHeader(state, &z, &hdr, sizeof(hdr))) {
412 ViceLog(0, ("fs_stateInvalidateDump: failed to invalidate old dump file header '%s'\n",
417 if (fs_stateSync(state)) {
418 ViceLog(0, ("fs_stateInvalidateDump: failed to sync changes to disk\n"));
428 fs_stateCommitDump(struct fs_dump_state * state)
435 #ifdef FS_STATE_USE_MMAP
436 if (fs_stateTruncateFile(state)) {
437 ViceLog(0, ("fs_stateCommitDump: failed to truncate dump file to proper size\n"));
443 /* ensure that all pending data I/Os for the state file have been committed
444 * _before_ we make the metadata I/Os */
445 if (fs_stateSync(state)) {
446 ViceLog(0, ("fs_stateCommitDump: failed to sync changes to disk\n"));
451 #ifdef FS_STATE_USE_MMAP
452 /* XXX madvise may not exist on all platforms, so
453 * we may need to add some ifdefs at some point... */
455 madvise((((char *)state->mmap.map) + sizeof(struct fs_state_header)),
456 state->mmap.size - sizeof(struct fs_state_header),
461 /* build the header, and write it to disk */
462 fs_stateFillHeader(state->hdr);
464 state->hdr->valid = 0;
466 if (fs_stateWriteHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
467 ViceLog(0, ("fs_stateCommitDump: failed to write header to dump file '%s'\n",
472 if (fs_stateSync(state)) {
473 ViceLog(0, ("fs_stateCommitDump: failed to sync new header to disk\n"));
483 fs_stateLoadDump(struct fs_dump_state * state)
487 struct afs_stat status;
488 afs_int32 now = FT_ApproxTime();
492 if ((fd = afs_open(state->fn, O_RDWR)) == -1 ||
493 (afs_fstat(fd, &status) == -1)) {
494 ViceLog(0, ("fs_stateLoadDump: failed to load state dump file '%s'\n",
500 state->mode = FS_STATE_LOAD_MODE;
501 state->file_len = status.st_size;
503 #ifdef FS_STATE_USE_MMAP
504 if (fs_stateMapFile(state)) {
505 ViceLog(0, ("fs_stateLoadDump: failed to memory map state dump file '%s'\n",
512 if (fs_stateReadHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
513 ViceLog(0, ("fs_stateLoadDump: failed to read header from dump file '%s'\n",
519 /* check the validity of the header */
520 if (fs_stateCheckHeader(state->hdr)) {
521 ViceLog(1, ("fs_stateLoadDump: header failed validity checks; not restoring '%s'\n",
527 if ((state->hdr->timestamp + HOST_STATE_VALID_WINDOW) >= now) {
528 state->flags.do_host_restore = 1;
530 ViceLog(0, ("fs_stateLoadDump: warning: dump is too old for host and callback restore; skipping those steps\n"));
538 fs_stateCloseDump(struct fs_dump_state * state)
540 #ifdef FS_STATE_USE_MMAP
541 fs_stateUnmapFile(state);
548 fs_stateWrite(struct fs_dump_state * state,
549 void * buf, size_t len)
553 #ifdef FS_STATE_USE_MMAP
554 if (fs_stateCheckIOSafety(state, len)) {
555 if (fs_stateResizeFile(state, len)) {
556 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
563 memcpy(state->mmap.cursor, buf, len);
564 fs_stateIncCursor(state, len);
566 if (write(state->fd, buf, len) != len) {
567 ViceLog(0, ("fs_stateWrite: write failed\n"));
578 fs_stateRead(struct fs_dump_state * state,
579 void * buf, size_t len)
583 #ifdef FS_STATE_USE_MMAP
584 if (fs_stateCheckIOSafety(state, len)) {
585 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
591 memcpy(buf, state->mmap.cursor, len);
592 fs_stateIncCursor(state, len);
594 if (read(state->fd, buf, len) != len) {
595 ViceLog(0, ("fs_stateRead: read failed\n"));
606 fs_stateWriteV(struct fs_dump_state * state,
607 struct iovec * iov, int niov)
612 for (i=0; i < niov; i++) {
613 len += iov[i].iov_len;
616 #ifdef FS_STATE_USE_MMAP
617 if (fs_stateCheckIOSafety(state, len)) {
618 if (fs_stateResizeFile(state, len)) {
619 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
626 for (i=0; i < niov; i++) {
627 memcpy(state->mmap.cursor, iov[i].iov_base, iov[i].iov_len);
628 fs_stateIncCursor(state, iov[i].iov_len);
631 if (writev(state->fd, iov, niov) != len) {
632 ViceLog(0, ("fs_stateWriteV: write failed\n"));
643 fs_stateReadV(struct fs_dump_state * state,
644 struct iovec * iov, int niov)
649 for (i=0; i < niov; i++) {
650 len += iov[i].iov_len;
653 #ifdef FS_STATE_USE_MMAP
654 if (fs_stateCheckIOSafety(state, len)) {
655 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
661 for (i=0; i < niov; i++) {
662 memcpy(iov[i].iov_base, state->mmap.cursor, iov[i].iov_len);
663 fs_stateIncCursor(state, iov[i].iov_len);
666 if (readv(state->fd, iov, niov) != len) {
667 ViceLog(0, ("fs_stateReadV: read failed\n"));
678 fs_stateWriteHeader(struct fs_dump_state * state,
680 void * hdr, size_t len)
684 if (fs_stateSeek(state, offset)) {
685 ViceLog(0, ("fs_stateWriteHeader: could not seek to correct position in dump file '%s'\n",
691 if (fs_stateWrite(state, hdr, len)) {
692 ViceLog(0, ("fs_stateWriteHeader: write failed\n"));
702 fs_stateReadHeader(struct fs_dump_state * state,
704 void * hdr, size_t len)
708 if (fs_stateSeek(state, offset)) {
709 ViceLog(0, ("fs_stateReadHeader: could not seek to correct position in dump file '%s'\n",
715 if (fs_stateRead(state, hdr,len)) {
716 ViceLog(0, ("fs_stateReadHeader: read failed\n"));
725 #ifdef FS_STATE_USE_MMAP
727 fs_stateSizeFile(struct fs_dump_state * state)
730 state->file_len = FS_STATE_INIT_FILESIZE;
731 if (afs_ftruncate(state->fd, state->file_len) != 0)
737 fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
742 #ifdef FS_STATE_USE_MMAP
743 fs_stateUnmapFile(state);
746 inc = ((min_add / FS_STATE_INIT_FILESIZE)+1) * FS_STATE_INIT_FILESIZE;
747 state->file_len += inc;
749 if (afs_ftruncate(state->fd, state->file_len) != 0) {
750 ViceLog(0, ("fs_stateResizeFile: truncate failed\n"));
755 #ifdef FS_STATE_USE_MMAP
756 if (fs_stateMapFile(state)) {
757 ViceLog(0, ("fs_stateResizeFile: remapping memory mapped file failed\n"));
768 fs_stateTruncateFile(struct fs_dump_state * state)
772 #ifdef AFS_LARGEFILE_ENV
773 if (afs_ftruncate(state->fd, state->eof_offset) != 0) {
778 SplitInt64(state->eof_offset, hi, lo);
779 if (afs_ftruncate(state->fd, lo) != 0) {
788 #ifdef FS_STATE_USE_MMAP
790 fs_stateMapFile(struct fs_dump_state * state)
794 switch(state->mode) {
795 case FS_STATE_LOAD_MODE:
796 flags = PROT_READ | PROT_WRITE; /* loading involves a header invalidation */
798 case FS_STATE_DUMP_MODE:
802 ViceLog(0, ("fs_stateMapFile: invalid dump state mode\n"));
806 state->mmap.map = afs_mmap(NULL,
813 if (state->mmap.map == MAP_FAILED) {
814 state->mmap.size = 0;
815 state->mmap.map = NULL;
816 ViceLog(0, ("fs_stateMapFile: failed to memory map file '%s'\n",
822 state->mmap.size = state->file_len;
823 state->mmap.cursor = state->mmap.map;
824 state->mmap.offset = 0;
826 /* for state loading, accesses will be sequential, so let's give
827 * the VM subsystem a heads up */
828 if (state->mode == FS_STATE_LOAD_MODE) {
829 /* XXX madvise may not exist on all platforms, so
830 * we may need to add some ifdefs at some point... */
831 flags = MADV_SEQUENTIAL | MADV_WILLNEED;
832 #ifdef AFS_SUN510_ENV
833 flags |= MADV_ACCESS_LWP; /* added in solaris 9 12/02 */
835 madvise(state->mmap.map, state->mmap.size, flags);
843 fs_stateUnmapFile(struct fs_dump_state * state)
847 if (munmap(state->mmap.map, state->mmap.size) == -1) {
848 ViceLog(0, ("fs_stateUnmapFile: failed to unmap dump file '%s'\n",
857 #endif /* FS_STATE_USE_MMAP */
859 #ifdef FS_STATE_USE_MMAP
861 fs_stateSync(struct fs_dump_state * state)
865 msync(state->mmap.map, state->mmap.size, MS_SYNC);
870 #else /* !FS_STATE_USE_MMAP */
872 fs_stateSync(struct fs_dump_state * state)
876 if (fsync(state->fd) == -1)
882 #endif /* !FS_STATE_USE_MMAP */
885 fs_stateIncEOF(struct fs_dump_state * state, afs_int32 len)
888 FillInt64(temp, 0, len);
889 AddUInt64(state->eof_offset, temp, &state->eof_offset);
893 #ifdef FS_STATE_USE_MMAP
895 fs_stateIncCursor(struct fs_dump_state * state, size_t len)
899 state->mmap.offset += len;
901 p = (char *) state->mmap.cursor;
903 state->mmap.cursor = (void *) p;
909 fs_stateCheckIOSafety(struct fs_dump_state * state, size_t len)
913 if ((state->mmap.offset + len) > state->mmap.size) {
918 #endif /* FS_STATE_USE_MMAP */
920 #ifdef FS_STATE_USE_MMAP
922 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
928 SplitInt64(*offset, hi, lo);
931 p = (char *) state->mmap.map;
937 state->mmap.cursor = (void *) p;
940 #ifdef AFS_LARGEFILE_ENV
941 state->mmap.offset = *offset;
945 state->mmap.offset = lo;
950 #else /* !FS_STATE_USE_MMAP */
952 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
955 #ifndef AFS_LARGEFILE_ENV
956 afs_uint32 high, low;
958 SplitInt64(*offset, high, low);
964 if (afs_lseek(state->fd, low, SEEK_SET) == -1)
967 if (afs_lseek(state->fd, *offset, SEEK_SET) == -1)
972 #endif /* !FS_STATE_USE_MMAP */
975 fs_stateFillHeader(struct fs_state_header * hdr)
977 hdr->stamp.magic = FS_STATE_MAGIC;
978 hdr->stamp.version = FS_STATE_VERSION;
980 hdr->sys_name = SYS_NAME_ID;
982 hdr->sys_name = 0xFFFFFFFF;
984 hdr->timestamp = FT_ApproxTime();
985 hdr->server_uuid = FS_HostUUID;
987 #ifdef WORDS_BIGENDIAN
992 #ifdef FS_STATS_DETAILED
993 hdr->stats_detailed = 1;
995 hdr->stats_detailed = 0;
997 if (strlcpy(hdr->server_version_string, cml_version_number, sizeof(hdr->server_version_string))
998 >= sizeof(hdr->server_version_string)) {
999 ViceLog(0, ("fs_stateFillHeader: WARNING -- cml_version_number field truncated\n"));
1005 fs_stateCheckHeader(struct fs_state_header * hdr)
1010 ViceLog(0, ("fs_stateCheckHeader: dump was previously flagged invalid\n"));
1013 #ifdef WORDS_BIGENDIAN
1014 else if (!hdr->endianness) {
1015 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1018 #else /* AFSLITTLE_ENDIAN */
1019 else if (hdr->endianness) {
1020 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1023 #endif /* AFSLITTLE_ENDIAN */
1025 else if (hdr->stamp.magic != FS_STATE_MAGIC) {
1026 ViceLog(0, ("fs_stateCheckHeader: invalid dump header\n"));
1029 else if (hdr->stamp.version != FS_STATE_VERSION) {
1030 ViceLog(0, ("fs_stateCheckHeader: unknown dump format version number\n"));
1034 #ifdef FS_STATS_DETAILED
1035 else if (!hdr->stats_detailed) {
1036 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1039 #else /* FS_STATS_DETAILED */
1040 else if (hdr->stats_detailed) {
1041 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1044 #endif /* FS_STATS_DETAILED */
1046 else if (!afs_uuid_equal(&hdr->server_uuid, &FS_HostUUID)) {
1047 ViceLog(0, ("fs_stateCheckHeader: server UUID does not match this server's UUID\n"));
1051 /* the cml_version_string is included for informational purposes only. If someone ever
1052 * wants to limit state dump reloading based upon the contents of this string, just
1053 * uncomment the following code. uncommenting this code is _strongly discouraged_ because
1054 * we already make use of the version stamps in the various dump headers to deal with
1055 * data structure version incompatabilities.
1056 else if (strncmp(hdr->server_version_string, cml_version_number,
1057 sizeof(hdr->server_version_string)) != 0) {
1058 ViceLog(0, ("fs_stateCheckHeader: dump from different server version\n"));
1063 else if (strncmp(hdr->server_version_string, cml_version_number,
1064 sizeof(hdr->server_version_string)) != 0) {
1065 ViceLog(0, ("fs_stateCheckHeader: dump from different server version ; attempting state reload anyway\n"));
1073 fs_stateAlloc(struct fs_dump_state * state)
1076 memset(state, 0, sizeof(struct fs_dump_state));
1078 state->fn = AFSDIR_SERVER_FSSTATE_FILEPATH;
1079 state->hdr = (struct fs_state_header *)malloc(sizeof(struct fs_state_header));
1080 state->h_hdr = (struct host_state_header *)malloc(sizeof(struct host_state_header));
1081 state->cb_hdr = (struct callback_state_header *)malloc(sizeof(struct callback_state_header));
1082 state->cb_timeout_hdr = (struct callback_state_timeout_header *)
1083 malloc(sizeof(struct callback_state_timeout_header));
1084 state->cb_fehash_hdr = (struct callback_state_fehash_header *)
1085 malloc(sizeof(struct callback_state_fehash_header));
1086 if ((state->hdr == NULL) || (state->h_hdr == NULL) || (state->cb_hdr == NULL) ||
1087 (state->cb_timeout_hdr == NULL) || (state->cb_fehash_hdr == NULL))
1093 fs_stateFree(struct fs_dump_state * state)
1100 free(state->cb_hdr);
1101 if (state->cb_timeout_hdr)
1102 free(state->cb_timeout_hdr);
1103 if (state->cb_fehash_hdr)
1104 free(state->cb_fehash_hdr);
1105 if (state->h_map.entries)
1106 free(state->h_map.entries);
1107 if (state->fe_map.entries)
1108 free(state->fe_map.entries);
1109 if (state->cb_map.entries)
1110 free(state->cb_map.entries);
1114 #endif /* AFS_DEMAND_ATTACH_FS */