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);
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 *
/* 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)
{
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))
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 */
}
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];
/* 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;
/* 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;
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,
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];
/* 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;
/* 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;
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,
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];
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,
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];
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;
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,
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 */
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
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];
}
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 */
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
{
afs_int32 errorcode;
afs_uint32 maxvolumeid;
- struct ubik_trans *trans;
+ struct vl_ctx ctx;
char rxstr[AFS_RXINFO_LEN];
COUNT_REQ(VLGETNEWVOLUMEID);
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;
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);
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];
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;
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;
/* 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;
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 */
/* 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;
/* 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,
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];
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;
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 */
/* 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;
/* 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,
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];
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;
/* 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,
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;
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;
/* 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);
afs_int32 voloper)
{
afs_int32 timestamp, blockindex, errorcode;
- struct ubik_trans *trans;
+ struct vl_ctx ctx;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
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;
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);
afs_int32 releasetype)
{
afs_int32 blockindex, errorcode;
- struct ubik_trans *trans;
+ struct vl_ctx ctx;
struct nvlentry tentry;
char rxstr[AFS_RXINFO_LEN];
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;
}
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,
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;
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));
}
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;
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;
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;
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;
} 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();
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)
&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;
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
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;
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;
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;
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;
} 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();
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)
&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;
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));
}
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;
*nentries = 0;
*nextstartindex = -1;
- errorcode = Init_VLdbase(&trans, LOCKREAD, this_op);
+ errorcode = Init_VLdbase(&ctx, LOCKREAD, this_op);
if (errorcode)
return errorcode;
(nvldbentry *) malloc(maxCount * sizeof(nvldbentry));
if (Vldbentry == NULL) {
COUNT_ABO;
- ubik_AbortTrans(trans);
+ ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
*/
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;
/* 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;
/* 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();
if (errorcode) {
COUNT_ABO;
- ubik_AbortTrans(trans);
+ ubik_AbortTrans(ctx.trans);
if (vldbentries->nbulkentries_val)
free((char *)vldbentries->nbulkentries_val);
vldbentries->nbulkentries_val = 0;
VLog(5,
("N2ListAttrs nentries=%d %s\n", vldbentries->nbulkentries_len,
rxinfo(rxstr, rxcall)));
- return (ubik_EndTrans(trans));
+ return (ubik_EndTrans(ctx.trans));
}
}
vldb_list *vldbentries)
{
int errorcode;
- struct ubik_trans *trans;
+ struct vl_ctx ctx;
struct nvlentry tentry;
vldblist vllist, *vllistptr;
afs_int32 blockindex, count, match;
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;
/* 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);
/* 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) {
/* 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++) {
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);
(*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
nvldb_list *vldbentries)
{
int errorcode;
- struct ubik_trans *trans;
+ struct vl_ctx ctx;
struct nvlentry tentry;
nvldblist vllist, *vllistptr;
afs_int32 blockindex, count, match;
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;
/* 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);
/* 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) {
/* 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++) {
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);
(*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,
vital_vlheader *vital_header)
{
afs_int32 errorcode;
- struct ubik_trans *trans;
+ struct vl_ctx ctx;
char rxstr[AFS_RXINFO_LEN];
COUNT_REQ(VLGETSTATS);
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
bulkaddrs *addrsp)
{
afs_int32 errorcode;
- struct ubik_trans *trans;
+ struct vl_ctx ctx;
int nservers, i;
afs_uint32 *taddrp;
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"));
if (!taddrp) {
COUNT_ABO;
- ubik_AbortTrans(trans);
+ ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
}
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));
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;
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 */
}
}
if (cnt <= 0) {
- ubik_AbortTrans(trans);
+ ubik_AbortTrans(ctx.trans);
return VL_INDEXERANGE;
}
(" 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;
}
change = 1;
}
if (!change) {
- return (ubik_EndTrans(trans));
+ return (ubik_EndTrans(ctx.trans));
}
}
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);
}
}
* 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);
}
}
/* 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;
}
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
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;
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++) {
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 =
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)
}
}
addrsp->bulkaddrs_len = *nentries = nservers;
- return (ubik_EndTrans(trans));
+ return (ubik_EndTrans(ctx.trans));
}
/* ============> End of Exported vldb RPC functions <============= */
/* 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;
}
/* 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)
{
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;
}
static int
-nvldbentry_to_vlentry(struct ubik_trans *atrans,
+nvldbentry_to_vlentry(struct vl_ctx *ctx,
struct nvldbentry *VldbEntry,
struct nvlentry *VlEntry)
{
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;
* 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)
checkids[BACKVOL] = updateentry->BackupId;
}
- if (EntryIDExists(trans, checkids, MAXTYPES, &errorcode)) {
+ if (EntryIDExists(ctx, checkids, MAXTYPES, &errorcode)) {
return VL_IDEXIST;
} else if (errorcode) {
return errorcode;
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) {
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) {
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);
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;
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];
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;
}
return VL_BADPARTITION;
if ((j =
repsite_exists(VlEntry,
- IpAddrToRelAddr(updateentry->
+ IpAddrToRelAddr(ctx, updateentry->
RepsitesTargetServer[i],
- trans),
+ 1),
updateentry->RepsitesTargetPart[i])) !=
-1)
VlEntry->serverPartition[j] =
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
}
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;
}
/* 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));
}
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;
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);
* 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();
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));
/* 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;
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;}
/* 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;
}
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;
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);
/* 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);
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);
/* 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);
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)
{
/* 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);
}
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);
}
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));
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],
/* 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 {
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;
/* 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;
}
* 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;
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;
}
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;
}
* 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;
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;
}
* 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
* @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;
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) {
/**
* 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
* 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;
* 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;
}
int
-HashNDump(struct ubik_trans *trans, int hashindex)
+HashNDump(struct vl_ctx *ctx, int hashindex)
{
int i = 0;
int blockindex;
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,
int
-HashIdDump(struct ubik_trans *trans, int hashindex)
+HashIdDump(struct vl_ctx *ctx, int hashindex)
{
int i = 0;
int blockindex;
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,
* 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;
}
/* 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;
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;
/* 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;
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],
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;
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;
int
-HashVolname(struct ubik_trans *trans, afs_int32 blockindex,
+HashVolname(struct vl_ctx *ctx, afs_int32 blockindex,
struct nvlentry *aentry)
{
afs_int32 hashindex;
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;
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;
/* 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;
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;
}
*/
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;
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;
}
/* 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;
}
* 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)))