2 * Copyright 2006-2010, 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
10 /* Main program file. Define globals. */
14 * fssync administration tool
18 #include <afsconfig.h>
19 #include <afs/param.h>
32 #include <WINNT/afsevent.h>
34 #include <sys/param.h>
38 #endif /* ITIMER_REAL */
41 #include <afs/afsint.h>
42 #include <afs/afs_assert.h>
47 #include <afs/osi_inode.h>
52 #include <afs/afsutil.h>
53 #include <afs/fileutil.h>
61 #include "volume_inline.h"
62 #include "partition.h"
63 #include "daemon_com.h"
64 #include "daemon_com_inline.h"
66 #include "fssync_inline.h"
72 int VolumeChanged; /* hack to make dir package happy */
84 struct volop_state * vop;
87 #ifndef AFS_DEMAND_ATTACH_FS
88 /* remember argv/argc for later, if we need to re-exec */
89 static char **fssd_argv;
93 static int common_prolog(struct cmd_syndesc *, struct state *);
94 static int common_volop_prolog(struct cmd_syndesc *, struct state *);
96 static int do_volop(struct state *, afs_int32 command, SYNC_response * res);
98 static int VolOnline(struct cmd_syndesc * as, void * rock);
99 static int VolOffline(struct cmd_syndesc * as, void * rock);
100 static int VolMode(struct cmd_syndesc * as, void * rock);
101 static int VolDetach(struct cmd_syndesc * as, void * rock);
102 static int VolBreakCBKs(struct cmd_syndesc * as, void * rock);
103 static int VolMove(struct cmd_syndesc * as, void * rock);
104 static int VolList(struct cmd_syndesc * as, void * rock);
105 static int VolLeaveOff(struct cmd_syndesc * as, void * rock);
106 static int VolForceAttach(struct cmd_syndesc * as, void * rock);
107 static int VolForceError(struct cmd_syndesc * as, void * rock);
108 static int VolQuery(struct cmd_syndesc * as, void * rock);
109 static int VolHdrQuery(struct cmd_syndesc * as, void * rock);
110 static int VolOpQuery(struct cmd_syndesc * as, void * rock);
111 static int StatsQuery(struct cmd_syndesc * as, void * rock);
112 static int VnQuery(struct cmd_syndesc * as, void * rock);
114 static int VGCQuery(struct cmd_syndesc * as, void * rock);
115 static int VGCAdd(struct cmd_syndesc * as, void * rock);
116 static int VGCDel(struct cmd_syndesc * as, void * rock);
117 static int VGCScan(struct cmd_syndesc * as, void * rock);
118 static int VGCScanAll(struct cmd_syndesc * as, void * rock);
120 static void print_vol_stats_general(VolPkgStats * stats);
121 static void print_vol_stats_viceP(struct DiskPartitionStats64 * stats);
122 static void print_vol_stats_hash(struct VolumeHashChainStats * stats);
123 #ifdef AFS_DEMAND_ATTACH_FS
124 static void print_vol_stats_hdr(struct volume_hdr_LRU_stats * stats);
128 #include "AFS_component_version_number.c"
132 #define COMMON_PARMS_OFFSET 12
133 #define COMMON_PARMS(ts) \
134 cmd_Seek(ts, COMMON_PARMS_OFFSET); \
135 cmd_AddParm(ts, "-reason", CMD_SINGLE, CMD_OPTIONAL, "sync protocol reason code"); \
136 cmd_AddParm(ts, "-programtype", CMD_SINGLE, CMD_OPTIONAL, "program type code")
138 #define COMMON_VOLOP_PARMS_OFFSET 10
139 #define COMMON_VOLOP_PARMS(ts) \
140 cmd_Seek(ts, COMMON_VOLOP_PARMS_OFFSET); \
141 cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id"); \
142 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name")
144 #define CUSTOM_PARMS_OFFSET 1
147 #define VOLOP_PARMS_DECL(ts) \
148 COMMON_VOLOP_PARMS(ts); \
150 #define COMMON_PARMS_DECL(ts) \
154 main(int argc, char **argv)
156 struct cmd_syndesc *ts;
159 /* Initialize directory paths */
160 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
162 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
164 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
169 #ifndef AFS_DEMAND_ATTACH_FS
174 ts = cmd_CreateSyntax("online", VolOnline, NULL, "bring a volume online (FSYNC_VOL_ON opcode)");
175 VOLOP_PARMS_DECL(ts);
177 ts = cmd_CreateSyntax("offline", VolOffline, NULL, "take a volume offline (FSYNC_VOL_OFF opcode)");
178 VOLOP_PARMS_DECL(ts);
180 ts = cmd_CreateSyntax("mode", VolMode, NULL, "change volume attach mode (FSYNC_VOL_NEEDVOLUME opcode)");
181 VOLOP_PARMS_DECL(ts);
182 cmd_CreateAlias(ts, "needvolume");
184 ts = cmd_CreateSyntax("detach", VolDetach, NULL, "detach a volume (FSYNC_VOL_DONE opcode)");
185 VOLOP_PARMS_DECL(ts);
187 ts = cmd_CreateSyntax("callback", VolBreakCBKs, NULL, "break callbacks for volume (FSYNC_VOL_BREAKCBKS opcode)");
188 VOLOP_PARMS_DECL(ts);
189 cmd_CreateAlias(ts, "cbk");
191 ts = cmd_CreateSyntax("move", VolMove, NULL, "set volume moved flag (FSYNC_VOL_MOVE opcode)");
192 VOLOP_PARMS_DECL(ts);
194 ts = cmd_CreateSyntax("list", VolList, NULL, "sync local volume list (FSYNC_VOL_LISTVOLUMES opcode)");
195 VOLOP_PARMS_DECL(ts);
196 cmd_CreateAlias(ts, "ls");
198 ts = cmd_CreateSyntax("leaveoff", VolLeaveOff, 0, "leave volume offline (FSYNC_VOL_LEAVE_OFF opcode)");
199 VOLOP_PARMS_DECL(ts);
201 ts = cmd_CreateSyntax("attach", VolForceAttach, 0, "force full attachment (FSYNC_VOL_ATTACH opcode)");
202 VOLOP_PARMS_DECL(ts);
204 ts = cmd_CreateSyntax("error", VolForceError, 0, "force into hard error state (FSYNC_VOL_FORCE_ERROR opcode)");
205 VOLOP_PARMS_DECL(ts);
207 ts = cmd_CreateSyntax("query", VolQuery, NULL, "get volume structure (FSYNC_VOL_QUERY opcode)");
208 VOLOP_PARMS_DECL(ts);
209 cmd_CreateAlias(ts, "qry");
211 ts = cmd_CreateSyntax("header", VolHdrQuery, NULL, "get volume disk data structure (FSYNC_VOL_QUERY_HDR opcode)");
212 VOLOP_PARMS_DECL(ts);
213 cmd_CreateAlias(ts, "hdr");
215 ts = cmd_CreateSyntax("volop", VolOpQuery, NULL, "get pending volume operation info (FSYNC_VOL_QUERY_VOP opcode)");
216 VOLOP_PARMS_DECL(ts);
217 cmd_CreateAlias(ts, "vop");
219 ts = cmd_CreateSyntax("vnode", VnQuery, NULL, "get vnode structure (FSYNC_VOL_QUERY_VNODE opcode)");
220 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
221 cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id");
222 cmd_AddParm(ts, "-vnodeid", CMD_SINGLE, 0, "vnode id");
223 cmd_AddParm(ts, "-unique", CMD_SINGLE, 0, "uniquifier");
224 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
225 COMMON_PARMS_DECL(ts);
227 ts = cmd_CreateSyntax("stats", StatsQuery, NULL, "see 'stats help' for more information");
228 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
229 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "subcommand");
230 cmd_AddParm(ts, "-arg1", CMD_SINGLE, CMD_OPTIONAL, "arg1");
231 cmd_AddParm(ts, "-arg2", CMD_SINGLE, CMD_OPTIONAL, "arg2");
232 COMMON_PARMS_DECL(ts);
234 ts = cmd_CreateSyntax("vgcquery", VGCQuery, 0, "query volume group cache (FSYNC_VG_QUERY opcode)");
235 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
236 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
237 cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id");
238 COMMON_PARMS_DECL(ts);
239 cmd_CreateAlias(ts, "vgcqry");
241 ts = cmd_CreateSyntax("vgcadd", VGCAdd, 0, "add entry to volume group cache (FSYNC_VG_ADD opcode)");
242 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
243 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
244 cmd_AddParm(ts, "-parent", CMD_SINGLE, 0, "parent volume id");
245 cmd_AddParm(ts, "-child", CMD_SINGLE, 0, "child volume id");
246 COMMON_PARMS_DECL(ts);
248 ts = cmd_CreateSyntax("vgcdel", VGCDel, 0, "delete entry from volume group cache (FSYNC_VG_DEL opcode)");
249 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
250 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
251 cmd_AddParm(ts, "-parent", CMD_SINGLE, 0, "parent volume id");
252 cmd_AddParm(ts, "-child", CMD_SINGLE, 0, "child volume id");
253 COMMON_PARMS_DECL(ts);
255 ts = cmd_CreateSyntax("vgcscan", VGCScan, 0,
256 "start volume group cache re-scan"
257 " (FSYNC_VG_SCAN opcode)");
258 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
259 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
260 COMMON_PARMS_DECL(ts);
262 ts = cmd_CreateSyntax("vgcscanall", VGCScanAll, 0,
263 "start whole-server volume group cache re-scan"
264 " (FSYNC_VG_SCAN_ALL opcode)");
265 COMMON_PARMS_DECL(ts);
267 err = cmd_Dispatch(argc, argv);
271 #ifdef AFS_DEMAND_ATTACH_FS
272 # define dafs_prolog()
274 /* Try to detect if the fileserver is DAFS, and if so, re-exec as the
275 * DAFS-enabled fssync-debug (dafssync_debug). If we fail to detect or
276 * exec, just try to proceed anyway as if the server is not DAFS */
281 SYNC_PROTO_BUF_DECL(res_buf);
285 res.payload.len = SYNC_PROTO_MAX_LEN;
286 res.payload.buf = res_buf;
288 /* LISTVOLUMES is a no-op; we just want to get the response header flags
289 * to see if the server reports itself as DAFS or not */
290 code = FSYNC_VolOp(0, NULL, FSYNC_VOL_LISTVOLUMES, FSYNC_WHATEVER, &res);
292 /* probably failed to contact the fileserver; later code will provide
293 * some warning/error indication */
297 if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
298 /* fileserver is not DAFS, so we don't need to do anything */
302 dfssd = afs_exec_alt(fssd_argc, fssd_argv, "da", NULL);
304 fprintf(stderr, "\n*** server asserted demand attach extensions, but we failed\n"
305 "*** to exec a DAFS-enabled fssync-debug '%s' (errno=%d);\n"
306 "*** attempting to proceed without it.\n\n", dfssd, errno);
310 #endif /* !AFS_DEMAND_ATTACH_FS */
313 common_prolog(struct cmd_syndesc * as, struct state * state)
316 VolumePackageOptions opts;
319 if (afs_winsockInit() < 0) {
324 VOptDefaults(debugUtility, &opts);
325 if (VInitVolumePackage2(debugUtility, &opts)) {
326 /* VInitVolumePackage2 can fail on e.g. partition attachment errors,
327 * but we don't really care, since all we're doing is trying to use
329 fprintf(stderr, "errors encountered initializing volume package, but "
330 "trying to continue anyway\n");
334 if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) { /* -reason */
335 state->reason = atoi(ti->data);
337 if ((ti = as->parms[COMMON_PARMS_OFFSET+1].items)) { /* -programtype */
338 if (!strcmp(ti->data, "fileServer")) {
339 programType = fileServer;
340 } else if (!strcmp(ti->data, "volumeUtility")) {
341 programType = volumeUtility;
342 } else if (!strcmp(ti->data, "salvager")) {
343 programType = salvager;
344 } else if (!strcmp(ti->data, "salvageServer")) {
345 programType = salvageServer;
346 } else if (!strcmp(ti->data, "volumeServer")) {
347 programType = volumeServer;
348 } else if (!strcmp(ti->data, "volumeSalvager")) {
349 programType = volumeSalvager;
351 programType = (ProgramType) atoi(ti->data);
361 common_volop_prolog(struct cmd_syndesc * as, struct state * state)
365 state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
366 osi_Assert(state->vop != NULL);
368 if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET].items)) { /* -volumeid */
369 state->vop->volume = atoi(ti->data);
371 fprintf(stderr, "required argument -volumeid not given\n");
374 if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET+1].items)) { /* -partition */
375 strlcpy(state->vop->partName, ti->data, sizeof(state->vop->partName));
377 memset(state->vop->partName, 0, sizeof(state->vop->partName));
384 debug_response(afs_int32 code, SYNC_response * res)
391 fprintf(stderr, "warning: response code indicates possible protocol error.\n");
394 fprintf(stderr, "FSSYNC service returned %d (%s)\n", code, SYNC_res2string(code));
397 fprintf(stderr, "protocol header response code was %d (%s)\n",
398 res->hdr.response, SYNC_res2string(res->hdr.response));
399 fprintf(stderr, "protocol reason code was %d (%s)\n",
400 res->hdr.reason, FSYNC_reason2string(res->hdr.reason));
407 do_volop(struct state * state, afs_int32 command, SYNC_response * res)
410 SYNC_PROTO_BUF_DECL(res_buf);
415 res->payload.len = SYNC_PROTO_MAX_LEN;
416 res->payload.buf = res_buf;
419 fprintf(stderr, "calling FSYNC_VolOp with command code %d (%s)\n",
420 command, FSYNC_com2string(command));
422 code = FSYNC_VolOp(state->vop->volume,
423 state->vop->partName,
428 debug_response(code, res);
437 #define ENUMTOSTRING(en) #en
438 #define ENUMCASE(en) \
440 return ENUMTOSTRING(en); \
443 #define FLAGTOSTRING(fl) #fl
444 #define FLAGCASE(bitstr, fl, str, count) \
446 if ((bitstr) & (fl)) { \
448 strlcat((str), " | ", sizeof(str)); \
449 strlcat((str), FLAGTOSTRING(fl), sizeof(str)); \
455 VolOnline(struct cmd_syndesc * as, void * rock)
459 common_prolog(as, &state);
460 common_volop_prolog(as, &state);
462 do_volop(&state, FSYNC_VOL_ON, NULL);
468 VolOffline(struct cmd_syndesc * as, void * rock)
472 common_prolog(as, &state);
473 common_volop_prolog(as, &state);
475 do_volop(&state, FSYNC_VOL_OFF, NULL);
481 VolMode(struct cmd_syndesc * as, void * rock)
485 common_prolog(as, &state);
486 common_volop_prolog(as, &state);
488 do_volop(&state, FSYNC_VOL_NEEDVOLUME, NULL);
494 VolDetach(struct cmd_syndesc * as, void * rock)
498 common_prolog(as, &state);
499 common_volop_prolog(as, &state);
501 do_volop(&state, FSYNC_VOL_DONE, NULL);
507 VolBreakCBKs(struct cmd_syndesc * as, void * rock)
511 common_prolog(as, &state);
512 common_volop_prolog(as, &state);
514 do_volop(&state, FSYNC_VOL_BREAKCBKS, NULL);
520 VolMove(struct cmd_syndesc * as, void * rock)
524 common_prolog(as, &state);
525 common_volop_prolog(as, &state);
527 do_volop(&state, FSYNC_VOL_MOVE, NULL);
533 VolList(struct cmd_syndesc * as, void * rock)
537 common_prolog(as, &state);
538 common_volop_prolog(as, &state);
540 do_volop(&state, FSYNC_VOL_LISTVOLUMES, NULL);
546 VolLeaveOff(struct cmd_syndesc * as, void * rock)
550 common_prolog(as, &state);
551 common_volop_prolog(as, &state);
553 do_volop(&state, FSYNC_VOL_LEAVE_OFF, NULL);
559 VolForceAttach(struct cmd_syndesc * as, void * rock)
563 common_prolog(as, &state);
564 common_volop_prolog(as, &state);
566 do_volop(&state, FSYNC_VOL_ATTACH, NULL);
572 VolForceError(struct cmd_syndesc * as, void * rock)
576 common_prolog(as, &state);
577 common_volop_prolog(as, &state);
579 do_volop(&state, FSYNC_VOL_FORCE_ERROR, NULL);
584 #ifdef AFS_DEMAND_ATTACH_FS
586 vol_state_to_string(VolState state)
589 ENUMCASE(VOL_STATE_UNATTACHED);
590 ENUMCASE(VOL_STATE_PREATTACHED);
591 ENUMCASE(VOL_STATE_ATTACHING);
592 ENUMCASE(VOL_STATE_ATTACHED);
593 ENUMCASE(VOL_STATE_UPDATING);
594 ENUMCASE(VOL_STATE_GET_BITMAP);
595 ENUMCASE(VOL_STATE_HDR_LOADING);
596 ENUMCASE(VOL_STATE_HDR_ATTACHING);
597 ENUMCASE(VOL_STATE_SHUTTING_DOWN);
598 ENUMCASE(VOL_STATE_GOING_OFFLINE);
599 ENUMCASE(VOL_STATE_OFFLINING);
600 ENUMCASE(VOL_STATE_DETACHING);
601 ENUMCASE(VOL_STATE_SALVSYNC_REQ);
602 ENUMCASE(VOL_STATE_SALVAGING);
603 ENUMCASE(VOL_STATE_ERROR);
604 ENUMCASE(VOL_STATE_VNODE_ALLOC);
605 ENUMCASE(VOL_STATE_VNODE_GET);
606 ENUMCASE(VOL_STATE_VNODE_CLOSE);
607 ENUMCASE(VOL_STATE_VNODE_RELEASE);
608 ENUMCASE(VOL_STATE_VLRU_ADD);
609 ENUMCASE(VOL_STATE_DELETED);
610 ENUMCASE(VOL_STATE_SALVAGE_REQ);
611 ENUMCASE(VOL_STATE_FREED);
613 return "**UNKNOWN**";
618 vol_flags_to_string(afs_uint16 flags)
620 static char str[256];
624 FLAGCASE(flags, VOL_HDR_ATTACHED, str, count);
625 FLAGCASE(flags, VOL_HDR_LOADED, str, count);
626 FLAGCASE(flags, VOL_HDR_IN_LRU, str, count);
627 FLAGCASE(flags, VOL_IN_HASH, str, count);
628 FLAGCASE(flags, VOL_ON_VBYP_LIST, str, count);
629 FLAGCASE(flags, VOL_IS_BUSY, str, count);
630 FLAGCASE(flags, VOL_ON_VLRU, str, count);
631 FLAGCASE(flags, VOL_HDR_DONTSALV, str, count);
632 FLAGCASE(flags, VOL_LOCKED, str, count);
638 vlru_idx_to_string(int idx)
641 ENUMCASE(VLRU_QUEUE_NEW);
642 ENUMCASE(VLRU_QUEUE_MID);
643 ENUMCASE(VLRU_QUEUE_OLD);
644 ENUMCASE(VLRU_QUEUE_CANDIDATE);
645 ENUMCASE(VLRU_QUEUE_HELD);
646 ENUMCASE(VLRU_QUEUE_INVALID);
648 return "**UNKNOWN**";
654 vn_state_to_string(VnState state)
657 ENUMCASE(VN_STATE_INVALID);
658 ENUMCASE(VN_STATE_RELEASING);
659 ENUMCASE(VN_STATE_CLOSING);
660 ENUMCASE(VN_STATE_ALLOC);
661 ENUMCASE(VN_STATE_ONLINE);
662 ENUMCASE(VN_STATE_LOAD);
663 ENUMCASE(VN_STATE_EXCLUSIVE);
664 ENUMCASE(VN_STATE_STORE);
665 ENUMCASE(VN_STATE_READ);
666 ENUMCASE(VN_STATE_ERROR);
668 return "**UNKNOWN**";
673 vn_flags_to_string(afs_uint32 flags)
675 static char str[128];
679 FLAGCASE(flags, VN_ON_HASH, str, count);
680 FLAGCASE(flags, VN_ON_LRU, str, count);
681 FLAGCASE(flags, VN_ON_VVN, str, count);
688 VolQuery(struct cmd_syndesc * as, void * rock)
691 SYNC_PROTO_BUF_DECL(res_buf);
694 #ifdef AFS_DEMAND_ATTACH_FS
700 res.hdr.response_len = sizeof(res.hdr);
701 res.payload.buf = res_buf;
702 res.payload.len = SYNC_PROTO_MAX_LEN;
704 common_prolog(as, &state);
705 common_volop_prolog(as, &state);
707 do_volop(&state, FSYNC_VOL_QUERY, &res);
709 if (res.hdr.response == SYNC_OK) {
710 memcpy(&v, res.payload.buf, sizeof(Volume));
712 printf("volume = {\n");
713 printf("\thashid = %u\n", v.hashid);
714 printf("\theader = %p\n", v.header);
715 printf("\tdevice = %d\n", v.device);
716 printf("\tpartition = %p\n", v.partition);
717 printf("\tlinkHandle = %p\n", v.linkHandle);
718 printf("\tnextVnodeUnique = %u\n", v.nextVnodeUnique);
719 printf("\tdiskDataHandle = %p\n", v.diskDataHandle);
720 printf("\tvnodeHashOffset = %u\n", v.vnodeHashOffset);
721 printf("\tshuttingDown = %d\n", v.shuttingDown);
722 printf("\tgoingOffline = %d\n", v.goingOffline);
723 printf("\tcacheCheck = %u\n", v.cacheCheck);
724 printf("\tnUsers = %d\n", v.nUsers);
725 printf("\tneedsPutBack = %d\n", v.needsPutBack);
726 printf("\tspecialStatus = %d\n", v.specialStatus);
727 printf("\tupdateTime = %u\n", v.updateTime);
729 printf("\tvnodeIndex[vSmall] = {\n");
730 printf("\t\thandle = %p\n", v.vnodeIndex[vSmall].handle);
731 printf("\t\tbitmap = %p\n", v.vnodeIndex[vSmall].bitmap);
732 printf("\t\tbitmapSize = %u\n", v.vnodeIndex[vSmall].bitmapSize);
733 printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vSmall].bitmapOffset);
735 printf("\tvnodeIndex[vLarge] = {\n");
736 printf("\t\thandle = %p\n", v.vnodeIndex[vLarge].handle);
737 printf("\t\tbitmap = %p\n", v.vnodeIndex[vLarge].bitmap);
738 printf("\t\tbitmapSize = %u\n", v.vnodeIndex[vLarge].bitmapSize);
739 printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vLarge].bitmapOffset);
741 #ifdef AFS_DEMAND_ATTACH_FS
742 if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
743 printf("\tupdateTime = %u\n", v.updateTime);
744 printf("\tattach_state = %s\n", vol_state_to_string(v.attach_state));
745 printf("\tattach_flags = %s\n", vol_flags_to_string(v.attach_flags));
746 printf("\tnWaiters = %d\n", v.nWaiters);
747 printf("\tchainCacheCheck = %d\n", v.chainCacheCheck);
749 /* online salvage structure */
750 printf("\tsalvage = {\n");
751 printf("\t\tprio = %u\n", v.salvage.prio);
752 printf("\t\treason = %d\n", v.salvage.reason);
753 printf("\t\trequested = %d\n", v.salvage.requested);
754 printf("\t\tscheduled = %d\n", v.salvage.scheduled);
757 /* statistics structure */
758 printf("\tstats = {\n");
760 printf("\t\thash_lookups = {\n");
761 SplitInt64(v.stats.hash_lookups,hi,lo);
762 printf("\t\t\thi = %u\n", hi);
763 printf("\t\t\tlo = %u\n", lo);
766 printf("\t\thash_short_circuits = {\n");
767 SplitInt64(v.stats.hash_short_circuits,hi,lo);
768 printf("\t\t\thi = %u\n", hi);
769 printf("\t\t\tlo = %u\n", lo);
772 printf("\t\thdr_loads = {\n");
773 SplitInt64(v.stats.hdr_loads,hi,lo);
774 printf("\t\t\thi = %u\n", hi);
775 printf("\t\t\tlo = %u\n", lo);
778 printf("\t\thdr_gets = {\n");
779 SplitInt64(v.stats.hdr_gets,hi,lo);
780 printf("\t\t\thi = %u\n", hi);
781 printf("\t\t\tlo = %u\n", lo);
784 printf("\t\tattaches = %u\n", v.stats.attaches);
785 printf("\t\tsoft_detaches = %u\n", v.stats.soft_detaches);
786 printf("\t\tsalvages = %u\n", v.stats.salvages);
787 printf("\t\tvol_ops = %u\n", v.stats.vol_ops);
789 printf("\t\tlast_attach = %u\n", v.stats.last_attach);
790 printf("\t\tlast_get = %u\n", v.stats.last_get);
791 printf("\t\tlast_promote = %u\n", v.stats.last_promote);
792 printf("\t\tlast_hdr_get = %u\n", v.stats.last_hdr_get);
793 printf("\t\tlast_hdr_load = %u\n", v.stats.last_hdr_load);
794 printf("\t\tlast_salvage = %u\n", v.stats.last_salvage);
795 printf("\t\tlast_salvage_req = %u\n", v.stats.last_salvage_req);
796 printf("\t\tlast_vol_op = %u\n", v.stats.last_vol_op);
800 printf("\tvlru = {\n");
801 printf("\t\tidx = %d (%s)\n",
802 v.vlru.idx, vlru_idx_to_string(v.vlru.idx));
805 /* volume op state */
806 printf("\tpending_vol_op = %p\n", v.pending_vol_op);
808 #else /* !AFS_DEMAND_ATTACH_FS */
809 if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
810 printf("*** server asserted demand attach extensions. this fssync-debug\n"
811 "*** is not built to recognize those extensions. please use an\n"
812 "*** fssync-debug with demand attach if you need to dump dafs\n"
813 "*** extended state.\n");
815 #endif /* !AFS_DEMAND_ATTACH_FS */
823 VolHdrQuery(struct cmd_syndesc * as, void * rock)
826 SYNC_PROTO_BUF_DECL(res_buf);
831 res.hdr.response_len = sizeof(res.hdr);
832 res.payload.buf = res_buf;
833 res.payload.len = SYNC_PROTO_MAX_LEN;
835 common_prolog(as, &state);
836 common_volop_prolog(as, &state);
838 do_volop(&state, FSYNC_VOL_QUERY_HDR, &res);
840 if (res.hdr.response == SYNC_OK) {
841 memcpy(&v, res.payload.buf, sizeof(VolumeDiskData));
843 printf("VolumeDiskData = {\n");
844 printf("\tstamp = {\n");
845 printf("\t\tmagic = 0x%x\n", v.stamp.magic);
846 printf("\t\tversion = %u\n", v.stamp.version);
849 printf("\tid = %u\n", v.id);
850 printf("\tname = '%s'\n", v.name);
852 printf("\tinUse = %d (%s)\n", v.inUse, VPTypeToString(v.inUse));
854 printf("\tinUse = %d (no)\n", v.inUse);
856 printf("\tinService = %d\n", v.inService);
857 printf("\tblessed = %d\n", v.blessed);
858 printf("\tneedsSalvaged = %d\n", v.needsSalvaged);
859 printf("\tuniquifier = %u\n", v.uniquifier);
860 printf("\ttype = %d\n", v.type);
861 printf("\tparentId = %u\n", v.parentId);
862 printf("\tcloneId = %u\n", v.cloneId);
863 printf("\tbackupId = %u\n", v.backupId);
864 printf("\trestoredFromId = %u\n", v.restoredFromId);
865 printf("\tneedsCallback = %d\n", v.needsCallback);
866 printf("\tdestroyMe = %d\n", v.destroyMe);
867 printf("\tdontSalvage = %d\n", v.dontSalvage);
868 printf("\tmaxquota = %d\n", v.maxquota);
869 printf("\tminquota = %d\n", v.minquota);
870 printf("\tmaxfiles = %d\n", v.maxfiles);
871 printf("\taccountNumber = %u\n", v.accountNumber);
872 printf("\towner = %u\n", v.owner);
873 printf("\tfilecount = %d\n", v.filecount);
874 printf("\tdiskused = %d\n", v.diskused);
875 printf("\tdayUse = %d\n", v.dayUse);
876 for (i = 0; i < 7; i++) {
877 printf("\tweekUse[%d] = %d\n", i, v.weekUse[i]);
879 printf("\tdayUseDate = %u\n", v.dayUseDate);
880 printf("\tcreationDate = %u\n", v.creationDate);
881 printf("\taccessDate = %u\n", v.accessDate);
882 printf("\tupdateDate = %u\n", v.updateDate);
883 printf("\texpirationDate = %u\n", v.expirationDate);
884 printf("\tbackupDate = %u\n", v.backupDate);
885 printf("\tcopyDate = %u\n", v.copyDate);
886 #ifdef OPENAFS_VOL_STATS
887 printf("\tstat_initialized = %d\n", v.stat_initialized);
889 printf("\tmtd = '%s'\n", v.motd);
898 VolOpQuery(struct cmd_syndesc * as, void * rock)
901 SYNC_PROTO_BUF_DECL(res_buf);
903 FSSYNC_VolOp_info vop;
905 res.hdr.response_len = sizeof(res.hdr);
906 res.payload.buf = res_buf;
907 res.payload.len = SYNC_PROTO_MAX_LEN;
909 common_prolog(as, &state);
910 common_volop_prolog(as, &state);
912 do_volop(&state, FSYNC_VOL_QUERY_VOP, &res);
914 if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
915 printf("*** file server not compiled with demand attach extensions.\n");
916 printf("*** pending volume operation metadata not available.\n");
919 if (res.hdr.response == SYNC_OK) {
920 memcpy(&vop, res.payload.buf, sizeof(FSSYNC_VolOp_info));
922 printf("pending_vol_op = {\n");
924 printf("\tcom = {\n");
925 printf("\t\tproto_version = %u\n", vop.com.proto_version);
926 printf("\t\tpkt_seq = %u\n", vop.com.pkt_seq);
927 printf("\t\tcom_seq = %u\n", vop.com.com_seq);
928 printf("\t\tprogramType = %d (%s)\n",
929 vop.com.programType, VPTypeToString(vop.com.programType));
930 printf("\t\tpid = %d\n", vop.com.pid);
931 printf("\t\ttid = %d\n", vop.com.tid);
932 printf("\t\tcommand = %d (%s)\n",
933 vop.com.command, FSYNC_com2string(vop.com.command));
934 printf("\t\treason = %d (%s)\n",
935 vop.com.reason, FSYNC_reason2string(vop.com.reason));
936 printf("\t\tcommand_len = %u\n", vop.com.command_len);
937 printf("\t\tflags = 0x%lux\n", afs_printable_uint32_lu(vop.com.flags));
940 printf("\tvop = {\n");
941 printf("\t\tvolume = %u\n", vop.vop.volume);
942 if (strnlen(vop.vop.partName, sizeof(vop.vop.partName)) <
943 sizeof(vop.vop.partName)) {
944 printf("\t\tpartName = '%s'\n", vop.vop.partName);
946 printf("\t\tpartName = (illegal string)\n");
957 vn_prolog(struct cmd_syndesc * as, struct state * state)
961 state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
962 osi_Assert(state->vop != NULL);
964 if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) { /* -volumeid */
965 state->vop->volume = atoi(ti->data);
967 fprintf(stderr, "required argument -volumeid not given\n");
970 if ((ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -vnodeid */
971 state->vop->vnode = atoi(ti->data);
973 fprintf(stderr, "required argument -vnodeid not given\n");
976 if ((ti = as->parms[CUSTOM_PARMS_OFFSET+2].items)) { /* -unique */
977 state->vop->unique = atoi(ti->data);
979 state->vop->unique = 0;
982 if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET+3].items)) { /* -partition */
983 strlcpy(state->vop->partName, ti->data, sizeof(state->vop->partName));
985 memset(state->vop->partName, 0, sizeof(state->vop->partName));
992 do_vnqry(struct state * state, SYNC_response * res)
995 int command = FSYNC_VOL_QUERY_VNODE;
996 FSSYNC_VnQry_hdr qry;
998 qry.volume = state->vop->volume;
999 qry.vnode = state->vop->vnode;
1000 qry.unique = state->vop->unique;
1002 strlcpy(qry.partName, state->vop->partName, sizeof(qry.partName));
1004 fprintf(stderr, "calling FSYNC_GenericOp with command code %d (%s)\n",
1005 command, FSYNC_com2string(command));
1007 code = FSYNC_GenericOp(&qry, sizeof(qry), command, FSYNC_OPERATOR, res);
1009 debug_response(code, res);
1017 VnQuery(struct cmd_syndesc * as, void * rock)
1020 SYNC_PROTO_BUF_DECL(res_buf);
1026 res.hdr.response_len = sizeof(res.hdr);
1027 res.payload.buf = res_buf;
1028 res.payload.len = SYNC_PROTO_MAX_LEN;
1030 common_prolog(as, &state);
1031 vn_prolog(as, &state);
1033 do_vnqry(&state, &res);
1035 if (res.hdr.response == SYNC_OK) {
1036 memcpy(&v, res.payload.buf, sizeof(Vnode));
1038 printf("vnode = {\n");
1040 printf("\tvid_hash = {\n");
1041 printf("\t\tnext = %p\n", v.vid_hash.next);
1042 printf("\t\tprev = %p\n", v.vid_hash.prev);
1045 printf("\thashNext = %p\n", v.hashNext);
1046 printf("\tlruNext = %p\n", v.lruNext);
1047 printf("\tlruPrev = %p\n", v.lruPrev);
1048 printf("\thashIndex = %hu\n", v.hashIndex);
1049 printf("\tchanged_newTime = %u\n", (unsigned int) v.changed_newTime);
1050 printf("\tchanged_oldTime = %u\n", (unsigned int) v.changed_oldTime);
1051 printf("\tdelete = %u\n", (unsigned int) v.delete);
1052 printf("\tvnodeNumber = %u\n", v.vnodeNumber);
1053 printf("\tvolumePtr = %p\n", v.volumePtr);
1054 printf("\tnUsers = %u\n", v.nUsers);
1055 printf("\tcacheCheck = %u\n", v.cacheCheck);
1057 #ifdef AFS_DEMAND_ATTACH_FS
1058 if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
1059 printf("*** this fssync-debug is built to expect demand attach extensions.\n"
1060 "*** server asserted that is was not compiled with demand attach.\n"
1061 "*** please use an fssync-debug without demand attach to match your\n"
1066 printf("\tnReaders = %u\n", v.nReaders);
1067 printf("\tvn_state_flags = %s\n", vn_flags_to_string(v.vn_state_flags));
1068 printf("\tvn_state = %s\n", vn_state_to_string(v.vn_state));
1070 if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
1071 printf("*** server asserted demand attach extensions. this fssync-debug is not\n"
1072 "*** built to recognize those extensions. please use an fssync-debug\n"
1073 "*** with demand attach to match your server.\n");
1076 #endif /* !AFS_DEMAND_ATTACH_FS */
1078 printf("\tvcp = %p\n", v.vcp);
1079 printf("\thandle = %p\n", v.handle);
1081 printf("\tdisk = {\n");
1082 printf("\t\ttype = %u\n", v.disk.type);
1083 printf("\t\tcloned = %u\n", v.disk.cloned);
1084 printf("\t\tmodeBits = %u\n", v.disk.modeBits);
1085 printf("\t\tlinkCount = %d\n", v.disk.linkCount);
1086 printf("\t\tlength = %u\n", v.disk.length);
1087 printf("\t\tuniquifier = %u\n", v.disk.uniquifier);
1088 printf("\t\tdataVersion = %u\n", v.disk.dataVersion);
1089 printf("\t\tvn_ino_lo = %u\n", v.disk.vn_ino_lo);
1090 printf("\t\tunixModifyTime = %u\n", v.disk.unixModifyTime);
1091 printf("\t\tauthor = %u\n", v.disk.author);
1092 printf("\t\towner = %u\n", v.disk.owner);
1093 printf("\t\tparent = %u\n", v.disk.parent);
1094 printf("\t\tvnodeMagic = %u\n", v.disk.vnodeMagic);
1096 printf("\t\tlock = {\n");
1097 printf("\t\t\tlockCount = %d\n", v.disk.lock.lockCount);
1098 printf("\t\t\tlockTime = %d\n", v.disk.lock.lockTime);
1101 printf("\t\tserverModifyTime = %u\n", v.disk.serverModifyTime);
1102 printf("\t\tgroup = %d\n", v.disk.group);
1103 printf("\t\tvn_ino_hi = %d\n", v.disk.vn_ino_hi);
1104 printf("\t\tvn_length_hi = %u\n", v.disk.vn_length_hi);
1116 StatsQuery(struct cmd_syndesc * as, void * rock)
1120 struct cmd_item *ti;
1122 SYNC_PROTO_BUF_DECL(res_buf);
1124 FSSYNC_StatsOp_hdr scom;
1126 res.hdr.response_len = sizeof(res.hdr);
1127 res.payload.buf = res_buf;
1128 res.payload.len = SYNC_PROTO_MAX_LEN;
1130 if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) { /* -subcommand */
1131 if (!strcasecmp(ti->data, "vicep")) {
1132 command = FSYNC_VOL_STATS_VICEP;
1133 } else if (!strcasecmp(ti->data, "hash")) {
1134 command = FSYNC_VOL_STATS_HASH;
1135 #ifdef AFS_DEMAND_ATTACH_FS
1136 } else if (!strcasecmp(ti->data, "hdr")) {
1137 command = FSYNC_VOL_STATS_HDR;
1138 } else if (!strcasecmp(ti->data, "vlru")) {
1139 command = FSYNC_VOL_STATS_VLRU;
1141 } else if (!strcasecmp(ti->data, "pkg")) {
1142 command = FSYNC_VOL_STATS_GENERAL;
1143 } else if (!strcasecmp(ti->data, "help")) {
1144 fprintf(stderr, "fssync-debug stats subcommands:\n");
1145 fprintf(stderr, "\tpkg\tgeneral volume package stats\n");
1146 fprintf(stderr, "\tvicep\tvice partition stats\n");
1147 fprintf(stderr, "\thash\tvolume hash chain stats\n");
1148 #ifdef AFS_DEMAND_ATTACH_FS
1149 fprintf(stderr, "\thdr\tvolume header cache stats\n");
1150 fprintf(stderr, "\tvlru\tvlru generation stats\n");
1154 fprintf(stderr, "invalid stats subcommand");
1158 command = FSYNC_VOL_STATS_GENERAL;
1161 if ((ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -arg1 */
1163 case FSYNC_VOL_STATS_VICEP:
1164 strlcpy(scom.args.partName, ti->data, sizeof(state.vop->partName));
1166 case FSYNC_VOL_STATS_HASH:
1167 scom.args.hash_bucket = atoi(ti->data);
1169 case FSYNC_VOL_STATS_VLRU:
1170 scom.args.vlru_generation = atoi(ti->data);
1173 fprintf(stderr, "unrecognized arguments\n");
1178 case FSYNC_VOL_STATS_VICEP:
1179 case FSYNC_VOL_STATS_HASH:
1180 case FSYNC_VOL_STATS_VLRU:
1181 fprintf(stderr, "this subcommand requires more parameters\n");
1186 common_prolog(as, &state);
1188 fprintf(stderr, "calling FSYNC_askfs with command code %d (%s)\n",
1189 command, FSYNC_com2string(command));
1191 code = FSYNC_StatsOp(&scom, command, FSYNC_WHATEVER, &res);
1198 fprintf(stderr, "possible sync protocol error. return code was %d\n", code);
1201 fprintf(stderr, "FSYNC_VolOp returned %d (%s)\n", code, SYNC_res2string(code));
1202 fprintf(stderr, "protocol response code was %d (%s)\n",
1203 res.hdr.response, SYNC_res2string(res.hdr.response));
1204 fprintf(stderr, "protocol reason code was %d (%s)\n",
1205 res.hdr.reason, FSYNC_reason2string(res.hdr.reason));
1209 if (res.hdr.response == SYNC_OK) {
1211 case FSYNC_VOL_STATS_GENERAL:
1213 struct VolPkgStats vol_stats;
1214 memcpy(&vol_stats, res_buf, sizeof(vol_stats));
1215 print_vol_stats_general(&vol_stats);
1218 case FSYNC_VOL_STATS_VICEP:
1220 struct DiskPartitionStats64 vicep_stats;
1221 memcpy(&vicep_stats, res_buf, sizeof(vicep_stats));
1222 print_vol_stats_viceP(&vicep_stats);
1225 case FSYNC_VOL_STATS_HASH:
1227 struct VolumeHashChainStats hash_stats;
1228 memcpy(&hash_stats, res_buf, sizeof(hash_stats));
1229 print_vol_stats_hash(&hash_stats);
1232 #ifdef AFS_DEMAND_ATTACH_FS
1233 case FSYNC_VOL_STATS_HDR:
1235 struct volume_hdr_LRU_stats hdr_stats;
1236 memcpy(&hdr_stats, res_buf, sizeof(hdr_stats));
1237 print_vol_stats_hdr(&hdr_stats);
1240 #endif /* AFS_DEMAND_ATTACH_FS */
1248 print_vol_stats_general(VolPkgStats * stats)
1250 #ifdef AFS_DEMAND_ATTACH_FS
1255 printf("VolPkgStats = {\n");
1256 #ifdef AFS_DEMAND_ATTACH_FS
1257 for (i = 0; i < VOL_STATE_COUNT; i++) {
1258 printf("\tvol_state_count[%s] = %d\n",
1259 vol_state_to_string(i),
1260 stats->state_levels[i]);
1263 SplitInt64(stats->hash_looks, hi, lo);
1264 printf("\thash_looks = {\n");
1265 printf("\t\thi = %u\n", hi);
1266 printf("\t\tlo = %u\n", lo);
1269 SplitInt64(stats->hash_reorders, hi, lo);
1270 printf("\thash_reorders = {\n");
1271 printf("\t\thi = %u\n", hi);
1272 printf("\t\tlo = %u\n", lo);
1275 SplitInt64(stats->salvages, hi, lo);
1276 printf("\tsalvages = {\n");
1277 printf("\t\thi = %u\n", hi);
1278 printf("\t\tlo = %u\n", lo);
1281 SplitInt64(stats->vol_ops, hi, lo);
1282 printf("\tvol_ops = {\n");
1283 printf("\t\thi = %u\n", hi);
1284 printf("\t\tlo = %u\n", lo);
1287 SplitInt64(stats->hdr_loads, hi, lo);
1288 printf("\thdr_loads = {\n");
1289 printf("\t\thi = %u\n", hi);
1290 printf("\t\tlo = %u\n", lo);
1293 SplitInt64(stats->hdr_gets, hi, lo);
1294 printf("\thdr_gets = {\n");
1295 printf("\t\thi = %u\n", hi);
1296 printf("\t\tlo = %u\n", lo);
1299 SplitInt64(stats->attaches, hi, lo);
1300 printf("\tattaches = {\n");
1301 printf("\t\thi = %u\n", hi);
1302 printf("\t\tlo = %u\n", lo);
1305 SplitInt64(stats->soft_detaches, hi, lo);
1306 printf("\tsoft_detaches = {\n");
1307 printf("\t\thi = %u\n", hi);
1308 printf("\t\tlo = %u\n", lo);
1311 printf("\thdr_cache_size = %d\n", stats->hdr_cache_size);
1317 print_vol_stats_viceP(struct DiskPartitionStats64 * stats)
1319 printf("DiskPartitionStats64 = {\n");
1320 printf("\tfree = %" AFS_INT64_FMT "\n", stats->free);
1321 printf("\tminFree = %" AFS_INT64_FMT "\n", stats->minFree);
1322 printf("\ttotalUsable = %" AFS_INT64_FMT "\n", stats->totalUsable);
1323 printf("\tf_files = %" AFS_INT64_FMT "\n", stats->f_files);
1324 #ifdef AFS_DEMAND_ATTACH_FS
1325 printf("\tvol_list_len = %d\n", stats->vol_list_len);
1331 print_vol_stats_hash(struct VolumeHashChainStats * stats)
1333 #ifdef AFS_DEMAND_ATTACH_FS
1337 printf("DiskPartitionStats = {\n");
1338 printf("\ttable_size = %d\n", stats->table_size);
1339 printf("\tchain_len = %d\n", stats->chain_len);
1341 #ifdef AFS_DEMAND_ATTACH_FS
1342 printf("\tchain_cacheCheck = %d\n", stats->chain_cacheCheck);
1343 printf("\tchain_busy = %d\n", stats->chain_busy);
1345 SplitInt64(stats->chain_looks, hi, lo);
1346 printf("\tchain_looks = {\n");
1347 printf("\t\thi = %u\n", hi);
1348 printf("\t\tlo = %u\n", lo);
1351 SplitInt64(stats->chain_gets, hi, lo);
1352 printf("\tchain_gets = {\n");
1353 printf("\t\thi = %u\n", hi);
1354 printf("\t\tlo = %u\n", lo);
1357 SplitInt64(stats->chain_reorders, hi, lo);
1358 printf("\tchain_reorders = {\n");
1359 printf("\t\thi = %u\n", hi);
1360 printf("\t\tlo = %u\n", lo);
1362 #endif /* AFS_DEMAND_ATTACH_FS */
1368 #ifdef AFS_DEMAND_ATTACH_FS
1370 print_vol_stats_hdr(struct volume_hdr_LRU_stats * stats)
1372 printf("volume_hdr_LRU_stats = {\n");
1373 printf("\tfree = %d\n", stats->free);
1374 printf("\tused = %d\n", stats->used);
1375 printf("\tattached = %d\n", stats->attached);
1378 #endif /* AFS_DEMAND_ATTACH_FS */
1385 * - CUSTOM_PARMS_OFFSET+0 is partition string
1386 * - CUSTOM_PARMS_OFFSET+1 is volume id
1388 * @return operation status
1392 VGCQuery(struct cmd_syndesc * as, void * rock)
1398 FSSYNC_VGQry_response_t q_res;
1401 struct cmd_item *ti;
1403 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1406 partName = ti->data;
1408 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -volumeid */
1411 volid = atoi(ti->data);
1413 common_prolog(as, &state);
1415 fprintf(stderr, "calling FSYNC_VCGQuery\n");
1417 code = FSYNC_VGCQuery(partName, volid, &q_res, &res);
1419 debug_response(code, &res);
1421 if (code == SYNC_OK) {
1423 printf("\trw\t=\t%u\n", q_res.rw);
1424 printf("\tchildren\t= (\n");
1425 for (i = 0; i < VOL_VG_MAX_VOLS; i++) {
1426 if (q_res.children[i]) {
1427 printf("\t\t%u\n", q_res.children[i]);
1439 VGCAdd(struct cmd_syndesc * as, void * rock)
1444 VolumeId parent, child;
1445 struct cmd_item *ti;
1448 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1451 partName = ti->data;
1453 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -parent */
1456 parent = atoi(ti->data);
1458 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+2].items)) { /* -child */
1461 child = atoi(ti->data);
1463 common_prolog(as, &state);
1464 fprintf(stderr, "calling FSYNC_VCGAdd\n");
1465 code = FSYNC_VGCAdd(partName, parent, child, state.reason, &res);
1466 debug_response(code, &res);
1474 VGCDel(struct cmd_syndesc * as, void * rock)
1479 VolumeId parent, child;
1480 struct cmd_item *ti;
1483 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1486 partName = ti->data;
1488 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -parent */
1491 parent = atoi(ti->data);
1493 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+2].items)) { /* -child */
1496 child = atoi(ti->data);
1498 state.reason = FSYNC_WHATEVER;
1500 common_prolog(as, &state);
1501 fprintf(stderr, "calling FSYNC_VCGDel\n");
1502 code = FSYNC_VGCDel(partName, parent, child, state.reason, &res);
1503 debug_response(code, &res);
1511 VGCScan(struct cmd_syndesc * as, void * rock)
1516 struct cmd_item *ti;
1518 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1521 partName = ti->data;
1523 common_prolog(as, &state);
1524 fprintf(stderr, "calling FSYNC_VCGScan\n");
1525 code = FSYNC_VGCScan(partName, state.reason);
1526 debug_response(code, NULL);
1534 VGCScanAll(struct cmd_syndesc * as, void * rock)
1539 common_prolog(as, &state);
1540 fprintf(stderr, "calling FSYNC_VCGScanAll\n");
1541 code = FSYNC_VGCScan(NULL, state.reason);
1542 debug_response(code, NULL);