static int VolOpQuery(struct cmd_syndesc * as, void * rock) { struct state state; SYNC_PROTO_BUF_DECL(res_buf); SYNC_response res; FSSYNC_VolOp_info vop; int i; res.hdr.response_len = sizeof(res.hdr); res.payload.buf = res_buf; res.payload.len = SYNC_PROTO_MAX_LEN; common_prolog(as, &state); common_volop_prolog(as, &state); do_volop(&state, FSYNC_VOL_QUERY_VOP, &res); if (!(res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) { printf("*** file server not compiled with demand attach extensions.\n"); printf("*** pending volume operation metadata not available.\n"); } if (res.hdr.response == SYNC_OK) { memcpy(&vop, res.payload.buf, sizeof(FSSYNC_VolOp_info)); printf("pending_vol_op = {\n"); printf("\tcom = {\n"); printf("\t\tproto_version = %u\n", vop.com.proto_version); printf("\t\tpkt_seq = %u\n", vop.com.pkt_seq); printf("\t\tcom_seq = %u\n", vop.com.com_seq); printf("\t\tprogramType = %d (%s)\n", vop.com.programType, program_type_to_string(vop.com.programType)); printf("\t\tpid = %d\n", vop.com.pid); printf("\t\ttid = %d\n", vop.com.tid); printf("\t\tcommand = %d (%s)\n", vop.com.command, command_code_to_string(vop.com.command)); printf("\t\treason = %d (%s)\n", vop.com.reason, reason_code_to_string(vop.com.reason)); printf("\t\tcommand_len = %u\n", vop.com.command_len); printf("\t\tflags = 0x%x\n", vop.com.flags); printf("\t}\n"); printf("\tvop = {\n"); printf("\t\tvolume = %u\n", vop.vop.volume); if (afs_strnlen(vop.vop.partName, sizeof(vop.vop.partName)) < sizeof(vop.vop.partName)) { printf("\t\tpartName = '%s'\n", vop.vop.partName); } else { printf("\t\tpartName = (illegal string)\n"); } printf("\t}\n"); printf("}\n"); } return 0; }
static int do_salvop(struct fssync_state * state, afs_int32 command, SYNC_response * res) { afs_int32 code; SALVSYNC_response_hdr hdr_l, *hdr; SYNC_response res_l; if (!res) { res = &res_l; res->payload.len = sizeof(hdr_l); res->payload.buf = hdr = &hdr_l; } else { hdr = (SALVSYNC_response_hdr *) res->payload.buf; } fprintf(stderr, "calling SALVSYNC_SalvageVolume with command code %d (%s)\n", command, command_code_to_string(command)); code = SALVSYNC_SalvageVolume(state->sop->volume, state->sop->partName, command, state->reason, state->sop->prio, res); switch (code) { case SYNC_OK: case SYNC_DENIED: break; default: fprintf(stderr, "possible sync protocol error. return code was %d\n", code); } fprintf(stderr, "SALVSYNC_SalvageVolume returned %d (%s)\n", code, response_code_to_string(code)); fprintf(stderr, "protocol response code was %d (%s)\n", res->hdr.response, response_code_to_string(res->hdr.response)); fprintf(stderr, "protocol reason code was %d (%s)\n", res->hdr.reason, reason_code_to_string(res->hdr.reason)); printf("state = {\n"); if (res->hdr.flags & SALVSYNC_FLAG_VOL_STATS_VALID) { printf("\tstate = %d (%s)\n", hdr->state, state_code_to_string(hdr->state)); printf("\tprio = %d\n", hdr->prio); } printf("\tsq_len = %d\n", hdr->sq_len); printf("\tpq_len = %d\n", hdr->pq_len); printf("}\n"); VDisconnectSALV(); return 0; }
static int do_volop(struct state * state, afs_int32 command, SYNC_response * res) { afs_int32 code; SYNC_PROTO_BUF_DECL(res_buf); SYNC_response res_l; if (!res) { res = &res_l; res->payload.len = SYNC_PROTO_MAX_LEN; res->payload.buf = res_buf; } fprintf(stderr, "calling FSYNC_VolOp with command code %d (%s)\n", command, command_code_to_string(command)); code = FSYNC_VolOp(state->vop->volume, state->vop->partName, command, state->reason, res); switch (code) { case SYNC_OK: case SYNC_DENIED: break; default: fprintf(stderr, "possible sync protocol error. return code was %d\n", code); } fprintf(stderr, "FSYNC_VolOp returned %d (%s)\n", code, response_code_to_string(code)); fprintf(stderr, "protocol response code was %d (%s)\n", res->hdr.response, response_code_to_string(res->hdr.response)); fprintf(stderr, "protocol reason code was %d (%s)\n", res->hdr.reason, reason_code_to_string(res->hdr.reason)); VDisconnectFS(); }
static int do_vnqry(struct state * state, SYNC_response * res) { afs_int32 code; int command = FSYNC_VOL_QUERY_VNODE; FSSYNC_VnQry_hdr qry; qry.volume = state->vop->volume; qry.vnode = state->vop->vnode; qry.unique = state->vop->unique; qry.spare = 0; strlcpy(qry.partName, state->vop->partName, sizeof(qry.partName)); fprintf(stderr, "calling FSYNC_GenericOp with command code %d (%s)\n", command, command_code_to_string(command)); code = FSYNC_GenericOp(&qry, sizeof(qry), command, FSYNC_OPERATOR, res); switch (code) { case SYNC_OK: case SYNC_DENIED: break; default: fprintf(stderr, "possible sync protocol error. return code was %d\n", code); } fprintf(stderr, "FSYNC_GenericOp returned %d (%s)\n", code, response_code_to_string(code)); fprintf(stderr, "protocol response code was %d (%s)\n", res->hdr.response, response_code_to_string(res->hdr.response)); fprintf(stderr, "protocol reason code was %d (%s)\n", res->hdr.reason, reason_code_to_string(res->hdr.reason)); VDisconnectFS(); return 0; }
static int StatsQuery(struct cmd_syndesc * as, void * rock) { afs_int32 code; int command; struct cmd_item *ti; struct state state; SYNC_PROTO_BUF_DECL(res_buf); SYNC_response res; FSSYNC_StatsOp_hdr scom; union { void * ptr; struct VolPkgStats * vol_stats; struct VolumeHashChainStats * hash_stats; #ifdef AFS_DEMAND_ATTACH_FS struct volume_hdr_LRU_stats * hdr_stats; #endif struct DiskPartitionStats64 * vicep_stats; } sres; sres.ptr = res_buf; res.hdr.response_len = sizeof(res.hdr); res.payload.buf = res_buf; res.payload.len = SYNC_PROTO_MAX_LEN; if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) { /* -subcommand */ if (!strcasecmp(ti->data, "vicep")) { command = FSYNC_VOL_STATS_VICEP; } else if (!strcasecmp(ti->data, "hash")) { command = FSYNC_VOL_STATS_HASH; #ifdef AFS_DEMAND_ATTACH_FS } else if (!strcasecmp(ti->data, "hdr")) { command = FSYNC_VOL_STATS_HDR; } else if (!strcasecmp(ti->data, "vlru")) { command = FSYNC_VOL_STATS_VLRU; #endif } else if (!strcasecmp(ti->data, "pkg")) { command = FSYNC_VOL_STATS_GENERAL; } else if (!strcasecmp(ti->data, "help")) { fprintf(stderr, "fssync-debug stats subcommands:\n"); fprintf(stderr, "\tpkg\tgeneral volume package stats\n"); fprintf(stderr, "\tvicep\tvice partition stats\n"); fprintf(stderr, "\thash\tvolume hash chain stats\n"); #ifdef AFS_DEMAND_ATTACH_FS fprintf(stderr, "\thdr\tvolume header cache stats\n"); fprintf(stderr, "\tvlru\tvlru generation stats\n"); #endif exit(0); } else { fprintf(stderr, "invalid stats subcommand"); exit(1); } } else { command = FSYNC_VOL_STATS_GENERAL; } if ((ti = as->parms[CUSTOM_PARMS_OFFSET+1].items)) { /* -arg1 */ switch (command) { case FSYNC_VOL_STATS_VICEP: strlcpy(scom.args.partName, ti->data, sizeof(state.vop->partName)); break; case FSYNC_VOL_STATS_HASH: scom.args.hash_bucket = atoi(ti->data); break; case FSYNC_VOL_STATS_VLRU: scom.args.vlru_generation = atoi(ti->data); break; default: fprintf(stderr, "unrecognized arguments\n"); exit(1); } } else { switch (command) { case FSYNC_VOL_STATS_VICEP: case FSYNC_VOL_STATS_HASH: case FSYNC_VOL_STATS_VLRU: fprintf(stderr, "this subcommand requires more parameters\n"); exit(1); } } common_prolog(as, &state); fprintf(stderr, "calling FSYNC_askfs with command code %d (%s)\n", command, command_code_to_string(command)); code = FSYNC_StatsOp(&scom, command, FSYNC_WHATEVER, &res); switch (code) { case SYNC_OK: case SYNC_DENIED: break; default: fprintf(stderr, "possible sync protocol error. return code was %d\n", code); } fprintf(stderr, "FSYNC_VolOp returned %d (%s)\n", code, response_code_to_string(code)); fprintf(stderr, "protocol response code was %d (%s)\n", res.hdr.response, response_code_to_string(res.hdr.response)); fprintf(stderr, "protocol reason code was %d (%s)\n", res.hdr.reason, reason_code_to_string(res.hdr.reason)); VDisconnectFS(); if (res.hdr.response == SYNC_OK) { switch (command) { case FSYNC_VOL_STATS_GENERAL: print_vol_stats_general(sres.vol_stats); break; case FSYNC_VOL_STATS_VICEP: print_vol_stats_viceP(sres.vicep_stats); break; case FSYNC_VOL_STATS_HASH: print_vol_stats_hash(sres.hash_stats); break; #ifdef AFS_DEMAND_ATTACH_FS case FSYNC_VOL_STATS_HDR: print_vol_stats_hdr(sres.hdr_stats); break; #endif /* AFS_DEMAND_ATTACH_FS */ } } return 0; }