DEVEL15-large-partition-support-20080305
[openafs.git] / src / vol / fssync-debug.c
1 /*
2  * Copyright 2006-2008, Sine Nomine Associates and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 /* Main program file. Define globals. */
11 #define MAIN 1
12
13 /*
14  * fssync administration tool
15  */
16
17
18 #include <afsconfig.h>
19 #include <afs/param.h>
20
21 RCSID
22     ("$Header$");
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <dirent.h>
28 #include <sys/stat.h>
29 #include <time.h>
30 #include <errno.h>
31 #ifdef AFS_NT40_ENV
32 #include <io.h>
33 #include <WINNT/afsevent.h>
34 #else
35 #include <sys/param.h>
36 #include <sys/file.h>
37 #ifndef ITIMER_REAL
38 #include <sys/time.h>
39 #endif /* ITIMER_REAL */
40 #endif
41 #include <rx/xdr.h>
42 #include <afs/afsint.h>
43 #include <afs/assert.h>
44
45
46 #include <fcntl.h>
47
48 #ifndef AFS_NT40_ENV
49 #include <afs/osi_inode.h>
50 #endif
51
52 #include <afs/cmd.h>
53 #include <afs/afsutil.h>
54 #include <afs/fileutil.h>
55
56 #include "nfs.h"
57 #include "lwp.h"
58 #include "lock.h"
59 #include "ihandle.h"
60 #include "vnode.h"
61 #include "volume.h"
62 #include "partition.h"
63 #include "daemon_com.h"
64 #include "fssync.h"
65 #ifdef AFS_NT40_ENV
66 #include <pthread.h>
67 #endif
68
69 int VolumeChanged; /* hack to make dir package happy */
70
71
72 struct volop_state {
73     afs_uint32 volume;
74     afs_uint32 vnode;
75     afs_uint32 unique;
76     char partName[16];
77 };
78
79 struct state {
80     afs_int32 reason;
81     struct volop_state * vop;
82 };
83
84 static int common_prolog(struct cmd_syndesc *, struct state *);
85 static int common_volop_prolog(struct cmd_syndesc *, struct state *);
86
87 static int do_volop(struct state *, afs_int32 command, SYNC_response * res);
88
89 static char * response_code_to_string(afs_int32);
90 static char * command_code_to_string(afs_int32);
91 static char * reason_code_to_string(afs_int32);
92 static char * program_type_to_string(afs_int32);
93
94 static int VolOnline(struct cmd_syndesc * as, void * rock);
95 static int VolOffline(struct cmd_syndesc * as, void * rock);
96 static int VolMode(struct cmd_syndesc * as, void * rock);
97 static int VolDetach(struct cmd_syndesc * as, void * rock);
98 static int VolBreakCBKs(struct cmd_syndesc * as, void * rock);
99 static int VolMove(struct cmd_syndesc * as, void * rock);
100 static int VolList(struct cmd_syndesc * as, void * rock);
101 static int VolQuery(struct cmd_syndesc * as, void * rock);
102 static int VolHdrQuery(struct cmd_syndesc * as, void * rock);
103 static int VolOpQuery(struct cmd_syndesc * as, void * rock);
104 static int StatsQuery(struct cmd_syndesc * as, void * rock);
105 static int VnQuery(struct cmd_syndesc * as, void * rock);
106
107 static void print_vol_stats_general(VolPkgStats * stats);
108 static void print_vol_stats_viceP(struct DiskPartitionStats64 * stats);
109 static void print_vol_stats_hash(struct VolumeHashChainStats * stats);
110 #ifdef AFS_DEMAND_ATTACH_FS
111 static void print_vol_stats_hdr(struct volume_hdr_LRU_stats * stats);
112 #endif
113
114 #ifndef AFS_NT40_ENV
115 #include "AFS_component_version_number.c"
116 #endif
117 #define MAX_ARGS 128
118
119 #define COMMON_PARMS_OFFSET    12
120 #define COMMON_PARMS(ts) \
121     cmd_Seek(ts, COMMON_PARMS_OFFSET); \
122     cmd_AddParm(ts, "-reason", CMD_SINGLE, CMD_OPTIONAL, "sync protocol reason code"); \
123     cmd_AddParm(ts, "-programtype", CMD_SINGLE, CMD_OPTIONAL, "program type code")
124
125 #define COMMON_VOLOP_PARMS_OFFSET    10
126 #define COMMON_VOLOP_PARMS(ts) \
127     cmd_Seek(ts, COMMON_VOLOP_PARMS_OFFSET); \
128     cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id"); \
129     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name")
130
131 #define CUSTOM_PARMS_OFFSET 1
132
133
134 #define VOLOP_PARMS_DECL(ts) \
135     COMMON_VOLOP_PARMS(ts); \
136     COMMON_PARMS(ts)
137 #define COMMON_PARMS_DECL(ts) \
138     COMMON_PARMS(ts)
139
140 int
141 main(int argc, char **argv)
142 {
143     struct cmd_syndesc *ts;
144     int err = 0;
145     int i;
146     extern char cml_version_number[];
147
148     /* Initialize directory paths */
149     if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
150 #ifdef AFS_NT40_ENV
151         ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
152 #endif
153         fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
154                 argv[0]);
155         exit(2);
156     }
157
158     
159     ts = cmd_CreateSyntax("online", VolOnline, NULL, "bring a volume online (FSYNC_VOL_ON opcode)");
160     VOLOP_PARMS_DECL(ts);
161
162     ts = cmd_CreateSyntax("offline", VolOffline, NULL, "take a volume offline (FSYNC_VOL_OFF opcode)");
163     VOLOP_PARMS_DECL(ts);
164
165     ts = cmd_CreateSyntax("mode", VolMode, NULL, "change volume attach mode (FSYNC_VOL_NEEDVOLUME opcode)");
166     VOLOP_PARMS_DECL(ts);
167     cmd_CreateAlias(ts, "needvolume");
168
169     ts = cmd_CreateSyntax("detach", VolDetach, NULL, "detach a volume (FSYNC_VOL_DONE opcode)");
170     VOLOP_PARMS_DECL(ts);
171
172     ts = cmd_CreateSyntax("callback", VolBreakCBKs, NULL, "break callbacks for volume (FSYNC_VOL_BREAKCBKS opcode)");
173     VOLOP_PARMS_DECL(ts);
174     cmd_CreateAlias(ts, "cbk");
175
176     ts = cmd_CreateSyntax("move", VolMove, NULL, "set volume moved flag (FSYNC_VOL_MOVE opcode)");
177     VOLOP_PARMS_DECL(ts);
178
179     ts = cmd_CreateSyntax("list", VolList, NULL, "sync local volume list (FSYNC_VOL_LISTVOLUMES opcode)");
180     VOLOP_PARMS_DECL(ts);
181     cmd_CreateAlias(ts, "ls");
182
183     ts = cmd_CreateSyntax("query", VolQuery, NULL, "get volume structure (FSYNC_VOL_QUERY opcode)");
184     VOLOP_PARMS_DECL(ts);
185     cmd_CreateAlias(ts, "qry");
186
187     ts = cmd_CreateSyntax("header", VolHdrQuery, NULL, "get volume disk data structure (FSYNC_VOL_QUERY_HDR opcode)");
188     VOLOP_PARMS_DECL(ts);
189     cmd_CreateAlias(ts, "hdr");
190
191     ts = cmd_CreateSyntax("volop", VolOpQuery, NULL, "get pending volume operation info (FSYNC_VOL_QUERY_VOP opcode)");
192     VOLOP_PARMS_DECL(ts);
193     cmd_CreateAlias(ts, "vop");
194
195     ts = cmd_CreateSyntax("vnode", VnQuery, NULL, "get vnode structure (FSYNC_VOL_QUERY_VNODE opcode)");
196     cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
197     cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id");
198     cmd_AddParm(ts, "-vnodeid", CMD_SINGLE, 0, "vnode id");
199     cmd_AddParm(ts, "-unique", CMD_SINGLE, 0, "uniquifier");
200     cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "paritition name");
201     COMMON_PARMS_DECL(ts);
202
203     ts = cmd_CreateSyntax("stats", StatsQuery, NULL, "see 'stats help' for more information");
204     cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
205     cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "subcommand");
206     cmd_AddParm(ts, "-arg1", CMD_SINGLE, CMD_OPTIONAL, "arg1");
207     cmd_AddParm(ts, "-arg2", CMD_SINGLE, CMD_OPTIONAL, "arg2");
208     COMMON_PARMS_DECL(ts);
209
210     err = cmd_Dispatch(argc, argv);
211     exit(err);
212 }
213
214 static int
215 common_prolog(struct cmd_syndesc * as, struct state * state)
216 {
217     register struct cmd_item *ti;
218
219 #ifdef AFS_NT40_ENV
220     if (afs_winsockInit() < 0) {
221         Exit(1);
222     }
223 #endif
224
225     VInitVolumePackage(debugUtility, 1, 1,
226                        DONT_CONNECT_FS, 0);
227     DInit(1);
228
229     if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) {  /* -reason */
230         state->reason = atoi(ti->data);
231     }
232     if ((ti = as->parms[COMMON_PARMS_OFFSET+1].items)) {        /* -programtype */
233         if (!strcmp(ti->data, "fileServer")) {
234             programType = fileServer;
235         } else if (!strcmp(ti->data, "volumeUtility")) {
236             programType = volumeUtility;
237         } else if (!strcmp(ti->data, "salvager")) {
238             programType = salvager;
239         } else if (!strcmp(ti->data, "salvageServer")) {
240             programType = salvageServer;
241         } else {
242             programType = (ProgramType) atoi(ti->data);
243         }
244     }
245
246     VConnectFS();
247
248     return 0;
249 }
250
251 static int
252 common_volop_prolog(struct cmd_syndesc * as, struct state * state)
253 {
254     register struct cmd_item *ti;
255     char pname[100], *temp;
256
257     state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
258     assert(state->vop != NULL);
259
260     if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET].items)) {    /* -volumeid */
261         state->vop->volume = atoi(ti->data);
262     } else {
263         fprintf(stderr, "required argument -volumeid not given\n");
264     }
265
266     if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET+1].items)) {  /* -partition */
267         strlcpy(state->vop->partName, ti->data, sizeof(state->vop->partName));
268     } else {
269         memset(state->vop->partName, 0, sizeof(state->vop->partName));
270     }
271
272     return 0;
273 }
274
275 static int
276 do_volop(struct state * state, afs_int32 command, SYNC_response * res)
277 {
278     afs_int32 code;
279     SYNC_PROTO_BUF_DECL(res_buf);
280     SYNC_response res_l;
281
282     if (!res) {
283         res = &res_l;
284         res->payload.len = SYNC_PROTO_MAX_LEN;
285         res->payload.buf = res_buf;
286     }
287
288     fprintf(stderr, "calling FSYNC_VolOp with command code %d (%s)\n", 
289             command, command_code_to_string(command));
290
291     code = FSYNC_VolOp(state->vop->volume,
292                        state->vop->partName,
293                        command,
294                        state->reason,
295                        res);
296
297     switch (code) {
298     case SYNC_OK:
299     case SYNC_DENIED:
300         break;
301     default:
302         fprintf(stderr, "possible sync protocol error. return code was %d\n", code);
303     }
304
305     fprintf(stderr, "FSYNC_VolOp returned %d (%s)\n", code, response_code_to_string(code));
306     fprintf(stderr, "protocol response code was %d (%s)\n", 
307             res->hdr.response, response_code_to_string(res->hdr.response));
308     fprintf(stderr, "protocol reason code was %d (%s)\n", 
309             res->hdr.reason, reason_code_to_string(res->hdr.reason));
310
311     VDisconnectFS();
312 }
313
314
315 #define ENUMTOSTRING(en)  #en
316 #define ENUMCASE(en) \
317     case en: \
318         return ENUMTOSTRING(en); \
319         break
320
321 #define FLAGTOSTRING(fl)  #fl
322 #define FLAGCASE(bitstr, fl, str, count) \
323     do { \
324         if ((bitstr) & (fl)) { \
325             if (count) \
326                 strlcat((str), " | ", sizeof(str)); \
327             strlcat((str), FLAGTOSTRING(fl), sizeof(str)); \
328             (count)++; \
329         } \
330     } while (0)
331
332 static char *
333 response_code_to_string(afs_int32 response)
334 {
335     switch (response) {
336         ENUMCASE(SYNC_OK);
337         ENUMCASE(SYNC_DENIED);
338         ENUMCASE(SYNC_COM_ERROR);
339         ENUMCASE(SYNC_BAD_COMMAND);
340         ENUMCASE(SYNC_FAILED);
341     default:
342         return "**UNKNOWN**";
343     }
344 }
345
346 static char *
347 command_code_to_string(afs_int32 command)
348 {
349     switch (command) {
350         ENUMCASE(SYNC_COM_CHANNEL_CLOSE);
351         ENUMCASE(FSYNC_VOL_ON);
352         ENUMCASE(FSYNC_VOL_OFF);
353         ENUMCASE(FSYNC_VOL_LISTVOLUMES);
354         ENUMCASE(FSYNC_VOL_NEEDVOLUME);
355         ENUMCASE(FSYNC_VOL_MOVE);
356         ENUMCASE(FSYNC_VOL_BREAKCBKS);
357         ENUMCASE(FSYNC_VOL_DONE);
358         ENUMCASE(FSYNC_VOL_QUERY);
359         ENUMCASE(FSYNC_VOL_QUERY_HDR);
360         ENUMCASE(FSYNC_VOL_QUERY_VOP);
361         ENUMCASE(FSYNC_VOL_STATS_GENERAL);
362         ENUMCASE(FSYNC_VOL_STATS_VICEP);
363         ENUMCASE(FSYNC_VOL_STATS_HASH);
364         ENUMCASE(FSYNC_VOL_STATS_HDR);
365         ENUMCASE(FSYNC_VOL_STATS_VLRU);
366         ENUMCASE(FSYNC_VOL_ATTACH);
367         ENUMCASE(FSYNC_VOL_FORCE_ERROR);
368         ENUMCASE(FSYNC_VOL_LEAVE_OFF);
369         ENUMCASE(FSYNC_VOL_QUERY_VNODE);
370     default:
371         return "**UNKNOWN**";
372     }
373 }
374
375 static char *
376 reason_code_to_string(afs_int32 reason)
377 {
378     switch (reason) {
379         ENUMCASE(SYNC_REASON_NONE);
380         ENUMCASE(SYNC_REASON_MALFORMED_PACKET);
381         ENUMCASE(SYNC_REASON_NOMEM);
382         ENUMCASE(SYNC_REASON_ENCODING_ERROR);
383         ENUMCASE(FSYNC_WHATEVER);
384         ENUMCASE(FSYNC_SALVAGE);
385         ENUMCASE(FSYNC_MOVE);
386         ENUMCASE(FSYNC_OPERATOR);
387         ENUMCASE(FSYNC_EXCLUSIVE);
388         ENUMCASE(FSYNC_UNKNOWN_VOLID);
389         ENUMCASE(FSYNC_HDR_NOT_ATTACHED);
390         ENUMCASE(FSYNC_NO_PENDING_VOL_OP);
391         ENUMCASE(FSYNC_VOL_PKG_ERROR);
392         ENUMCASE(FSYNC_UNKNOWN_VNID);
393     default:
394         return "**UNKNOWN**";
395     }
396 }
397
398 static char *
399 program_type_to_string(afs_int32 type)
400 {
401     switch ((ProgramType)type) {
402         ENUMCASE(fileServer);
403         ENUMCASE(volumeUtility);
404         ENUMCASE(salvager);
405         ENUMCASE(salvageServer);
406         ENUMCASE(debugUtility);
407     default:
408         return "**UNKNOWN**";
409     }
410 }
411
412 static int 
413 VolOnline(struct cmd_syndesc * as, void * rock)
414 {
415     struct state state;
416
417     common_prolog(as, &state);
418     common_volop_prolog(as, &state);
419
420     do_volop(&state, FSYNC_VOL_ON, NULL);
421
422     return 0;
423 }
424
425 static int 
426 VolOffline(struct cmd_syndesc * as, void * rock)
427 {
428     struct state state;
429
430     common_prolog(as, &state);
431     common_volop_prolog(as, &state);
432
433     do_volop(&state, FSYNC_VOL_OFF, NULL);
434
435     return 0;
436 }
437
438 static int
439 VolMode(struct cmd_syndesc * as, void * rock)
440 {
441     struct state state;
442
443     common_prolog(as, &state);
444     common_volop_prolog(as, &state);
445
446     do_volop(&state, FSYNC_VOL_NEEDVOLUME, NULL);
447
448     return 0;
449 }
450
451 static int
452 VolDetach(struct cmd_syndesc * as, void * rock)
453 {
454     struct state state;
455
456     common_prolog(as, &state);
457     common_volop_prolog(as, &state);
458
459     do_volop(&state, FSYNC_VOL_DONE, NULL);
460
461     return 0;
462 }
463
464 static int
465 VolBreakCBKs(struct cmd_syndesc * as, void * rock)
466 {
467     struct state state;
468
469     common_prolog(as, &state);
470     common_volop_prolog(as, &state);
471
472     do_volop(&state, FSYNC_VOL_BREAKCBKS, NULL);
473
474     return 0;
475 }
476
477 static int
478 VolMove(struct cmd_syndesc * as, void * rock)
479 {
480     struct state state;
481
482     common_prolog(as, &state);
483     common_volop_prolog(as, &state);
484
485     do_volop(&state, FSYNC_VOL_MOVE, NULL);
486
487     return 0;
488 }
489
490 static int
491 VolList(struct cmd_syndesc * as, void * rock)
492 {
493     struct state state;
494
495     common_prolog(as, &state);
496     common_volop_prolog(as, &state);
497
498     do_volop(&state, FSYNC_VOL_LISTVOLUMES, NULL);
499
500     return 0;
501 }
502
503 #ifdef AFS_DEMAND_ATTACH_FS
504 static char *
505 vol_state_to_string(VolState state)
506 {
507     switch (state) {
508         ENUMCASE(VOL_STATE_UNATTACHED);
509         ENUMCASE(VOL_STATE_PREATTACHED);
510         ENUMCASE(VOL_STATE_ATTACHING);
511         ENUMCASE(VOL_STATE_ATTACHED);
512         ENUMCASE(VOL_STATE_UPDATING);
513         ENUMCASE(VOL_STATE_GET_BITMAP);
514         ENUMCASE(VOL_STATE_HDR_LOADING);
515         ENUMCASE(VOL_STATE_HDR_ATTACHING);
516         ENUMCASE(VOL_STATE_SHUTTING_DOWN);
517         ENUMCASE(VOL_STATE_GOING_OFFLINE);
518         ENUMCASE(VOL_STATE_OFFLINING);
519         ENUMCASE(VOL_STATE_DETACHING);
520         ENUMCASE(VOL_STATE_SALVSYNC_REQ);
521         ENUMCASE(VOL_STATE_SALVAGING);
522         ENUMCASE(VOL_STATE_ERROR);
523         ENUMCASE(VOL_STATE_VNODE_ALLOC);
524         ENUMCASE(VOL_STATE_VNODE_GET);
525         ENUMCASE(VOL_STATE_VNODE_CLOSE);
526         ENUMCASE(VOL_STATE_VNODE_RELEASE);
527         ENUMCASE(VOL_STATE_VLRU_ADD);
528         ENUMCASE(VOL_STATE_FREED);
529     default:
530         return "**UNKNOWN**";
531     }
532 }
533
534 static char *
535 vol_flags_to_string(afs_uint16 flags)
536 {
537     static char str[128];
538     int count = 0;
539     str[0]='\0';
540
541     FLAGCASE(flags, VOL_HDR_ATTACHED, str, count);
542     FLAGCASE(flags, VOL_HDR_LOADED, str, count);
543     FLAGCASE(flags, VOL_HDR_IN_LRU, str, count);
544     FLAGCASE(flags, VOL_IN_HASH, str, count);
545     FLAGCASE(flags, VOL_ON_VBYP_LIST, str, count);
546     FLAGCASE(flags, VOL_IS_BUSY, str, count);
547     FLAGCASE(flags, VOL_ON_VLRU, str, count);
548     FLAGCASE(flags, VOL_HDR_DONTSALV, str, count);
549
550     return str;
551 }
552
553 static char *
554 vlru_idx_to_string(int idx)
555 {
556     switch (idx) {
557         ENUMCASE(VLRU_QUEUE_NEW);
558         ENUMCASE(VLRU_QUEUE_MID);
559         ENUMCASE(VLRU_QUEUE_OLD);
560         ENUMCASE(VLRU_QUEUE_CANDIDATE);
561         ENUMCASE(VLRU_QUEUE_HELD);
562         ENUMCASE(VLRU_QUEUE_INVALID);
563     default:
564         return "**UNKNOWN**";
565     }
566 }
567
568
569 static char *
570 vn_state_to_string(VnState state)
571 {
572     switch (state) {
573         ENUMCASE(VN_STATE_INVALID);
574         ENUMCASE(VN_STATE_RELEASING);
575         ENUMCASE(VN_STATE_CLOSING);
576         ENUMCASE(VN_STATE_ALLOC);
577         ENUMCASE(VN_STATE_ONLINE);
578         ENUMCASE(VN_STATE_LOAD);
579         ENUMCASE(VN_STATE_EXCLUSIVE);
580         ENUMCASE(VN_STATE_STORE);
581         ENUMCASE(VN_STATE_READ);
582         ENUMCASE(VN_STATE_ERROR);
583     default:
584         return "**UNKNOWN**";
585     }
586 }
587
588 static char *
589 vn_flags_to_string(afs_uint32 flags)
590 {
591     static char str[128];
592     int count = 0;
593     str[0]='\0';
594
595     FLAGCASE(flags, VN_ON_HASH, str, count);
596     FLAGCASE(flags, VN_ON_LRU, str, count);
597     FLAGCASE(flags, VN_ON_VVN, str, count);
598
599     return str;
600 }
601 #endif
602
603 static int
604 VolQuery(struct cmd_syndesc * as, void * rock)
605 {
606     struct state state;
607     SYNC_PROTO_BUF_DECL(res_buf);
608     SYNC_response res;
609     Volume v;
610     int hi, lo;
611
612     res.hdr.response_len = sizeof(res.hdr);
613     res.payload.buf = res_buf;
614     res.payload.len = SYNC_PROTO_MAX_LEN;
615
616     common_prolog(as, &state);
617     common_volop_prolog(as, &state);
618
619     do_volop(&state, FSYNC_VOL_QUERY, &res);
620
621     if (res.hdr.response == SYNC_OK) {
622         memcpy(&v, res.payload.buf, sizeof(Volume));
623
624         printf("volume = {\n");
625         printf("\thashid          = %u\n", v.hashid);
626         printf("\theader          = 0x%x\n", v.header);
627         printf("\tdevice          = %d\n", v.device);
628         printf("\tpartition       = 0x%x\n", v.partition);
629         printf("\tlinkHandle      = 0x%x\n", v.linkHandle);
630         printf("\tnextVnodeUnique = %u\n", v.nextVnodeUnique);
631         printf("\tdiskDataHandle  = 0x%x\n", v.diskDataHandle);
632         printf("\tvnodeHashOffset = %u\n", v.vnodeHashOffset);
633         printf("\tshuttingDown    = %d\n", v.shuttingDown);
634         printf("\tgoingOffline    = %d\n", v.goingOffline);
635         printf("\tcacheCheck      = %u\n", v.cacheCheck);
636         printf("\tnUsers          = %d\n", v.nUsers);
637         printf("\tneedsPutBack    = %d\n", v.needsPutBack);
638         printf("\tspecialStatus   = %d\n", v.specialStatus);
639         printf("\tupdateTime      = %u\n", v.updateTime);
640         
641         printf("\tvnodeIndex[vSmall] = {\n");
642         printf("\t\thandle       = 0x%x\n", v.vnodeIndex[vSmall].handle);
643         printf("\t\tbitmap       = 0x%x\n", v.vnodeIndex[vSmall].bitmap);
644         printf("\t\tbitmapSize   = %u\n", v.vnodeIndex[vSmall].bitmapSize);
645         printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vSmall].bitmapOffset);
646         printf("\t}\n");
647         printf("\tvnodeIndex[vLarge] = {\n");
648         printf("\t\thandle       = 0x%x\n", v.vnodeIndex[vLarge].handle);
649         printf("\t\tbitmap       = 0x%x\n", v.vnodeIndex[vLarge].bitmap);
650         printf("\t\tbitmapSize   = %u\n", v.vnodeIndex[vLarge].bitmapSize);
651         printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vLarge].bitmapOffset);
652         printf("\t}\n");
653 #ifdef AFS_DEMAND_ATTACH_FS
654         if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
655             printf("\tupdateTime      = %u\n", v.updateTime);
656             printf("\tattach_state    = %s\n", vol_state_to_string(v.attach_state));
657             printf("\tattach_flags    = %s\n", vol_flags_to_string(v.attach_flags));
658             printf("\tnWaiters        = %d\n", v.nWaiters);
659             printf("\tchainCacheCheck = %d\n", v.chainCacheCheck);
660             
661             /* online salvage structure */
662             printf("\tsalvage = {\n");
663             printf("\t\tprio      = %u\n", v.salvage.prio);
664             printf("\t\treason    = %d\n", v.salvage.reason);
665             printf("\t\trequested = %d\n", v.salvage.requested);
666             printf("\t\tscheduled = %d\n", v.salvage.scheduled);
667             printf("\t}\n");
668             
669             /* statistics structure */
670             printf("\tstats = {\n");
671
672             printf("\t\thash_lookups = {\n");
673             SplitInt64(v.stats.hash_lookups,hi,lo);
674             printf("\t\t\thi = %u\n", hi);
675             printf("\t\t\tlo = %u\n", lo);
676             printf("\t\t}\n");
677
678             printf("\t\thash_short_circuits = {\n");
679             SplitInt64(v.stats.hash_short_circuits,hi,lo);
680             printf("\t\t\thi = %u\n", hi);
681             printf("\t\t\tlo = %u\n", lo);
682             printf("\t\t}\n");
683
684             printf("\t\thdr_loads = {\n");
685             SplitInt64(v.stats.hdr_loads,hi,lo);
686             printf("\t\t\thi = %u\n", hi);
687             printf("\t\t\tlo = %u\n", lo);
688             printf("\t\t}\n");
689
690             printf("\t\thdr_gets = {\n");
691             SplitInt64(v.stats.hdr_gets,hi,lo);
692             printf("\t\t\thi = %u\n", hi);
693             printf("\t\t\tlo = %u\n", lo);
694             printf("\t\t}\n");
695             
696             printf("\t\tattaches         = %u\n", v.stats.attaches);
697             printf("\t\tsoft_detaches    = %u\n", v.stats.soft_detaches);
698             printf("\t\tsalvages         = %u\n", v.stats.salvages);
699             printf("\t\tvol_ops          = %u\n", v.stats.vol_ops);
700             
701             printf("\t\tlast_attach      = %u\n", v.stats.last_attach);
702             printf("\t\tlast_get         = %u\n", v.stats.last_get);
703             printf("\t\tlast_promote     = %u\n", v.stats.last_promote);
704             printf("\t\tlast_hdr_get     = %u\n", v.stats.last_hdr_get);
705             printf("\t\tlast_hdr_load    = %u\n", v.stats.last_hdr_load);
706             printf("\t\tlast_salvage     = %u\n", v.stats.last_salvage);
707             printf("\t\tlast_salvage_req = %u\n", v.stats.last_salvage_req);
708             printf("\t\tlast_vol_op      = %u\n", v.stats.last_vol_op);
709             printf("\t}\n");
710             
711             /* VLRU state */
712             printf("\tvlru = {\n");
713             printf("\t\tidx = %d (%s)\n", 
714                    v.vlru.idx, vlru_idx_to_string(v.vlru.idx));
715             printf("\t}\n");
716
717             /* volume op state */
718             printf("\tpending_vol_op  = 0x%x\n", v.pending_vol_op);
719         }
720 #else /* !AFS_DEMAND_ATTACH_FS */
721         if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
722             printf("*** server asserted demand attach extensions. fssync-debug not built to\n");
723             printf("*** recognize those extensions. please recompile fssync-debug if you need\n");
724             printf("*** to dump dafs extended state\n");
725         }
726 #endif /* !AFS_DEMAND_ATTACH_FS */
727         printf("}\n");
728     }
729
730     return 0;
731 }
732
733 static int
734 VolHdrQuery(struct cmd_syndesc * as, void * rock)
735 {
736     struct state state;
737     SYNC_PROTO_BUF_DECL(res_buf);
738     SYNC_response res;
739     VolumeDiskData v;
740     int i;
741
742     res.hdr.response_len = sizeof(res.hdr);
743     res.payload.buf = res_buf;
744     res.payload.len = SYNC_PROTO_MAX_LEN;
745
746     common_prolog(as, &state);
747     common_volop_prolog(as, &state);
748
749     do_volop(&state, FSYNC_VOL_QUERY_HDR, &res);
750
751     if (res.hdr.response == SYNC_OK) {
752         memcpy(&v, res.payload.buf, sizeof(VolumeDiskData));
753
754         printf("VolumeDiskData = {\n");
755         printf("\tstamp = {\n");
756         printf("\t\tmagic   = 0x%x\n", v.stamp.magic);
757         printf("\t\tversion = %u\n", v.stamp.version);
758         printf("\t}\n");
759         
760         printf("\tid               = %u\n", v.id);
761         printf("\tname             = '%s'\n", v.name);
762         printf("\tinUse            = %d\n", v.inUse);
763         printf("\tinService        = %d\n", v.inService);
764         printf("\tblessed          = %d\n", v.blessed);
765         printf("\tneedsSalvaged    = %d\n", v.needsSalvaged);
766         printf("\tuniquifier       = %u\n", v.uniquifier);
767         printf("\ttype             = %d\n", v.type);
768         printf("\tparentId         = %u\n", v.parentId);
769         printf("\tcloneId          = %u\n", v.cloneId);
770         printf("\tbackupId         = %u\n", v.backupId);
771         printf("\trestoredFromId   = %u\n", v.restoredFromId);
772         printf("\tneedsCallback    = %d\n", v.needsCallback);
773         printf("\tdestroyMe        = %d\n", v.destroyMe);
774         printf("\tdontSalvage      = %d\n", v.dontSalvage);
775         printf("\tmaxquota         = %d\n", v.maxquota);
776         printf("\tminquota         = %d\n", v.minquota);
777         printf("\tmaxfiles         = %d\n", v.maxfiles);
778         printf("\taccountNumber    = %u\n", v.accountNumber);
779         printf("\towner            = %u\n", v.owner);
780         printf("\tfilecount        = %d\n", v.filecount);
781         printf("\tdiskused         = %d\n", v.diskused);
782         printf("\tdayUse           = %d\n", v.dayUse);
783         for (i = 0; i < 7; i++) {
784             printf("\tweekUse[%d]       = %d\n", i, v.weekUse[i]);
785         }
786         printf("\tdayUseDate       = %u\n", v.dayUseDate);
787         printf("\tcreationDate     = %u\n", v.creationDate);
788         printf("\taccessDate       = %u\n", v.accessDate);
789         printf("\tupdateDate       = %u\n", v.updateDate);
790         printf("\texpirationDate   = %u\n", v.expirationDate);
791         printf("\tbackupDate       = %u\n", v.backupDate);
792         printf("\tcopyDate         = %u\n", v.copyDate);
793 #ifdef OPENAFS_VOL_STATS
794         printf("\tstat_initialized = %d\n", v.stat_initialized);
795 #else
796         printf("\tmtd              = '%s'\n", v.motd);
797 #endif
798         printf("}\n");
799     }
800
801     return 0;
802 }
803
804 static int
805 VolOpQuery(struct cmd_syndesc * as, void * rock)
806 {
807     struct state state;
808     SYNC_PROTO_BUF_DECL(res_buf);
809     SYNC_response res;
810     FSSYNC_VolOp_info vop;
811     int i;
812
813     res.hdr.response_len = sizeof(res.hdr);
814     res.payload.buf = res_buf;
815     res.payload.len = SYNC_PROTO_MAX_LEN;
816
817     common_prolog(as, &state);
818     common_volop_prolog(as, &state);
819
820     do_volop(&state, FSYNC_VOL_QUERY_VOP, &res);
821
822     if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
823         printf("*** file server not compiled with demand attach extensions.\n");
824         printf("*** pending volume operation metadata not available.\n");
825     }
826
827     if (res.hdr.response == SYNC_OK) {
828         memcpy(&vop, res.payload.buf, sizeof(FSSYNC_VolOp_info));
829
830         printf("pending_vol_op = {\n");
831
832         printf("\tcom = {\n");
833         printf("\t\tproto_version  = %u\n", vop.com.proto_version);
834         printf("\t\tprogramType    = %d (%s)\n", 
835                vop.com.programType, program_type_to_string(vop.com.programType));
836         printf("\t\tcommand        = %d (%s)\n", 
837                vop.com.command, command_code_to_string(vop.com.command));
838         printf("\t\treason         = %d (%s)\n", 
839                vop.com.reason, reason_code_to_string(vop.com.reason));
840         printf("\t\tcommand_len    = %u\n", vop.com.command_len);
841         printf("\t\tflags          = 0x%x\n", vop.com.flags);
842         printf("\t}\n");
843
844         printf("\tvop = {\n");
845         printf("\t\tvolume         = %u\n", vop.vop.volume);
846         if (afs_strnlen(vop.vop.partName, sizeof(vop.vop.partName)) <
847             sizeof(vop.vop.partName)) {
848             printf("\t\tpartName       = '%s'\n", vop.vop.partName);
849         } else {
850             printf("\t\tpartName       = (illegal string)\n");
851         }
852         printf("\t}\n");
853
854         printf("}\n");
855     }
856
857     return 0;
858 }
859
860 static int
861 vn_prolog(struct cmd_syndesc * as, struct state * state)
862 {
863     register struct cmd_item *ti;
864     char pname[100], *temp;
865
866     state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
867     assert(state->vop != NULL);
868
869     if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) {  /* -volumeid */
870         state->vop->volume = atoi(ti->data);
871     } else {
872         fprintf(stderr, "required argument -volumeid not given\n");
873     }
874
875     if ((ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) {        /* -vnodeid */
876         state->vop->vnode = atoi(ti->data);
877     } else {
878         fprintf(stderr, "required argument -vnodeid not given\n");
879     }
880
881     if ((ti = as->parms[CUSTOM_PARMS_OFFSET+2].items)) {        /* -unique */
882         state->vop->unique = atoi(ti->data);
883     } else {
884         state->vop->unique = 0;
885     }
886
887     if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET+3].items)) {  /* -partition */
888         strlcpy(state->vop->partName, ti->data, sizeof(state->vop->partName));
889     } else {
890         memset(state->vop->partName, 0, sizeof(state->vop->partName));
891     }
892
893     return 0;
894 }
895
896 static int
897 do_vnqry(struct state * state, SYNC_response * res)
898 {
899     afs_int32 code;
900     int command = FSYNC_VOL_QUERY_VNODE;
901     FSSYNC_VnQry_hdr qry;
902
903     qry.volume = state->vop->volume;
904     qry.vnode = state->vop->vnode;
905     qry.unique = state->vop->unique;
906     qry.spare = 0;
907     strlcpy(qry.partName, state->vop->partName, sizeof(qry.partName));
908
909     fprintf(stderr, "calling FSYNC_GenericOp with command code %d (%s)\n", 
910             command, command_code_to_string(command));
911
912     code = FSYNC_GenericOp(&qry, sizeof(qry), command, FSYNC_OPERATOR, res);
913
914     switch (code) {
915     case SYNC_OK:
916     case SYNC_DENIED:
917         break;
918     default:
919         fprintf(stderr, "possible sync protocol error. return code was %d\n", code);
920     }
921
922     fprintf(stderr, "FSYNC_GenericOp returned %d (%s)\n", code, response_code_to_string(code));
923     fprintf(stderr, "protocol response code was %d (%s)\n", 
924             res->hdr.response, response_code_to_string(res->hdr.response));
925     fprintf(stderr, "protocol reason code was %d (%s)\n", 
926             res->hdr.reason, reason_code_to_string(res->hdr.reason));
927
928     VDisconnectFS();
929
930     return 0;
931 }
932
933 static int
934 VnQuery(struct cmd_syndesc * as, void * rock)
935 {
936     struct state state;
937     SYNC_PROTO_BUF_DECL(res_buf);
938     SYNC_response res;
939     Vnode v;
940     int hi, lo;
941
942     res.hdr.response_len = sizeof(res.hdr);
943     res.payload.buf = res_buf;
944     res.payload.len = SYNC_PROTO_MAX_LEN;
945
946     common_prolog(as, &state);
947     vn_prolog(as, &state);
948
949     do_vnqry(&state, &res);
950
951     if (res.hdr.response == SYNC_OK) {
952         memcpy(&v, res.payload.buf, sizeof(Volume));
953
954         printf("vnode = {\n");
955
956         printf("\tvid_hash = {\n");
957         printf("\t\tnext = 0x%lx\n", v.vid_hash.next);
958         printf("\t\tprev = 0x%lx\n", v.vid_hash.prev);
959         printf("\t}\n");
960
961         printf("\thashNext        = 0x%lx\n", v.hashNext);
962         printf("\tlruNext         = 0x%lx\n", v.lruNext);
963         printf("\tlruPrev         = 0x%lx\n", v.lruPrev);
964         printf("\thashIndex       = %hu\n", v.hashIndex);
965         printf("\tchanged_newTime = %u\n", (unsigned int) v.changed_newTime);
966         printf("\tchanged_oldTime = %u\n", (unsigned int) v.changed_oldTime);
967         printf("\tdelete          = %u\n", (unsigned int) v.delete);
968         printf("\tvnodeNumber     = %u\n", v.vnodeNumber);
969         printf("\tvolumePtr       = 0x%lx\n", v.volumePtr);
970         printf("\tnUsers          = %u\n", v.nUsers);
971         printf("\tcacheCheck      = %u\n", v.cacheCheck);
972
973 #ifdef AFS_DEMAND_ATTACH_FS
974         if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
975             printf("*** fssync-debug built to expect demand attach extensions.  server asserted\n");
976             printf("*** that it was not compiled with demand attach turned on.  please recompile\n");
977             printf("*** fssync-debug to match your server\n");
978             goto done;
979         }
980
981         printf("\tnReaders        = %u\n", v.nReaders);
982         printf("\tvn_state_flags  = %s\n", vn_flags_to_string(v.vn_state_flags));
983         printf("\tvn_state        = %s\n", vn_state_to_string(v.vn_state));
984 #else
985         if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
986             printf("*** server asserted demand attach extensions. fssync-debug not built to\n");
987             printf("*** recognize those extensions. please recompile fssync-debug if you need\n");
988             printf("*** to dump dafs extended state\n");
989             goto done;
990         }
991 #endif /* !AFS_DEMAND_ATTACH_FS */
992
993         printf("\twriter          = %u\n", v.writer);
994         printf("\tvcp             = 0x%lx\n", v.vcp);
995         printf("\thandle          = 0x%lx\n", v.handle);
996
997         printf("\tdisk = {\n");
998         printf("\t\ttype              = %u\n", v.disk.type);
999         printf("\t\tcloned            = %u\n", v.disk.cloned);
1000         printf("\t\tmodeBits          = %u\n", v.disk.modeBits);
1001         printf("\t\tlinkCount         = %d\n", v.disk.linkCount);
1002         printf("\t\tlength            = %u\n", v.disk.length);
1003         printf("\t\tuniquifier        = %u\n", v.disk.uniquifier);
1004         printf("\t\tdataVersion       = %u\n", v.disk.dataVersion);
1005         printf("\t\tvn_ino_lo         = %u\n", v.disk.vn_ino_lo);
1006         printf("\t\tunixModifyTime    = %u\n", v.disk.unixModifyTime);
1007         printf("\t\tauthor            = %u\n", v.disk.author);
1008         printf("\t\towner             = %u\n", v.disk.owner);
1009         printf("\t\tparent            = %u\n", v.disk.parent);
1010         printf("\t\tvnodeMagic        = %u\n", v.disk.vnodeMagic);
1011
1012         printf("\t\tlock = {\n");
1013         printf("\t\t\tlockCount   = %d\n", v.disk.lock.lockCount);
1014         printf("\t\t\tlockTime    = %d\n", v.disk.lock.lockTime);
1015         printf("\t\t}\n");
1016
1017         printf("\t\tserverModifyTime  = %u\n", v.disk.serverModifyTime);
1018         printf("\t\tgroup             = %d\n", v.disk.group);
1019         printf("\t\tvn_ino_hi         = %d\n", v.disk.vn_ino_hi);
1020         printf("\t\treserved6         = %u\n", v.disk.reserved6);
1021         printf("\t}\n");
1022
1023         printf("}\n");
1024     }
1025
1026  done:
1027     return 0;
1028 }
1029
1030
1031 static int
1032 StatsQuery(struct cmd_syndesc * as, void * rock)
1033 {
1034     afs_int32 code;
1035     int command;
1036     struct cmd_item *ti;
1037     struct state state;
1038     SYNC_PROTO_BUF_DECL(res_buf);
1039     SYNC_response res;
1040     FSSYNC_StatsOp_hdr scom;
1041     union {
1042         void * ptr;
1043         struct VolPkgStats * vol_stats;
1044         struct VolumeHashChainStats * hash_stats;
1045 #ifdef AFS_DEMAND_ATTACH_FS
1046         struct volume_hdr_LRU_stats * hdr_stats;
1047 #endif
1048         struct DiskPartitionStats64 * vicep_stats;
1049     } sres;
1050
1051     sres.ptr = res_buf;
1052     res.hdr.response_len = sizeof(res.hdr);
1053     res.payload.buf = res_buf;
1054     res.payload.len = SYNC_PROTO_MAX_LEN;
1055
1056     if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) {  /* -subcommand */
1057         if (!strcasecmp(ti->data, "vicep")) {
1058             command = FSYNC_VOL_STATS_VICEP;
1059         } else if (!strcasecmp(ti->data, "hash")) {
1060             command = FSYNC_VOL_STATS_HASH;
1061 #ifdef AFS_DEMAND_ATTACH_FS
1062         } else if (!strcasecmp(ti->data, "hdr")) {
1063             command = FSYNC_VOL_STATS_HDR;
1064         } else if (!strcasecmp(ti->data, "vlru")) {
1065             command = FSYNC_VOL_STATS_VLRU;
1066 #endif
1067         } else if (!strcasecmp(ti->data, "pkg")) {
1068             command = FSYNC_VOL_STATS_GENERAL;
1069         } else if (!strcasecmp(ti->data, "help")) {
1070             fprintf(stderr, "fssync-debug stats subcommands:\n");
1071             fprintf(stderr, "\tpkg\tgeneral volume package stats\n");
1072             fprintf(stderr, "\tvicep\tvice partition stats\n");
1073             fprintf(stderr, "\thash\tvolume hash chain stats\n");
1074 #ifdef AFS_DEMAND_ATTACH_FS
1075             fprintf(stderr, "\thdr\tvolume header cache stats\n");
1076             fprintf(stderr, "\tvlru\tvlru generation stats\n");
1077 #endif
1078             exit(0);
1079         } else {
1080             fprintf(stderr, "invalid stats subcommand");
1081             exit(1);
1082         }
1083     } else {
1084         command = FSYNC_VOL_STATS_GENERAL;
1085     }
1086
1087     if ((ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) {        /* -arg1 */
1088         switch (command) {
1089         case FSYNC_VOL_STATS_VICEP:
1090             strlcpy(scom.args.partName, ti->data, sizeof(state.vop->partName));
1091             break;
1092         case FSYNC_VOL_STATS_HASH:
1093             scom.args.hash_bucket = atoi(ti->data);
1094             break;
1095         case FSYNC_VOL_STATS_VLRU:
1096             scom.args.vlru_generation = atoi(ti->data);
1097             break;
1098         default:
1099             fprintf(stderr, "unrecognized arguments\n");
1100             exit(1);
1101         }
1102     } else {
1103         switch (command) {
1104         case FSYNC_VOL_STATS_VICEP:
1105         case FSYNC_VOL_STATS_HASH:
1106         case FSYNC_VOL_STATS_VLRU:
1107             fprintf(stderr, "this subcommand requires more parameters\n");
1108             exit(1);
1109         }
1110     }
1111
1112     common_prolog(as, &state);
1113
1114     fprintf(stderr, "calling FSYNC_askfs with command code %d (%s)\n", 
1115             command, command_code_to_string(command));
1116
1117     code = FSYNC_StatsOp(&scom, command, FSYNC_WHATEVER, &res);
1118
1119     switch (code) {
1120     case SYNC_OK:
1121     case SYNC_DENIED:
1122         break;
1123     default:
1124         fprintf(stderr, "possible sync protocol error. return code was %d\n", code);
1125     }
1126
1127     fprintf(stderr, "FSYNC_VolOp returned %d (%s)\n", code, response_code_to_string(code));
1128     fprintf(stderr, "protocol response code was %d (%s)\n", 
1129             res.hdr.response, response_code_to_string(res.hdr.response));
1130     fprintf(stderr, "protocol reason code was %d (%s)\n", 
1131             res.hdr.reason, reason_code_to_string(res.hdr.reason));
1132
1133     VDisconnectFS();
1134
1135     if (res.hdr.response == SYNC_OK) {
1136         switch (command) {
1137         case FSYNC_VOL_STATS_GENERAL:
1138             print_vol_stats_general(sres.vol_stats);
1139             break;
1140         case FSYNC_VOL_STATS_VICEP:
1141             print_vol_stats_viceP(sres.vicep_stats);
1142             break;
1143         case FSYNC_VOL_STATS_HASH:
1144             print_vol_stats_hash(sres.hash_stats);
1145             break;
1146 #ifdef AFS_DEMAND_ATTACH_FS
1147         case FSYNC_VOL_STATS_HDR:
1148             print_vol_stats_hdr(sres.hdr_stats);
1149             break;
1150 #endif /* AFS_DEMAND_ATTACH_FS */
1151         }
1152     }
1153
1154     return 0;
1155 }
1156
1157 static void
1158 print_vol_stats_general(VolPkgStats * stats)
1159 {
1160     int i;
1161     afs_uint32 hi, lo;
1162
1163     printf("VolPkgStats = {\n");
1164 #ifdef AFS_DEMAND_ATTACH_FS
1165     for (i = 0; i < VOL_STATE_COUNT; i++) {
1166         printf("\tvol_state_count[%s] = %d\n", 
1167                vol_state_to_string(i),
1168                stats->state_levels[i]);
1169     }
1170
1171     SplitInt64(stats->hash_looks, hi, lo);
1172     printf("\thash_looks = {\n");
1173     printf("\t\thi = %u\n", hi);
1174     printf("\t\tlo = %u\n", lo);
1175     printf("\t}\n");
1176
1177     SplitInt64(stats->hash_reorders, hi, lo);
1178     printf("\thash_reorders = {\n");
1179     printf("\t\thi = %u\n", hi);
1180     printf("\t\tlo = %u\n", lo);
1181     printf("\t}\n");
1182
1183     SplitInt64(stats->salvages, hi, lo);
1184     printf("\tsalvages = {\n");
1185     printf("\t\thi = %u\n", hi);
1186     printf("\t\tlo = %u\n", lo);
1187     printf("\t}\n");
1188
1189     SplitInt64(stats->vol_ops, hi, lo);
1190     printf("\tvol_ops = {\n");
1191     printf("\t\thi = %u\n", hi);
1192     printf("\t\tlo = %u\n", lo);
1193     printf("\t}\n");
1194 #endif
1195     SplitInt64(stats->hdr_loads, hi, lo);
1196     printf("\thdr_loads = {\n");
1197     printf("\t\thi = %u\n", hi);
1198     printf("\t\tlo = %u\n", lo);
1199     printf("\t}\n");
1200
1201     SplitInt64(stats->hdr_gets, hi, lo);
1202     printf("\thdr_gets = {\n");
1203     printf("\t\thi = %u\n", hi);
1204     printf("\t\tlo = %u\n", lo);
1205     printf("\t}\n");
1206
1207     SplitInt64(stats->attaches, hi, lo);
1208     printf("\tattaches = {\n");
1209     printf("\t\thi = %u\n", hi);
1210     printf("\t\tlo = %u\n", lo);
1211     printf("\t}\n");
1212
1213     SplitInt64(stats->soft_detaches, hi, lo);
1214     printf("\tsoft_detaches = {\n");
1215     printf("\t\thi = %u\n", hi);
1216     printf("\t\tlo = %u\n", lo);
1217     printf("\t}\n");
1218
1219     printf("\thdr_cache_size = %d\n", stats->hdr_cache_size);
1220             
1221     printf("}\n");
1222 }
1223
1224 static void
1225 print_vol_stats_viceP(struct DiskPartitionStats64 * stats)
1226 {
1227     printf("DiskPartitionStats64 = {\n");
1228     printf("\tfree = %lld\n", stats->free);
1229     printf("\tminFree = %lld\n", stats->minFree);
1230     printf("\ttotalUsable = %lld\n", stats->totalUsable);
1231     printf("\tf_files = %lld\n", stats->f_files);
1232 #ifdef AFS_DEMAND_ATTACH_FS
1233     printf("\tvol_list_len = %d\n", stats->vol_list_len);
1234 #endif
1235     printf("}\n");
1236 }
1237
1238 static void
1239 print_vol_stats_hash(struct VolumeHashChainStats * stats)
1240 {
1241     afs_uint32 hi, lo;
1242
1243     printf("DiskPartitionStats = {\n");
1244     printf("\ttable_size = %d\n", stats->table_size);
1245     printf("\tchain_len = %d\n", stats->chain_len);
1246
1247 #ifdef AFS_DEMAND_ATTACH_FS
1248     printf("\tchain_cacheCheck = %d\n", stats->chain_cacheCheck);
1249     printf("\tchain_busy = %d\n", stats->chain_busy);
1250
1251     SplitInt64(stats->chain_looks, hi, lo);
1252     printf("\tchain_looks = {\n");
1253     printf("\t\thi = %u\n", hi);
1254     printf("\t\tlo = %u\n", lo);
1255     printf("\t}\n");
1256
1257     SplitInt64(stats->chain_gets, hi, lo);
1258     printf("\tchain_gets = {\n");
1259     printf("\t\thi = %u\n", hi);
1260     printf("\t\tlo = %u\n", lo);
1261     printf("\t}\n");
1262
1263     SplitInt64(stats->chain_reorders, hi, lo);
1264     printf("\tchain_reorders = {\n");
1265     printf("\t\thi = %u\n", hi);
1266     printf("\t\tlo = %u\n", lo);
1267     printf("\t}\n");
1268 #endif /* AFS_DEMAND_ATTACH_FS */
1269
1270     printf("}\n");
1271 }
1272
1273
1274 #ifdef AFS_DEMAND_ATTACH_FS
1275 static void
1276 print_vol_stats_hdr(struct volume_hdr_LRU_stats * stats)
1277 {
1278     printf("volume_hdr_LRU_stats = {\n");
1279     printf("\tfree = %d\n", stats->free);
1280     printf("\tused = %d\n", stats->used);
1281     printf("\tattached = %d\n", stats->attached);
1282     printf("}\n");
1283 }
1284 #endif /* AFS_DEMAND_ATTACH_FS */
1285