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>
24 #include <WINNT/afsevent.h>
29 #include <afs/afsint.h>
32 #include <afs/osi_inode.h>
37 #include <afs/afsutil.h>
38 #include <afs/fileutil.h>
39 #include <rx/rx_queue.h>
46 #include "volume_inline.h"
47 #include "partition.h"
48 #include "daemon_com.h"
49 #include "daemon_com_inline.h"
51 #include "fssync_inline.h"
57 int VolumeChanged; /* hack to make dir package happy */
69 struct volop_state * vop;
72 #ifndef AFS_DEMAND_ATTACH_FS
73 /* remember argv/argc for later, if we need to re-exec */
74 static char **fssd_argv;
78 static int common_prolog(struct cmd_syndesc *, struct fssync_state *);
79 static int common_volop_prolog(struct cmd_syndesc *, struct fssync_state *);
81 static int do_volop(struct fssync_state *, afs_int32 command,
84 static int VolOnline(struct cmd_syndesc * as, void * rock);
85 static int VolOffline(struct cmd_syndesc * as, void * rock);
86 static int VolMode(struct cmd_syndesc * as, void * rock);
87 static int VolDetach(struct cmd_syndesc * as, void * rock);
88 static int VolBreakCBKs(struct cmd_syndesc * as, void * rock);
89 static int VolMove(struct cmd_syndesc * as, void * rock);
90 static int VolList(struct cmd_syndesc * as, void * rock);
91 static int VolLeaveOff(struct cmd_syndesc * as, void * rock);
92 static int VolForceAttach(struct cmd_syndesc * as, void * rock);
93 static int VolForceError(struct cmd_syndesc * as, void * rock);
94 static int VolQuery(struct cmd_syndesc * as, void * rock);
95 static int VolHdrQuery(struct cmd_syndesc * as, void * rock);
96 static int VolOpQuery(struct cmd_syndesc * as, void * rock);
97 static int StatsQuery(struct cmd_syndesc * as, void * rock);
98 static int VnQuery(struct cmd_syndesc * as, void * rock);
100 static int VGCQuery(struct cmd_syndesc * as, void * rock);
101 static int VGCAdd(struct cmd_syndesc * as, void * rock);
102 static int VGCDel(struct cmd_syndesc * as, void * rock);
103 static int VGCScan(struct cmd_syndesc * as, void * rock);
104 static int VGCScanAll(struct cmd_syndesc * as, void * rock);
106 static void print_vol_stats_general(VolPkgStats * stats);
107 static void print_vol_stats_viceP(struct DiskPartitionStats64 * stats);
108 static void print_vol_stats_hash(struct VolumeHashChainStats * stats);
109 #ifdef AFS_DEMAND_ATTACH_FS
110 static void print_vol_stats_hdr(struct volume_hdr_LRU_stats * stats);
114 #include "AFS_component_version_number.c"
118 #define COMMON_PARMS_OFFSET 12
119 #define COMMON_PARMS(ts) \
120 cmd_Seek(ts, COMMON_PARMS_OFFSET); \
121 cmd_AddParm(ts, "-reason", CMD_SINGLE, CMD_OPTIONAL, "sync protocol reason code"); \
122 cmd_AddParm(ts, "-programtype", CMD_SINGLE, CMD_OPTIONAL, "program type code")
124 #define COMMON_VOLOP_PARMS_OFFSET 10
125 #define COMMON_VOLOP_PARMS(ts) \
126 cmd_Seek(ts, COMMON_VOLOP_PARMS_OFFSET); \
127 cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id"); \
128 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name")
130 #define CUSTOM_PARMS_OFFSET 1
133 #define VOLOP_PARMS_DECL(ts) \
134 COMMON_VOLOP_PARMS(ts); \
136 #define COMMON_PARMS_DECL(ts) \
140 main(int argc, char **argv)
142 struct cmd_syndesc *ts;
145 /* Initialize directory paths */
146 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
148 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
150 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
155 #ifndef AFS_DEMAND_ATTACH_FS
160 ts = cmd_CreateSyntax("online", VolOnline, NULL, 0, "bring a volume online (FSYNC_VOL_ON opcode)");
161 VOLOP_PARMS_DECL(ts);
163 ts = cmd_CreateSyntax("offline", VolOffline, NULL, 0, "take a volume offline (FSYNC_VOL_OFF opcode)");
164 VOLOP_PARMS_DECL(ts);
166 ts = cmd_CreateSyntax("mode", VolMode, NULL, 0, "change volume attach mode (FSYNC_VOL_NEEDVOLUME opcode)");
167 VOLOP_PARMS_DECL(ts);
168 cmd_CreateAlias(ts, "needvolume");
170 ts = cmd_CreateSyntax("detach", VolDetach, NULL, 0, "detach a volume (FSYNC_VOL_DONE opcode)");
171 VOLOP_PARMS_DECL(ts);
173 ts = cmd_CreateSyntax("callback", VolBreakCBKs, NULL, 0, "break callbacks for volume (FSYNC_VOL_BREAKCBKS opcode)");
174 VOLOP_PARMS_DECL(ts);
175 cmd_CreateAlias(ts, "cbk");
177 ts = cmd_CreateSyntax("move", VolMove, NULL, 0, "set volume moved flag (FSYNC_VOL_MOVE opcode)");
178 VOLOP_PARMS_DECL(ts);
180 ts = cmd_CreateSyntax("list", VolList, NULL, 0, "sync local volume list (FSYNC_VOL_LISTVOLUMES opcode)");
181 VOLOP_PARMS_DECL(ts);
182 cmd_CreateAlias(ts, "ls");
184 ts = cmd_CreateSyntax("leaveoff", VolLeaveOff, 0, 0, "leave volume offline (FSYNC_VOL_LEAVE_OFF opcode)");
185 VOLOP_PARMS_DECL(ts);
187 ts = cmd_CreateSyntax("attach", VolForceAttach, 0, 0, "force full attachment (FSYNC_VOL_ATTACH opcode)");
188 VOLOP_PARMS_DECL(ts);
190 ts = cmd_CreateSyntax("error", VolForceError, 0, 0, "force into hard error state (FSYNC_VOL_FORCE_ERROR opcode)");
191 VOLOP_PARMS_DECL(ts);
193 ts = cmd_CreateSyntax("query", VolQuery, NULL, 0, "get volume structure (FSYNC_VOL_QUERY opcode)");
194 VOLOP_PARMS_DECL(ts);
195 cmd_CreateAlias(ts, "qry");
197 ts = cmd_CreateSyntax("header", VolHdrQuery, NULL, 0, "get volume disk data structure (FSYNC_VOL_QUERY_HDR opcode)");
198 VOLOP_PARMS_DECL(ts);
199 cmd_CreateAlias(ts, "hdr");
201 ts = cmd_CreateSyntax("volop", VolOpQuery, NULL, 0, "get pending volume operation info (FSYNC_VOL_QUERY_VOP opcode)");
202 VOLOP_PARMS_DECL(ts);
203 cmd_CreateAlias(ts, "vop");
205 ts = cmd_CreateSyntax("vnode", VnQuery, NULL, 0, "get vnode structure (FSYNC_VOL_QUERY_VNODE opcode)");
206 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
207 cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id");
208 cmd_AddParm(ts, "-vnodeid", CMD_SINGLE, 0, "vnode id");
209 cmd_AddParm(ts, "-unique", CMD_SINGLE, 0, "uniquifier");
210 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
211 COMMON_PARMS_DECL(ts);
213 ts = cmd_CreateSyntax("stats", StatsQuery, NULL, 0, "see 'stats help' for more information");
214 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
215 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "subcommand");
216 cmd_AddParm(ts, "-arg1", CMD_SINGLE, CMD_OPTIONAL, "arg1");
217 cmd_AddParm(ts, "-arg2", CMD_SINGLE, CMD_OPTIONAL, "arg2");
218 COMMON_PARMS_DECL(ts);
220 ts = cmd_CreateSyntax("vgcquery", VGCQuery, 0, 0, "query volume group cache (FSYNC_VG_QUERY opcode)");
221 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
222 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
223 cmd_AddParm(ts, "-volumeid", CMD_SINGLE, 0, "volume id");
224 COMMON_PARMS_DECL(ts);
225 cmd_CreateAlias(ts, "vgcqry");
227 ts = cmd_CreateSyntax("vgcadd", VGCAdd, 0, 0, "add entry to volume group cache (FSYNC_VG_ADD opcode)");
228 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
229 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
230 cmd_AddParm(ts, "-parent", CMD_SINGLE, 0, "parent volume id");
231 cmd_AddParm(ts, "-child", CMD_SINGLE, 0, "child volume id");
232 COMMON_PARMS_DECL(ts);
234 ts = cmd_CreateSyntax("vgcdel", VGCDel, 0, 0, "delete entry from volume group cache (FSYNC_VG_DEL opcode)");
235 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
236 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
237 cmd_AddParm(ts, "-parent", CMD_SINGLE, 0, "parent volume id");
238 cmd_AddParm(ts, "-child", CMD_SINGLE, 0, "child volume id");
239 COMMON_PARMS_DECL(ts);
241 ts = cmd_CreateSyntax("vgcscan", VGCScan, 0, 0,
242 "start volume group cache re-scan"
243 " (FSYNC_VG_SCAN opcode)");
244 cmd_Seek(ts, CUSTOM_PARMS_OFFSET);
245 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
246 COMMON_PARMS_DECL(ts);
248 ts = cmd_CreateSyntax("vgcscanall", VGCScanAll, 0, 0,
249 "start whole-server volume group cache re-scan"
250 " (FSYNC_VG_SCAN_ALL opcode)");
251 COMMON_PARMS_DECL(ts);
253 err = cmd_Dispatch(argc, argv);
257 #ifdef AFS_DEMAND_ATTACH_FS
258 # define dafs_prolog()
260 /* Try to detect if the fileserver is DAFS, and if so, re-exec as the
261 * DAFS-enabled fssync-debug (dafssync_debug). If we fail to detect or
262 * exec, just try to proceed anyway as if the server is not DAFS */
267 SYNC_PROTO_BUF_DECL(res_buf);
271 res.payload.len = SYNC_PROTO_MAX_LEN;
272 res.payload.buf = res_buf;
274 /* LISTVOLUMES is a no-op; we just want to get the response header flags
275 * to see if the server reports itself as DAFS or not */
276 code = FSYNC_VolOp(0, NULL, FSYNC_VOL_LISTVOLUMES, FSYNC_WHATEVER, &res);
277 VDisconnectFS(); /* disconnect before continuing */
279 /* probably failed to contact the fileserver; later code will provide
280 * some warning/error indication */
284 if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
285 /* fileserver is not DAFS, so we don't need to do anything */
289 dfssd = afs_exec_alt(fssd_argc, fssd_argv, "da", NULL);
291 fprintf(stderr, "\n*** server asserted demand attach extensions, but we failed\n"
292 "*** to exec a DAFS-enabled fssync-debug '%s' (errno=%d);\n"
293 "*** attempting to proceed without it.\n\n", dfssd, errno);
297 #endif /* !AFS_DEMAND_ATTACH_FS */
300 common_prolog(struct cmd_syndesc * as, struct fssync_state * state)
303 VolumePackageOptions opts;
306 if (afs_winsockInit() < 0) {
311 VOptDefaults(debugUtility, &opts);
312 if (VInitVolumePackage2(debugUtility, &opts)) {
313 /* VInitVolumePackage2 can fail on e.g. partition attachment errors,
314 * but we don't really care, since all we're doing is trying to use
316 fprintf(stderr, "errors encountered initializing volume package, but "
317 "trying to continue anyway\n");
321 if ((ti = as->parms[COMMON_PARMS_OFFSET].items)) { /* -reason */
322 state->reason = atoi(ti->data);
324 state->reason = FSYNC_WHATEVER;
327 if ((ti = as->parms[COMMON_PARMS_OFFSET+1].items)) { /* -programtype */
328 if (!strcmp(ti->data, "fileServer")) {
329 programType = fileServer;
330 } else if (!strcmp(ti->data, "volumeUtility")) {
331 programType = volumeUtility;
332 } else if (!strcmp(ti->data, "salvager")) {
333 programType = salvager;
334 } else if (!strcmp(ti->data, "salvageServer")) {
335 programType = salvageServer;
336 } else if (!strcmp(ti->data, "volumeServer")) {
337 programType = volumeServer;
338 } else if (!strcmp(ti->data, "volumeSalvager")) {
339 programType = volumeSalvager;
341 programType = (ProgramType) atoi(ti->data);
351 common_volop_prolog(struct cmd_syndesc * as, struct fssync_state * state)
355 state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
356 opr_Assert(state->vop != NULL);
358 if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET].items)) { /* -volumeid */
359 state->vop->volume = atoi(ti->data);
361 fprintf(stderr, "required argument -volumeid not given\n");
364 if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET+1].items)) { /* -partition */
365 strlcpy(state->vop->partName, ti->data, sizeof(state->vop->partName));
367 memset(state->vop->partName, 0, sizeof(state->vop->partName));
374 debug_response(afs_int32 code, SYNC_response * res)
381 fprintf(stderr, "warning: response code indicates possible protocol error.\n");
384 fprintf(stderr, "FSSYNC service returned %d (%s)\n", code, SYNC_res2string(code));
387 fprintf(stderr, "protocol header response code was %d (%s)\n",
388 res->hdr.response, SYNC_res2string(res->hdr.response));
389 fprintf(stderr, "protocol reason code was %d (%s)\n",
390 res->hdr.reason, FSYNC_reason2string(res->hdr.reason));
397 do_volop(struct fssync_state * state, afs_int32 command, SYNC_response * res)
400 SYNC_PROTO_BUF_DECL(res_buf);
405 res->payload.len = SYNC_PROTO_MAX_LEN;
406 res->payload.buf = res_buf;
409 fprintf(stderr, "calling FSYNC_VolOp with command code %d (%s)\n",
410 command, FSYNC_com2string(command));
412 code = FSYNC_VolOp(state->vop->volume,
413 state->vop->partName,
418 debug_response(code, res);
427 #define ENUMTOSTRING(en) #en
428 #define ENUMCASE(en) \
429 case en: return ENUMTOSTRING(en)
431 #define FLAGTOSTRING(fl) #fl
432 #define FLAGCASE(bitstr, fl, str, count) \
434 if ((bitstr) & (fl)) { \
436 strlcat((str), " | ", sizeof(str)); \
437 strlcat((str), FLAGTOSTRING(fl), sizeof(str)); \
443 VolOnline(struct cmd_syndesc * as, void * rock)
445 struct fssync_state state;
447 common_prolog(as, &state);
448 common_volop_prolog(as, &state);
450 if (*(state.vop->partName)==0) {
451 fprintf(stderr, "required argument -partition not given\n");
454 do_volop(&state, FSYNC_VOL_ON, NULL);
460 VolOffline(struct cmd_syndesc * as, void * rock)
462 struct fssync_state state;
464 common_prolog(as, &state);
465 common_volop_prolog(as, &state);
467 do_volop(&state, FSYNC_VOL_OFF, NULL);
473 VolMode(struct cmd_syndesc * as, void * rock)
475 struct fssync_state state;
477 common_prolog(as, &state);
478 common_volop_prolog(as, &state);
480 do_volop(&state, FSYNC_VOL_NEEDVOLUME, NULL);
486 VolDetach(struct cmd_syndesc * as, void * rock)
488 struct fssync_state state;
490 common_prolog(as, &state);
491 common_volop_prolog(as, &state);
493 do_volop(&state, FSYNC_VOL_DONE, NULL);
499 VolBreakCBKs(struct cmd_syndesc * as, void * rock)
501 struct fssync_state state;
503 common_prolog(as, &state);
504 common_volop_prolog(as, &state);
506 do_volop(&state, FSYNC_VOL_BREAKCBKS, NULL);
512 VolMove(struct cmd_syndesc * as, void * rock)
514 struct fssync_state state;
516 common_prolog(as, &state);
517 common_volop_prolog(as, &state);
519 do_volop(&state, FSYNC_VOL_MOVE, NULL);
525 VolList(struct cmd_syndesc * as, void * rock)
527 struct fssync_state state;
529 common_prolog(as, &state);
530 common_volop_prolog(as, &state);
532 do_volop(&state, FSYNC_VOL_LISTVOLUMES, NULL);
538 VolLeaveOff(struct cmd_syndesc * as, void * rock)
540 struct fssync_state state;
542 common_prolog(as, &state);
543 common_volop_prolog(as, &state);
545 do_volop(&state, FSYNC_VOL_LEAVE_OFF, NULL);
551 VolForceAttach(struct cmd_syndesc * as, void * rock)
553 struct fssync_state state;
555 common_prolog(as, &state);
556 common_volop_prolog(as, &state);
558 do_volop(&state, FSYNC_VOL_ATTACH, NULL);
564 VolForceError(struct cmd_syndesc * as, void * rock)
566 struct fssync_state state;
568 common_prolog(as, &state);
569 common_volop_prolog(as, &state);
571 do_volop(&state, FSYNC_VOL_FORCE_ERROR, NULL);
576 #ifdef AFS_DEMAND_ATTACH_FS
578 vol_state_to_string(VolState state)
581 ENUMCASE(VOL_STATE_UNATTACHED);
582 ENUMCASE(VOL_STATE_PREATTACHED);
583 ENUMCASE(VOL_STATE_ATTACHING);
584 ENUMCASE(VOL_STATE_ATTACHED);
585 ENUMCASE(VOL_STATE_UPDATING);
586 ENUMCASE(VOL_STATE_GET_BITMAP);
587 ENUMCASE(VOL_STATE_HDR_LOADING);
588 ENUMCASE(VOL_STATE_HDR_ATTACHING);
589 ENUMCASE(VOL_STATE_SHUTTING_DOWN);
590 ENUMCASE(VOL_STATE_GOING_OFFLINE);
591 ENUMCASE(VOL_STATE_OFFLINING);
592 ENUMCASE(VOL_STATE_DETACHING);
593 ENUMCASE(VOL_STATE_SALVSYNC_REQ);
594 ENUMCASE(VOL_STATE_SALVAGING);
595 ENUMCASE(VOL_STATE_ERROR);
596 ENUMCASE(VOL_STATE_VNODE_ALLOC);
597 ENUMCASE(VOL_STATE_VNODE_GET);
598 ENUMCASE(VOL_STATE_VNODE_CLOSE);
599 ENUMCASE(VOL_STATE_VNODE_RELEASE);
600 ENUMCASE(VOL_STATE_VLRU_ADD);
601 ENUMCASE(VOL_STATE_DELETED);
602 ENUMCASE(VOL_STATE_SALVAGE_REQ);
603 ENUMCASE(VOL_STATE_FREED);
605 return "**UNKNOWN**";
610 vol_flags_to_string(afs_uint16 flags)
612 static char str[256];
616 FLAGCASE(flags, VOL_HDR_ATTACHED, str, count);
617 FLAGCASE(flags, VOL_HDR_LOADED, str, count);
618 FLAGCASE(flags, VOL_HDR_IN_LRU, str, count);
619 FLAGCASE(flags, VOL_IN_HASH, str, count);
620 FLAGCASE(flags, VOL_ON_VBYP_LIST, str, count);
621 FLAGCASE(flags, VOL_IS_BUSY, str, count);
622 FLAGCASE(flags, VOL_ON_VLRU, str, count);
623 FLAGCASE(flags, VOL_HDR_DONTSALV, str, count);
624 FLAGCASE(flags, VOL_LOCKED, str, count);
630 vlru_idx_to_string(int idx)
633 ENUMCASE(VLRU_QUEUE_NEW);
634 ENUMCASE(VLRU_QUEUE_MID);
635 ENUMCASE(VLRU_QUEUE_OLD);
636 ENUMCASE(VLRU_QUEUE_CANDIDATE);
637 ENUMCASE(VLRU_QUEUE_HELD);
638 ENUMCASE(VLRU_QUEUE_INVALID);
640 return "**UNKNOWN**";
646 vn_state_to_string(VnState state)
649 ENUMCASE(VN_STATE_INVALID);
650 ENUMCASE(VN_STATE_RELEASING);
651 ENUMCASE(VN_STATE_CLOSING);
652 ENUMCASE(VN_STATE_ALLOC);
653 ENUMCASE(VN_STATE_ONLINE);
654 ENUMCASE(VN_STATE_LOAD);
655 ENUMCASE(VN_STATE_EXCLUSIVE);
656 ENUMCASE(VN_STATE_STORE);
657 ENUMCASE(VN_STATE_READ);
658 ENUMCASE(VN_STATE_ERROR);
660 return "**UNKNOWN**";
665 vn_flags_to_string(afs_uint32 flags)
667 static char str[128];
671 FLAGCASE(flags, VN_ON_HASH, str, count);
672 FLAGCASE(flags, VN_ON_LRU, str, count);
673 FLAGCASE(flags, VN_ON_VVN, str, count);
680 VolQuery(struct cmd_syndesc * as, void * rock)
682 struct fssync_state state;
683 SYNC_PROTO_BUF_DECL(res_buf);
689 res.hdr.response_len = sizeof(res.hdr);
690 res.payload.buf = res_buf;
691 res.payload.len = SYNC_PROTO_MAX_LEN;
693 common_prolog(as, &state);
694 common_volop_prolog(as, &state);
696 do_volop(&state, FSYNC_VOL_QUERY, &res);
698 if (res.hdr.response == SYNC_OK) {
699 memcpy(&v, res.payload.buf, sizeof(Volume));
701 printf("volume = {\n");
702 printf("\thashid = %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(v.hashid));
703 printf("\theader = %p\n", v.header);
704 printf("\tdevice = %d\n", v.device);
705 printf("\tpartition = %p\n", v.partition);
706 printf("\tlinkHandle = %p\n", v.linkHandle);
707 printf("\tnextVnodeUnique = %u\n", v.nextVnodeUnique);
708 printf("\tdiskDataHandle = %p\n", v.diskDataHandle);
709 printf("\tvnodeHashOffset = %u\n", v.vnodeHashOffset);
710 printf("\tshuttingDown = %d\n", v.shuttingDown);
711 printf("\tgoingOffline = %d\n", v.goingOffline);
712 printf("\tcacheCheck = %u\n", v.cacheCheck);
713 printf("\tnUsers = %d\n", v.nUsers);
714 printf("\tneedsPutBack = %d\n", v.needsPutBack);
715 printf("\tspecialStatus = %d\n", v.specialStatus);
716 printf("\tupdateTime = %u\n", v.updateTime);
718 printf("\tvnodeIndex[vSmall] = {\n");
719 printf("\t\thandle = %p\n", v.vnodeIndex[vSmall].handle);
720 printf("\t\tbitmap = %p\n", v.vnodeIndex[vSmall].bitmap);
721 printf("\t\tbitmapSize = %u\n", v.vnodeIndex[vSmall].bitmapSize);
722 printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vSmall].bitmapOffset);
724 printf("\tvnodeIndex[vLarge] = {\n");
725 printf("\t\thandle = %p\n", v.vnodeIndex[vLarge].handle);
726 printf("\t\tbitmap = %p\n", v.vnodeIndex[vLarge].bitmap);
727 printf("\t\tbitmapSize = %u\n", v.vnodeIndex[vLarge].bitmapSize);
728 printf("\t\tbitmapOffset = %u\n", v.vnodeIndex[vLarge].bitmapOffset);
730 #ifdef AFS_DEMAND_ATTACH_FS
731 if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
732 printf("\tupdateTime = %u\n", v.updateTime);
733 printf("\tattach_state = %s\n", vol_state_to_string(v.attach_state));
734 printf("\tattach_flags = %s\n", vol_flags_to_string(v.attach_flags));
735 printf("\tnWaiters = %d\n", v.nWaiters);
736 printf("\tchainCacheCheck = %d\n", v.chainCacheCheck);
738 /* online salvage structure */
739 printf("\tsalvage = {\n");
740 printf("\t\tprio = %u\n", v.salvage.prio);
741 printf("\t\treason = %d\n", v.salvage.reason);
742 printf("\t\trequested = %d\n", v.salvage.requested);
743 printf("\t\tscheduled = %d\n", v.salvage.scheduled);
746 /* statistics structure */
747 printf("\tstats = {\n");
749 printf("\t\thash_lookups = %"AFS_INT64_FMT"\n",
750 v.stats.hash_lookups);
751 printf("\t\thash_short_circuits = %"AFS_INT64_FMT"\n",
752 v.stats.hash_short_circuits);
753 printf("\t\thdr_loads = %"AFS_INT64_FMT"\n",
755 printf("\t\thdr_gets = %"AFS_INT64_FMT"\n",
759 printf("\t\tattaches = %u\n", v.stats.attaches);
760 printf("\t\tsoft_detaches = %u\n", v.stats.soft_detaches);
761 printf("\t\tsalvages = %u\n", v.stats.salvages);
762 printf("\t\tvol_ops = %u\n", v.stats.vol_ops);
764 printf("\t\tlast_attach = %u\n", v.stats.last_attach);
765 printf("\t\tlast_get = %u\n", v.stats.last_get);
766 printf("\t\tlast_promote = %u\n", v.stats.last_promote);
767 printf("\t\tlast_hdr_get = %u\n", v.stats.last_hdr_get);
768 printf("\t\tlast_hdr_load = %u\n", v.stats.last_hdr_load);
769 printf("\t\tlast_salvage = %u\n", v.stats.last_salvage);
770 printf("\t\tlast_salvage_req = %u\n", v.stats.last_salvage_req);
771 printf("\t\tlast_vol_op = %u\n", v.stats.last_vol_op);
775 printf("\tvlru = {\n");
776 printf("\t\tidx = %d (%s)\n",
777 v.vlru.idx, vlru_idx_to_string(v.vlru.idx));
780 /* volume op state */
781 printf("\tpending_vol_op = %p\n", v.pending_vol_op);
783 #else /* !AFS_DEMAND_ATTACH_FS */
784 if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
785 printf("*** server asserted demand attach extensions. this fssync-debug\n"
786 "*** is not built to recognize those extensions. please use an\n"
787 "*** fssync-debug with demand attach if you need to dump dafs\n"
788 "*** extended state.\n");
790 #endif /* !AFS_DEMAND_ATTACH_FS */
798 VolHdrQuery(struct cmd_syndesc * as, void * rock)
800 struct fssync_state state;
801 SYNC_PROTO_BUF_DECL(res_buf);
806 res.hdr.response_len = sizeof(res.hdr);
807 res.payload.buf = res_buf;
808 res.payload.len = SYNC_PROTO_MAX_LEN;
810 common_prolog(as, &state);
811 common_volop_prolog(as, &state);
813 do_volop(&state, FSYNC_VOL_QUERY_HDR, &res);
815 if (res.hdr.response == SYNC_OK) {
816 memcpy(&v, res.payload.buf, sizeof(VolumeDiskData));
818 printf("VolumeDiskData = {\n");
819 printf("\tstamp = {\n");
820 printf("\t\tmagic = 0x%x\n", v.stamp.magic);
821 printf("\t\tversion = %u\n", v.stamp.version);
824 printf("\tid = %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(v.id));
825 printf("\tname = '%s'\n", v.name);
827 printf("\tinUse = %d (%s)\n", v.inUse, VPTypeToString(v.inUse));
829 printf("\tinUse = %d (no)\n", v.inUse);
831 printf("\tinService = %d\n", v.inService);
832 printf("\tblessed = %d\n", v.blessed);
833 printf("\tneedsSalvaged = %d\n", v.needsSalvaged);
834 printf("\tuniquifier = %u\n", v.uniquifier);
835 printf("\ttype = %d\n", v.type);
836 printf("\tparentId = %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(v.parentId));
837 printf("\tcloneId = %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(v.cloneId));
838 printf("\tbackupId = %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(v.backupId));
839 printf("\trestoredFromId = %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(v.restoredFromId));
840 printf("\tneedsCallback = %d\n", v.needsCallback);
841 printf("\tdestroyMe = %d\n", v.destroyMe);
842 printf("\tdontSalvage = %d\n", v.dontSalvage);
843 printf("\tmaxquota = %d\n", v.maxquota);
844 printf("\tminquota = %d\n", v.minquota);
845 printf("\tmaxfiles = %d\n", v.maxfiles);
846 printf("\taccountNumber = %u\n", v.accountNumber);
847 printf("\towner = %u\n", v.owner);
848 printf("\tfilecount = %d\n", v.filecount);
849 printf("\tdiskused = %d\n", v.diskused);
850 printf("\tdayUse = %d\n", v.dayUse);
851 for (i = 0; i < 7; i++) {
852 printf("\tweekUse[%d] = %d\n", i, v.weekUse[i]);
854 printf("\tdayUseDate = %u\n", v.dayUseDate);
855 printf("\tcreationDate = %u\n", v.creationDate);
856 printf("\taccessDate = %u\n", v.accessDate);
857 printf("\tupdateDate = %u\n", v.updateDate);
858 printf("\texpirationDate = %u\n", v.expirationDate);
859 printf("\tbackupDate = %u\n", v.backupDate);
860 printf("\tcopyDate = %u\n", v.copyDate);
861 printf("\tstat_initialized = %d\n", v.stat_initialized);
869 VolOpQuery(struct cmd_syndesc * as, void * rock)
871 struct fssync_state state;
872 SYNC_PROTO_BUF_DECL(res_buf);
874 FSSYNC_VolOp_info vop;
876 res.hdr.response_len = sizeof(res.hdr);
877 res.payload.buf = res_buf;
878 res.payload.len = SYNC_PROTO_MAX_LEN;
880 common_prolog(as, &state);
881 common_volop_prolog(as, &state);
883 do_volop(&state, FSYNC_VOL_QUERY_VOP, &res);
885 if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
886 printf("*** file server not compiled with demand attach extensions.\n");
887 printf("*** pending volume operation metadata not available.\n");
890 if (res.hdr.response == SYNC_OK) {
891 memcpy(&vop, res.payload.buf, sizeof(FSSYNC_VolOp_info));
893 printf("pending_vol_op = {\n");
895 printf("\tcom = {\n");
896 printf("\t\tproto_version = %u\n", vop.com.proto_version);
897 printf("\t\tpkt_seq = %u\n", vop.com.pkt_seq);
898 printf("\t\tcom_seq = %u\n", vop.com.com_seq);
899 printf("\t\tprogramType = %d (%s)\n",
900 vop.com.programType, VPTypeToString(vop.com.programType));
901 printf("\t\tpid = %d\n", vop.com.pid);
902 printf("\t\ttid = %d\n", vop.com.tid);
903 printf("\t\tcommand = %d (%s)\n",
904 vop.com.command, FSYNC_com2string(vop.com.command));
905 printf("\t\treason = %d (%s)\n",
906 vop.com.reason, FSYNC_reason2string(vop.com.reason));
907 printf("\t\tcommand_len = %u\n", vop.com.command_len);
908 printf("\t\tflags = 0x%lux\n", afs_printable_uint32_lu(vop.com.flags));
911 printf("\tvop = {\n");
912 printf("\t\tvolume = %" AFS_VOLID_FMT "\n", afs_printable_VolumeId_lu(vop.vop.volume));
913 if (strnlen(vop.vop.partName, sizeof(vop.vop.partName)) <
914 sizeof(vop.vop.partName)) {
915 printf("\t\tpartName = '%s'\n", vop.vop.partName);
917 printf("\t\tpartName = (illegal string)\n");
928 vn_prolog(struct cmd_syndesc * as, struct fssync_state * state)
932 state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state));
933 osi_Assert(state->vop != NULL);
935 if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) { /* -volumeid */
936 state->vop->volume = atoi(ti->data);
938 fprintf(stderr, "required argument -volumeid not given\n");
941 if ((ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -vnodeid */
942 state->vop->vnode = atoi(ti->data);
944 fprintf(stderr, "required argument -vnodeid not given\n");
947 if ((ti = as->parms[CUSTOM_PARMS_OFFSET+2].items)) { /* -unique */
948 state->vop->unique = atoi(ti->data);
950 state->vop->unique = 0;
953 if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET+3].items)) { /* -partition */
954 strlcpy(state->vop->partName, ti->data, sizeof(state->vop->partName));
956 memset(state->vop->partName, 0, sizeof(state->vop->partName));
963 do_vnqry(struct fssync_state * state, SYNC_response * res)
966 int command = FSYNC_VOL_QUERY_VNODE;
967 FSSYNC_VnQry_hdr qry;
969 qry.volume = state->vop->volume;
970 qry.vnode = state->vop->vnode;
971 qry.unique = state->vop->unique;
973 strlcpy(qry.partName, state->vop->partName, sizeof(qry.partName));
975 fprintf(stderr, "calling FSYNC_GenericOp with command code %d (%s)\n",
976 command, FSYNC_com2string(command));
978 code = FSYNC_GenericOp(&qry, sizeof(qry), command, FSYNC_OPERATOR, res);
980 debug_response(code, res);
988 VnQuery(struct cmd_syndesc * as, void * rock)
990 struct fssync_state state;
991 SYNC_PROTO_BUF_DECL(res_buf);
997 res.hdr.response_len = sizeof(res.hdr);
998 res.payload.buf = res_buf;
999 res.payload.len = SYNC_PROTO_MAX_LEN;
1001 common_prolog(as, &state);
1002 vn_prolog(as, &state);
1004 do_vnqry(&state, &res);
1006 if (res.hdr.response == SYNC_OK) {
1007 memcpy(&v, res.payload.buf, sizeof(Vnode));
1009 printf("vnode = {\n");
1011 printf("\tvid_hash = {\n");
1012 printf("\t\tnext = %p\n", v.vid_hash.next);
1013 printf("\t\tprev = %p\n", v.vid_hash.prev);
1016 printf("\thashNext = %p\n", v.hashNext);
1017 printf("\tlruNext = %p\n", v.lruNext);
1018 printf("\tlruPrev = %p\n", v.lruPrev);
1019 printf("\thashIndex = %hu\n", v.hashIndex);
1020 printf("\tchanged_newTime = %u\n", (unsigned int) v.changed_newTime);
1021 printf("\tchanged_oldTime = %u\n", (unsigned int) v.changed_oldTime);
1022 printf("\tdelete = %u\n", (unsigned int) v.delete);
1023 printf("\tvnodeNumber = %u\n", v.vnodeNumber);
1024 printf("\tvolumePtr = %p\n", v.volumePtr);
1025 printf("\tnUsers = %u\n", v.nUsers);
1026 printf("\tcacheCheck = %u\n", v.cacheCheck);
1028 #ifdef AFS_DEMAND_ATTACH_FS
1029 if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) {
1030 printf("*** this fssync-debug is built to expect demand attach extensions.\n"
1031 "*** server asserted that is was not compiled with demand attach.\n"
1032 "*** please use an fssync-debug without demand attach to match your\n"
1037 printf("\tnReaders = %u\n", v.nReaders);
1038 printf("\tvn_state_flags = %s\n", vn_flags_to_string(v.vn_state_flags));
1039 printf("\tvn_state = %s\n", vn_state_to_string(v.vn_state));
1041 if (res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS) {
1042 printf("*** server asserted demand attach extensions. this fssync-debug is not\n"
1043 "*** built to recognize those extensions. please use an fssync-debug\n"
1044 "*** with demand attach to match your server.\n");
1047 #endif /* !AFS_DEMAND_ATTACH_FS */
1049 printf("\tvcp = %p\n", v.vcp);
1050 printf("\thandle = %p\n", v.handle);
1052 printf("\tdisk = {\n");
1053 printf("\t\ttype = %u\n", v.disk.type);
1054 printf("\t\tcloned = %u\n", v.disk.cloned);
1055 printf("\t\tmodeBits = %u\n", v.disk.modeBits);
1056 printf("\t\tlinkCount = %d\n", v.disk.linkCount);
1057 printf("\t\tlength = %u\n", v.disk.length);
1058 printf("\t\tuniquifier = %u\n", v.disk.uniquifier);
1059 printf("\t\tdataVersion = %u\n", v.disk.dataVersion);
1060 printf("\t\tvn_ino_lo = %u\n", v.disk.vn_ino_lo);
1061 printf("\t\tunixModifyTime = %u\n", v.disk.unixModifyTime);
1062 printf("\t\tauthor = %u\n", v.disk.author);
1063 printf("\t\towner = %u\n", v.disk.owner);
1064 printf("\t\tparent = %u\n", v.disk.parent);
1065 printf("\t\tvnodeMagic = %u\n", v.disk.vnodeMagic);
1067 printf("\t\tlock = {\n");
1068 printf("\t\t\tlockCount = %d\n", v.disk.lock.lockCount);
1069 printf("\t\t\tlockTime = %d\n", v.disk.lock.lockTime);
1072 printf("\t\tserverModifyTime = %u\n", v.disk.serverModifyTime);
1073 printf("\t\tgroup = %d\n", v.disk.group);
1074 printf("\t\tvn_ino_hi = %d\n", v.disk.vn_ino_hi);
1075 printf("\t\tvn_length_hi = %u\n", v.disk.vn_length_hi);
1087 StatsQuery(struct cmd_syndesc * as, void * rock)
1091 struct cmd_item *ti;
1092 struct fssync_state state;
1093 SYNC_PROTO_BUF_DECL(res_buf);
1095 FSSYNC_StatsOp_hdr scom;
1097 res.hdr.response_len = sizeof(res.hdr);
1098 res.payload.buf = res_buf;
1099 res.payload.len = SYNC_PROTO_MAX_LEN;
1101 if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) { /* -subcommand */
1102 if (!strcasecmp(ti->data, "vicep")) {
1103 command = FSYNC_VOL_STATS_VICEP;
1104 } else if (!strcasecmp(ti->data, "hash")) {
1105 command = FSYNC_VOL_STATS_HASH;
1106 #ifdef AFS_DEMAND_ATTACH_FS
1107 } else if (!strcasecmp(ti->data, "hdr")) {
1108 command = FSYNC_VOL_STATS_HDR;
1109 } else if (!strcasecmp(ti->data, "vlru")) {
1110 command = FSYNC_VOL_STATS_VLRU;
1112 } else if (!strcasecmp(ti->data, "pkg")) {
1113 command = FSYNC_VOL_STATS_GENERAL;
1114 } else if (!strcasecmp(ti->data, "help")) {
1115 fprintf(stderr, "fssync-debug stats subcommands:\n");
1116 fprintf(stderr, "\tpkg\tgeneral volume package stats\n");
1117 fprintf(stderr, "\tvicep\tvice partition stats\n");
1118 fprintf(stderr, "\thash\tvolume hash chain stats\n");
1119 #ifdef AFS_DEMAND_ATTACH_FS
1120 fprintf(stderr, "\thdr\tvolume header cache stats\n");
1121 fprintf(stderr, "\tvlru\tvlru generation stats\n");
1125 fprintf(stderr, "invalid stats subcommand");
1129 command = FSYNC_VOL_STATS_GENERAL;
1132 if ((ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -arg1 */
1134 case FSYNC_VOL_STATS_VICEP:
1135 strlcpy(scom.args.partName, ti->data, sizeof(state.vop->partName));
1137 case FSYNC_VOL_STATS_HASH:
1138 scom.args.hash_bucket = atoi(ti->data);
1140 case FSYNC_VOL_STATS_VLRU:
1141 scom.args.vlru_generation = atoi(ti->data);
1144 fprintf(stderr, "unrecognized arguments\n");
1149 case FSYNC_VOL_STATS_VICEP:
1150 case FSYNC_VOL_STATS_HASH:
1151 case FSYNC_VOL_STATS_VLRU:
1152 fprintf(stderr, "this subcommand requires more parameters\n");
1157 common_prolog(as, &state);
1159 fprintf(stderr, "calling FSYNC_askfs with command code %d (%s)\n",
1160 command, FSYNC_com2string(command));
1162 code = FSYNC_StatsOp(&scom, command, FSYNC_WHATEVER, &res);
1169 fprintf(stderr, "possible sync protocol error. return code was %d\n", code);
1172 fprintf(stderr, "FSYNC_VolOp returned %d (%s)\n", code, SYNC_res2string(code));
1173 fprintf(stderr, "protocol response code was %d (%s)\n",
1174 res.hdr.response, SYNC_res2string(res.hdr.response));
1175 fprintf(stderr, "protocol reason code was %d (%s)\n",
1176 res.hdr.reason, FSYNC_reason2string(res.hdr.reason));
1180 if (res.hdr.response == SYNC_OK) {
1182 case FSYNC_VOL_STATS_GENERAL:
1184 struct VolPkgStats vol_stats;
1185 memcpy(&vol_stats, res_buf, sizeof(vol_stats));
1186 print_vol_stats_general(&vol_stats);
1189 case FSYNC_VOL_STATS_VICEP:
1191 struct DiskPartitionStats64 vicep_stats;
1192 memcpy(&vicep_stats, res_buf, sizeof(vicep_stats));
1193 print_vol_stats_viceP(&vicep_stats);
1196 case FSYNC_VOL_STATS_HASH:
1198 struct VolumeHashChainStats hash_stats;
1199 memcpy(&hash_stats, res_buf, sizeof(hash_stats));
1200 print_vol_stats_hash(&hash_stats);
1203 #ifdef AFS_DEMAND_ATTACH_FS
1204 case FSYNC_VOL_STATS_HDR:
1206 struct volume_hdr_LRU_stats hdr_stats;
1207 memcpy(&hdr_stats, res_buf, sizeof(hdr_stats));
1208 print_vol_stats_hdr(&hdr_stats);
1211 #endif /* AFS_DEMAND_ATTACH_FS */
1219 print_vol_stats_general(VolPkgStats * stats)
1221 #ifdef AFS_DEMAND_ATTACH_FS
1225 printf("VolPkgStats = {\n");
1226 #ifdef AFS_DEMAND_ATTACH_FS
1227 for (i = 0; i < VOL_STATE_COUNT; i++) {
1228 printf("\tvol_state_count[%s] = %d\n",
1229 vol_state_to_string(i),
1230 stats->state_levels[i]);
1233 printf("\thash_looks = %"AFS_INT64_FMT"\n",
1235 printf("\thash_reorders = %"AFS_INT64_FMT"\n",
1236 stats->hash_reorders);
1237 printf("\tsalvages = %"AFS_INT64_FMT"\n",
1239 printf("\tvol_ops = %"AFS_INT64_FMT"\n",
1242 printf("\thdr_loads = %"AFS_INT64_FMT"\n",
1244 printf("\thdr_gets = %"AFS_INT64_FMT"\n",
1246 printf("\tattaches = %"AFS_INT64_FMT"\n",
1248 printf("\tsoft_detaches = %"AFS_INT64_FMT"\n",
1249 stats->soft_detaches);
1250 printf("\thdr_cache_size = %d\n", stats->hdr_cache_size);
1256 print_vol_stats_viceP(struct DiskPartitionStats64 * stats)
1258 printf("DiskPartitionStats64 = {\n");
1259 printf("\tfree = %" AFS_INT64_FMT "\n", stats->free);
1260 printf("\tminFree = %" AFS_INT64_FMT "\n", stats->minFree);
1261 printf("\ttotalUsable = %" AFS_INT64_FMT "\n", stats->totalUsable);
1262 printf("\tf_files = %" AFS_INT64_FMT "\n", stats->f_files);
1263 #ifdef AFS_DEMAND_ATTACH_FS
1264 printf("\tvol_list_len = %d\n", stats->vol_list_len);
1270 print_vol_stats_hash(struct VolumeHashChainStats * stats)
1272 printf("DiskPartitionStats = {\n");
1273 printf("\ttable_size = %d\n", stats->table_size);
1274 printf("\tchain_len = %d\n", stats->chain_len);
1276 #ifdef AFS_DEMAND_ATTACH_FS
1277 printf("\tchain_cacheCheck = %d\n", stats->chain_cacheCheck);
1278 printf("\tchain_busy = %d\n", stats->chain_busy);
1280 printf("\tchain_looks = %"AFS_INT64_FMT"\n",
1281 stats->chain_looks);
1282 printf("\tchain_gets = %"AFS_INT64_FMT"\n",
1284 printf("\tchain_reorders = %"AFS_INT64_FMT"\n",
1285 stats->chain_reorders);
1286 #endif /* AFS_DEMAND_ATTACH_FS */
1292 #ifdef AFS_DEMAND_ATTACH_FS
1294 print_vol_stats_hdr(struct volume_hdr_LRU_stats * stats)
1296 printf("volume_hdr_LRU_stats = {\n");
1297 printf("\tfree = %d\n", stats->free);
1298 printf("\tused = %d\n", stats->used);
1299 printf("\tattached = %d\n", stats->attached);
1302 #endif /* AFS_DEMAND_ATTACH_FS */
1309 * - CUSTOM_PARMS_OFFSET+0 is partition string
1310 * - CUSTOM_PARMS_OFFSET+1 is volume id
1312 * @return operation status
1316 VGCQuery(struct cmd_syndesc * as, void * rock)
1319 struct fssync_state state;
1322 FSSYNC_VGQry_response_t q_res;
1325 struct cmd_item *ti;
1327 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1330 partName = ti->data;
1332 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -volumeid */
1335 volid = atoi(ti->data);
1337 common_prolog(as, &state);
1339 fprintf(stderr, "calling FSYNC_VCGQuery\n");
1341 code = FSYNC_VGCQuery(partName, volid, &q_res, &res);
1343 debug_response(code, &res);
1345 if (code == SYNC_OK) {
1347 printf("\trw\t=\t%u\n", q_res.rw);
1348 printf("\tchildren\t= (\n");
1349 for (i = 0; i < VOL_VG_MAX_VOLS; i++) {
1350 if (q_res.children[i]) {
1351 printf("\t\t%u\n", q_res.children[i]);
1363 VGCAdd(struct cmd_syndesc * as, void * rock)
1366 struct fssync_state state;
1368 VolumeId parent, child;
1369 struct cmd_item *ti;
1372 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1375 partName = ti->data;
1377 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -parent */
1380 parent = atoi(ti->data);
1382 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+2].items)) { /* -child */
1385 child = atoi(ti->data);
1387 common_prolog(as, &state);
1388 fprintf(stderr, "calling FSYNC_VCGAdd\n");
1389 code = FSYNC_VGCAdd(partName, parent, child, state.reason, &res);
1390 debug_response(code, &res);
1398 VGCDel(struct cmd_syndesc * as, void * rock)
1401 struct fssync_state state;
1403 VolumeId parent, child;
1404 struct cmd_item *ti;
1407 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1410 partName = ti->data;
1412 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -parent */
1415 parent = atoi(ti->data);
1417 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+2].items)) { /* -child */
1420 child = atoi(ti->data);
1422 common_prolog(as, &state);
1423 fprintf(stderr, "calling FSYNC_VCGDel\n");
1424 code = FSYNC_VGCDel(partName, parent, child, state.reason, &res);
1425 debug_response(code, &res);
1433 VGCScan(struct cmd_syndesc * as, void * rock)
1436 struct fssync_state state;
1438 struct cmd_item *ti;
1440 if (!(ti = as->parms[CUSTOM_PARMS_OFFSET+0].items)) { /* -partition */
1443 partName = ti->data;
1445 common_prolog(as, &state);
1446 fprintf(stderr, "calling FSYNC_VCGScan\n");
1447 code = FSYNC_VGCScan(partName, state.reason);
1448 debug_response(code, NULL);
1456 VGCScanAll(struct cmd_syndesc * as, void * rock)
1459 struct fssync_state state;
1461 common_prolog(as, &state);
1462 fprintf(stderr, "calling FSYNC_VCGScanAll\n");
1463 code = FSYNC_VGCScan(NULL, state.reason);
1464 debug_response(code, NULL);