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 1
106 #ifdef FS_STATE_USE_MMAP
107 #define FS_STATE_INIT_FILESIZE (8 * 1024 * 1024) /* truncate to 8MB initially */
109 #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[];
142 fs_stateFileOpen(struct fs_dump_state *state)
145 return(state->fd != -1);
147 return(state->fd >= 0);
154 * save all fileserver state
159 int ret = 0, verified = 1;
160 struct fs_dump_state state;
162 /* save and restore need to be atomic wrt other host package operations */
165 ViceLog(0, ("fs_stateSave: commencing fileserver state dump\n"));
167 if (fs_stateAlloc(&state)) {
168 ViceLog(0, ("fs_stateSave: memory allocation failed; dump aborted\n"));
174 * on busy servers, these checks will inevitably fail since stuff drops H_LOCK
175 * all over the place (with structs left in inconsistent states) while RPCs to
176 * clients happen (grumble, grumble, the host package needs to be rewritten...)
178 * the current hack is to force the background threads that deal with host and
179 * callback state offline early in the shutdown process, do VShutdown, come
180 * back and wait for those threads to die, THEN do the state dump
182 * BUT, this still has one flaw -- what do we do about rx worker threads that
183 * are blocked in the host package making an RPC call to a cm???
185 * perhaps we need a refcounter that keeps track of threads blocked in rpc calls
186 * with H_LOCK dropped (and the host struct likely left in an inconsistent state)
188 * or better yet, we need to associate a state machine with each host object
189 * (kind of like demand attach Volume structures).
191 * sigh. I suspect we'll need to revisit this issue
194 if (fs_state.options.fs_state_verify_before_save) {
195 ViceLog(0, ("fs_stateSave: performing internal consistency checks before proceeding with state dump\n"));
197 if (h_stateVerify(&state)) {
198 ViceLog(0, ("fs_stateSave: error: host table consistency checks failed; state dump will not be marked clean\n"));
203 if (cb_stateVerify(&state)) {
204 ViceLog(0, ("fs_stateSave: error: callback table consistency checks failed; state dump will not be marked clean\n"));
209 /* if a consistency check asserted the bail flag, reset it */
212 ViceLog(0, ("fs_stateSave: proceeding with dump\n"));
215 if (fs_stateCreateDump(&state)) {
216 ViceLog(0, ("fs_stateSave: error: dump create failed\n"));
221 if (h_stateSave(&state)) {
222 ViceLog(0, ("fs_stateSave: error: host state dump failed\n"));
227 if (cb_stateSave(&state)) {
228 ViceLog(0, ("fs_stateSave: error: callback state dump failed\n"));
237 if (fs_stateCommitDump(&state)) {
238 ViceLog(0, ("fs_stateSave: error: dump commit failed\n"));
244 ViceLog(0, ("fs_stateSave: fileserver state dump completed successfully\n"));
246 ViceLog(0, ("fs_stateSave: fileserver state dump completed, but not marked clean.\n"));
247 ViceLog(0, ("fs_stateSave: please save a copy of '%s' for use by technical support\n",
252 if (fs_stateFileOpen(&state))
253 fs_stateCloseDump(&state);
254 fs_stateFree(&state);
261 * restore all fileserver state
263 * this function must appear as one atomic operation to the host and callback
264 * packages, hence H_LOCK is held for the entirety of the process.
267 fs_stateRestore(void)
270 struct fs_dump_state state;
272 /* save and restore need to be atomic wrt other host package operations */
275 ViceLog(0, ("fs_stateRestore: commencing fileserver state restore\n"));
277 if (fs_stateAlloc(&state)) {
278 ViceLog(0, ("fs_stateRestore: memory allocation failed\n"));
283 if (fs_stateLoadDump(&state)) {
284 ViceLog(0, ("fs_stateRestore: failed to load dump file '%s'\n", state.fn));
289 if (fs_stateInvalidateDump(&state)) {
290 ViceLog(0, ("fs_stateRestore: failed to invalidate dump file '%s'\n", state.fn));
296 if (state.flags.do_host_restore) {
297 if (h_stateRestore(&state)) {
298 ViceLog(0, ("fs_stateRestore: error: host state restore failed. exiting avoid further corruption\n"));
301 ViceLog(0, ("fs_stateRestore: host table restored\n"));
303 if (cb_stateRestore(&state)) {
304 ViceLog(0, ("fs_stateRestore: error: callback state restore failed. exiting to avoid further corruption\n"));
307 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack tables restored\n"));
309 if (h_stateRestoreIndices(&state)) {
310 ViceLog(0, ("fs_stateRestore: error: host index remapping failed. exiting to avoid further corruption\n"));
313 ViceLog(0, ("fs_stateRestore: host table indices remapped\n"));
315 if (cb_stateRestoreIndices(&state)) {
316 ViceLog(0, ("fs_stateRestore: error: callback index remapping failed. exiting to avoid further corruption\n"));
319 ViceLog(0, ("fs_stateRestore: FileEntry and CallBack indices remapped\n"));
322 ViceLog(0, ("fs_stateRestore: restore phase complete\n"));
324 if (fs_state.options.fs_state_verify_after_restore) {
325 ViceLog(0, ("fs_stateRestore: beginning state verification phase\n"));
327 if (state.flags.do_host_restore) {
328 if (h_stateVerify(&state)) {
329 ViceLog(0, ("fs_stateRestore: error: host table consistency checks failed; exiting to avoid further corruption\n"));
333 if (cb_stateVerify(&state)) {
334 ViceLog(0, ("fs_stateRestore: error: callback table consistency checks failed; exiting to avoid further corruption\n"));
339 ViceLog(0, ("fs_stateRestore: fileserver state verification complete\n"));
342 ViceLog(0, ("fs_stateRestore: restore was successful\n"));
346 fs_stateInvalidateDump(&state);
347 fs_stateCloseDump(&state);
349 fs_stateFree(&state);
355 fs_stateCreateDump(struct fs_dump_state * state)
358 char savedump[MAXPATHLEN];
359 struct afs_stat status;
361 afs_snprintf(savedump, sizeof(savedump), "%s.old", state->fn);
363 if (afs_stat(state->fn, &status) == 0) {
364 renamefile(state->fn, savedump);
367 if (((fd = afs_open(state->fn,
368 O_RDWR | O_CREAT | O_TRUNC,
369 S_IRUSR | S_IWUSR)) == -1) ||
370 (afs_fstat(fd, &status) == -1)) {
371 ViceLog(0, ("fs_stateCreateDump: failed to create state dump file '%s'\n",
378 state->mode = FS_STATE_DUMP_MODE;
379 memset(state->hdr, 0, sizeof(struct fs_state_header));
380 fs_stateIncEOF(state, sizeof(struct fs_state_header));
382 #ifdef FS_STATE_USE_MMAP
383 if (fs_stateSizeFile(state)) {
384 ViceLog(0, ("fs_stateCreateDump: failed to resize state dump file '%s'\n",
390 if (fs_stateMapFile(state)) {
391 ViceLog(0, ("fs_stateCreateDump: failed to memory map state dump file '%s'\n",
398 ret = fs_stateInvalidateDump(state);
405 fs_stateInvalidateDump(struct fs_dump_state * state)
409 struct fs_state_header hdr;
411 #ifdef FS_STATE_USE_MMAP
412 if (state->mmap.map == NULL) {
417 memcpy(&hdr, state->hdr, sizeof(hdr));
421 /* write a bogus header to flag dump in progress */
422 if (fs_stateWriteHeader(state, &z, &hdr, sizeof(hdr))) {
423 ViceLog(0, ("fs_stateInvalidateDump: failed to invalidate old dump file header '%s'\n",
428 if (fs_stateSync(state)) {
429 ViceLog(0, ("fs_stateInvalidateDump: failed to sync changes to disk\n"));
439 fs_stateCommitDump(struct fs_dump_state * state)
446 #ifdef FS_STATE_USE_MMAP
447 if (fs_stateTruncateFile(state)) {
448 ViceLog(0, ("fs_stateCommitDump: failed to truncate dump file to proper size\n"));
454 /* ensure that all pending data I/Os for the state file have been committed
455 * _before_ we make the metadata I/Os */
456 if (fs_stateSync(state)) {
457 ViceLog(0, ("fs_stateCommitDump: failed to sync changes to disk\n"));
462 #ifdef FS_STATE_USE_MMAP
463 /* XXX madvise may not exist on all platforms, so
464 * we may need to add some ifdefs at some point... */
466 madvise((((char *)state->mmap.map) + sizeof(struct fs_state_header)),
467 state->mmap.size - sizeof(struct fs_state_header),
472 /* build the header, and write it to disk */
473 fs_stateFillHeader(state->hdr);
475 state->hdr->valid = 0;
477 if (fs_stateWriteHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
478 ViceLog(0, ("fs_stateCommitDump: failed to write header to dump file '%s'\n",
483 if (fs_stateSync(state)) {
484 ViceLog(0, ("fs_stateCommitDump: failed to sync new header to disk\n"));
494 fs_stateLoadDump(struct fs_dump_state * state)
498 struct afs_stat status;
499 afs_int32 now = FT_ApproxTime();
503 if ((fd = afs_open(state->fn, O_RDWR)) == -1 ||
504 (afs_fstat(fd, &status) == -1)) {
505 ViceLog(0, ("fs_stateLoadDump: failed to load state dump file '%s'\n",
511 state->mode = FS_STATE_LOAD_MODE;
512 state->file_len = status.st_size;
514 #ifdef FS_STATE_USE_MMAP
515 if (fs_stateMapFile(state)) {
516 ViceLog(0, ("fs_stateLoadDump: failed to memory map state dump file '%s'\n",
523 if (fs_stateReadHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
524 ViceLog(0, ("fs_stateLoadDump: failed to read header from dump file '%s'\n",
530 /* check the validity of the header */
531 if (fs_stateCheckHeader(state->hdr)) {
532 ViceLog(1, ("fs_stateLoadDump: header failed validity checks; not restoring '%s'\n",
538 if ((state->hdr->timestamp + HOST_STATE_VALID_WINDOW) >= now) {
539 state->flags.do_host_restore = 1;
541 ViceLog(0, ("fs_stateLoadDump: warning: dump is too old for host and callback restore; skipping those steps\n"));
549 fs_stateCloseDump(struct fs_dump_state * state)
551 #ifdef FS_STATE_USE_MMAP
552 fs_stateUnmapFile(state);
559 fs_stateWrite(struct fs_dump_state * state,
560 void * buf, size_t len)
564 #ifdef FS_STATE_USE_MMAP
565 if (fs_stateCheckIOSafety(state, len)) {
566 if (fs_stateResizeFile(state, len)) {
567 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
574 memcpy(state->mmap.cursor, buf, len);
575 fs_stateIncCursor(state, len);
577 if (write(state->fd, buf, len) != len) {
578 ViceLog(0, ("fs_stateWrite: write failed\n"));
589 fs_stateRead(struct fs_dump_state * state,
590 void * buf, size_t len)
594 #ifdef FS_STATE_USE_MMAP
595 if (fs_stateCheckIOSafety(state, len)) {
596 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
602 memcpy(buf, state->mmap.cursor, len);
603 fs_stateIncCursor(state, len);
605 if (read(state->fd, buf, len) != len) {
606 ViceLog(0, ("fs_stateRead: read failed\n"));
617 fs_stateWriteV(struct fs_dump_state * state,
618 struct iovec * iov, int niov)
623 for (i=0; i < niov; i++) {
624 len += iov[i].iov_len;
627 #ifdef FS_STATE_USE_MMAP
628 if (fs_stateCheckIOSafety(state, len)) {
629 if (fs_stateResizeFile(state, len)) {
630 ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
637 for (i=0; i < niov; i++) {
638 memcpy(state->mmap.cursor, iov[i].iov_base, iov[i].iov_len);
639 fs_stateIncCursor(state, iov[i].iov_len);
643 if (writev(state->fd, iov, niov) != len) {
644 ViceLog(0, ("fs_stateWriteV: write failed\n"));
648 #else /* AFS_NT40_ENV */
649 for (i=0; i < niov; i++) {
650 if (write(state->fd, iov[i].iov_base, iov[i].iov_len) != iov[i].iov_len) {
651 ViceLog(0, ("fs_stateWriteV: write failed\n"));
656 #endif /* AFS_NT40_ENV */
664 fs_stateReadV(struct fs_dump_state * state,
665 struct iovec * iov, int niov)
670 for (i=0; i < niov; i++) {
671 len += iov[i].iov_len;
674 #ifdef FS_STATE_USE_MMAP
675 if (fs_stateCheckIOSafety(state, len)) {
676 ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
682 for (i=0; i < niov; i++) {
683 memcpy(iov[i].iov_base, state->mmap.cursor, iov[i].iov_len);
684 fs_stateIncCursor(state, iov[i].iov_len);
688 if (readv(state->fd, iov, niov) != len) {
689 ViceLog(0, ("fs_stateReadV: read failed\n"));
694 for (i=0; i < niov; i++) {
695 if (read(state->fd, iov[i].iov_base, iov[i].iov_len) != iov[i].iov_len) {
696 ViceLog(0, ("fs_stateReadV: read failed\n"));
701 #endif /* AFS_NT40_ENV */
709 fs_stateWriteHeader(struct fs_dump_state * state,
711 void * hdr, size_t len)
715 if (fs_stateSeek(state, offset)) {
716 ViceLog(0, ("fs_stateWriteHeader: could not seek to correct position in dump file '%s'\n",
722 if (fs_stateWrite(state, hdr, len)) {
723 ViceLog(0, ("fs_stateWriteHeader: write failed\n"));
733 fs_stateReadHeader(struct fs_dump_state * state,
735 void * hdr, size_t len)
739 if (fs_stateSeek(state, offset)) {
740 ViceLog(0, ("fs_stateReadHeader: could not seek to correct position in dump file '%s'\n",
746 if (fs_stateRead(state, hdr,len)) {
747 ViceLog(0, ("fs_stateReadHeader: read failed\n"));
756 #ifdef FS_STATE_USE_MMAP
758 fs_stateSizeFile(struct fs_dump_state * state)
761 state->file_len = FS_STATE_INIT_FILESIZE;
762 if (afs_ftruncate(state->fd, state->file_len) != 0)
768 fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
773 fs_stateUnmapFile(state);
775 inc = ((min_add / FS_STATE_INIT_FILESIZE)+1) * FS_STATE_INIT_FILESIZE;
776 state->file_len += inc;
778 if (afs_ftruncate(state->fd, state->file_len) != 0) {
779 ViceLog(0, ("fs_stateResizeFile: truncate failed\n"));
784 if (fs_stateMapFile(state)) {
785 ViceLog(0, ("fs_stateResizeFile: remapping memory mapped file failed\n"));
795 fs_stateTruncateFile(struct fs_dump_state * state)
799 if (afs_ftruncate(state->fd, state->eof_offset) != 0) {
807 fs_stateMapFile(struct fs_dump_state * state)
811 switch(state->mode) {
812 case FS_STATE_LOAD_MODE:
813 flags = PROT_READ | PROT_WRITE; /* loading involves a header invalidation */
815 case FS_STATE_DUMP_MODE:
819 ViceLog(0, ("fs_stateMapFile: invalid dump state mode\n"));
823 state->mmap.map = afs_mmap(NULL,
830 if (state->mmap.map == MAP_FAILED) {
831 state->mmap.size = 0;
832 state->mmap.map = NULL;
833 ViceLog(0, ("fs_stateMapFile: failed to memory map file '%s'\n",
839 state->mmap.size = state->file_len;
840 state->mmap.cursor = state->mmap.map;
841 state->mmap.offset = 0;
843 /* for state loading, accesses will be sequential, so let's give
844 * the VM subsystem a heads up */
845 if (state->mode == FS_STATE_LOAD_MODE) {
846 /* XXX madvise may not exist on all platforms, so
847 * we may need to add some ifdefs at some point... */
848 flags = MADV_SEQUENTIAL | MADV_WILLNEED;
849 #ifdef AFS_SUN510_ENV
850 flags |= MADV_ACCESS_LWP; /* added in solaris 9 12/02 */
852 madvise(state->mmap.map, state->mmap.size, flags);
860 fs_stateUnmapFile(struct fs_dump_state * state)
864 if (munmap(state->mmap.map, state->mmap.size) == -1) {
865 ViceLog(0, ("fs_stateUnmapFile: failed to unmap dump file '%s'\n",
876 fs_stateSync(struct fs_dump_state * state)
880 msync(state->mmap.map, state->mmap.size, MS_SYNC);
884 #else /* !FS_STATE_USE_MMAP */
886 fs_stateSync(struct fs_dump_state * state)
890 if (fsync(state->fd) == -1)
895 #endif /* !FS_STATE_USE_MMAP */
898 fs_stateIncEOF(struct fs_dump_state * state, afs_int32 len)
901 FillInt64(temp, 0, len);
902 AddUInt64(state->eof_offset, temp, &state->eof_offset);
906 #ifdef FS_STATE_USE_MMAP
908 fs_stateIncCursor(struct fs_dump_state * state, size_t len)
912 state->mmap.offset += len;
914 p = (char *) state->mmap.cursor;
916 state->mmap.cursor = (void *) p;
922 fs_stateCheckIOSafety(struct fs_dump_state * state, size_t len)
926 if ((state->mmap.offset + len) > state->mmap.size) {
931 #endif /* FS_STATE_USE_MMAP */
933 #ifdef FS_STATE_USE_MMAP
935 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
941 SplitInt64(*offset, hi, lo);
944 p = (char *) state->mmap.map;
950 state->mmap.cursor = (void *) p;
953 state->mmap.offset = *offset;
957 #else /* !FS_STATE_USE_MMAP */
959 fs_stateSeek(struct fs_dump_state * state, afs_uint64 * offset)
963 if (afs_lseek(state->fd, *offset, SEEK_SET) == -1)
968 #endif /* !FS_STATE_USE_MMAP */
971 fs_stateFillHeader(struct fs_state_header * hdr)
973 hdr->stamp.magic = FS_STATE_MAGIC;
974 hdr->stamp.version = FS_STATE_VERSION;
976 hdr->sys_name = SYS_NAME_ID;
978 hdr->sys_name = 0xFFFFFFFF;
980 hdr->timestamp = FT_ApproxTime();
981 hdr->server_uuid = FS_HostUUID;
983 #ifdef WORDS_BIGENDIAN
988 #ifdef FS_STATS_DETAILED
989 hdr->stats_detailed = 1;
991 hdr->stats_detailed = 0;
993 if (strlcpy(hdr->server_version_string, cml_version_number, sizeof(hdr->server_version_string))
994 >= sizeof(hdr->server_version_string)) {
995 ViceLog(0, ("fs_stateFillHeader: WARNING -- cml_version_number field truncated\n"));
1001 fs_stateCheckHeader(struct fs_state_header * hdr)
1006 ViceLog(0, ("fs_stateCheckHeader: dump was previously flagged invalid\n"));
1009 #ifdef WORDS_BIGENDIAN
1010 else if (!hdr->endianness) {
1011 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1014 #else /* AFSLITTLE_ENDIAN */
1015 else if (hdr->endianness) {
1016 ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
1019 #endif /* AFSLITTLE_ENDIAN */
1021 else if (hdr->stamp.magic != FS_STATE_MAGIC) {
1022 ViceLog(0, ("fs_stateCheckHeader: invalid dump header\n"));
1025 else if (hdr->stamp.version != FS_STATE_VERSION) {
1026 ViceLog(0, ("fs_stateCheckHeader: unknown dump format version number\n"));
1030 #ifdef FS_STATS_DETAILED
1031 else if (!hdr->stats_detailed) {
1032 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1035 #else /* FS_STATS_DETAILED */
1036 else if (hdr->stats_detailed) {
1037 ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
1040 #endif /* FS_STATS_DETAILED */
1042 else if (!afs_uuid_equal(&hdr->server_uuid, &FS_HostUUID)) {
1043 ViceLog(0, ("fs_stateCheckHeader: server UUID does not match this server's UUID\n"));
1047 /* the cml_version_string is included for informational purposes only. If someone ever
1048 * wants to limit state dump reloading based upon the contents of this string, just
1049 * uncomment the following code. uncommenting this code is _strongly discouraged_ because
1050 * we already make use of the version stamps in the various dump headers to deal with
1051 * data structure version incompatabilities.
1052 else if (strncmp(hdr->server_version_string, cml_version_number,
1053 sizeof(hdr->server_version_string)) != 0) {
1054 ViceLog(0, ("fs_stateCheckHeader: dump from different server version\n"));
1059 else if (strncmp(hdr->server_version_string, cml_version_number,
1060 sizeof(hdr->server_version_string)) != 0) {
1061 ViceLog(0, ("fs_stateCheckHeader: dump from different server version ; attempting state reload anyway\n"));
1069 fs_stateAlloc(struct fs_dump_state * state)
1072 memset(state, 0, sizeof(struct fs_dump_state));
1074 state->fn = (char *)AFSDIR_SERVER_FSSTATE_FILEPATH;
1075 state->hdr = (struct fs_state_header *)malloc(sizeof(struct fs_state_header));
1076 state->h_hdr = (struct host_state_header *)malloc(sizeof(struct host_state_header));
1077 state->cb_hdr = (struct callback_state_header *)malloc(sizeof(struct callback_state_header));
1078 state->cb_timeout_hdr = (struct callback_state_timeout_header *)
1079 malloc(sizeof(struct callback_state_timeout_header));
1080 state->cb_fehash_hdr = (struct callback_state_fehash_header *)
1081 malloc(sizeof(struct callback_state_fehash_header));
1082 if ((state->hdr == NULL) || (state->h_hdr == NULL) || (state->cb_hdr == NULL) ||
1083 (state->cb_timeout_hdr == NULL) || (state->cb_fehash_hdr == NULL))
1089 fs_stateFree(struct fs_dump_state * state)
1096 free(state->cb_hdr);
1097 if (state->cb_timeout_hdr)
1098 free(state->cb_timeout_hdr);
1099 if (state->cb_fehash_hdr)
1100 free(state->cb_fehash_hdr);
1101 if (state->h_map.entries)
1102 free(state->h_map.entries);
1103 if (state->fe_map.entries)
1104 free(state->fe_map.entries);
1105 if (state->cb_map.entries)
1106 free(state->cb_map.entries);
1110 #endif /* AFS_DEMAND_ATTACH_FS */