From 3bf0350218dcf4d6e086941fac394769b6b9cc4a Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 21 May 2010 11:12:50 -0500 Subject: [PATCH] vlserver: Add a struct for trans-specific data Instead of passing a ubik_trans pointer to many functions inside the vlserver, pass a vlserver-defined vl_ctx struct, so we can add new things to keep track of in a transaction that are not part of ubik. Change-Id: Icf8df6bfdf8960134493ab7f379f0f65b92bdb5a Reviewed-on: http://gerrit.openafs.org/2104 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/vlserver/vlprocs.c | 518 +++++++++++++++++++-------------------- src/vlserver/vlserver.c | 10 +- src/vlserver/vlserver_internal.h | 43 ++-- src/vlserver/vlutils.c | 134 +++++----- 4 files changed, 354 insertions(+), 351 deletions(-) diff --git a/src/vlserver/vlprocs.c b/src/vlserver/vlprocs.c index 55d5e6f..7029a2a 100644 --- a/src/vlserver/vlprocs.c +++ b/src/vlserver/vlprocs.c @@ -59,18 +59,18 @@ static int put_nattributeentry(struct nvldbentry **, struct nvldbentry **, struct nvldbentry **, nbulkentries *, struct nvlentry *, afs_int32, afs_int32, afs_int32 *, afs_int32 *); -static int RemoveEntry(struct ubik_trans *trans, afs_int32 entryptr, +static int RemoveEntry(struct vl_ctx *ctx, afs_int32 entryptr, struct nvlentry *tentry); static void ReleaseEntry(struct nvlentry *tentry, afs_int32 releasetype); static int check_vldbentry(struct vldbentry *aentry); static int check_nvldbentry(struct nvldbentry *aentry); -static int vldbentry_to_vlentry(struct ubik_trans *atrans, +static int vldbentry_to_vlentry(struct vl_ctx *ctx, struct vldbentry *VldbEntry, struct nvlentry *VlEntry); -static int nvldbentry_to_vlentry(struct ubik_trans *atrans, +static int nvldbentry_to_vlentry(struct vl_ctx *ctx, struct nvldbentry *VldbEntry, struct nvlentry *VlEntry); -static int get_vldbupdateentry(struct ubik_trans *trans, afs_int32 blockindex, +static int get_vldbupdateentry(struct vl_ctx *ctx, afs_int32 blockindex, struct VldbUpdateEntry *updateentry, struct nvlentry *VlEntry); static int repsite_exists(struct nvlentry *VlEntry, int server, int partition); @@ -85,9 +85,9 @@ static int InvalidVolname(char *volname); static int InvalidVoltype(afs_int32 voltype); static int InvalidOperation(afs_int32 voloper); static int InvalidReleasetype(afs_int32 releasetype); -static int IpAddrToRelAddr(afs_uint32 ipaddr, struct ubik_trans *atrans); -static int ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2, - struct ubik_trans *atrans); +static int IpAddrToRelAddr(struct vl_ctx *ctx, afs_uint32 ipaddr, int create); +static int ChangeIPAddr(struct vl_ctx *ctx, afs_uint32 ipaddr1, + afs_uint32 ipaddr2); #define AFS_RXINFO_LEN 128 static char * @@ -119,7 +119,7 @@ rxinfo(char * str, struct rx_call *rxcall) /* This is called to initialize the database, set the appropriate locks and make sure that the vldb header is valid */ int -Init_VLdbase(struct ubik_trans **trans, +Init_VLdbase(struct vl_ctx *ctx, int locktype, /* indicate read or write transaction */ int this_op) { @@ -127,34 +127,34 @@ Init_VLdbase(struct ubik_trans **trans, for (pass = 1; pass <= 3; pass++) { if (pass == 2) { /* take write lock to rebuild the db */ - errorcode = ubik_BeginTrans(VL_dbase, UBIK_WRITETRANS, trans); + errorcode = ubik_BeginTrans(VL_dbase, UBIK_WRITETRANS, &ctx->trans); wl = 1; } else if (locktype == LOCKREAD) { errorcode = - ubik_BeginTransReadAny(VL_dbase, UBIK_READTRANS, trans); + ubik_BeginTransReadAny(VL_dbase, UBIK_READTRANS, &ctx->trans); wl = 0; } else { - errorcode = ubik_BeginTrans(VL_dbase, UBIK_WRITETRANS, trans); + errorcode = ubik_BeginTrans(VL_dbase, UBIK_WRITETRANS, &ctx->trans); wl = 1; } if (errorcode) return errorcode; - errorcode = ubik_SetLock(*trans, 1, 1, locktype); + errorcode = ubik_SetLock(ctx->trans, 1, 1, locktype); if (errorcode) { COUNT_ABO; - ubik_AbortTrans(*trans); + ubik_AbortTrans(ctx->trans); return errorcode; } /* check that dbase is initialized and setup cheader */ /* 2nd pass we try to rebuild the header */ - errorcode = CheckInit(*trans, ((pass == 2) ? 1 : 0)); + errorcode = CheckInit(ctx->trans, ((pass == 2) ? 1 : 0)); if (!errorcode && wl && extent_mod) - errorcode = readExtents(*trans); /* Fix the mh extent blocks */ + errorcode = readExtents(ctx->trans); /* Fix the mh extent blocks */ if (errorcode) { COUNT_ABO; - ubik_AbortTrans(*trans); + ubik_AbortTrans(ctx->trans); /* Only rebuld if the database is empty */ /* Exit if can't rebuild */ if ((pass == 1) && (errorcode != VL_EMPTY)) @@ -163,7 +163,7 @@ Init_VLdbase(struct ubik_trans **trans, return errorcode; } else { /* No errorcode */ if (pass == 2) { - ubik_EndTrans(*trans); /* Rebuilt db. End trans, then retake original lock */ + ubik_EndTrans(ctx->trans); /* Rebuilt db. End trans, then retake original lock */ } else { break; /* didn't rebuild and successful - exit */ } @@ -180,7 +180,7 @@ Init_VLdbase(struct ubik_trans **trans, afs_int32 SVL_CreateEntry(struct rx_call *rxcall, struct vldbentry *newentry) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 errorcode, blockindex; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; @@ -193,13 +193,13 @@ SVL_CreateEntry(struct rx_call *rxcall, struct vldbentry *newentry) /* Do some validity tests on new entry */ if ((errorcode = check_vldbentry(newentry)) - || (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + || (errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("OCreate Volume %d %s\n", newentry->volumeId[RWVOL], rxinfo(rxstr, rxcall))); - if (EntryIDExists(trans, newentry->volumeId, MAXTYPES, &errorcode)) { + if (EntryIDExists(&ctx, newentry->volumeId, MAXTYPES, &errorcode)) { /* at least one of the specified IDs already exists; we fail */ errorcode = VL_IDEXIST; goto abort; @@ -209,14 +209,14 @@ SVL_CreateEntry(struct rx_call *rxcall, struct vldbentry *newentry) /* Is this following check (by volume name) necessary?? */ /* If entry already exists, we fail */ - if (FindByName(trans, newentry->name, &tentry, &errorcode)) { + if (FindByName(&ctx, newentry->name, &tentry, &errorcode)) { errorcode = VL_NAMEEXIST; goto abort; } else if (errorcode) { goto abort; } - blockindex = AllocBlock(trans, &tentry); + blockindex = AllocBlock(&ctx, &tentry); if (blockindex == 0) { errorcode = VL_CREATEFAIL; goto abort; @@ -224,24 +224,24 @@ SVL_CreateEntry(struct rx_call *rxcall, struct vldbentry *newentry) memset(&tentry, 0, sizeof(struct nvlentry)); /* Convert to its internal representation; both in host byte order */ - if ((errorcode = vldbentry_to_vlentry(trans, newentry, &tentry))) { - FreeBlock(trans, blockindex); + if ((errorcode = vldbentry_to_vlentry(&ctx, newentry, &tentry))) { + FreeBlock(&ctx, blockindex); goto abort; } /* Actually insert the entry in vldb */ - errorcode = ThreadVLentry(trans, blockindex, &tentry); + errorcode = ThreadVLentry(&ctx, blockindex, &tentry); if (errorcode) { - FreeBlock(trans, blockindex); + FreeBlock(&ctx, blockindex); goto abort; } else { - errorcode = ubik_EndTrans(trans); + errorcode = ubik_EndTrans(ctx.trans); goto end; } abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLCreateEntryEvent, errorcode, AUD_STR, @@ -253,7 +253,7 @@ SVL_CreateEntry(struct rx_call *rxcall, struct vldbentry *newentry) afs_int32 SVL_CreateEntryN(struct rx_call *rxcall, struct nvldbentry *newentry) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 errorcode, blockindex; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; @@ -266,13 +266,13 @@ SVL_CreateEntryN(struct rx_call *rxcall, struct nvldbentry *newentry) /* Do some validity tests on new entry */ if ((errorcode = check_nvldbentry(newentry)) - || (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + || (errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("Create Volume %d %s\n", newentry->volumeId[RWVOL], rxinfo(rxstr, rxcall))); - if (EntryIDExists(trans, newentry->volumeId, MAXTYPES, &errorcode)) { + if (EntryIDExists(&ctx, newentry->volumeId, MAXTYPES, &errorcode)) { /* at least one of the specified IDs already exists; we fail */ errorcode = VL_IDEXIST; goto abort; @@ -282,14 +282,14 @@ SVL_CreateEntryN(struct rx_call *rxcall, struct nvldbentry *newentry) /* Is this following check (by volume name) necessary?? */ /* If entry already exists, we fail */ - if (FindByName(trans, newentry->name, &tentry, &errorcode)) { + if (FindByName(&ctx, newentry->name, &tentry, &errorcode)) { errorcode = VL_NAMEEXIST; goto abort; } else if (errorcode) { goto abort; } - blockindex = AllocBlock(trans, &tentry); + blockindex = AllocBlock(&ctx, &tentry); if (blockindex == 0) { errorcode = VL_CREATEFAIL; goto abort; @@ -297,24 +297,24 @@ SVL_CreateEntryN(struct rx_call *rxcall, struct nvldbentry *newentry) memset(&tentry, 0, sizeof(struct nvlentry)); /* Convert to its internal representation; both in host byte order */ - if ((errorcode = nvldbentry_to_vlentry(trans, newentry, &tentry))) { - FreeBlock(trans, blockindex); + if ((errorcode = nvldbentry_to_vlentry(&ctx, newentry, &tentry))) { + FreeBlock(&ctx, blockindex); goto abort; } /* Actually insert the entry in vldb */ - errorcode = ThreadVLentry(trans, blockindex, &tentry); + errorcode = ThreadVLentry(&ctx, blockindex, &tentry); if (errorcode) { - FreeBlock(trans, blockindex); + FreeBlock(&ctx, blockindex); goto abort; } else { - errorcode = ubik_EndTrans(trans); + errorcode = ubik_EndTrans(ctx.trans); goto end; } abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLCreateEntryEvent, errorcode, AUD_STR, @@ -326,7 +326,7 @@ SVL_CreateEntryN(struct rx_call *rxcall, struct nvldbentry *newentry) afs_int32 SVL_ChangeAddr(struct rx_call *rxcall, afs_uint32 ip1, afs_uint32 ip2) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 errorcode; char rxstr[AFS_RXINFO_LEN]; @@ -336,20 +336,20 @@ SVL_ChangeAddr(struct rx_call *rxcall, afs_uint32 ip1, afs_uint32 ip2) goto end; } - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("Change Addr %u -> %u %s\n", ip1, ip2, rxinfo(rxstr, rxcall))); - if ((errorcode = ChangeIPAddr(ip1, ip2, trans))) + if ((errorcode = ChangeIPAddr(&ctx, ip1, ip2))) goto abort; else { - errorcode = ubik_EndTrans(trans); + errorcode = ubik_EndTrans(ctx.trans); goto end; } abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLChangeAddrEvent, errorcode, AUD_LONG, ip1, AUD_LONG, @@ -361,7 +361,7 @@ SVL_ChangeAddr(struct rx_call *rxcall, afs_uint32 ip1, afs_uint32 ip2) afs_int32 SVL_DeleteEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 blockindex, errorcode; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; @@ -373,11 +373,11 @@ SVL_DeleteEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype) if ((voltype != -1) && (InvalidVoltype(voltype))) END(VL_BADVOLTYPE); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("Delete Volume %u %s\n", volid, rxinfo(rxstr, rxcall))); - blockindex = FindByID(trans, volid, voltype, &tentry, &errorcode); + blockindex = FindByID(&ctx, volid, voltype, &tentry, &errorcode); if (blockindex == 0) { /* volid not found */ if (!errorcode) errorcode = VL_NOENT; @@ -387,15 +387,15 @@ SVL_DeleteEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype) if (tentry.flags & VLDELETED) { /* Already deleted; return */ ABORT(VL_ENTDELETED); } - if ((errorcode = RemoveEntry(trans, blockindex, &tentry))) { + if ((errorcode = RemoveEntry(&ctx, blockindex, &tentry))) { goto abort; } - errorcode = (ubik_EndTrans(trans)); + errorcode = (ubik_EndTrans(ctx.trans)); goto end; abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLDeleteEntryEvent, errorcode, AUD_LONG, volid, @@ -413,29 +413,29 @@ GetEntryByID(struct rx_call *rxcall, afs_int32 new, afs_int32 this_op) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 blockindex, errorcode; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; if ((voltype != -1) && (InvalidVoltype(voltype))) return VL_BADVOLTYPE; - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; VLog(5, ("GetVolumeByID %u (%d) %s\n", volid, new, rxinfo(rxstr, rxcall))); - blockindex = FindByID(trans, volid, voltype, &tentry, &errorcode); + blockindex = FindByID(&ctx, volid, voltype, &tentry, &errorcode); if (blockindex == 0) { /* entry not found */ if (!errorcode) errorcode = VL_NOENT; COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return errorcode; } if (tentry.flags & VLDELETED) { /* Entry is deleted! */ COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_ENTDELETED; } /* Convert from the internal to external form */ @@ -445,7 +445,7 @@ GetEntryByID(struct rx_call *rxcall, vlentry_to_uvldbentry(&tentry, (struct uvldbentry *)aentry); else vlentry_to_vldbentry(&tentry, (struct vldbentry *)aentry); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } afs_int32 @@ -502,7 +502,7 @@ GetEntryByName(struct rx_call *rxcall, int new, int this_op) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 blockindex, errorcode; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; @@ -512,20 +512,20 @@ GetEntryByName(struct rx_call *rxcall, } if (InvalidVolname(volname)) return VL_BADNAME; - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; VLog(5, ("GetVolumeByName %s (%d) %s\n", volname, new, rxinfo(rxstr, rxcall))); - blockindex = FindByName(trans, volname, &tentry, &errorcode); + blockindex = FindByName(&ctx, volname, &tentry, &errorcode); if (blockindex == 0) { /* entry not found */ if (!errorcode) errorcode = VL_NOENT; COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return errorcode; } if (tentry.flags & VLDELETED) { /* Entry is deleted */ COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_ENTDELETED; } /* Convert to external entry representation */ @@ -535,7 +535,7 @@ GetEntryByName(struct rx_call *rxcall, vlentry_to_uvldbentry(&tentry, (struct uvldbentry *)aentry); else vlentry_to_vldbentry(&tentry, (struct vldbentry *)aentry); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } afs_int32 @@ -575,7 +575,7 @@ SVL_GetNewVolumeId(struct rx_call *rxcall, afs_uint32 Maxvolidbump, { afs_int32 errorcode; afs_uint32 maxvolumeid; - struct ubik_trans *trans; + struct vl_ctx ctx; char rxstr[AFS_RXINFO_LEN]; COUNT_REQ(VLGETNEWVOLUMEID); @@ -585,10 +585,10 @@ SVL_GetNewVolumeId(struct rx_call *rxcall, afs_uint32 Maxvolidbump, if (Maxvolidbump < 0 || Maxvolidbump > MAXBUMPCOUNT) END(VL_BADVOLIDBUMP); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; - *newvolumeid = maxvolumeid = NextUnusedID(trans, + *newvolumeid = maxvolumeid = NextUnusedID(&ctx, ntohl(cheader.vital_header.MaxVolumeId), Maxvolidbump, &errorcode); if (errorcode) { goto abort; @@ -597,15 +597,15 @@ SVL_GetNewVolumeId(struct rx_call *rxcall, afs_uint32 Maxvolidbump, maxvolumeid += Maxvolidbump; VLog(1, ("GetNewVolid newmax=%u %s\n", maxvolumeid, rxinfo(rxstr, rxcall))); cheader.vital_header.MaxVolumeId = htonl(maxvolumeid); - if (write_vital_vlheader(trans)) { + if (write_vital_vlheader(&ctx)) { ABORT(VL_IO); } - errorcode = (ubik_EndTrans(trans)); + errorcode = (ubik_EndTrans(ctx.trans)); goto end; abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLGetNewVolumeIdEvent, errorcode, AUD_END); @@ -621,7 +621,7 @@ afs_int32 SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, struct vldbentry *newentry, afs_int32 releasetype) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 blockindex, errorcode, typeindex; int hashnewname; int hashVol[MAXTYPES]; @@ -644,12 +644,12 @@ SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, if (releasetype && InvalidReleasetype(releasetype)) END(VL_BADRELLOCKTYPE); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("OReplace Volume %u %s\n", volid, rxinfo(rxstr, rxcall))); /* find vlentry we're changing */ - blockindex = FindByID(trans, volid, voltype, &tentry, &errorcode); + blockindex = FindByID(&ctx, volid, voltype, &tentry, &errorcode); if (blockindex == 0) { /* entry not found */ if (!errorcode) errorcode = VL_NOENT; @@ -668,7 +668,7 @@ SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, checkids[typeindex] = newentry->volumeId[typeindex]; } } - if (EntryIDExists(trans, checkids, MAXTYPES, &errorcode)) { + if (EntryIDExists(&ctx, checkids, MAXTYPES, &errorcode)) { ABORT(VL_IDEXIST); } else if (errorcode) { goto abort; @@ -677,7 +677,7 @@ SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, /* make sure the name we're changing to doesn't already exist */ if (strcmp(newentry->name, tentry.name)) { struct nvlentry tmp_entry; - if (FindByName(trans, newentry->name, &tmp_entry, &errorcode)) { + if (FindByName(&ctx, newentry->name, &tmp_entry, &errorcode)) { ABORT(VL_NAMEEXIST); } else if (errorcode) { goto abort; @@ -691,7 +691,7 @@ SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, if (tentry.volumeId[typeindex] != newentry->volumeId[typeindex]) { if (tentry.volumeId[typeindex]) if ((errorcode = - UnhashVolid(trans, typeindex, blockindex, &tentry))) { + UnhashVolid(&ctx, typeindex, blockindex, &tentry))) { goto abort; } /* we must rehash new id if the id is different and the ID is nonzero */ @@ -701,7 +701,7 @@ SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, /* Rehash volname if it changes */ if (strcmp(newentry->name, tentry.name)) { /* Name changes; redo hashing */ - if ((errorcode = UnhashVolname(trans, blockindex, &tentry))) { + if ((errorcode = UnhashVolname(&ctx, blockindex, &tentry))) { goto abort; } hashnewname = 1; @@ -709,32 +709,32 @@ SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, /* after this, tentry is new entry, not old one. vldbentry_to_vlentry * doesn't touch hash chains */ - if ((errorcode = vldbentry_to_vlentry(trans, newentry, &tentry))) { + if ((errorcode = vldbentry_to_vlentry(&ctx, newentry, &tentry))) { goto abort; } for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) { if (hashVol[typeindex] && tentry.volumeId[typeindex]) { - if ((errorcode = HashVolid(trans, typeindex, blockindex, &tentry))) { + if ((errorcode = HashVolid(&ctx, typeindex, blockindex, &tentry))) { goto abort; } } } if (hashnewname) - HashVolname(trans, blockindex, &tentry); + HashVolname(&ctx, blockindex, &tentry); if (releasetype) ReleaseEntry(&tentry, releasetype); /* Unlock entry if necessary */ - if (vlentrywrite(trans, blockindex, &tentry, sizeof(tentry))) { + if (vlentrywrite(ctx.trans, blockindex, &tentry, sizeof(tentry))) { ABORT(VL_IO); } - END(ubik_EndTrans(trans)); + END(ubik_EndTrans(ctx.trans)); abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLReplaceVLEntryEvent, errorcode, AUD_LONG, volid, @@ -746,7 +746,7 @@ afs_int32 SVL_ReplaceEntryN(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, struct nvldbentry *newentry, afs_int32 releasetype) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 blockindex, errorcode, typeindex; int hashnewname; int hashVol[MAXTYPES]; @@ -768,12 +768,12 @@ SVL_ReplaceEntryN(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, if (releasetype && InvalidReleasetype(releasetype)) END(VL_BADRELLOCKTYPE); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("Replace Volume %u %s\n", volid, rxinfo(rxstr, rxcall))); /* find vlentry we're changing */ - blockindex = FindByID(trans, volid, voltype, &tentry, &errorcode); + blockindex = FindByID(&ctx, volid, voltype, &tentry, &errorcode); if (blockindex == 0) { /* entry not found */ if (!errorcode) errorcode = VL_NOENT; @@ -792,7 +792,7 @@ SVL_ReplaceEntryN(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, if (tentry.volumeId[typeindex] != newentry->volumeId[typeindex]) { if (tentry.volumeId[typeindex]) if ((errorcode = - UnhashVolid(trans, typeindex, blockindex, &tentry))) { + UnhashVolid(&ctx, typeindex, blockindex, &tentry))) { goto abort; } /* we must rehash new id if the id is different and the ID is nonzero */ @@ -802,7 +802,7 @@ SVL_ReplaceEntryN(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, /* Rehash volname if it changes */ if (strcmp(newentry->name, tentry.name)) { /* Name changes; redo hashing */ - if ((errorcode = UnhashVolname(trans, blockindex, &tentry))) { + if ((errorcode = UnhashVolname(&ctx, blockindex, &tentry))) { goto abort; } hashnewname = 1; @@ -810,32 +810,32 @@ SVL_ReplaceEntryN(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, /* after this, tentry is new entry, not old one. vldbentry_to_vlentry * doesn't touch hash chains */ - if ((errorcode = nvldbentry_to_vlentry(trans, newentry, &tentry))) { + if ((errorcode = nvldbentry_to_vlentry(&ctx, newentry, &tentry))) { goto abort; } for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) { if (hashVol[typeindex] && tentry.volumeId[typeindex]) { - if ((errorcode = HashVolid(trans, typeindex, blockindex, &tentry))) { + if ((errorcode = HashVolid(&ctx, typeindex, blockindex, &tentry))) { goto abort; } } } if (hashnewname) - HashVolname(trans, blockindex, &tentry); + HashVolname(&ctx, blockindex, &tentry); if (releasetype) ReleaseEntry(&tentry, releasetype); /* Unlock entry if necessary */ - if (vlentrywrite(trans, blockindex, &tentry, sizeof(tentry))) { + if (vlentrywrite(ctx.trans, blockindex, &tentry, sizeof(tentry))) { ABORT(VL_IO); } - END(ubik_EndTrans(trans)); + END(ubik_EndTrans(ctx.trans)); abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLReplaceVLEntryEvent, errorcode, AUD_LONG, volid, @@ -856,7 +856,7 @@ SVL_UpdateEntry(struct rx_call *rxcall, struct VldbUpdateEntry *updateentry, /* Update entry copied here */ afs_int32 releasetype) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 blockindex, errorcode; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; @@ -868,11 +868,11 @@ SVL_UpdateEntry(struct rx_call *rxcall, END(VL_BADVOLTYPE); if (releasetype && InvalidReleasetype(releasetype)) END(VL_BADRELLOCKTYPE); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("Update Volume %u %s\n", volid, rxinfo(rxstr, rxcall))); - blockindex = FindByID(trans, volid, voltype, &tentry, &errorcode); + blockindex = FindByID(&ctx, volid, voltype, &tentry, &errorcode); if (blockindex == 0) { /* entry not found */ if (!errorcode) errorcode = VL_NOENT; @@ -881,19 +881,19 @@ SVL_UpdateEntry(struct rx_call *rxcall, /* Do the actual updating of the entry, tentry. */ if ((errorcode = - get_vldbupdateentry(trans, blockindex, updateentry, &tentry))) { + get_vldbupdateentry(&ctx, blockindex, updateentry, &tentry))) { goto abort; } if (releasetype) ReleaseEntry(&tentry, releasetype); /* Unlock entry if necessary */ - if (vlentrywrite(trans, blockindex, &tentry, sizeof(tentry))) { + if (vlentrywrite(ctx.trans, blockindex, &tentry, sizeof(tentry))) { ABORT(VL_IO); } - END(ubik_EndTrans(trans)); + END(ubik_EndTrans(ctx.trans)); abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLUpdateEntryEvent, errorcode, AUD_LONG, volid, @@ -908,7 +908,7 @@ SVL_UpdateEntryByName(struct rx_call *rxcall, struct VldbUpdateEntry *updateentry, /* Update entry copied here */ afs_int32 releasetype) { - struct ubik_trans *trans; + struct vl_ctx ctx; afs_int32 blockindex, errorcode; struct nvlentry tentry; @@ -917,10 +917,10 @@ SVL_UpdateEntryByName(struct rx_call *rxcall, END(VL_PERM); if (releasetype && InvalidReleasetype(releasetype)) END(VL_BADRELLOCKTYPE); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; - blockindex = FindByName(trans, volname, &tentry, &errorcode); + blockindex = FindByName(&ctx, volname, &tentry, &errorcode); if (blockindex == 0) { /* entry not found */ if (!errorcode) errorcode = VL_NOENT; @@ -929,19 +929,19 @@ SVL_UpdateEntryByName(struct rx_call *rxcall, /* Do the actual updating of the entry, tentry. */ if ((errorcode = - get_vldbupdateentry(trans, blockindex, updateentry, &tentry))) { + get_vldbupdateentry(&ctx, blockindex, updateentry, &tentry))) { goto abort; } if (releasetype) ReleaseEntry(&tentry, releasetype); /* Unlock entry if necessary */ - if (vlentrywrite(trans, blockindex, &tentry, sizeof(tentry))) { + if (vlentrywrite(ctx.trans, blockindex, &tentry, sizeof(tentry))) { ABORT(VL_IO); } - END(ubik_EndTrans(trans)); + END(ubik_EndTrans(ctx.trans)); abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLUpdateEntryEvent, errorcode, AUD_LONG, -1, AUD_END); @@ -955,7 +955,7 @@ SVL_SetLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, afs_int32 voloper) { afs_int32 timestamp, blockindex, errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; @@ -966,11 +966,11 @@ SVL_SetLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, END(VL_BADVOLTYPE); if (InvalidOperation(voloper)) END(VL_BADVOLOPER); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("SetLock Volume %u %s\n", volid, rxinfo(rxstr, rxcall))); - blockindex = FindByID(trans, volid, voltype, &tentry, &errorcode); + blockindex = FindByID(&ctx, volid, voltype, &tentry, &errorcode); if (blockindex == NULLO) { if (!errorcode) errorcode = VL_NOENT; @@ -998,14 +998,14 @@ SVL_SetLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, tentry.flags &= ~VLOP_ALLOPERS; /* Clear any possible older operation bit */ tentry.flags |= voloper; - if (vlentrywrite(trans, blockindex, &tentry, sizeof(tentry))) { + if (vlentrywrite(ctx.trans, blockindex, &tentry, sizeof(tentry))) { ABORT(VL_IO); } - END(ubik_EndTrans(trans)); + END(ubik_EndTrans(ctx.trans)); abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLSetLockEvent, errorcode, AUD_LONG, volid, AUD_END); @@ -1022,7 +1022,7 @@ SVL_ReleaseLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, afs_int32 releasetype) { afs_int32 blockindex, errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; @@ -1033,11 +1033,11 @@ SVL_ReleaseLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, END(VL_BADVOLTYPE); if (releasetype && InvalidReleasetype(releasetype)) END(VL_BADRELLOCKTYPE); - if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKWRITE, this_op))) goto end; VLog(1, ("ReleaseLock Volume %u %s\n", volid, rxinfo(rxstr, rxcall))); - blockindex = FindByID(trans, volid, voltype, &tentry, &errorcode); + blockindex = FindByID(&ctx, volid, voltype, &tentry, &errorcode); if (blockindex == NULLO) { if (!errorcode) errorcode = VL_NOENT; @@ -1048,14 +1048,14 @@ SVL_ReleaseLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype, } if (releasetype) ReleaseEntry(&tentry, releasetype); /* Unlock the appropriate fields */ - if (vlentrywrite(trans, blockindex, &tentry, sizeof(tentry))) { + if (vlentrywrite(ctx.trans, blockindex, &tentry, sizeof(tentry))) { ABORT(VL_IO); } - END(ubik_EndTrans(trans)); + END(ubik_EndTrans(ctx.trans)); abort: COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); end: osi_auditU(rxcall, VLReleaseLockEvent, errorcode, AUD_LONG, volid, @@ -1074,19 +1074,19 @@ SVL_ListEntry(struct rx_call *rxcall, afs_int32 previous_index, struct vldbentry *aentry) { int errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; COUNT_REQ(VLLISTENTRY); - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; VLog(25, ("OListEntry index=%d %s\n", previous_index, rxinfo(rxstr, rxcall))); - *next_index = NextEntry(trans, previous_index, &tentry, count); + *next_index = NextEntry(&ctx, previous_index, &tentry, count); if (*next_index) vlentry_to_vldbentry(&tentry, aentry); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } /* ListEntry returns a single vldb entry, aentry, with offset previous_index; @@ -1099,18 +1099,18 @@ SVL_ListEntryN(struct rx_call *rxcall, afs_int32 previous_index, struct nvldbentry *aentry) { int errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; char rxstr[AFS_RXINFO_LEN]; COUNT_REQ(VLLISTENTRYN); - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; VLog(25, ("ListEntry index=%d %s\n", previous_index, rxinfo(rxstr, rxcall))); - *next_index = NextEntry(trans, previous_index, &tentry, count); + *next_index = NextEntry(&ctx, previous_index, &tentry, count); if (*next_index) vlentry_to_nvldbentry(&tentry, aentry); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } @@ -1127,7 +1127,7 @@ SVL_ListAttributes(struct rx_call *rxcall, bulkentries *vldbentries) { int errorcode, allocCount = 0; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; struct vldbentry *Vldbentry = 0, *VldbentryFirst = 0, *VldbentryLast = 0; int pollcount = 0; @@ -1136,14 +1136,14 @@ SVL_ListAttributes(struct rx_call *rxcall, COUNT_REQ(VLLISTATTRIBUTES); vldbentries->bulkentries_val = 0; vldbentries->bulkentries_len = *nentries = 0; - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; allocCount = VLDBALLOCCOUNT; Vldbentry = VldbentryFirst = vldbentries->bulkentries_val = (vldbentry *) malloc(allocCount * sizeof(vldbentry)); if (Vldbentry == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } VldbentryLast = VldbentryFirst + allocCount; @@ -1153,12 +1153,12 @@ SVL_ListAttributes(struct rx_call *rxcall, afs_int32 blockindex; blockindex = - FindByID(trans, attributes->volumeid, -1, &tentry, &errorcode); + FindByID(&ctx, attributes->volumeid, -1, &tentry, &errorcode); if (blockindex == 0) { if (!errorcode) errorcode = VL_NOENT; COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); if (vldbentries->bulkentries_val) free((char *)vldbentries->bulkentries_val); vldbentries->bulkentries_val = 0; @@ -1169,7 +1169,7 @@ SVL_ListAttributes(struct rx_call *rxcall, put_attributeentry(&Vldbentry, &VldbentryFirst, &VldbentryLast, vldbentries, &tentry, nentries, &allocCount))) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); if (vldbentries->bulkentries_val) free((char *)vldbentries->bulkentries_val); vldbentries->bulkentries_val = 0; @@ -1179,7 +1179,7 @@ SVL_ListAttributes(struct rx_call *rxcall, } else { afs_int32 nextblockindex = 0, count = 0, k = 0, match = 0; while ((nextblockindex = - NextEntry(trans, nextblockindex, &tentry, &count))) { + NextEntry(&ctx, nextblockindex, &tentry, &count))) { if (++pollcount > 50) { #ifndef AFS_PTHREAD_ENV IOMGR_Poll(); @@ -1190,7 +1190,7 @@ SVL_ListAttributes(struct rx_call *rxcall, if (attributes->Mask & VLLIST_SERVER) { int serverindex; if ((serverindex = - IpAddrToRelAddr(attributes->server, NULL)) == -1) + IpAddrToRelAddr(&ctx, attributes->server, 0)) == -1) continue; for (k = 0; k < OMAXNSERVERS; k++) { if (tentry.serverNumber[k] == BADSERVERID) @@ -1231,7 +1231,7 @@ SVL_ListAttributes(struct rx_call *rxcall, &VldbentryLast, vldbentries, &tentry, nentries, &allocCount))) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); if (vldbentries->bulkentries_val) free((char *)vldbentries->bulkentries_val); vldbentries->bulkentries_val = 0; @@ -1249,14 +1249,14 @@ SVL_ListAttributes(struct rx_call *rxcall, sizeof(vldbentry)); if (vldbentries->bulkentries_val == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } } VLog(5, ("ListAttrs nentries=%d %s\n", vldbentries->bulkentries_len, rxinfo(rxstr, rxcall))); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } afs_int32 @@ -1266,7 +1266,7 @@ SVL_ListAttributesN(struct rx_call *rxcall, nbulkentries *vldbentries) { int errorcode, allocCount = 0; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; struct nvldbentry *Vldbentry = 0, *VldbentryFirst = 0, *VldbentryLast = 0; int pollcount = 0; @@ -1275,14 +1275,14 @@ SVL_ListAttributesN(struct rx_call *rxcall, COUNT_REQ(VLLISTATTRIBUTESN); vldbentries->nbulkentries_val = 0; vldbentries->nbulkentries_len = *nentries = 0; - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; allocCount = VLDBALLOCCOUNT; Vldbentry = VldbentryFirst = vldbentries->nbulkentries_val = (nvldbentry *) malloc(allocCount * sizeof(nvldbentry)); if (Vldbentry == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } VldbentryLast = VldbentryFirst + allocCount; @@ -1292,12 +1292,12 @@ SVL_ListAttributesN(struct rx_call *rxcall, afs_int32 blockindex; blockindex = - FindByID(trans, attributes->volumeid, -1, &tentry, &errorcode); + FindByID(&ctx, attributes->volumeid, -1, &tentry, &errorcode); if (blockindex == 0) { if (!errorcode) errorcode = VL_NOENT; COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); if (vldbentries->nbulkentries_val) free((char *)vldbentries->nbulkentries_val); vldbentries->nbulkentries_val = 0; @@ -1309,7 +1309,7 @@ SVL_ListAttributesN(struct rx_call *rxcall, vldbentries, &tentry, 0, 0, nentries, &allocCount))) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); if (vldbentries->nbulkentries_val) free((char *)vldbentries->nbulkentries_val); vldbentries->nbulkentries_val = 0; @@ -1319,7 +1319,7 @@ SVL_ListAttributesN(struct rx_call *rxcall, } else { afs_int32 nextblockindex = 0, count = 0, k = 0, match = 0; while ((nextblockindex = - NextEntry(trans, nextblockindex, &tentry, &count))) { + NextEntry(&ctx, nextblockindex, &tentry, &count))) { if (++pollcount > 50) { #ifndef AFS_PTHREAD_ENV IOMGR_Poll(); @@ -1331,7 +1331,7 @@ SVL_ListAttributesN(struct rx_call *rxcall, if (attributes->Mask & VLLIST_SERVER) { int serverindex; if ((serverindex = - IpAddrToRelAddr(attributes->server, NULL)) == -1) + IpAddrToRelAddr(&ctx, attributes->server, 0)) == -1) continue; for (k = 0; k < NMAXNSERVERS; k++) { if (tentry.serverNumber[k] == BADSERVERID) @@ -1372,7 +1372,7 @@ SVL_ListAttributesN(struct rx_call *rxcall, &VldbentryLast, vldbentries, &tentry, 0, 0, nentries, &allocCount))) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); if (vldbentries->nbulkentries_val) free((char *)vldbentries->nbulkentries_val); vldbentries->nbulkentries_val = 0; @@ -1390,14 +1390,14 @@ SVL_ListAttributesN(struct rx_call *rxcall, sizeof(nvldbentry)); if (vldbentries->nbulkentries_val == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } } VLog(5, ("NListAttrs nentries=%d %s\n", vldbentries->nbulkentries_len, rxinfo(rxstr, rxcall))); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } @@ -1411,7 +1411,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, afs_int32 *nextstartindex) { int errorcode = 0, maxCount = VLDBALLOCCOUNT; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; struct nvldbentry *Vldbentry = 0, *VldbentryFirst = 0, *VldbentryLast = 0; afs_int32 blockindex = 0, count = 0, k, match; @@ -1436,7 +1436,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, *nentries = 0; *nextstartindex = -1; - errorcode = Init_VLdbase(&trans, LOCKREAD, this_op); + errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op); if (errorcode) return errorcode; @@ -1444,7 +1444,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, (nvldbentry *) malloc(maxCount * sizeof(nvldbentry)); if (Vldbentry == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } @@ -1455,7 +1455,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, */ if (attributes->Mask & VLLIST_VOLUMEID) { blockindex = - FindByID(trans, attributes->volumeid, -1, &tentry, &errorcode); + FindByID(&ctx, attributes->volumeid, -1, &tentry, &errorcode); if (blockindex == 0) { if (!errorcode) errorcode = VL_NOENT; @@ -1477,7 +1477,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, /* Get the server index for matching server address */ if (attributes->Mask & VLLIST_SERVER) { serverindex = - IpAddrToRelAddr(attributes->server, NULL); + IpAddrToRelAddr(&ctx, attributes->server, 0); if (serverindex == -1) goto done; findserver = 1; @@ -1504,7 +1504,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, /* Read each entry and see if it is the one we want */ blockindex = startindex; - while ((blockindex = NextEntry(trans, blockindex, &tentry, &count))) { + while ((blockindex = NextEntry(&ctx, blockindex, &tentry, &count))) { if (++pollcount > 50) { #ifndef AFS_PTHREAD_ENV IOMGR_Poll(); @@ -1654,7 +1654,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, if (errorcode) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); if (vldbentries->nbulkentries_val) free((char *)vldbentries->nbulkentries_val); vldbentries->nbulkentries_val = 0; @@ -1665,7 +1665,7 @@ SVL_ListAttributesN2(struct rx_call *rxcall, VLog(5, ("N2ListAttrs nentries=%d %s\n", vldbentries->nbulkentries_len, rxinfo(rxstr, rxcall))); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } } @@ -1683,7 +1683,7 @@ SVL_LinkedList(struct rx_call *rxcall, vldb_list *vldbentries) { int errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; vldblist vllist, *vllistptr; afs_int32 blockindex, count, match; @@ -1692,7 +1692,7 @@ SVL_LinkedList(struct rx_call *rxcall, int pollcount = 0; COUNT_REQ(VLLINKEDLIST); - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; *nentries = 0; @@ -1702,17 +1702,17 @@ SVL_LinkedList(struct rx_call *rxcall, /* List by volumeid */ if (attributes->Mask & VLLIST_VOLUMEID) { blockindex = - FindByID(trans, attributes->volumeid, -1, &tentry, &errorcode); + FindByID(&ctx, attributes->volumeid, -1, &tentry, &errorcode); if (!blockindex) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return (errorcode ? errorcode : VL_NOENT); } vllist = (single_vldbentry *) malloc(sizeof(single_vldbentry)); if (vllist == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } vlentry_to_vldbentry(&tentry, &vllist->VldbEntry); @@ -1725,8 +1725,8 @@ SVL_LinkedList(struct rx_call *rxcall, /* Search by server, partition, and flags */ else { - for (blockindex = NextEntry(trans, 0, &tentry, &count); blockindex; - blockindex = NextEntry(trans, blockindex, &tentry, &count)) { + for (blockindex = NextEntry(&ctx, 0, &tentry, &count); blockindex; + blockindex = NextEntry(&ctx, blockindex, &tentry, &count)) { match = 0; if (++pollcount > 50) { @@ -1739,7 +1739,7 @@ SVL_LinkedList(struct rx_call *rxcall, /* Does this volume exist on the desired server */ if (attributes->Mask & VLLIST_SERVER) { serverindex = - IpAddrToRelAddr(attributes->server, NULL); + IpAddrToRelAddr(&ctx, attributes->server, 0); if (serverindex == -1) continue; for (k = 0; k < OMAXNSERVERS; k++) { @@ -1783,7 +1783,7 @@ SVL_LinkedList(struct rx_call *rxcall, vllist = (single_vldbentry *) malloc(sizeof(single_vldbentry)); if (vllist == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } vlentry_to_vldbentry(&tentry, &vllist->VldbEntry); @@ -1794,13 +1794,13 @@ SVL_LinkedList(struct rx_call *rxcall, (*nentries)++; if (smallMem && (*nentries >= VLDBALLOCCOUNT)) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_SIZEEXCEEDED; } } } *vllistptr = NULL; - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } afs_int32 @@ -1810,7 +1810,7 @@ SVL_LinkedListN(struct rx_call *rxcall, nvldb_list *vldbentries) { int errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; struct nvlentry tentry; nvldblist vllist, *vllistptr; afs_int32 blockindex, count, match; @@ -1819,7 +1819,7 @@ SVL_LinkedListN(struct rx_call *rxcall, int pollcount = 0; COUNT_REQ(VLLINKEDLISTN); - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; *nentries = 0; @@ -1829,17 +1829,17 @@ SVL_LinkedListN(struct rx_call *rxcall, /* List by volumeid */ if (attributes->Mask & VLLIST_VOLUMEID) { blockindex = - FindByID(trans, attributes->volumeid, -1, &tentry, &errorcode); + FindByID(&ctx, attributes->volumeid, -1, &tentry, &errorcode); if (!blockindex) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return (errorcode ? errorcode : VL_NOENT); } vllist = (single_nvldbentry *) malloc(sizeof(single_nvldbentry)); if (vllist == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } vlentry_to_nvldbentry(&tentry, &vllist->VldbEntry); @@ -1852,8 +1852,8 @@ SVL_LinkedListN(struct rx_call *rxcall, /* Search by server, partition, and flags */ else { - for (blockindex = NextEntry(trans, 0, &tentry, &count); blockindex; - blockindex = NextEntry(trans, blockindex, &tentry, &count)) { + for (blockindex = NextEntry(&ctx, 0, &tentry, &count); blockindex; + blockindex = NextEntry(&ctx, blockindex, &tentry, &count)) { match = 0; if (++pollcount > 50) { @@ -1866,7 +1866,7 @@ SVL_LinkedListN(struct rx_call *rxcall, /* Does this volume exist on the desired server */ if (attributes->Mask & VLLIST_SERVER) { serverindex = - IpAddrToRelAddr(attributes->server, NULL); + IpAddrToRelAddr(&ctx, attributes->server, 0); if (serverindex == -1) continue; for (k = 0; k < NMAXNSERVERS; k++) { @@ -1910,7 +1910,7 @@ SVL_LinkedListN(struct rx_call *rxcall, vllist = (single_nvldbentry *) malloc(sizeof(single_nvldbentry)); if (vllist == NULL) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } vlentry_to_nvldbentry(&tentry, &vllist->VldbEntry); @@ -1921,13 +1921,13 @@ SVL_LinkedListN(struct rx_call *rxcall, (*nentries)++; if (smallMem && (*nentries >= VLDBALLOCCOUNT)) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_SIZEEXCEEDED; } } } *vllistptr = NULL; - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } /* Get back vldb header statistics (allocs, frees, maxvolumeid, @@ -1940,7 +1940,7 @@ SVL_GetStats(struct rx_call *rxcall, vital_vlheader *vital_header) { afs_int32 errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; char rxstr[AFS_RXINFO_LEN]; COUNT_REQ(VLGETSTATS); @@ -1949,13 +1949,13 @@ SVL_GetStats(struct rx_call *rxcall, if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL)) /* Must be in 'UserList' to use */ return VL_PERM; #endif - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; VLog(5, ("GetStats %s\n", rxinfo(rxstr, rxcall))); memcpy((char *)vital_header, (char *)&cheader.vital_header, sizeof(vital_vlheader)); memcpy((char *)stats, (char *)&dynamic_statistics, sizeof(vldstats)); - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } /* Get the list of file server addresses from the VLDB. Currently it's pretty @@ -1971,7 +1971,7 @@ SVL_GetAddrs(struct rx_call *rxcall, bulkaddrs *addrsp) { afs_int32 errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; int nservers, i; afs_uint32 *taddrp; @@ -1980,7 +1980,7 @@ SVL_GetAddrs(struct rx_call *rxcall, addrsp->bulkaddrs_val = 0; memset(spare3, 0, sizeof(struct VLCallBack)); - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; VLog(5, ("GetAddrs\n")); @@ -1990,7 +1990,7 @@ SVL_GetAddrs(struct rx_call *rxcall, if (!taddrp) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } @@ -2002,7 +2002,7 @@ SVL_GetAddrs(struct rx_call *rxcall, } addrsp->bulkaddrs_len = *nentries = nservers; - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } #define PADDR(addr) VLog(0,("%d.%d.%d.%d", (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8) &0xff, addr&0xff)); @@ -2012,7 +2012,7 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, bulkaddrs *addrsp) { afs_int32 code; - struct ubik_trans *trans; + struct vl_ctx ctx; int cnt, h, i, j, k, m, base, index; struct extentaddr *exp = 0, *tex; afsUUID tuuid; @@ -2027,7 +2027,7 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, COUNT_REQ(VLREGADDR); if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL)) return (VL_PERM); - if ((code = Init_VLdbase(&trans, LOCKWRITE, this_op))) + if ((code = Init_VLdbase(&ctx, LOCKWRITE, this_op))) return code; /* Eliminate duplicates from IP address list */ @@ -2050,7 +2050,7 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, } } if (cnt <= 0) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_INDEXERANGE; } @@ -2199,7 +2199,7 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, (" and/or remove the sysid file from the registering fileserver\n")); VLog(0, (" before the fileserver can be registered in the VLDB.\n")); - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_MULTIPADDR; } @@ -2224,7 +2224,7 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, change = 1; } if (!change) { - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } } @@ -2284,9 +2284,9 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, VLog(0,(", in the VLDB (new uuid):\n")); code = - FindExtentBlock(trans, uuidp, 1, ReplaceEntry, &exp, &fbase); + FindExtentBlock(&ctx, uuidp, 1, ReplaceEntry, &exp, &fbase); if (code || !exp) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return (code ? code : VL_IO); } } @@ -2295,9 +2295,9 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, * well as use a new slot of the HostAddress array. */ VLog(0, (" It will create a new entry in the VLDB.\n")); - code = FindExtentBlock(trans, uuidp, 1, -1, &exp, &fbase); + code = FindExtentBlock(&ctx, uuidp, 1, -1, &exp, &fbase); if (code || !exp) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return (code ? code : VL_IO); } } @@ -2318,11 +2318,11 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, /* Write the new mh entry out */ if (vlwrite - (trans, + (ctx.trans, DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[fbase]), (char *)ex_addr[fbase], (char *)exp), (char *)exp, sizeof(*exp))) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_IO; } @@ -2373,13 +2373,13 @@ SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1, doff = DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[base]), (char *)ex_addr[base], (char *)tex); - if (vlwrite(trans, doff, (char *)tex, sizeof(*tex))) { - ubik_AbortTrans(trans); + if (vlwrite(ctx.trans, doff, (char *)tex, sizeof(*tex))) { + ubik_AbortTrans(ctx.trans); return VL_IO; } } - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } afs_int32 @@ -2391,7 +2391,7 @@ SVL_GetAddrsU(struct rx_call *rxcall, bulkaddrs *addrsp) { afs_int32 errorcode, index = -1, offset; - struct ubik_trans *trans; + struct vl_ctx ctx; int nservers, i, j, base = 0; struct extentaddr *exp = 0; afsUUID tuuid; @@ -2402,12 +2402,12 @@ SVL_GetAddrsU(struct rx_call *rxcall, addrsp->bulkaddrs_len = *nentries = 0; addrsp->bulkaddrs_val = 0; VLog(5, ("GetAddrsU %s\n", rxinfo(rxstr, rxcall))); - if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))) + if ((errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op))) return errorcode; if (attributes->Mask & VLADDR_IPADDR) { if (attributes->Mask & (VLADDR_INDEX | VLADDR_UUID)) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_BADMASK; } for (base = 0; base < VL_MAX_ADDREXTBLKS; base++) { @@ -2432,51 +2432,51 @@ SVL_GetAddrsU(struct rx_call *rxcall, break; } if (base >= VL_MAX_ADDREXTBLKS) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOENT; } } else if (attributes->Mask & VLADDR_INDEX) { if (attributes->Mask & (VLADDR_IPADDR | VLADDR_UUID)) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_BADMASK; } index = attributes->index; if (index < 1 || index >= (VL_MAX_ADDREXTBLKS * VL_MHSRV_PERBLK)) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_INDEXERANGE; } base = index / VL_MHSRV_PERBLK; offset = index % VL_MHSRV_PERBLK; if (offset == 0) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOENT; } if (!ex_addr[base]) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_INDEXERANGE; } exp = &ex_addr[base][offset]; } else if (attributes->Mask & VLADDR_UUID) { if (attributes->Mask & (VLADDR_IPADDR | VLADDR_INDEX)) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_BADMASK; } if (!ex_addr[0]) { /* mh servers probably aren't setup on this vldb */ - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOENT; } if ((errorcode = - FindExtentBlock(trans, &attributes->uuid, 0, -1, &exp, &base))) { - ubik_AbortTrans(trans); + FindExtentBlock(&ctx, &attributes->uuid, 0, -1, &exp, &base))) { + ubik_AbortTrans(ctx.trans); return errorcode; } } else { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_BADMASK; } if (exp == NULL) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOENT; } addrsp->bulkaddrs_val = taddrp = @@ -2484,13 +2484,13 @@ SVL_GetAddrsU(struct rx_call *rxcall, nservers = *nentries = addrsp->bulkaddrs_len = 0; if (!taddrp) { COUNT_ABO; - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOMEM; } tuuid = exp->ex_hostuuid; afs_ntohuuid(&tuuid); if (afs_uuid_is_nil(&tuuid)) { - ubik_AbortTrans(trans); + ubik_AbortTrans(ctx.trans); return VL_NOENT; } if (uuidpo) @@ -2512,7 +2512,7 @@ SVL_GetAddrsU(struct rx_call *rxcall, } } addrsp->bulkaddrs_len = *nentries = nservers; - return (ubik_EndTrans(trans)); + return (ubik_EndTrans(ctx.trans)); } /* ============> End of Exported vldb RPC functions <============= */ @@ -2603,14 +2603,14 @@ put_nattributeentry(struct nvldbentry **Vldbentry, /* Common code to actually remove a vldb entry from the database. */ static int -RemoveEntry(struct ubik_trans *trans, afs_int32 entryptr, +RemoveEntry(struct vl_ctx *ctx, afs_int32 entryptr, struct nvlentry *tentry) { int errorcode; - if ((errorcode = UnthreadVLentry(trans, entryptr, tentry))) + if ((errorcode = UnthreadVLentry(ctx, entryptr, tentry))) return errorcode; - if ((errorcode = FreeBlock(trans, entryptr))) + if ((errorcode = FreeBlock(ctx, entryptr))) return errorcode; return 0; } @@ -2677,7 +2677,7 @@ check_nvldbentry(struct nvldbentry *aentry) /* Convert from the external vldb entry representation to its internal (more compact) form. This call should not change the hash chains! */ static int -vldbentry_to_vlentry(struct ubik_trans *atrans, +vldbentry_to_vlentry(struct vl_ctx *ctx, struct vldbentry *VldbEntry, struct nvlentry *VlEntry) { @@ -2686,7 +2686,7 @@ vldbentry_to_vlentry(struct ubik_trans *atrans, if (strcmp(VlEntry->name, VldbEntry->name)) strncpy(VlEntry->name, VldbEntry->name, sizeof(VlEntry->name)); for (i = 0; i < VldbEntry->nServers; i++) { - serverindex = IpAddrToRelAddr(VldbEntry->serverNumber[i], atrans); + serverindex = IpAddrToRelAddr(ctx, VldbEntry->serverNumber[i], 1); if (serverindex == -1) return VL_BADSERVER; VlEntry->serverNumber[i] = serverindex; @@ -2704,7 +2704,7 @@ vldbentry_to_vlentry(struct ubik_trans *atrans, } static int -nvldbentry_to_vlentry(struct ubik_trans *atrans, +nvldbentry_to_vlentry(struct vl_ctx *ctx, struct nvldbentry *VldbEntry, struct nvlentry *VlEntry) { @@ -2713,7 +2713,7 @@ nvldbentry_to_vlentry(struct ubik_trans *atrans, if (strcmp(VlEntry->name, VldbEntry->name)) strncpy(VlEntry->name, VldbEntry->name, sizeof(VlEntry->name)); for (i = 0; i < VldbEntry->nServers; i++) { - serverindex = IpAddrToRelAddr(VldbEntry->serverNumber[i], atrans); + serverindex = IpAddrToRelAddr(ctx, VldbEntry->serverNumber[i], 1); if (serverindex == -1) return VL_BADSERVER; VlEntry->serverNumber[i] = serverindex; @@ -2736,7 +2736,7 @@ nvldbentry_to_vlentry(struct ubik_trans *atrans, * checks are performed. */ static int -get_vldbupdateentry(struct ubik_trans *trans, +get_vldbupdateentry(struct vl_ctx *ctx, afs_int32 blockindex, struct VldbUpdateEntry *updateentry, struct nvlentry *VlEntry) @@ -2758,7 +2758,7 @@ get_vldbupdateentry(struct ubik_trans *trans, checkids[BACKVOL] = updateentry->BackupId; } - if (EntryIDExists(trans, checkids, MAXTYPES, &errorcode)) { + if (EntryIDExists(ctx, checkids, MAXTYPES, &errorcode)) { return VL_IDEXIST; } else if (errorcode) { return errorcode; @@ -2770,24 +2770,24 @@ get_vldbupdateentry(struct ubik_trans *trans, if (InvalidVolname(updateentry->name)) return VL_BADNAME; - if (FindByName(trans, updateentry->name, &tentry, &errorcode)) { + if (FindByName(ctx, updateentry->name, &tentry, &errorcode)) { return VL_NAMEEXIST; } else if (errorcode) { return errorcode; } - if ((errorcode = UnhashVolname(trans, blockindex, VlEntry))) + if ((errorcode = UnhashVolname(ctx, blockindex, VlEntry))) return errorcode; strncpy(VlEntry->name, updateentry->name, sizeof(VlEntry->name)); - HashVolname(trans, blockindex, VlEntry); + HashVolname(ctx, blockindex, VlEntry); } if (updateentry->Mask & VLUPDATE_VOLNAMEHASH) { - if ((errorcode = UnhashVolname(trans, blockindex, VlEntry))) { + if ((errorcode = UnhashVolname(ctx, blockindex, VlEntry))) { if (errorcode != VL_NOENT) return errorcode; } - HashVolname(trans, blockindex, VlEntry); + HashVolname(ctx, blockindex, VlEntry); } if (updateentry->Mask & VLUPDATE_FLAGS) { @@ -2797,30 +2797,30 @@ get_vldbupdateentry(struct ubik_trans *trans, VlEntry->cloneId = updateentry->cloneId; } if (updateentry->Mask & VLUPDATE_RWID) { - if ((errorcode = UnhashVolid(trans, RWVOL, blockindex, VlEntry))) { + if ((errorcode = UnhashVolid(ctx, RWVOL, blockindex, VlEntry))) { if (errorcode != VL_NOENT) return errorcode; } VlEntry->volumeId[RWVOL] = updateentry->spares3; /* rw id */ - if ((errorcode = HashVolid(trans, RWVOL, blockindex, VlEntry))) + if ((errorcode = HashVolid(ctx, RWVOL, blockindex, VlEntry))) return errorcode; } if (updateentry->Mask & VLUPDATE_READONLYID) { - if ((errorcode = UnhashVolid(trans, ROVOL, blockindex, VlEntry))) { + if ((errorcode = UnhashVolid(ctx, ROVOL, blockindex, VlEntry))) { if (errorcode != VL_NOENT) return errorcode; } VlEntry->volumeId[ROVOL] = updateentry->ReadOnlyId; - if ((errorcode = HashVolid(trans, ROVOL, blockindex, VlEntry))) + if ((errorcode = HashVolid(ctx, ROVOL, blockindex, VlEntry))) return errorcode; } if (updateentry->Mask & VLUPDATE_BACKUPID) { - if ((errorcode = UnhashVolid(trans, BACKVOL, blockindex, VlEntry))) { + if ((errorcode = UnhashVolid(ctx, BACKVOL, blockindex, VlEntry))) { if (errorcode != VL_NOENT) return errorcode; } VlEntry->volumeId[BACKVOL] = updateentry->BackupId; - if ((errorcode = HashVolid(trans, BACKVOL, blockindex, VlEntry))) + if ((errorcode = HashVolid(ctx, BACKVOL, blockindex, VlEntry))) return errorcode; } if (updateentry->Mask & VLUPDATE_REPSITES) { @@ -2836,9 +2836,9 @@ get_vldbupdateentry(struct ubik_trans *trans, if (updateentry->RepsitesMask[i] & VLUPDATE_REPS_DELETE) { if ((j = repsite_exists(VlEntry, - IpAddrToRelAddr(updateentry-> + IpAddrToRelAddr(ctx, updateentry-> RepsitesTargetServer[i], - trans), + 1), updateentry->RepsitesTargetPart[i])) != -1) repsite_compress(VlEntry, j); @@ -2853,8 +2853,7 @@ get_vldbupdateentry(struct ubik_trans *trans, return VL_BADPARTITION; if (repsite_exists (VlEntry, - IpAddrToRelAddr(updateentry->RepsitesNewServer[i], - trans), + IpAddrToRelAddr(ctx, updateentry->RepsitesNewServer[i], 1), updateentry->RepsitesNewPart[i]) != -1) return VL_DUPREPSERVER; for (j = 0; @@ -2863,8 +2862,8 @@ get_vldbupdateentry(struct ubik_trans *trans, if (j >= OMAXNSERVERS) return VL_REPSFULL; if ((serverindex = - IpAddrToRelAddr(updateentry->RepsitesNewServer[i], - trans)) == -1) + IpAddrToRelAddr(ctx, updateentry->RepsitesNewServer[i], + 1)) == -1) return VL_BADSERVER; VlEntry->serverNumber[j] = serverindex; VlEntry->serverPartition[j] = updateentry->RepsitesNewPart[i]; @@ -2878,14 +2877,14 @@ get_vldbupdateentry(struct ubik_trans *trans, return VL_BADSERVER; */ if ((j = repsite_exists(VlEntry, - IpAddrToRelAddr(updateentry-> + IpAddrToRelAddr(ctx, updateentry-> RepsitesTargetServer[i], - trans), + 1), updateentry->RepsitesTargetPart[i])) != -1) { VlEntry->serverNumber[j] = - IpAddrToRelAddr(updateentry->RepsitesNewServer[i], - trans); + IpAddrToRelAddr(ctx, updateentry->RepsitesNewServer[i], + 1); } else return VL_NOREPSERVER; } @@ -2895,9 +2894,9 @@ get_vldbupdateentry(struct ubik_trans *trans, return VL_BADPARTITION; if ((j = repsite_exists(VlEntry, - IpAddrToRelAddr(updateentry-> + IpAddrToRelAddr(ctx, updateentry-> RepsitesTargetServer[i], - trans), + 1), updateentry->RepsitesTargetPart[i])) != -1) VlEntry->serverPartition[j] = @@ -2908,9 +2907,9 @@ get_vldbupdateentry(struct ubik_trans *trans, if (updateentry->RepsitesMask[i] & VLUPDATE_REPS_MODFLAG) { if ((j = repsite_exists(VlEntry, - IpAddrToRelAddr(updateentry-> + IpAddrToRelAddr(ctx, updateentry-> RepsitesTargetServer[i], - trans), + 1), updateentry->RepsitesTargetPart[i])) != -1) { if (updateentry->RepsitesNewFlags[i] < 0 @@ -3135,7 +3134,7 @@ InvalidReleasetype(afs_int32 releasetype) } static int -IpAddrToRelAddr(afs_uint32 ipaddr, struct ubik_trans *atrans) +IpAddrToRelAddr(struct vl_ctx *ctx, afs_uint32 ipaddr, int create) { int i, j; afs_int32 code, base, index; @@ -3175,12 +3174,12 @@ IpAddrToRelAddr(afs_uint32 ipaddr, struct ubik_trans *atrans) } /* allocate the new server a server id pronto */ - if (atrans) { + if (create) { for (i = 0; i <= MAXSERVERID; i++) { if (cheader.IpMappedAddr[i] == 0) { cheader.IpMappedAddr[i] = htonl(ipaddr); code = - vlwrite(atrans, + vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.IpMappedAddr[i]), (char *)&cheader.IpMappedAddr[i], sizeof(afs_int32)); @@ -3195,7 +3194,7 @@ IpAddrToRelAddr(afs_uint32 ipaddr, struct ubik_trans *atrans) } static int -ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2, struct ubik_trans *atrans) +ChangeIPAddr(struct vl_ctx *ctx, afs_uint32 ipaddr1, afs_uint32 ipaddr2) { int i, j; afs_int32 code; @@ -3208,9 +3207,6 @@ ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2, struct ubik_trans *atrans) struct nvlentry tentry; int ipaddr1_id = -1, ipaddr2_id = -1; - if (!atrans) - return VL_CREATEFAIL; - /* Don't let addr change to 256.*.*.* : Causes internal error below */ if ((ipaddr2 & 0xff000000) == 0xff000000) return (VL_BADSERVER); @@ -3284,8 +3280,8 @@ ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2, struct ubik_trans *atrans) * server entry: return error "volume entry exists". */ if (ipaddr2 == 0) { - for (blockindex = NextEntry(atrans, 0, &tentry, &count); blockindex; - blockindex = NextEntry(atrans, blockindex, &tentry, &count)) { + for (blockindex = NextEntry(ctx, 0, &tentry, &count); blockindex; + blockindex = NextEntry(ctx, blockindex, &tentry, &count)) { if (++pollcount > 50) { #ifndef AFS_PTHREAD_ENV IOMGR_Poll(); @@ -3332,7 +3328,7 @@ ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2, struct ubik_trans *atrans) afs_htonuuid(&tuuid); exp->ex_hostuuid = tuuid; code = - vlwrite(atrans, + vlwrite(ctx->trans, DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[base]), (char *)ex_addr[base], (char *)exp), (char *)&tuuid, sizeof(tuuid)); @@ -3343,7 +3339,7 @@ ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2, struct ubik_trans *atrans) /* Now change the host address entry */ cheader.IpMappedAddr[ipaddr1_id] = htonl(ipaddr2); code = - vlwrite(atrans, DOFFSET(0, &cheader, &cheader.IpMappedAddr[ipaddr1_id]), + vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.IpMappedAddr[ipaddr1_id]), (char *) &cheader.IpMappedAddr[ipaddr1_id], sizeof(afs_int32)); HostAddress[ipaddr1_id] = ipaddr2; diff --git a/src/vlserver/vlserver.c b/src/vlserver/vlserver.c index e0982f9..738b36a 100644 --- a/src/vlserver/vlserver.c +++ b/src/vlserver/vlserver.c @@ -87,20 +87,20 @@ static void * CheckSignal(void *unused) { int i, errorcode; - struct ubik_trans *trans; + struct vl_ctx ctx; if ((errorcode = - Init_VLdbase(&trans, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE))) + Init_VLdbase(&ctx, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE))) return (void *)(intptr_t)errorcode; VLog(0, ("Dump name hash table out\n")); for (i = 0; i < HASHSIZE; i++) { - HashNDump(trans, i); + HashNDump(&ctx, i); } VLog(0, ("Dump id hash table out\n")); for (i = 0; i < HASHSIZE; i++) { - HashIdDump(trans, i); + HashIdDump(&ctx, i); } - return ((void *)(intptr_t)ubik_EndTrans(trans)); + return ((void *)(intptr_t)ubik_EndTrans(ctx.trans)); } /*CheckSignal */ diff --git a/src/vlserver/vlserver_internal.h b/src/vlserver/vlserver_internal.h index b7764ba..716ac21 100644 --- a/src/vlserver/vlserver_internal.h +++ b/src/vlserver/vlserver_internal.h @@ -10,46 +10,53 @@ #ifndef _VLSERVER_INTERNAL_H #define _VLSERVER_INTERNAL_H +/** + * context for a transaction of a single VL operation. + */ +struct vl_ctx { + struct ubik_trans *trans; +}; + /* vlprocs.c */ -extern int Init_VLdbase(struct ubik_trans **trans, int locktype, int this_op); +extern int Init_VLdbase(struct vl_ctx *ctx, int locktype, int this_op); /* vlutils.c */ extern afs_int32 vlwrite(struct ubik_trans *trans, afs_int32 offset, void *buffer, afs_int32 length); extern afs_int32 vlentrywrite(struct ubik_trans *trans, afs_int32 offset, void *buffer, afs_int32 length); -extern int write_vital_vlheader(struct ubik_trans *trans); +extern int write_vital_vlheader(struct vl_ctx *ctx); extern afs_int32 readExtents(struct ubik_trans *trans); extern afs_int32 CheckInit(struct ubik_trans *trans, int builddb); -extern afs_int32 AllocBlock(struct ubik_trans *trans, +extern afs_int32 AllocBlock(struct vl_ctx *ctx, struct nvlentry *tentry); -extern afs_int32 FindExtentBlock(struct ubik_trans *trans, afsUUID *uuidp, +extern afs_int32 FindExtentBlock(struct vl_ctx *ctx, afsUUID *uuidp, afs_int32 createit, afs_int32 hostslot, struct extentaddr **expp, afs_int32 *basep); -extern afs_int32 FindByID(struct ubik_trans *trans, afs_uint32 volid, +extern afs_int32 FindByID(struct vl_ctx *ctx, afs_uint32 volid, afs_int32 voltype, struct nvlentry *tentry, afs_int32 *error); -extern afs_int32 FindByName(struct ubik_trans *trans, char *volname, +extern afs_int32 FindByName(struct vl_ctx *ctx, char *volname, struct nvlentry *tentry, afs_int32 *error); -extern int EntryIDExists(struct ubik_trans *trans, const afs_uint32 *ids, +extern int EntryIDExists(struct vl_ctx *ctx, const afs_uint32 *ids, afs_int32 ids_len, afs_int32 *error); -extern afs_uint32 NextUnusedID(struct ubik_trans *trans, afs_uint32 maxvolid, +extern afs_uint32 NextUnusedID(struct vl_ctx *ctx, afs_uint32 maxvolid, afs_uint32 bump, afs_int32 *error); -extern int HashNDump(struct ubik_trans *trans, int hashindex); -extern int HashIdDump(struct ubik_trans *trans, int hashindex); -extern int ThreadVLentry(struct ubik_trans *trans, afs_int32 blockindex, +extern int HashNDump(struct vl_ctx *ctx, int hashindex); +extern int HashIdDump(struct vl_ctx *ctx, int hashindex); +extern int ThreadVLentry(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *tentry); -extern int UnthreadVLentry(struct ubik_trans *trans, afs_int32 blockindex, +extern int UnthreadVLentry(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *aentry); -extern int HashVolid(struct ubik_trans *trans, afs_int32 voltype, +extern int HashVolid(struct vl_ctx *ctx, afs_int32 voltype, afs_int32 blockindex, struct nvlentry *tentry); -extern int UnhashVolid(struct ubik_trans *trans, afs_int32 voltype, +extern int UnhashVolid(struct vl_ctx *ctx, afs_int32 voltype, afs_int32 blockindex, struct nvlentry *aentry); -extern int HashVolname(struct ubik_trans *trans, afs_int32 blockindex, +extern int HashVolname(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *aentry); -extern int UnhashVolname(struct ubik_trans *trans, afs_int32 blockindex, +extern int UnhashVolname(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *aentry); -extern afs_int32 NextEntry(struct ubik_trans *trans, afs_int32 blockindex, +extern afs_int32 NextEntry(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *tentry, afs_int32 *remaining); -extern int FreeBlock(struct ubik_trans *trans, afs_int32 blockindex); +extern int FreeBlock(struct vl_ctx *ctx, afs_int32 blockindex); #endif diff --git a/src/vlserver/vlutils.c b/src/vlserver/vlutils.c index b5ad49a..c327f7e 100644 --- a/src/vlserver/vlutils.c +++ b/src/vlserver/vlutils.c @@ -33,7 +33,7 @@ struct extentaddr extentaddr; extern struct extentaddr *ex_addr[]; int vldbversion = 0; -static int index_OK(struct ubik_trans *trans, afs_int32 blockindex); +static int index_OK(struct vl_ctx *ctx, afs_int32 blockindex); #define ERROR_EXIT(code) {error=(code); goto error_exit;} @@ -188,10 +188,10 @@ vlentryread(struct ubik_trans *trans, afs_int32 offset, char *buffer, /* Convenient write of small critical vldb header info to the database. */ int -write_vital_vlheader(struct ubik_trans *trans) +write_vital_vlheader(struct vl_ctx *ctx) { if (vlwrite - (trans, 0, (char *)&cheader.vital_header, sizeof(vital_vlheader))) + (ctx->trans, 0, (char *)&cheader.vital_header, sizeof(vital_vlheader))) return VL_IO; return 0; } @@ -391,7 +391,7 @@ CheckInit(struct ubik_trans *trans, int builddb) afs_int32 -GetExtentBlock(struct ubik_trans *trans, afs_int32 base) +GetExtentBlock(struct vl_ctx *ctx, register afs_int32 base) { afs_int32 blockindex, code, error = 0; @@ -412,7 +412,7 @@ GetExtentBlock(struct ubik_trans *trans, afs_int32 base) ex_addr[base]->ex_flags = htonl(VLCONTBLOCK); blockindex = ntohl(cheader.vital_header.eofPtr); code = - vlwrite(trans, blockindex, (char *)ex_addr[base], + vlwrite(ctx->trans, blockindex, (char *)ex_addr[base], VL_ADDREXTBLK_SIZE); if (code) ERROR_EXIT(VL_IO); @@ -420,7 +420,7 @@ GetExtentBlock(struct ubik_trans *trans, afs_int32 base) /* Update the cheader.vitalheader structure on disk */ cheader.vital_header.eofPtr = blockindex + VL_ADDREXTBLK_SIZE; cheader.vital_header.eofPtr = htonl(cheader.vital_header.eofPtr); - code = write_vital_vlheader(trans); + code = write_vital_vlheader(ctx); if (code) ERROR_EXIT(VL_IO); @@ -428,7 +428,7 @@ GetExtentBlock(struct ubik_trans *trans, afs_int32 base) if (base == 0) { cheader.SIT = htonl(blockindex); code = - vlwrite(trans, DOFFSET(0, &cheader, &cheader.SIT), + vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.SIT), (char *)&cheader.SIT, sizeof(cheader.SIT)); if (code) ERROR_EXIT(VL_IO); @@ -437,7 +437,7 @@ GetExtentBlock(struct ubik_trans *trans, afs_int32 base) /* Write the address of this extension block into the base extension block */ ex_addr[0]->ex_contaddrs[base] = htonl(blockindex); code = - vlwrite(trans, ntohl(cheader.SIT), ex_addr[0], + vlwrite(ctx->trans, ntohl(cheader.SIT), ex_addr[0], sizeof(struct extentaddr)); if (code) ERROR_EXIT(VL_IO); @@ -449,7 +449,7 @@ GetExtentBlock(struct ubik_trans *trans, afs_int32 base) afs_int32 -FindExtentBlock(struct ubik_trans *trans, afsUUID *uuidp, +FindExtentBlock(struct vl_ctx *ctx, afsUUID *uuidp, afs_int32 createit, afs_int32 hostslot, struct extentaddr **expp, afs_int32 *basep) { @@ -462,7 +462,7 @@ FindExtentBlock(struct ubik_trans *trans, afsUUID *uuidp, /* Create the first extension block if it does not exist */ if (!cheader.SIT) { - code = GetExtentBlock(trans, 0); + code = GetExtentBlock(ctx, 0); if (code) ERROR_EXIT(code); } @@ -500,7 +500,7 @@ FindExtentBlock(struct ubik_trans *trans, afsUUID *uuidp, for (base = 0; base < VL_MAX_ADDREXTBLKS; base++) { if (!ex_addr[0]->ex_contaddrs[base]) { - code = GetExtentBlock(trans, base); + code = GetExtentBlock(ctx, base); if (code) ERROR_EXIT(code); } @@ -513,7 +513,7 @@ FindExtentBlock(struct ubik_trans *trans, afsUUID *uuidp, afs_htonuuid(&tuuid); exp->ex_hostuuid = tuuid; code = - vlwrite(trans, + vlwrite(ctx->trans, DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[base]), (char *)ex_addr[base], (char *)exp), (char *)&tuuid, sizeof(tuuid)); @@ -526,13 +526,13 @@ FindExtentBlock(struct ubik_trans *trans, afsUUID *uuidp, if (vldbversion != VLDBVERSION_4) { cheader.vital_header.vldbversion = htonl(VLDBVERSION_4); - code = write_vital_vlheader(trans); + code = write_vital_vlheader(ctx); if (code) ERROR_EXIT(VL_IO); } cheader.IpMappedAddr[i] = htonl(HostAddress[i]); code = - vlwrite(trans, + vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.IpMappedAddr[i]), (char *)&cheader.IpMappedAddr[i], @@ -553,14 +553,14 @@ FindExtentBlock(struct ubik_trans *trans, afsUUID *uuidp, /* Allocate a free block of storage for entry, returning address of a new zeroed entry (or zero if something is wrong). */ afs_int32 -AllocBlock(struct ubik_trans *trans, struct nvlentry *tentry) +AllocBlock(struct vl_ctx *ctx, struct nvlentry *tentry) { afs_int32 blockindex; if (cheader.vital_header.freePtr) { /* allocate this dude */ blockindex = ntohl(cheader.vital_header.freePtr); - if (vlentryread(trans, blockindex, (char *)tentry, sizeof(vlentry))) + if (vlentryread(ctx->trans, blockindex, (char *)tentry, sizeof(vlentry))) return 0; cheader.vital_header.freePtr = htonl(tentry->nextIdHash[0]); } else { @@ -569,7 +569,7 @@ AllocBlock(struct ubik_trans *trans, struct nvlentry *tentry) cheader.vital_header.eofPtr = htonl(blockindex + sizeof(vlentry)); } cheader.vital_header.allocs++; - if (write_vital_vlheader(trans)) + if (write_vital_vlheader(ctx)) return 0; memset(tentry, 0, sizeof(nvlentry)); /* zero new entry */ return blockindex; @@ -578,21 +578,21 @@ AllocBlock(struct ubik_trans *trans, struct nvlentry *tentry) /* Free a block given its index. It must already have been unthreaded. Returns zero for success or an error code on failure. */ int -FreeBlock(struct ubik_trans *trans, afs_int32 blockindex) +FreeBlock(struct vl_ctx *ctx, afs_int32 blockindex) { struct nvlentry tentry; /* check validity of blockindex just to be on the safe side */ - if (!index_OK(trans, blockindex)) + if (!index_OK(ctx, blockindex)) return VL_BADINDEX; memset(&tentry, 0, sizeof(nvlentry)); tentry.nextIdHash[0] = cheader.vital_header.freePtr; /* already in network order */ tentry.flags = htonl(VLFREE); cheader.vital_header.freePtr = htonl(blockindex); - if (vlwrite(trans, blockindex, (char *)&tentry, sizeof(nvlentry))) + if (vlwrite(ctx->trans, blockindex, (char *)&tentry, sizeof(nvlentry))) return VL_IO; cheader.vital_header.frees++; - if (write_vital_vlheader(trans)) + if (write_vital_vlheader(ctx)) return VL_IO; return 0; } @@ -604,7 +604,7 @@ FreeBlock(struct ubik_trans *trans, afs_int32 blockindex) * pointed to by tentry and return the block's index. If not found return 0. */ afs_int32 -FindByID(struct ubik_trans *trans, afs_uint32 volid, afs_int32 voltype, +FindByID(struct vl_ctx *ctx, afs_uint32 volid, afs_int32 voltype, struct nvlentry *tentry, afs_int32 *error) { afs_int32 typeindex, hashindex, blockindex; @@ -618,7 +618,7 @@ FindByID(struct ubik_trans *trans, afs_uint32 volid, afs_int32 voltype, blockindex != NULLO; blockindex = tentry->nextIdHash[typeindex]) { if (vlentryread - (trans, blockindex, (char *)tentry, sizeof(nvlentry))) { + (ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) { *error = VL_IO; return 0; } @@ -630,7 +630,7 @@ FindByID(struct ubik_trans *trans, afs_uint32 volid, afs_int32 voltype, for (blockindex = ntohl(cheader.VolidHash[voltype][hashindex]); blockindex != NULLO; blockindex = tentry->nextIdHash[voltype]) { if (vlentryread - (trans, blockindex, (char *)tentry, sizeof(nvlentry))) { + (ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) { *error = VL_IO; return 0; } @@ -647,7 +647,7 @@ FindByID(struct ubik_trans *trans, afs_uint32 volid, afs_int32 voltype, * found return 0. */ afs_int32 -FindByName(struct ubik_trans *trans, char *volname, struct nvlentry *tentry, +FindByName(struct vl_ctx *ctx, char *volname, struct nvlentry *tentry, afs_int32 *error) { afs_int32 hashindex; @@ -674,7 +674,7 @@ FindByName(struct ubik_trans *trans, char *volname, struct nvlentry *tentry, hashindex = NameHash(tname); for (blockindex = ntohl(cheader.VolnameHash[hashindex]); blockindex != NULLO; blockindex = tentry->nextNameHash) { - if (vlentryread(trans, blockindex, (char *)tentry, sizeof(nvlentry))) { + if (vlentryread(ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) { *error = VL_IO; return 0; } @@ -688,7 +688,7 @@ FindByName(struct ubik_trans *trans, char *volname, struct nvlentry *tentry, * Returns whether or not any of the supplied volume IDs already exist * in the vldb. * - * @param trans the ubik transaction + * @param ctx transaction context * @param ids an array of volume IDs * @param ids_len the number of elements in the 'ids' array * @param error filled in with an error code in case of error @@ -698,7 +698,7 @@ FindByName(struct ubik_trans *trans, char *volname, struct nvlentry *tentry, * @retval 0 none of the volume IDs are used, or an error occurred */ int -EntryIDExists(struct ubik_trans *trans, const afs_uint32 *ids, +EntryIDExists(struct vl_ctx *ctx, const afs_uint32 *ids, afs_int32 ids_len, afs_int32 *error) { afs_int32 typeindex; @@ -708,7 +708,7 @@ EntryIDExists(struct ubik_trans *trans, const afs_uint32 *ids, for (typeindex = 0; typeindex < ids_len; typeindex++) { if (ids[typeindex] - && FindByID(trans, ids[typeindex], -1, &tentry, error)) { + && FindByID(ctx, ids[typeindex], -1, &tentry, error)) { return 1; } else if (*error) { @@ -722,7 +722,7 @@ EntryIDExists(struct ubik_trans *trans, const afs_uint32 *ids, /** * Finds the next range of unused volume IDs in the vldb. * - * @param trans the ubik transaction + * @param ctx transaction context * @param maxvolid the current max vol ID, and where to start looking * for an unused volume ID range * @param bump how many volume IDs we need to be unused @@ -733,7 +733,7 @@ EntryIDExists(struct ubik_trans *trans, const afs_uint32 *ids, * an error */ afs_uint32 -NextUnusedID(struct ubik_trans *trans, afs_uint32 maxvolid, afs_uint32 bump, +NextUnusedID(struct vl_ctx *ctx, afs_uint32 maxvolid, afs_uint32 bump, afs_int32 *error) { struct nvlentry tentry; @@ -746,7 +746,7 @@ NextUnusedID(struct ubik_trans *trans, afs_uint32 maxvolid, afs_uint32 bump, * how many free volume IDs we've seen in a row, and return when * we've seen 'bump' unused IDs in a row */ for (id = maxvolid, nfree = 0; nfree < bump; ++id) { - if (FindByID(trans, id, -1, &tentry, error)) { + if (FindByID(ctx, id, -1, &tentry, error)) { nfree = 0; } else if (*error) { return 0; @@ -762,7 +762,7 @@ NextUnusedID(struct ubik_trans *trans, afs_uint32 maxvolid, afs_uint32 bump, } int -HashNDump(struct ubik_trans *trans, int hashindex) +HashNDump(struct vl_ctx *ctx, int hashindex) { int i = 0; int blockindex; @@ -770,7 +770,7 @@ HashNDump(struct ubik_trans *trans, int hashindex) for (blockindex = ntohl(cheader.VolnameHash[hashindex]); blockindex != NULLO; blockindex = tentry.nextNameHash) { - if (vlentryread(trans, blockindex, (char *)&tentry, sizeof(nvlentry))) + if (vlentryread(ctx->trans, blockindex, (char *)&tentry, sizeof(nvlentry))) return 0; i++; VLog(0, @@ -782,7 +782,7 @@ HashNDump(struct ubik_trans *trans, int hashindex) int -HashIdDump(struct ubik_trans *trans, int hashindex) +HashIdDump(struct vl_ctx *ctx, int hashindex) { int i = 0; int blockindex; @@ -790,7 +790,7 @@ HashIdDump(struct ubik_trans *trans, int hashindex) for (blockindex = ntohl(cheader.VolidHash[0][hashindex]); blockindex != NULLO; blockindex = tentry.nextIdHash[0]) { - if (vlentryread(trans, blockindex, (char *)&tentry, sizeof(nvlentry))) + if (vlentryread(ctx->trans, blockindex, (char *)&tentry, sizeof(nvlentry))) return 0; i++; VLog(0, @@ -806,38 +806,38 @@ HashIdDump(struct ubik_trans *trans, int hashindex) * routine returns zero if there were no errors. */ int -ThreadVLentry(struct ubik_trans *trans, afs_int32 blockindex, +ThreadVLentry(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *tentry) { int errorcode; - if (!index_OK(trans, blockindex)) + if (!index_OK(ctx, blockindex)) return VL_BADINDEX; /* Insert into volid's hash linked list */ - if ((errorcode = HashVolid(trans, RWVOL, blockindex, tentry))) + if ((errorcode = HashVolid(ctx, RWVOL, blockindex, tentry))) return errorcode; /* For rw entries we also enter the RO and BACK volume ids (if they * exist) in the hash tables; note all there volids (RW, RO, BACK) * should not be hashed yet! */ if (tentry->volumeId[ROVOL]) { - if ((errorcode = HashVolid(trans, ROVOL, blockindex, tentry))) + if ((errorcode = HashVolid(ctx, ROVOL, blockindex, tentry))) return errorcode; } if (tentry->volumeId[BACKVOL]) { - if ((errorcode = HashVolid(trans, BACKVOL, blockindex, tentry))) + if ((errorcode = HashVolid(ctx, BACKVOL, blockindex, tentry))) return errorcode; } /* Insert into volname's hash linked list */ - HashVolname(trans, blockindex, tentry); + HashVolname(ctx, blockindex, tentry); /* Update cheader entry */ - if (write_vital_vlheader(trans)) + if (write_vital_vlheader(ctx)) return VL_IO; /* Update hash list pointers in the entry itself */ - if (vlentrywrite(trans, blockindex, (char *)tentry, sizeof(nvlentry))) + if (vlentrywrite(ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) return VL_IO; return 0; } @@ -846,42 +846,42 @@ ThreadVLentry(struct ubik_trans *trans, afs_int32 blockindex, /* Remove a block from both the hash tables. If success return 0, else * return an error code. */ int -UnthreadVLentry(struct ubik_trans *trans, afs_int32 blockindex, +UnthreadVLentry(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *aentry) { afs_int32 errorcode, typeindex; - if (!index_OK(trans, blockindex)) + if (!index_OK(ctx, blockindex)) return VL_BADINDEX; - if ((errorcode = UnhashVolid(trans, RWVOL, blockindex, aentry))) + if ((errorcode = UnhashVolid(ctx, RWVOL, blockindex, aentry))) return errorcode; /* Take the RO/RW entries of their respective hash linked lists. */ for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) { - if ((errorcode = UnhashVolid(trans, typeindex, blockindex, aentry))) + if ((errorcode = UnhashVolid(ctx, typeindex, blockindex, aentry))) return errorcode; } /* Take it out of the Volname hash list */ - if ((errorcode = UnhashVolname(trans, blockindex, aentry))) + if ((errorcode = UnhashVolname(ctx, blockindex, aentry))) return errorcode; /* Update cheader entry */ - write_vital_vlheader(trans); + write_vital_vlheader(ctx); return 0; } /* cheader must have be read before this routine is called. */ int -HashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, +HashVolid(struct vl_ctx *ctx, afs_int32 voltype, afs_int32 blockindex, struct nvlentry *tentry) { afs_int32 hashindex, errorcode; struct nvlentry ventry; if (FindByID - (trans, tentry->volumeId[voltype], voltype, &ventry, &errorcode)) + (ctx, tentry->volumeId[voltype], voltype, &ventry, &errorcode)) return VL_IDALREADYHASHED; else if (errorcode) return errorcode; @@ -890,7 +890,7 @@ HashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, ntohl(cheader.VolidHash[voltype][hashindex]); cheader.VolidHash[voltype][hashindex] = htonl(blockindex); if (vlwrite - (trans, DOFFSET(0, &cheader, &cheader.VolidHash[voltype][hashindex]), + (ctx->trans, DOFFSET(0, &cheader, &cheader.VolidHash[voltype][hashindex]), (char *)&cheader.VolidHash[voltype][hashindex], sizeof(afs_int32))) return VL_IO; return 0; @@ -899,7 +899,7 @@ HashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, /* cheader must have be read before this routine is called. */ int -UnhashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, +UnhashVolid(struct vl_ctx *ctx, afs_int32 voltype, afs_int32 blockindex, struct nvlentry *aentry) { int hashindex, nextblockindex, prevblockindex; @@ -917,7 +917,7 @@ UnhashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, cheader.VolidHash[voltype][hashindex] = htonl(aentry->nextIdHash[voltype]); code = - vlwrite(trans, + vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.VolidHash[voltype][hashindex]), (char *)&cheader.VolidHash[voltype][hashindex], @@ -928,7 +928,7 @@ UnhashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, while (nextblockindex != blockindex) { prevblockindex = nextblockindex; /* always done once */ if (vlentryread - (trans, nextblockindex, (char *)&tentry, sizeof(nvlentry))) + (ctx->trans, nextblockindex, (char *)&tentry, sizeof(nvlentry))) return VL_IO; if ((nextblockindex = tentry.nextIdHash[voltype]) == NULLO) return VL_NOENT; @@ -936,7 +936,7 @@ UnhashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, temp = tentry.nextIdHash[voltype] = aentry->nextIdHash[voltype]; temp = htonl(temp); /* convert to network byte order before writing */ if (vlwrite - (trans, + (ctx->trans, DOFFSET(prevblockindex, &tentry, &tentry.nextIdHash[voltype]), (char *)&temp, sizeof(afs_int32))) return VL_IO; @@ -947,7 +947,7 @@ UnhashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex, int -HashVolname(struct ubik_trans *trans, afs_int32 blockindex, +HashVolname(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *aentry) { afs_int32 hashindex; @@ -958,7 +958,7 @@ HashVolname(struct ubik_trans *trans, afs_int32 blockindex, aentry->nextNameHash = ntohl(cheader.VolnameHash[hashindex]); cheader.VolnameHash[hashindex] = htonl(blockindex); code = - vlwrite(trans, DOFFSET(0, &cheader, &cheader.VolnameHash[hashindex]), + vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.VolnameHash[hashindex]), (char *)&cheader.VolnameHash[hashindex], sizeof(afs_int32)); if (code) return VL_IO; @@ -967,7 +967,7 @@ HashVolname(struct ubik_trans *trans, afs_int32 blockindex, int -UnhashVolname(struct ubik_trans *trans, afs_int32 blockindex, +UnhashVolname(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *aentry) { afs_int32 hashindex, nextblockindex, prevblockindex; @@ -981,14 +981,14 @@ UnhashVolname(struct ubik_trans *trans, afs_int32 blockindex, /* First on the hash list; just adjust pointers */ cheader.VolnameHash[hashindex] = htonl(aentry->nextNameHash); if (vlwrite - (trans, DOFFSET(0, &cheader, &cheader.VolnameHash[hashindex]), + (ctx->trans, DOFFSET(0, &cheader, &cheader.VolnameHash[hashindex]), (char *)&cheader.VolnameHash[hashindex], sizeof(afs_int32))) return VL_IO; } else { while (nextblockindex != blockindex) { prevblockindex = nextblockindex; /* always done at least once */ if (vlentryread - (trans, nextblockindex, (char *)&tentry, sizeof(nvlentry))) + (ctx->trans, nextblockindex, (char *)&tentry, sizeof(nvlentry))) return VL_IO; if ((nextblockindex = tentry.nextNameHash) == NULLO) return VL_NOENT; @@ -996,7 +996,7 @@ UnhashVolname(struct ubik_trans *trans, afs_int32 blockindex, tentry.nextNameHash = aentry->nextNameHash; temp = htonl(tentry.nextNameHash); if (vlwrite - (trans, DOFFSET(prevblockindex, &tentry, &tentry.nextNameHash), + (ctx->trans, DOFFSET(prevblockindex, &tentry, &tentry.nextNameHash), (char *)&temp, sizeof(afs_int32))) return VL_IO; } @@ -1011,7 +1011,7 @@ UnhashVolname(struct ubik_trans *trans, afs_int32 blockindex, */ afs_int32 -NextEntry(struct ubik_trans *trans, afs_int32 blockindex, +NextEntry(struct vl_ctx *ctx, afs_int32 blockindex, struct nvlentry *tentry, afs_int32 *remaining) { afs_int32 lastblockindex; @@ -1019,7 +1019,7 @@ NextEntry(struct ubik_trans *trans, afs_int32 blockindex, if (blockindex == 0) /* get first one */ blockindex = sizeof(cheader); else { - if (!index_OK(trans, blockindex)) { + if (!index_OK(ctx, blockindex)) { *remaining = -1; /* error */ return 0; } @@ -1028,7 +1028,7 @@ NextEntry(struct ubik_trans *trans, afs_int32 blockindex, /* now search for the first entry that isn't free */ for (lastblockindex = ntohl(cheader.vital_header.eofPtr); blockindex < lastblockindex;) { - if (vlentryread(trans, blockindex, (char *)tentry, sizeof(nvlentry))) { + if (vlentryread(ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) { *remaining = -1; return 0; } @@ -1056,7 +1056,7 @@ NextEntry(struct ubik_trans *trans, afs_int32 blockindex, * table */ static int -index_OK(struct ubik_trans *trans, afs_int32 blockindex) +index_OK(struct vl_ctx *ctx, afs_int32 blockindex) { if ((blockindex < sizeof(cheader)) || (blockindex >= ntohl(cheader.vital_header.eofPtr))) -- 1.9.4