extern int extent_mod;
extern struct afsconf_dir *vldb_confdir;
extern struct ubik_dbase *VL_dbase;
-struct vlheader cheader; /* kept in network byte order */
-extern afs_uint32 HostAddress[]; /* host addresses kept in host byte order */
int maxnservers;
-struct extentaddr *ex_addr[VL_MAX_ADDREXTBLKS] = { 0, 0, 0, 0 };
#define ABORT(c) do { \
errorcode = (c); \
goto abort; \
#define VLDBALLOCLIMIT 10000
#define VLDBALLOCINCR 2048
-static int put_attributeentry(struct vldbentry **, struct vldbentry **,
+static int put_attributeentry(struct vl_ctx *ctx,
+ struct vldbentry **, struct vldbentry **,
struct vldbentry **, bulkentries *,
struct nvlentry *, afs_int32 *, afs_int32 *);
-static int put_nattributeentry(struct nvldbentry **, struct nvldbentry **,
+static int put_nattributeentry(struct vl_ctx *ctx,
+ struct nvldbentry **, struct nvldbentry **,
struct nvldbentry **, nbulkentries *,
struct nvlentry *, afs_int32, afs_int32,
afs_int32 *, afs_int32 *);
struct nvlentry *VlEntry);
static int repsite_exists(struct nvlentry *VlEntry, int server, int partition);
static void repsite_compress(struct nvlentry *VlEntry, int offset);
-static void vlentry_to_vldbentry(struct nvlentry *VlEntry,
+static void vlentry_to_vldbentry(struct vl_ctx *ctx,
+ struct nvlentry *VlEntry,
struct vldbentry *VldbEntry);
-static void vlentry_to_nvldbentry(struct nvlentry *VlEntry,
+static void vlentry_to_nvldbentry(struct vl_ctx *ctx,
+ struct nvlentry *VlEntry,
struct nvldbentry *VldbEntry);
-static void vlentry_to_uvldbentry(struct nvlentry *VlEntry,
+static void vlentry_to_uvldbentry(struct vl_ctx *ctx,
+ struct nvlentry *VlEntry,
struct uvldbentry *VldbEntry);
static int InvalidVolname(char *volname);
static int InvalidVoltype(afs_int32 voltype);
}
}
}
+ if (errorcode == 0) {
+ errorcode = vlsetcache(ctx, locktype);
+ }
return errorcode;
}
}
/* Convert from the internal to external form */
if (new == 1)
- vlentry_to_nvldbentry(&tentry, (struct nvldbentry *)aentry);
+ vlentry_to_nvldbentry(&ctx, &tentry, (struct nvldbentry *)aentry);
else if (new == 2)
- vlentry_to_uvldbentry(&tentry, (struct uvldbentry *)aentry);
+ vlentry_to_uvldbentry(&ctx, &tentry, (struct uvldbentry *)aentry);
else
- vlentry_to_vldbentry(&tentry, (struct vldbentry *)aentry);
+ vlentry_to_vldbentry(&ctx, &tentry, (struct vldbentry *)aentry);
return (ubik_EndTrans(ctx.trans));
}
}
/* Convert to external entry representation */
if (new == 1)
- vlentry_to_nvldbentry(&tentry, (struct nvldbentry *)aentry);
+ vlentry_to_nvldbentry(&ctx, &tentry, (struct nvldbentry *)aentry);
else if (new == 2)
- vlentry_to_uvldbentry(&tentry, (struct uvldbentry *)aentry);
+ vlentry_to_uvldbentry(&ctx, &tentry, (struct uvldbentry *)aentry);
else
- vlentry_to_vldbentry(&tentry, (struct vldbentry *)aentry);
+ vlentry_to_vldbentry(&ctx, &tentry, (struct vldbentry *)aentry);
return (ubik_EndTrans(ctx.trans));
}
goto end;
*newvolumeid = maxvolumeid = NextUnusedID(&ctx,
- ntohl(cheader.vital_header.MaxVolumeId), Maxvolidbump, &errorcode);
+ ntohl(ctx.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);
+ ctx.cheader->vital_header.MaxVolumeId = htonl(maxvolumeid);
if (write_vital_vlheader(&ctx)) {
ABORT(VL_IO);
}
rxinfo(rxstr, rxcall)));
*next_index = NextEntry(&ctx, previous_index, &tentry, count);
if (*next_index)
- vlentry_to_vldbentry(&tentry, aentry);
+ vlentry_to_vldbentry(&ctx, &tentry, aentry);
return (ubik_EndTrans(ctx.trans));
}
VLog(25, ("ListEntry index=%d %s\n", previous_index, rxinfo(rxstr, rxcall)));
*next_index = NextEntry(&ctx, previous_index, &tentry, count);
if (*next_index)
- vlentry_to_nvldbentry(&tentry, aentry);
+ vlentry_to_nvldbentry(&ctx, &tentry, aentry);
return (ubik_EndTrans(ctx.trans));
}
return errorcode;
}
if ((errorcode =
- put_attributeentry(&Vldbentry, &VldbentryFirst, &VldbentryLast,
+ put_attributeentry(&ctx, &Vldbentry, &VldbentryFirst, &VldbentryLast,
vldbentries, &tentry, nentries, &allocCount))) {
COUNT_ABO;
ubik_AbortTrans(ctx.trans);
continue;
}
if ((errorcode =
- put_attributeentry(&Vldbentry, &VldbentryFirst,
+ put_attributeentry(&ctx, &Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry,
nentries, &allocCount))) {
COUNT_ABO;
return errorcode;
}
if ((errorcode =
- put_nattributeentry(&Vldbentry, &VldbentryFirst, &VldbentryLast,
+ put_nattributeentry(&ctx, &Vldbentry, &VldbentryFirst, &VldbentryLast,
vldbentries, &tentry, 0, 0, nentries,
&allocCount))) {
COUNT_ABO;
continue;
}
if ((errorcode =
- put_nattributeentry(&Vldbentry, &VldbentryFirst,
+ put_nattributeentry(&ctx, &Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry, 0,
0, nentries, &allocCount))) {
COUNT_ABO;
errorcode = VL_NOENT;
} else {
errorcode =
- put_nattributeentry(&Vldbentry, &VldbentryFirst,
+ put_nattributeentry(&ctx, &Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry, 0,
0, nentries, &maxCount);
if (errorcode)
/* Passed all the tests. Take it */
if (match) {
errorcode =
- put_nattributeentry(&Vldbentry, &VldbentryFirst,
+ put_nattributeentry(&ctx, &Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry,
matchtype, matchindex, nentries,
&maxCount);
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
- vlentry_to_vldbentry(&tentry, &vllist->VldbEntry);
+ vlentry_to_vldbentry(&ctx, &tentry, &vllist->VldbEntry);
vllist->next_vldb = NULL;
*vllistptr = vllist; /* Thread onto list */
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
- vlentry_to_vldbentry(&tentry, &vllist->VldbEntry);
+ vlentry_to_vldbentry(&ctx, &tentry, &vllist->VldbEntry);
vllist->next_vldb = NULL;
*vllistptr = vllist; /* Thread onto list */
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
- vlentry_to_nvldbentry(&tentry, &vllist->VldbEntry);
+ vlentry_to_nvldbentry(&ctx, &tentry, &vllist->VldbEntry);
vllist->next_vldb = NULL;
*vllistptr = vllist; /* Thread onto list */
ubik_AbortTrans(ctx.trans);
return VL_NOMEM;
}
- vlentry_to_nvldbentry(&tentry, &vllist->VldbEntry);
+ vlentry_to_nvldbentry(&ctx, &tentry, &vllist->VldbEntry);
vllist->next_vldb = NULL;
*vllistptr = vllist; /* Thread onto list */
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,
+ memcpy((char *)vital_header, (char *)&ctx.cheader->vital_header,
sizeof(vital_vlheader));
memcpy((char *)stats, (char *)&dynamic_statistics, sizeof(vldstats));
return (ubik_EndTrans(ctx.trans));
}
for (i = 0; i <= MAXSERVERID; i++) {
- if ((*taddrp = ntohl(cheader.IpMappedAddr[i]))) {
+ if ((*taddrp = ntohl(ctx.cheader->IpMappedAddr[i]))) {
taddrp++;
nservers++;
}
for (srvidx = 0; srvidx <= MAXSERVERID; srvidx++) {
willChangeEntry = 0;
WillReplaceEntry = 1;
- if ((HostAddress[srvidx] & 0xff000000) == 0xff000000) {
+ if ((ctx.hostaddress[srvidx] & 0xff000000) == 0xff000000) {
/* The server is registered as a multihomed */
- base = (HostAddress[srvidx] >> 16) & 0xff;
- index = HostAddress[srvidx] & 0x0000ffff;
+ base = (ctx.hostaddress[srvidx] >> 16) & 0xff;
+ index = ctx.hostaddress[srvidx] & 0x0000ffff;
if (base >= VL_MAX_ADDREXTBLKS) {
VLog(0,
("Internal error: Multihome extent base is too large. Base %d index %d\n",
base, index));
continue;
}
- if (!ex_addr[base]) {
+ if (!ctx.ex_addr[base]) {
VLog(0,
("Internal error: Multihome extent does not exist. Base %d\n",
base));
}
/* See if the addresses to register will change this server entry */
- exp = &ex_addr[base][index];
+ exp = &ctx.ex_addr[base][index];
tuuid = exp->ex_hostuuid;
afs_ntohuuid(&tuuid);
if (afs_uuid_equal(uuidp, &tuuid)) {
* See if the addresses to register will replace this server entry.
*/
for (k = 0; k < cnt; k++) {
- if (HostAddress[srvidx] == addrs[k]) {
+ if (ctx.hostaddress[srvidx] == addrs[k]) {
willChangeEntry = 1;
WillChange[count] = srvidx;
WillReplaceEntry = 1;
if (foundUuidEntry) {
VLog(0,
(" It would have replaced the existing VLDB server entry:\n"));
- base = (HostAddress[FoundUuid] >> 16) & 0xff;
- index = HostAddress[FoundUuid] & 0x0000ffff;
- exp = &ex_addr[base][index];
+ base = (ctx.hostaddress[FoundUuid] >> 16) & 0xff;
+ index = ctx.hostaddress[FoundUuid] & 0x0000ffff;
+ exp = &ctx.ex_addr[base][index];
for (addrbuf[0] = '\0', mhidx = 0; mhidx < VL_MAXIPADDRS_PERMH; mhidx++) {
if (!exp->ex_addrs[mhidx])
continue;
for (j = 0; j < count; j++) {
srvidx = WillChange[j];
addrbuf[0] = '\0';
- if ((HostAddress[srvidx] & 0xff000000) == 0xff000000) {
+ if ((ctx.hostaddress[srvidx] & 0xff000000) == 0xff000000) {
strlcat(addrbuf, "[", sizeof(addrbuf));
- base = (HostAddress[srvidx] >> 16) & 0xff;
- index = HostAddress[srvidx] & 0x0000ffff;
- exp = &ex_addr[base][index];
+ base = (ctx.hostaddress[srvidx] >> 16) & 0xff;
+ index = ctx.hostaddress[srvidx] & 0x0000ffff;
+ exp = &ctx.ex_addr[base][index];
for (mhidx = 0; mhidx < VL_MAXIPADDRS_PERMH; mhidx++) {
if (!exp->ex_addrs[mhidx])
continue;
}
strlcat(addrbuf, "]", sizeof(addrbuf));
} else {
- append_addr(addrbuf, HostAddress[srvidx], sizeof(addrbuf));
+ append_addr(addrbuf, ctx.hostaddress[srvidx], sizeof(addrbuf));
}
VLog(0, (" entry %d: %s\n", srvidx, addrbuf));
}
/* Found the entry with same uuid. See if we need to change it */
int change = 0;
- fbase = (HostAddress[FoundUuid] >> 16) & 0xff;
- index = HostAddress[FoundUuid] & 0x0000ffff;
- exp = &ex_addr[fbase][index];
+ fbase = (ctx.hostaddress[FoundUuid] >> 16) & 0xff;
+ index = ctx.hostaddress[FoundUuid] & 0x0000ffff;
+ exp = &ctx.ex_addr[fbase][index];
/* Determine if the entry has changed */
for (k = 0; ((k < cnt) && !change); k++) {
}
/* Have an entry that needs to be replaced */
- if ((HostAddress[ReplaceEntry] & 0xff000000) == 0xff000000) {
- fbase = (HostAddress[ReplaceEntry] >> 16) & 0xff;
- index = HostAddress[ReplaceEntry] & 0x0000ffff;
- exp = &ex_addr[fbase][index];
+ if ((ctx.hostaddress[ReplaceEntry] & 0xff000000) == 0xff000000) {
+ fbase = (ctx.hostaddress[ReplaceEntry] >> 16) & 0xff;
+ index = ctx.hostaddress[ReplaceEntry] & 0x0000ffff;
+ exp = &ctx.ex_addr[fbase][index];
VLog(0,
(" It will replace the following existing entry in the VLDB (new uuid):\n"));
VLog(0, (" entry %d: [%s]", ReplaceEntry, addrbuf));
} else {
/* Not a mh entry. So we have to create a new mh entry and
- * put it on the ReplaceEntry slot of the HostAddress array.
+ * put it on the ReplaceEntry slot of the ctx.hostaddress array.
*/
addrbuf[0] = '\0';
- append_addr(addrbuf, HostAddress[ReplaceEntry], sizeof(addrbuf));
+ append_addr(addrbuf, ctx.hostaddress[ReplaceEntry], sizeof(addrbuf));
VLog(0, (" It will replace existing entry %d, [%s], in the VLDB (new uuid):\n", ReplaceEntry, addrbuf));
code =
}
} else {
/* There is no entry for this server, must create a new mh entry as
- * well as use a new slot of the HostAddress array.
+ * well as use a new slot of the ctx.hostaddress array.
*/
VLog(0, (" It will create a new entry in the VLDB.\n"));
code = FindExtentBlock(&ctx, uuidp, 1, -1, &exp, &fbase);
/* Write the new mh entry out */
if (vlwrite
(ctx.trans,
- DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[fbase]),
- (char *)ex_addr[fbase], (char *)exp), (char *)exp,
+ DOFFSET(ntohl(ctx.ex_addr[0]->ex_contaddrs[fbase]),
+ (char *)ctx.ex_addr[fbase], (char *)exp), (char *)exp,
sizeof(*exp))) {
ubik_AbortTrans(ctx.trans);
return VL_IO;
if (willReplaceCnt && (WillChange[i] == ReplaceEntry))
continue;
- base = (HostAddress[WillChange[i]] >> 16) & 0xff;
- index = HostAddress[WillChange[i]] & 0x0000ffff;
- tex = &ex_addr[fbase][index];
+ base = (ctx.hostaddress[WillChange[i]] >> 16) & 0xff;
+ index = ctx.hostaddress[WillChange[i]] & 0x0000ffff;
+ tex = &ctx.ex_addr[fbase][index];
if (++m == 1)
VLog(0,
/* Write out the modified mh entry */
tex->ex_uniquifier = htonl(ntohl(tex->ex_uniquifier) + 1);
doff =
- DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[base]),
- (char *)ex_addr[base], (char *)tex);
+ DOFFSET(ntohl(ctx.ex_addr[0]->ex_contaddrs[base]),
+ (char *)ctx.ex_addr[base], (char *)tex);
if (vlwrite(ctx.trans, doff, (char *)tex, sizeof(*tex))) {
ubik_AbortTrans(ctx.trans);
return VL_IO;
return VL_BADMASK;
}
for (base = 0; base < VL_MAX_ADDREXTBLKS; base++) {
- if (!ex_addr[base])
+ if (!ctx.ex_addr[base])
break;
for (i = 1; i < VL_MHSRV_PERBLK; i++) {
- exp = &ex_addr[base][i];
+ exp = &ctx.ex_addr[base][i];
tuuid = exp->ex_hostuuid;
afs_ntohuuid(&tuuid);
if (afs_uuid_is_nil(&tuuid))
ubik_AbortTrans(ctx.trans);
return VL_NOENT;
}
- if (!ex_addr[base]) {
+ if (!ctx.ex_addr[base]) {
ubik_AbortTrans(ctx.trans);
return VL_INDEXERANGE;
}
- exp = &ex_addr[base][offset];
+ exp = &ctx.ex_addr[base][offset];
} else if (attributes->Mask & VLADDR_UUID) {
if (attributes->Mask & (VLADDR_IPADDR | VLADDR_INDEX)) {
ubik_AbortTrans(ctx.trans);
return VL_BADMASK;
}
- if (!ex_addr[0]) { /* mh servers probably aren't setup on this vldb */
+ if (!ctx.ex_addr[0]) { /* mh servers probably aren't setup on this vldb */
ubik_AbortTrans(ctx.trans);
return VL_NOENT;
}
/* Routine that copies the given vldb entry to the output buffer, vldbentries. */
static int
-put_attributeentry(struct vldbentry **Vldbentry,
+put_attributeentry(struct vl_ctx *ctx,
+ struct vldbentry **Vldbentry,
struct vldbentry **VldbentryFirst,
struct vldbentry **VldbentryLast,
bulkentries *vldbentries,
*VldbentryLast = *Vldbentry + allo;
*alloccnt += allo;
}
- vlentry_to_vldbentry(entry, *Vldbentry);
+ vlentry_to_vldbentry(ctx, entry, *Vldbentry);
(*Vldbentry)++;
(*nentries)++;
vldbentries->bulkentries_len++;
}
static int
-put_nattributeentry(struct nvldbentry **Vldbentry,
+put_nattributeentry(struct vl_ctx *ctx,
+ struct nvldbentry **Vldbentry,
struct nvldbentry **VldbentryFirst,
struct nvldbentry **VldbentryLast,
nbulkentries *vldbentries,
*VldbentryLast = *Vldbentry + allo;
*alloccnt += allo;
}
- vlentry_to_nvldbentry(entry, *Vldbentry);
+ vlentry_to_nvldbentry(ctx, entry, *Vldbentry);
(*Vldbentry)->matchindex = (matchtype << 16) + matchindex;
(*Vldbentry)++;
(*nentries)++;
/* Convert from the internal (compacted) vldb entry to the external
* representation used by the interface. */
static void
-vlentry_to_vldbentry(struct nvlentry *VlEntry, struct vldbentry *VldbEntry)
+vlentry_to_vldbentry(struct vl_ctx *ctx, struct nvlentry *VlEntry,
+ struct vldbentry *VldbEntry)
{
int i, j;
for (i = 0; i < OMAXNSERVERS; i++) {
if (VlEntry->serverNumber[i] == BADSERVERID)
break;
- if ((HostAddress[j = VlEntry->serverNumber[i]] & 0xff000000) ==
+ if ((ctx->hostaddress[j = VlEntry->serverNumber[i]] & 0xff000000) ==
0xff000000) {
struct extentaddr *exp;
int base, index;
- base = (HostAddress[j] >> 16) & 0xff;
- index = HostAddress[j] & 0x0000ffff;
- exp = &ex_addr[base][index];
+ base = (ctx->hostaddress[j] >> 16) & 0xff;
+ index = ctx->hostaddress[j] & 0x0000ffff;
+ exp = &ctx->ex_addr[base][index];
/* For now return the first ip address back */
for (j = 0; j < VL_MAXIPADDRS_PERMH; j++) {
if (exp->ex_addrs[j]) {
}
} else
VldbEntry->serverNumber[i] =
- HostAddress[VlEntry->serverNumber[i]];
+ ctx->hostaddress[VlEntry->serverNumber[i]];
VldbEntry->serverPartition[i] = VlEntry->serverPartition[i];
VldbEntry->serverFlags[i] = VlEntry->serverFlags[i];
}
/* Convert from the internal (compacted) vldb entry to the external
* representation used by the interface. */
static void
-vlentry_to_nvldbentry(struct nvlentry *VlEntry, struct nvldbentry *VldbEntry)
+vlentry_to_nvldbentry(struct vl_ctx *ctx, struct nvlentry *VlEntry,
+ struct nvldbentry *VldbEntry)
{
int i, j;
for (i = 0; i < NMAXNSERVERS; i++) {
if (VlEntry->serverNumber[i] == BADSERVERID)
break;
- if ((HostAddress[j = VlEntry->serverNumber[i]] & 0xff000000) ==
+ if ((ctx->hostaddress[j = VlEntry->serverNumber[i]] & 0xff000000) ==
0xff000000) {
struct extentaddr *exp;
int base, index;
- base = (HostAddress[j] >> 16) & 0xff;
- index = HostAddress[j] & 0x0000ffff;
- exp = &ex_addr[base][index];
+ base = (ctx->hostaddress[j] >> 16) & 0xff;
+ index = ctx->hostaddress[j] & 0x0000ffff;
+ exp = &ctx->ex_addr[base][index];
/* For now return the first ip address back */
for (j = 0; j < VL_MAXIPADDRS_PERMH; j++) {
if (exp->ex_addrs[j]) {
}
} else
VldbEntry->serverNumber[i] =
- HostAddress[VlEntry->serverNumber[i]];
+ ctx->hostaddress[VlEntry->serverNumber[i]];
VldbEntry->serverPartition[i] = VlEntry->serverPartition[i];
VldbEntry->serverFlags[i] = VlEntry->serverFlags[i];
}
}
static void
-vlentry_to_uvldbentry(struct nvlentry *VlEntry, struct uvldbentry *VldbEntry)
+vlentry_to_uvldbentry(struct vl_ctx *ctx, struct nvlentry *VlEntry,
+ struct uvldbentry *VldbEntry)
{
int i, j;
break;
VldbEntry->serverFlags[i] = VlEntry->serverFlags[i];
VldbEntry->serverUnique[i] = 0;
- if ((HostAddress[j = VlEntry->serverNumber[i]] & 0xff000000) ==
+ if ((ctx->hostaddress[j = VlEntry->serverNumber[i]] & 0xff000000) ==
0xff000000) {
struct extentaddr *exp;
int base, index;
afsUUID tuuid;
- base = (HostAddress[j] >> 16) & 0xff;
- index = HostAddress[j] & 0x0000ffff;
- exp = &ex_addr[base][index];
+ base = (ctx->hostaddress[j] >> 16) & 0xff;
+ index = ctx->hostaddress[j] & 0x0000ffff;
+ exp = &ctx->ex_addr[base][index];
tuuid = exp->ex_hostuuid;
afs_ntohuuid(&tuuid);
VldbEntry->serverFlags[i] |= VLSERVER_FLAG_UUID;
VldbEntry->serverUnique[i] = ntohl(exp->ex_uniquifier);
} else {
VldbEntry->serverNumber[i].time_low =
- HostAddress[VlEntry->serverNumber[i]];
+ ctx->hostaddress[VlEntry->serverNumber[i]];
}
VldbEntry->serverPartition[i] = VlEntry->serverPartition[i];
struct extentaddr *exp;
for (i = 0; i <= MAXSERVERID; i++) {
- if (HostAddress[i] == ipaddr)
+ if (ctx->hostaddress[i] == ipaddr)
return i;
- if ((HostAddress[i] & 0xff000000) == 0xff000000) {
- base = (HostAddress[i] >> 16) & 0xff;
- index = HostAddress[i] & 0x0000ffff;
+ if ((ctx->hostaddress[i] & 0xff000000) == 0xff000000) {
+ base = (ctx->hostaddress[i] >> 16) & 0xff;
+ index = ctx->hostaddress[i] & 0x0000ffff;
if (base >= VL_MAX_ADDREXTBLKS) {
VLog(0,
("Internal error: Multihome extent base is too large. Base %d index %d\n",
base, index));
return -1; /* EINVAL */
}
- if (!ex_addr[base]) {
+ if (!ctx->ex_addr[base]) {
VLog(0,
("Internal error: Multihome extent does not exist. Base %d\n",
base));
return -1; /* EINVAL */
}
- exp = &ex_addr[base][index];
+ exp = &ctx->ex_addr[base][index];
for (j = 0; j < VL_MAXIPADDRS_PERMH; j++) {
if (exp->ex_addrs[j] && (ntohl(exp->ex_addrs[j]) == ipaddr)) {
return i;
/* allocate the new server a server id pronto */
if (create) {
for (i = 0; i <= MAXSERVERID; i++) {
- if (cheader.IpMappedAddr[i] == 0) {
- cheader.IpMappedAddr[i] = htonl(ipaddr);
+ if (ctx->cheader->IpMappedAddr[i] == 0) {
+ ctx->cheader->IpMappedAddr[i] = htonl(ipaddr);
code =
vlwrite(ctx->trans,
- DOFFSET(0, &cheader, &cheader.IpMappedAddr[i]),
- (char *)&cheader.IpMappedAddr[i],
+ DOFFSET(0, ctx->cheader, &ctx->cheader->IpMappedAddr[i]),
+ (char *)&ctx->cheader->IpMappedAddr[i],
sizeof(afs_int32));
- HostAddress[i] = ipaddr;
+ ctx->hostaddress[i] = ipaddr;
if (code)
return -1;
return i;
}
for (i = 0; i <= MAXSERVERID; i++) {
- if ((HostAddress[i] & 0xff000000) == 0xff000000) {
- base = (HostAddress[i] >> 16) & 0xff;
- index = HostAddress[i] & 0x0000ffff;
+ if ((ctx->hostaddress[i] & 0xff000000) == 0xff000000) {
+ base = (ctx->hostaddress[i] >> 16) & 0xff;
+ index = ctx->hostaddress[i] & 0x0000ffff;
if ((base >= VL_MAX_ADDREXTBLKS) || (index >= VL_MHSRV_PERBLK)) {
VLog(0,
("Internal error: Multihome extent addr is too large. Base %d index %d\n",
return -1; /* EINVAL */
}
- exp = &ex_addr[base][index];
+ exp = &ctx->ex_addr[base][index];
for (mhidx = 0; mhidx < VL_MAXIPADDRS_PERMH; mhidx++) {
if (!exp->ex_addrs[mhidx])
continue;
}
}
} else {
- if (HostAddress[i] == ipaddr1) {
+ if (ctx->hostaddress[i] == ipaddr1) {
exp = NULL;
ipaddr1_id = i;
}
- if (ipaddr2 != 0 && HostAddress[i] == ipaddr2) {
+ if (ipaddr2 != 0 && ctx->hostaddress[i] == ipaddr2) {
ipaddr2_id = i;
}
}
exp->ex_hostuuid = tuuid;
code =
vlwrite(ctx->trans,
- DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[base]),
- (char *)ex_addr[base], (char *)exp),
+ DOFFSET(ntohl(ctx->ex_addr[0]->ex_contaddrs[base]),
+ (char *)ctx->ex_addr[base], (char *)exp),
(char *)&tuuid, sizeof(tuuid));
if (code)
return VL_IO;
}
/* Now change the host address entry */
- cheader.IpMappedAddr[ipaddr1_id] = htonl(ipaddr2);
+ ctx->cheader->IpMappedAddr[ipaddr1_id] = htonl(ipaddr2);
code =
- vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.IpMappedAddr[ipaddr1_id]),
+ vlwrite(ctx->trans, DOFFSET(0, ctx->cheader, &ctx->cheader->IpMappedAddr[ipaddr1_id]),
(char *)
- &cheader.IpMappedAddr[ipaddr1_id], sizeof(afs_int32));
- HostAddress[ipaddr1_id] = ipaddr2;
+ &ctx->cheader->IpMappedAddr[ipaddr1_id], sizeof(afs_int32));
+ ctx->hostaddress[ipaddr1_id] = ipaddr2;
if (code)
return VL_IO;
#include "vlserver.h"
#include "vlserver_internal.h"
-extern struct vlheader cheader;
struct vlheader xheader;
-extern afs_uint32 HostAddress[];
extern int maxnservers;
struct extentaddr extentaddr;
-extern struct extentaddr *ex_addr[];
+struct extentaddr *rd_ex_addr[VL_MAX_ADDREXTBLKS] = { 0, 0, 0, 0 };
+struct vlheader rd_cheader; /* kept in network byte order */
int vldbversion = 0;
static int index_OK(struct vl_ctx *ctx, afs_int32 blockindex);
write_vital_vlheader(struct vl_ctx *ctx)
{
if (vlwrite
- (ctx->trans, 0, (char *)&cheader.vital_header, sizeof(vital_vlheader)))
+ (ctx->trans, 0, (char *)&ctx->cheader->vital_header, sizeof(vital_vlheader)))
return VL_IO;
return 0;
}
int i;
extent_mod = 0;
- extentAddr = ntohl(cheader.SIT);
+ extentAddr = ntohl(rd_cheader.SIT);
if (!extentAddr)
return 0;
/* Read the first extension block */
- if (!ex_addr[0]) {
- ex_addr[0] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
- if (!ex_addr[0])
+ if (!rd_ex_addr[0]) {
+ rd_ex_addr[0] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
+ if (!rd_ex_addr[0])
ERROR_EXIT(VL_NOMEM);
}
- code = vlread(trans, extentAddr, (char *)ex_addr[0], VL_ADDREXTBLK_SIZE);
+ code = vlread(trans, extentAddr, (char *)rd_ex_addr[0], VL_ADDREXTBLK_SIZE);
if (code) {
- free(ex_addr[0]); /* Not the place to create it */
- ex_addr[0] = 0;
+ free(rd_ex_addr[0]); /* Not the place to create it */
+ rd_ex_addr[0] = 0;
ERROR_EXIT(VL_IO);
}
* continuation blocks
*/
for (i = 1; i < VL_MAX_ADDREXTBLKS; i++) {
- if (!ex_addr[0]->ex_contaddrs[i])
+ if (!rd_ex_addr[0]->ex_contaddrs[i])
continue;
/* Before reading it in, check to see if the address is good */
- if ((ntohl(ex_addr[0]->ex_contaddrs[i]) <
- ntohl(ex_addr[0]->ex_contaddrs[i - 1]) + VL_ADDREXTBLK_SIZE)
- || (ntohl(ex_addr[0]->ex_contaddrs[i]) >
- ntohl(cheader.vital_header.eofPtr) - VL_ADDREXTBLK_SIZE)) {
+ if ((ntohl(rd_ex_addr[0]->ex_contaddrs[i]) <
+ ntohl(rd_ex_addr[0]->ex_contaddrs[i - 1]) + VL_ADDREXTBLK_SIZE)
+ || (ntohl(rd_ex_addr[0]->ex_contaddrs[i]) >
+ ntohl(rd_cheader.vital_header.eofPtr) - VL_ADDREXTBLK_SIZE)) {
extent_mod = 1;
- ex_addr[0]->ex_contaddrs[i] = 0;
+ rd_ex_addr[0]->ex_contaddrs[i] = 0;
continue;
}
/* Read the continuation block */
- if (!ex_addr[i]) {
- ex_addr[i] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
- if (!ex_addr[i])
+ if (!rd_ex_addr[i]) {
+ rd_ex_addr[i] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
+ if (!rd_ex_addr[i])
ERROR_EXIT(VL_NOMEM);
}
code =
- vlread(trans, ntohl(ex_addr[0]->ex_contaddrs[i]),
- (char *)ex_addr[i], VL_ADDREXTBLK_SIZE);
+ vlread(trans, ntohl(rd_ex_addr[0]->ex_contaddrs[i]),
+ (char *)rd_ex_addr[i], VL_ADDREXTBLK_SIZE);
if (code) {
- free(ex_addr[i]); /* Not the place to create it */
- ex_addr[i] = 0;
+ free(rd_ex_addr[i]); /* Not the place to create it */
+ rd_ex_addr[i] = 0;
ERROR_EXIT(VL_IO);
}
/* After reading it in, check to see if its a real continuation block */
- if (ntohl(ex_addr[i]->ex_flags) != VLCONTBLOCK) {
+ if (ntohl(rd_ex_addr[i]->ex_flags) != VLCONTBLOCK) {
extent_mod = 1;
- ex_addr[0]->ex_contaddrs[i] = 0;
- free(ex_addr[i]); /* Not the place to create it */
- ex_addr[i] = 0;
+ rd_ex_addr[0]->ex_contaddrs[i] = 0;
+ free(rd_ex_addr[i]); /* Not the place to create it */
+ rd_ex_addr[i] = 0;
continue;
}
}
if (extent_mod) {
- code = vlwrite(trans, extentAddr, ex_addr[0], VL_ADDREXTBLK_SIZE);
+ code = vlwrite(trans, extentAddr, rd_ex_addr[0], VL_ADDREXTBLK_SIZE);
if (!code) {
VLog(0, ("Multihome server support modification\n"));
}
int *builddb_rock = rock;
int builddb = *builddb_rock;
afs_int32 error = 0, i, code, ubcode;
+ extern afs_uint32 rd_HostAddress[];
/* if version changed (or first call), read the header */
- ubcode = vlread(trans, 0, (char *)&cheader, sizeof(cheader));
- vldbversion = ntohl(cheader.vital_header.vldbversion);
+ ubcode = vlread(trans, 0, (char *)&rd_cheader, sizeof(rd_cheader));
+ vldbversion = ntohl(rd_cheader.vital_header.vldbversion);
if (!ubcode && (vldbversion != 0)) {
- memcpy(HostAddress, cheader.IpMappedAddr, sizeof(cheader.IpMappedAddr));
+ memcpy(rd_HostAddress, rd_cheader.IpMappedAddr, sizeof(rd_cheader.IpMappedAddr));
for (i = 0; i < MAXSERVERID + 1; i++) { /* cvt HostAddress to host order */
- HostAddress[i] = ntohl(HostAddress[i]);
+ rd_HostAddress[i] = ntohl(rd_HostAddress[i]);
}
code = readExtents(trans);
VLog(0, ("Can't read VLDB header, re-initialising...\n"));
/* try to write a good header */
- memset(&cheader, 0, sizeof(cheader));
- cheader.vital_header.vldbversion = htonl(VLDBVERSION);
- cheader.vital_header.headersize = htonl(sizeof(cheader));
+ memset(&rd_cheader, 0, sizeof(rd_cheader));
+ rd_cheader.vital_header.vldbversion = htonl(VLDBVERSION);
+ rd_cheader.vital_header.headersize = htonl(sizeof(rd_cheader));
/* DANGER: Must get this from a master place!! */
- cheader.vital_header.MaxVolumeId = htonl(0x20000000);
- cheader.vital_header.eofPtr = htonl(sizeof(cheader));
+ rd_cheader.vital_header.MaxVolumeId = htonl(0x20000000);
+ rd_cheader.vital_header.eofPtr = htonl(sizeof(rd_cheader));
for (i = 0; i < MAXSERVERID + 1; i++) {
- cheader.IpMappedAddr[i] = 0;
- HostAddress[i] = 0;
+ rd_cheader.IpMappedAddr[i] = 0;
+ rd_HostAddress[i] = 0;
}
- code = vlwrite(trans, 0, (char *)&cheader, sizeof(cheader));
+ code = vlwrite(trans, 0, (char *)&rd_cheader, sizeof(rd_cheader));
if (code) {
VLog(0, ("Can't write VLDB header (error = %d)\n", code));
ERROR_EXIT(VL_IO);
}
- vldbversion = ntohl(cheader.vital_header.vldbversion);
+ vldbversion = ntohl(rd_cheader.vital_header.vldbversion);
} else {
ERROR_EXIT(VL_EMPTY);
}
afs_int32 blockindex, code, error = 0;
/* Base 0 must exist before any other can be created */
- if ((base != 0) && !ex_addr[0])
+ if ((base != 0) && !ctx->ex_addr[0])
ERROR_EXIT(VL_CREATEFAIL); /* internal error */
- if (!ex_addr[0] || !ex_addr[0]->ex_contaddrs[base]) {
+ if (!ctx->ex_addr[0] || !ctx->ex_addr[0]->ex_contaddrs[base]) {
/* Create a new extension block */
- if (!ex_addr[base]) {
- ex_addr[base] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
- if (!ex_addr[base])
+ if (!ctx->ex_addr[base]) {
+ ctx->ex_addr[base] = (struct extentaddr *)malloc(VL_ADDREXTBLK_SIZE);
+ if (!ctx->ex_addr[base])
ERROR_EXIT(VL_NOMEM);
}
- memset(ex_addr[base], 0, VL_ADDREXTBLK_SIZE);
+ memset(ctx->ex_addr[base], 0, VL_ADDREXTBLK_SIZE);
/* Write the full extension block at end of vldb */
- ex_addr[base]->ex_flags = htonl(VLCONTBLOCK);
- blockindex = ntohl(cheader.vital_header.eofPtr);
+ ctx->ex_addr[base]->ex_flags = htonl(VLCONTBLOCK);
+ blockindex = ntohl(ctx->cheader->vital_header.eofPtr);
code =
- vlwrite(ctx->trans, blockindex, (char *)ex_addr[base],
+ vlwrite(ctx->trans, blockindex, (char *)ctx->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);
+ ctx->cheader->vital_header.eofPtr = blockindex + VL_ADDREXTBLK_SIZE;
+ ctx->cheader->vital_header.eofPtr = htonl(ctx->cheader->vital_header.eofPtr);
code = write_vital_vlheader(ctx);
if (code)
ERROR_EXIT(VL_IO);
/* Write the address of the base extension block in the vldb header */
if (base == 0) {
- cheader.SIT = htonl(blockindex);
+ ctx->cheader->SIT = htonl(blockindex);
code =
- vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.SIT),
- (char *)&cheader.SIT, sizeof(cheader.SIT));
+ vlwrite(ctx->trans, DOFFSET(0, ctx->cheader, &ctx->cheader->SIT),
+ (char *)&ctx->cheader->SIT, sizeof(ctx->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);
+ ctx->ex_addr[0]->ex_contaddrs[base] = htonl(blockindex);
code =
- vlwrite(ctx->trans, ntohl(cheader.SIT), ex_addr[0],
+ vlwrite(ctx->trans, ntohl(ctx->cheader->SIT), ctx->ex_addr[0],
sizeof(struct extentaddr));
if (code)
ERROR_EXIT(VL_IO);
*basep = 0;
/* Create the first extension block if it does not exist */
- if (!cheader.SIT) {
+ if (!ctx->cheader->SIT) {
code = GetExtentBlock(ctx, 0);
if (code)
ERROR_EXIT(code);
}
for (i = 0; i < MAXSERVERID + 1; i++) {
- if ((HostAddress[i] & 0xff000000) == 0xff000000) {
- if ((base = (HostAddress[i] >> 16) & 0xff) > VL_MAX_ADDREXTBLKS) {
+ if ((ctx->hostaddress[i] & 0xff000000) == 0xff000000) {
+ if ((base = (ctx->hostaddress[i] >> 16) & 0xff) > VL_MAX_ADDREXTBLKS) {
ERROR_EXIT(VL_INDEXERANGE);
}
- if ((index = HostAddress[i] & 0x0000ffff) > VL_MHSRV_PERBLK) {
+ if ((index = ctx->hostaddress[i] & 0x0000ffff) > VL_MHSRV_PERBLK) {
ERROR_EXIT(VL_INDEXERANGE);
}
- exp = &ex_addr[base][index];
+ exp = &ctx->ex_addr[base][index];
tuuid = exp->ex_hostuuid;
afs_ntohuuid(&tuuid);
if (afs_uuid_equal(uuidp, &tuuid)) {
if (createit) {
if (hostslot == -1) {
for (i = 0; i < MAXSERVERID + 1; i++) {
- if (!HostAddress[i])
+ if (!ctx->hostaddress[i])
break;
}
if (i > MAXSERVERID)
}
for (base = 0; base < VL_MAX_ADDREXTBLKS; base++) {
- if (!ex_addr[0]->ex_contaddrs[base]) {
+ if (!ctx->ex_addr[0]->ex_contaddrs[base]) {
code = GetExtentBlock(ctx, base);
if (code)
ERROR_EXIT(code);
}
for (j = 1; j < VL_MHSRV_PERBLK; j++) {
- exp = &ex_addr[base][j];
+ exp = &ctx->ex_addr[base][j];
tuuid = exp->ex_hostuuid;
afs_ntohuuid(&tuuid);
if (afs_uuid_is_nil(&tuuid)) {
exp->ex_hostuuid = tuuid;
code =
vlwrite(ctx->trans,
- DOFFSET(ntohl(ex_addr[0]->ex_contaddrs[base]),
- (char *)ex_addr[base], (char *)exp),
+ DOFFSET(ntohl(ctx->ex_addr[0]->ex_contaddrs[base]),
+ (char *)ctx->ex_addr[base], (char *)exp),
(char *)&tuuid, sizeof(tuuid));
if (code)
ERROR_EXIT(VL_IO);
- HostAddress[i] =
+ ctx->hostaddress[i] =
0xff000000 | ((base << 16) & 0xff0000) | (j & 0xffff);
*expp = exp;
*basep = base;
if (vldbversion != VLDBVERSION_4) {
- cheader.vital_header.vldbversion =
+ ctx->cheader->vital_header.vldbversion =
htonl(VLDBVERSION_4);
code = write_vital_vlheader(ctx);
if (code)
ERROR_EXIT(VL_IO);
}
- cheader.IpMappedAddr[i] = htonl(HostAddress[i]);
+ ctx->cheader->IpMappedAddr[i] = htonl(ctx->hostaddress[i]);
code =
vlwrite(ctx->trans,
- DOFFSET(0, &cheader,
- &cheader.IpMappedAddr[i]),
- (char *)&cheader.IpMappedAddr[i],
+ DOFFSET(0, ctx->cheader,
+ &ctx->cheader->IpMappedAddr[i]),
+ (char *)&ctx->cheader->IpMappedAddr[i],
sizeof(afs_int32));
if (code)
ERROR_EXIT(VL_IO);
{
afs_int32 blockindex;
- if (cheader.vital_header.freePtr) {
+ if (ctx->cheader->vital_header.freePtr) {
/* allocate this dude */
- blockindex = ntohl(cheader.vital_header.freePtr);
+ blockindex = ntohl(ctx->cheader->vital_header.freePtr);
if (vlentryread(ctx->trans, blockindex, (char *)tentry, sizeof(vlentry)))
return 0;
- cheader.vital_header.freePtr = htonl(tentry->nextIdHash[0]);
+ ctx->cheader->vital_header.freePtr = htonl(tentry->nextIdHash[0]);
} else {
/* hosed, nothing on free list, grow file */
- blockindex = ntohl(cheader.vital_header.eofPtr); /* remember this guy */
- cheader.vital_header.eofPtr = htonl(blockindex + sizeof(vlentry));
+ blockindex = ntohl(ctx->cheader->vital_header.eofPtr); /* remember this guy */
+ ctx->cheader->vital_header.eofPtr = htonl(blockindex + sizeof(vlentry));
}
- cheader.vital_header.allocs++;
+ ctx->cheader->vital_header.allocs++;
if (write_vital_vlheader(ctx))
return 0;
memset(tentry, 0, sizeof(nvlentry)); /* zero new entry */
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.nextIdHash[0] = ctx->cheader->vital_header.freePtr; /* already in network order */
tentry.flags = htonl(VLFREE);
- cheader.vital_header.freePtr = htonl(blockindex);
+ ctx->cheader->vital_header.freePtr = htonl(blockindex);
if (vlwrite(ctx->trans, blockindex, (char *)&tentry, sizeof(nvlentry)))
return VL_IO;
- cheader.vital_header.frees++;
+ ctx->cheader->vital_header.frees++;
if (write_vital_vlheader(ctx))
return VL_IO;
return 0;
if (voltype == -1) {
/* Should we have one big hash table for volids as opposed to the three ones? */
for (typeindex = 0; typeindex < MAXTYPES; typeindex++) {
- for (blockindex = ntohl(cheader.VolidHash[typeindex][hashindex]);
+ for (blockindex = ntohl(ctx->cheader->VolidHash[typeindex][hashindex]);
blockindex != NULLO;
blockindex = tentry->nextIdHash[typeindex]) {
if (vlentryread
}
}
} else {
- for (blockindex = ntohl(cheader.VolidHash[voltype][hashindex]);
+ for (blockindex = ntohl(ctx->cheader->VolidHash[voltype][hashindex]);
blockindex != NULLO; blockindex = tentry->nextIdHash[voltype]) {
if (vlentryread
(ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) {
*error = 0;
hashindex = NameHash(tname);
- for (blockindex = ntohl(cheader.VolnameHash[hashindex]);
+ for (blockindex = ntohl(ctx->cheader->VolnameHash[hashindex]);
blockindex != NULLO; blockindex = tentry->nextNameHash) {
if (vlentryread(ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) {
*error = VL_IO;
int blockindex;
struct nvlentry tentry;
- for (blockindex = ntohl(cheader.VolnameHash[hashindex]);
+ for (blockindex = ntohl(ctx->cheader->VolnameHash[hashindex]);
blockindex != NULLO; blockindex = tentry.nextNameHash) {
if (vlentryread(ctx->trans, blockindex, (char *)&tentry, sizeof(nvlentry)))
return 0;
int blockindex;
struct nvlentry tentry;
- for (blockindex = ntohl(cheader.VolidHash[0][hashindex]);
+ for (blockindex = ntohl(ctx->cheader->VolidHash[0][hashindex]);
blockindex != NULLO; blockindex = tentry.nextIdHash[0]) {
if (vlentryread(ctx->trans, blockindex, (char *)&tentry, sizeof(nvlentry)))
return 0;
return errorcode;
hashindex = IDHash(tentry->volumeId[voltype]);
tentry->nextIdHash[voltype] =
- ntohl(cheader.VolidHash[voltype][hashindex]);
- cheader.VolidHash[voltype][hashindex] = htonl(blockindex);
+ ntohl(ctx->cheader->VolidHash[voltype][hashindex]);
+ ctx->cheader->VolidHash[voltype][hashindex] = htonl(blockindex);
if (vlwrite
- (ctx->trans, DOFFSET(0, &cheader, &cheader.VolidHash[voltype][hashindex]),
- (char *)&cheader.VolidHash[voltype][hashindex], sizeof(afs_int32)))
+ (ctx->trans, DOFFSET(0, ctx->cheader, &ctx->cheader->VolidHash[voltype][hashindex]),
+ (char *)&ctx->cheader->VolidHash[voltype][hashindex], sizeof(afs_int32)))
return VL_IO;
return 0;
}
return 0;
/* Take it out of the VolId[voltype] hash list */
hashindex = IDHash(aentry->volumeId[voltype]);
- nextblockindex = ntohl(cheader.VolidHash[voltype][hashindex]);
+ nextblockindex = ntohl(ctx->cheader->VolidHash[voltype][hashindex]);
if (nextblockindex == blockindex) {
/* First on the hash list; just adjust pointers */
- cheader.VolidHash[voltype][hashindex] =
+ ctx->cheader->VolidHash[voltype][hashindex] =
htonl(aentry->nextIdHash[voltype]);
code =
vlwrite(ctx->trans,
- DOFFSET(0, &cheader,
- &cheader.VolidHash[voltype][hashindex]),
- (char *)&cheader.VolidHash[voltype][hashindex],
+ DOFFSET(0, ctx->cheader,
+ &ctx->cheader->VolidHash[voltype][hashindex]),
+ (char *)&ctx->cheader->VolidHash[voltype][hashindex],
sizeof(afs_int32));
if (code)
return VL_IO;
/* Insert into volname's hash linked list */
hashindex = NameHash(aentry->name);
- aentry->nextNameHash = ntohl(cheader.VolnameHash[hashindex]);
- cheader.VolnameHash[hashindex] = htonl(blockindex);
+ aentry->nextNameHash = ntohl(ctx->cheader->VolnameHash[hashindex]);
+ ctx->cheader->VolnameHash[hashindex] = htonl(blockindex);
code =
- vlwrite(ctx->trans, DOFFSET(0, &cheader, &cheader.VolnameHash[hashindex]),
- (char *)&cheader.VolnameHash[hashindex], sizeof(afs_int32));
+ vlwrite(ctx->trans, DOFFSET(0, ctx->cheader, &ctx->cheader->VolnameHash[hashindex]),
+ (char *)&ctx->cheader->VolnameHash[hashindex], sizeof(afs_int32));
if (code)
return VL_IO;
return 0;
/* Take it out of the Volname hash list */
hashindex = NameHash(aentry->name);
- nextblockindex = ntohl(cheader.VolnameHash[hashindex]);
+ nextblockindex = ntohl(ctx->cheader->VolnameHash[hashindex]);
if (nextblockindex == blockindex) {
/* First on the hash list; just adjust pointers */
- cheader.VolnameHash[hashindex] = htonl(aentry->nextNameHash);
+ ctx->cheader->VolnameHash[hashindex] = htonl(aentry->nextNameHash);
if (vlwrite
- (ctx->trans, DOFFSET(0, &cheader, &cheader.VolnameHash[hashindex]),
- (char *)&cheader.VolnameHash[hashindex], sizeof(afs_int32)))
+ (ctx->trans, DOFFSET(0, ctx->cheader, &ctx->cheader->VolnameHash[hashindex]),
+ (char *)&ctx->cheader->VolnameHash[hashindex], sizeof(afs_int32)))
return VL_IO;
} else {
while (nextblockindex != blockindex) {
afs_int32 lastblockindex;
if (blockindex == 0) /* get first one */
- blockindex = sizeof(cheader);
+ blockindex = sizeof(*ctx->cheader);
else {
if (!index_OK(ctx, blockindex)) {
*remaining = -1; /* error */
blockindex += sizeof(nvlentry);
}
/* now search for the first entry that isn't free */
- for (lastblockindex = ntohl(cheader.vital_header.eofPtr);
+ for (lastblockindex = ntohl(ctx->cheader->vital_header.eofPtr);
blockindex < lastblockindex;) {
if (vlentryread(ctx->trans, blockindex, (char *)tentry, sizeof(nvlentry))) {
*remaining = -1;
static int
index_OK(struct vl_ctx *ctx, afs_int32 blockindex)
{
- if ((blockindex < sizeof(cheader))
- || (blockindex >= ntohl(cheader.vital_header.eofPtr)))
+ if ((blockindex < sizeof(*ctx->cheader))
+ || (blockindex >= ntohl(ctx->cheader->vital_header.eofPtr)))
return 0;
return 1;
}
+
+int
+vlsetcache(struct vl_ctx *ctx, int locktype)
+{
+ extern afs_uint32 rd_HostAddress[];
+
+ ctx->hostaddress = rd_HostAddress;
+ ctx->ex_addr = rd_ex_addr;
+ ctx->cheader = &rd_cheader;
+ return 0;
+}