static int ChangeIPAddr(struct vl_ctx *ctx, afs_uint32 ipaddr1,
afs_uint32 ipaddr2);
+static_inline void
+countRequest(int opcode)
+{
+ if (opcode != 0) {
+ dynamic_statistics.requests[opcode - VL_LOWEST_OPCODE]++;
+ }
+}
+
+static_inline void
+countAbort(int opcode)
+{
+ if (opcode != 0) {
+ dynamic_statistics.aborts[opcode - VL_LOWEST_OPCODE]++;
+ }
+}
+
#define AFS_RXINFO_LEN 128
static char *
rxinfo(char * str, struct rx_call *rxcall)
int
Init_VLdbase(struct vl_ctx *ctx,
int locktype, /* indicate read or write transaction */
- int this_op)
+ int opcode)
{
int errorcode = 0, pass, wl;
errorcode = ubik_SetLock(ctx->trans, 1, 1, locktype);
if (errorcode) {
- COUNT_ABO;
+ countAbort(opcode);
ubik_AbortTrans(ctx->trans);
return errorcode;
}
if (!errorcode && wl && extent_mod)
errorcode = readExtents(ctx->trans); /* Fix the mh extent blocks */
if (errorcode) {
- COUNT_ABO;
+ countAbort(opcode);
ubik_AbortTrans(ctx->trans);
/* Only rebuld if the database is empty */
/* Exit if can't rebuild */
afs_int32
SVL_CreateEntry(struct rx_call *rxcall, struct vldbentry *newentry)
{
+ int this_op = VLCREATEENTRY;
struct vl_ctx ctx;
afs_int32 errorcode, blockindex;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLCREATEENTRY);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL)) {
errorcode = VL_PERM;
goto end;
}
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
afs_int32
SVL_CreateEntryN(struct rx_call *rxcall, struct nvldbentry *newentry)
{
+ int this_op = VLCREATEENTRYN;
struct vl_ctx ctx;
afs_int32 errorcode, blockindex;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLCREATEENTRYN);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL)) {
errorcode = VL_PERM;
goto end;
}
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
afs_int32
SVL_ChangeAddr(struct rx_call *rxcall, afs_uint32 ip1, afs_uint32 ip2)
{
+ int this_op = VLCHANGEADDR;
struct vl_ctx ctx;
afs_int32 errorcode;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLCHANGEADDR);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL)) {
errorcode = VL_PERM;
goto end;
}
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
afs_int32
SVL_DeleteEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype)
{
+ int this_op = VLDELETEENTRY;
struct vl_ctx ctx;
afs_int32 blockindex, errorcode;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLDELETEENTRY);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
goto end;
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
+ countRequest(this_op);
+
if ((voltype != -1) && (InvalidVoltype(voltype)))
return VL_BADVOLTYPE;
if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op)))
if (blockindex == 0) { /* entry not found */
if (!errorcode)
errorcode = VL_NOENT;
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return errorcode;
}
if (tentry.flags & VLDELETED) { /* Entry is deleted! */
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_ENTDELETED;
}
afs_int32 voltype,
vldbentry *aentry) /* entry data copied here */
{
- COUNT_REQ(VLGETENTRYBYID);
- return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 0, this_op));
+ return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 0,
+ VLGETENTRYBYID));
}
afs_int32
afs_int32 voltype,
nvldbentry *aentry) /* entry data copied here */
{
- COUNT_REQ(VLGETENTRYBYIDN);
- return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 1, this_op));
+ return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 1,
+ VLGETENTRYBYIDN));
}
afs_int32
afs_int32 voltype,
uvldbentry *aentry) /* entry data copied here */
{
- COUNT_REQ(VLGETENTRYBYIDU);
- return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 2, this_op));
+ return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 2,
+ VLGETENTRYBYIDU));
}
-
-
/* returns true if the id is a decimal integer, in which case we interpret
* it as an id. make the cache manager much simpler */
static int
if (blockindex == 0) { /* entry not found */
if (!errorcode)
errorcode = VL_NOENT;
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return errorcode;
}
if (tentry.flags & VLDELETED) { /* Entry is deleted */
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_ENTDELETED;
}
char *volname,
struct vldbentry *aentry) /* entry data copied here */
{
- COUNT_REQ(VLGETENTRYBYNAME);
- return (GetEntryByName(rxcall, volname, (char *)aentry, 0, this_op));
+ return (GetEntryByName(rxcall, volname, (char *)aentry, 0,
+ VLGETENTRYBYNAME));
}
char *volname,
struct nvldbentry *aentry) /* entry data copied here */
{
- COUNT_REQ(VLGETENTRYBYNAMEN);
- return (GetEntryByName(rxcall, volname, (char *)aentry, 1, this_op));
+ return (GetEntryByName(rxcall, volname, (char *)aentry, 1,
+ VLGETENTRYBYNAMEN));
}
afs_int32
char *volname,
struct uvldbentry *aentry) /* entry data copied here */
{
- COUNT_REQ(VLGETENTRYBYNAMEU);
- return (GetEntryByName(rxcall, volname, (char *)aentry, 2, this_op));
+ return (GetEntryByName(rxcall, volname, (char *)aentry, 2,
+ VLGETENTRYBYNAMEU));
}
SVL_GetNewVolumeId(struct rx_call *rxcall, afs_uint32 Maxvolidbump,
afs_uint32 *newvolumeid)
{
+ int this_op = VLGETNEWVOLUMEID;
afs_int32 errorcode;
afs_uint32 maxvolumeid;
struct vl_ctx ctx;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLGETNEWVOLUMEID);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
goto end;
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
struct vldbentry *newentry, afs_int32 releasetype)
{
+ int this_op = VLREPLACEENTRY;
struct vl_ctx ctx;
afs_int32 blockindex, errorcode, typeindex;
int hashnewname;
afs_uint32 checkids[MAXTYPES];
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLREPLACEENTRY);
+ countRequest(this_op);
for (typeindex = 0; typeindex < MAXTYPES; typeindex++)
hashVol[typeindex] = 0;
hashnewname = 0;
END(ubik_EndTrans(ctx.trans));
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
SVL_ReplaceEntryN(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
struct nvldbentry *newentry, afs_int32 releasetype)
{
+ int this_op = VLREPLACEENTRYN;
struct vl_ctx ctx;
afs_int32 blockindex, errorcode, typeindex;
int hashnewname;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLREPLACEENTRYN);
+ countRequest(this_op);
for (typeindex = 0; typeindex < MAXTYPES; typeindex++)
hashVol[typeindex] = 0;
hashnewname = 0;
END(ubik_EndTrans(ctx.trans));
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
struct VldbUpdateEntry *updateentry, /* Update entry copied here */
afs_int32 releasetype)
{
+ int this_op = VLUPDATEENTRY;
struct vl_ctx ctx;
afs_int32 blockindex, errorcode;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLUPDATEENTRY);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
if ((voltype != -1) && (InvalidVoltype(voltype)))
END(ubik_EndTrans(ctx.trans));
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
struct VldbUpdateEntry *updateentry, /* Update entry copied here */
afs_int32 releasetype)
{
+ int this_op = VLUPDATEENTRYBYNAME;
struct vl_ctx ctx;
afs_int32 blockindex, errorcode;
struct nvlentry tentry;
- COUNT_REQ(VLUPDATEENTRYBYNAME);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
if (releasetype && InvalidReleasetype(releasetype))
END(ubik_EndTrans(ctx.trans));
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
SVL_SetLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
afs_int32 voloper)
{
+ int this_op = VLSETLOCK;
afs_int32 timestamp, blockindex, errorcode;
struct vl_ctx ctx;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLSETLOCK);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
if ((voltype != -1) && (InvalidVoltype(voltype)))
END(ubik_EndTrans(ctx.trans));
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
SVL_ReleaseLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
afs_int32 releasetype)
{
+ int this_op = VLRELEASELOCK;
afs_int32 blockindex, errorcode;
struct vl_ctx ctx;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLRELEASELOCK);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
if ((voltype != -1) && (InvalidVoltype(voltype)))
END(ubik_EndTrans(ctx.trans));
abort:
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
end:
afs_int32 *count, afs_int32 *next_index,
struct vldbentry *aentry)
{
+ int this_op = VLLISTENTRY;
int errorcode;
struct vl_ctx ctx;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLLISTENTRY);
+ countRequest(this_op);
if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op)))
return errorcode;
VLog(25, ("OListEntry index=%d %s\n", previous_index,
afs_int32 *count, afs_int32 *next_index,
struct nvldbentry *aentry)
{
+ int this_op = VLLISTENTRYN;
int errorcode;
struct vl_ctx ctx;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLLISTENTRYN);
+ countRequest(this_op);
if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op)))
return errorcode;
VLog(25, ("ListEntry index=%d %s\n", previous_index, rxinfo(rxstr, rxcall)));
afs_int32 *nentries,
bulkentries *vldbentries)
{
+ int this_op = VLLISTATTRIBUTES;
int errorcode, allocCount = 0;
struct vl_ctx ctx;
struct nvlentry tentry;
int pollcount = 0;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLLISTATTRIBUTES);
+ countRequest(this_op);
vldbentries->bulkentries_val = 0;
vldbentries->bulkentries_len = *nentries = 0;
if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op)))
Vldbentry = VldbentryFirst = vldbentries->bulkentries_val =
(vldbentry *) malloc(allocCount * sizeof(vldbentry));
if (Vldbentry == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
if (blockindex == 0) {
if (!errorcode)
errorcode = VL_NOENT;
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
if (vldbentries->bulkentries_val)
free((char *)vldbentries->bulkentries_val);
if ((errorcode =
put_attributeentry(&ctx, &Vldbentry, &VldbentryFirst, &VldbentryLast,
vldbentries, &tentry, nentries, &allocCount))) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
if (vldbentries->bulkentries_val)
free((char *)vldbentries->bulkentries_val);
put_attributeentry(&ctx, &Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry,
nentries, &allocCount))) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
if (vldbentries->bulkentries_val)
free((char *)vldbentries->bulkentries_val);
vldbentries->bulkentries_len *
sizeof(vldbentry));
if (vldbentries->bulkentries_val == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
afs_int32 *nentries,
nbulkentries *vldbentries)
{
+ int this_op = VLLISTATTRIBUTESN;
int errorcode, allocCount = 0;
struct vl_ctx ctx;
struct nvlentry tentry;
int pollcount = 0;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLLISTATTRIBUTESN);
+ countRequest(this_op);
vldbentries->nbulkentries_val = 0;
vldbentries->nbulkentries_len = *nentries = 0;
if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op)))
Vldbentry = VldbentryFirst = vldbentries->nbulkentries_val =
(nvldbentry *) malloc(allocCount * sizeof(nvldbentry));
if (Vldbentry == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
if (blockindex == 0) {
if (!errorcode)
errorcode = VL_NOENT;
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
if (vldbentries->nbulkentries_val)
free((char *)vldbentries->nbulkentries_val);
put_nattributeentry(&ctx, &Vldbentry, &VldbentryFirst, &VldbentryLast,
vldbentries, &tentry, 0, 0, nentries,
&allocCount))) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
if (vldbentries->nbulkentries_val)
free((char *)vldbentries->nbulkentries_val);
put_nattributeentry(&ctx, &Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry, 0,
0, nentries, &allocCount))) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
if (vldbentries->nbulkentries_val)
free((char *)vldbentries->nbulkentries_val);
vldbentries->nbulkentries_len *
sizeof(nvldbentry));
if (vldbentries->nbulkentries_val == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
nbulkentries *vldbentries,
afs_int32 *nextstartindex)
{
+ int this_op = VLLISTATTRIBUTESN2;
int errorcode = 0, maxCount = VLDBALLOCCOUNT;
struct vl_ctx ctx;
struct nvlentry tentry;
char *t;
#endif
- COUNT_REQ(VLLISTATTRIBUTESN2);
+ countRequest(this_op);
vldbentries->nbulkentries_val = 0;
vldbentries->nbulkentries_len = 0;
*nentries = 0;
Vldbentry = VldbentryFirst = vldbentries->nbulkentries_val =
(nvldbentry *) malloc(maxCount * sizeof(nvldbentry));
if (Vldbentry == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
#endif
if (errorcode) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
if (vldbentries->nbulkentries_val)
free((char *)vldbentries->nbulkentries_val);
afs_int32 *nentries,
vldb_list *vldbentries)
{
+ int this_op = VLLINKEDLIST;
int errorcode;
struct vl_ctx ctx;
struct nvlentry tentry;
int serverindex;
int pollcount = 0;
- COUNT_REQ(VLLINKEDLIST);
+ countRequest(this_op);
if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op)))
return errorcode;
blockindex =
FindByID(&ctx, attributes->volumeid, -1, &tentry, &errorcode);
if (!blockindex) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return (errorcode ? errorcode : VL_NOENT);
}
vllist = (single_vldbentry *) malloc(sizeof(single_vldbentry));
if (vllist == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
vllist = (single_vldbentry *) malloc(sizeof(single_vldbentry));
if (vllist == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
vllistptr = &vllist->next_vldb;
(*nentries)++;
if (smallMem && (*nentries >= VLDBALLOCCOUNT)) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_SIZEEXCEEDED;
}
afs_int32 *nentries,
nvldb_list *vldbentries)
{
+ int this_op = VLLINKEDLISTN;
int errorcode;
struct vl_ctx ctx;
struct nvlentry tentry;
int serverindex;
int pollcount = 0;
- COUNT_REQ(VLLINKEDLISTN);
+ countRequest(this_op);
if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op)))
return errorcode;
blockindex =
FindByID(&ctx, attributes->volumeid, -1, &tentry, &errorcode);
if (!blockindex) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return (errorcode ? errorcode : VL_NOENT);
}
vllist = (single_nvldbentry *) malloc(sizeof(single_nvldbentry));
if (vllist == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
vllist = (single_nvldbentry *) malloc(sizeof(single_nvldbentry));
if (vllist == NULL) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
vllistptr = &vllist->next_vldb;
(*nentries)++;
if (smallMem && (*nentries >= VLDBALLOCCOUNT)) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_SIZEEXCEEDED;
}
vldstats *stats,
vital_vlheader *vital_header)
{
+ int this_op = VLGETSTATS;
afs_int32 errorcode;
struct vl_ctx ctx;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLGETSTATS);
+ countRequest(this_op);
#ifdef notdef
/* Allow users to get statistics freely */
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL)) /* Must be in 'UserList' to use */
afs_int32 *nentries,
bulkaddrs *addrsp)
{
+ int this_op = VLGETADDRS;
afs_int32 errorcode;
struct vl_ctx ctx;
int nservers, i;
afs_uint32 *taddrp;
- COUNT_REQ(VLGETADDRS);
+ countRequest(this_op);
addrsp->bulkaddrs_len = *nentries = 0;
addrsp->bulkaddrs_val = 0;
memset(spare3, 0, sizeof(struct VLCallBack));
nservers = *nentries = addrsp->bulkaddrs_len = 0;
if (!taddrp) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1,
bulkaddrs *addrsp)
{
+ int this_op = VLREGADDR;
afs_int32 code;
struct vl_ctx ctx;
int cnt, h, i, j, k, m, base, index;
int ReplaceEntry = 0;
int srvidx, mhidx;
- COUNT_REQ(VLREGADDR);
+ countRequest(this_op);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
return (VL_PERM);
if ((code = Init_VLdbase(&ctx, LOCKWRITE, this_op)))
afs_int32 *nentries,
bulkaddrs *addrsp)
{
+ int this_op = VLGETADDRSU;
afs_int32 errorcode, index = -1, offset;
struct vl_ctx ctx;
int nservers, i, j, base = 0;
afs_uint32 *taddrp, taddr;
char rxstr[AFS_RXINFO_LEN];
- COUNT_REQ(VLGETADDRSU);
+ countRequest(this_op);
addrsp->bulkaddrs_len = *nentries = 0;
addrsp->bulkaddrs_val = 0;
VLog(5, ("GetAddrsU %s\n", rxinfo(rxstr, rxcall)));
(afs_uint32 *) malloc(sizeof(afs_int32) * (MAXSERVERID + 1));
nservers = *nentries = addrsp->bulkaddrs_len = 0;
if (!taddrp) {
- COUNT_ABO;
+ countAbort(this_op);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}