{ if (verbose) { fprintf(STDOUT, (es), (p1), (p2)); fflush(STDOUT); } }
#define VPRINT3(es, p1, p2, p3) \
{ if (verbose) { fprintf(STDOUT, (es), (p1), (p2), (p3)); fflush(STDOUT); } }
+#define VPRINT4(es, p1, p2, p3, p4) \
+ { if (verbose) { fprintf(STDOUT, (es), (p1), (p2), (p3), (p4)); fflush(STDOUT); } }
#define VDONE \
{ if (verbose) { fprintf(STDOUT, " done\n"); fflush(STDOUT); } }
#define VEPRINT(es) \
#endif
static int DelVol(struct rx_connection *conn, afs_uint32 vid, afs_int32 part,
afs_int32 flags);
-static int GetTrans(struct nvldbentry *vldbEntryPtr, afs_int32 index,
+static int GetTrans(struct uvldbentry *vldbEntryPtr, afs_int32 index,
struct rx_connection **connPtr, afs_int32 * transPtr,
afs_uint32 * crtimePtr, afs_uint32 * uptimePtr,
afs_int32 *origflags);
void *cookie, manyResults * results);
static afs_int32 CheckVolume(volintInfo * volumeinfo, afs_uint32 aserver,
afs_int32 apart, afs_int32 * modentry,
- afs_uint32 * maxvolid, struct nvldbentry *aentry);
-
+ afs_uint32 * maxvolid, struct uvldbentry *aentry);
+static void dump_sig_handler(int x);
+static int sortVolumes(const void *a, const void *b);
+static afs_int32 CheckVldbRWBK(struct uvldbentry *entry,
+ afs_int32 * modified);
+static int CheckVldbRO(struct uvldbentry *entry, afs_int32 * modified);
+static afs_int32 CheckVldb(struct uvldbentry *entry, afs_int32 * modified,
+ afs_int32 *deleted);
+static afs_int32 VolumeExists(afs_uint32 server, afs_int32 partition,
+ afs_uint32 volumeid);
/*map the partition <partId> into partition name <partName>*/
void
return 0;
}
-void init_volintInfo(struct volintInfo *vinfo) {
+void
+init_volintInfo(struct volintInfo *vinfo) {
memset(vinfo, 0, sizeof(struct volintInfo));
vinfo->maxquota = -1;
#endif
-/* called by EmuerateEntry, show vldb entry in a reasonable format */
+/* called by EnumerateEntryU, show vldb entry in a reasonable format */
+void
+SubEnumerateEntryU(struct uvldbentry *entry)
+{
+ int i;
+ char pname[10];
+ int isMixed = 0;
+ char hoststr[16];
+
+#ifdef notdef
+ fprintf(STDOUT, " readWriteID %-10u ", entry->volumeId[RWVOL]);
+ if (entry->flags & RW_EXISTS)
+ fprintf(STDOUT, " valid \n");
+ else
+ fprintf(STDOUT, " invalid \n");
+ fprintf(STDOUT, " readOnlyID %-10u ", entry->volumeId[ROVOL]);
+ if (entry->flags & RO_EXISTS)
+ fprintf(STDOUT, " valid \n");
+ else
+ fprintf(STDOUT, " invalid \n");
+ fprintf(STDOUT, " backUpID %-10u ", entry->volumeId[BACKVOL]);
+ if (entry->flags & BACK_EXISTS)
+ fprintf(STDOUT, " valid \n");
+ else
+ fprintf(STDOUT, " invalid \n");
+ if ((entry->cloneId != 0) && (entry->flags & RO_EXISTS))
+ fprintf(STDOUT, " releaseClone %-10u \n", entry->cloneId);
+#else
+ if (entry->flags & RW_EXISTS)
+ fprintf(STDOUT, " RWrite: %-10u", entry->volumeId[RWVOL]);
+ if (entry->flags & RO_EXISTS)
+ fprintf(STDOUT, " ROnly: %-10u", entry->volumeId[ROVOL]);
+ if (entry->flags & BACK_EXISTS)
+ fprintf(STDOUT, " Backup: %-10u", entry->volumeId[BACKVOL]);
+ if ((entry->cloneId != 0) && (entry->flags & RO_EXISTS))
+ fprintf(STDOUT, " RClone: %-10lu", (unsigned long)entry->cloneId);
+ fprintf(STDOUT, "\n");
+#endif
+ fprintf(STDOUT, " number of sites -> %lu\n",
+ (unsigned long)entry->nServers);
+ for (i = 0; i < entry->nServers; i++) {
+ if (entry->serverFlags[i] & NEW_REPSITE)
+ isMixed = 1;
+ }
+ for (i = 0; i < entry->nServers; i++) {
+ MapPartIdIntoName(entry->serverPartition[i], pname);
+ fprintf(STDOUT, " server %s partition %s ",
+ noresolve ? afs_inet_ntoa_r(entry->serverUnique[i], hoststr) :
+ hostutil_GetNameByINet(entry->serverUnique[i]), pname);
+ if (entry->serverFlags[i] & ITSRWVOL)
+ fprintf(STDOUT, "RW Site ");
+ else
+ fprintf(STDOUT, "RO Site ");
+ if (isMixed) {
+ if (entry->serverFlags[i] & NEW_REPSITE)
+ fprintf(STDOUT," -- New release");
+ else
+ if (!(entry->serverFlags[i] & ITSRWVOL))
+ fprintf(STDOUT," -- Old release");
+ } else {
+ if (entry->serverFlags[i] & RO_DONTUSE)
+ fprintf(STDOUT, " -- Not released");
+ }
+ fprintf(STDOUT, "\n");
+ }
+
+ return;
+
+}
+
+/*enumerate the vldb entry corresponding to <entry> */
+void
+EnumerateEntryU(struct uvldbentry *entry)
+{
+
+ fprintf(STDOUT, "\n");
+ fprintf(STDOUT, "%s \n", entry->name);
+ SubEnumerateEntryU(entry);
+ return;
+}
+
+/* called by EnumerateEntry, show vldb entry in a reasonable format */
void
SubEnumerateEntry(struct nvldbentry *entry)
{
afs_int32 error;
afs_int32 rcode, vcode;
afs_int32 lastid;
- struct nvldbentry entry, storeEntry; /*the new vldb entry */
+ struct uvldbentry entry, storeEntry; /*the new vldb entry */
struct volintInfo tstatus;
tid = 0;
}
if (*anewid) {
- vcode = VLDB_GetEntryByID(*anewid, -1, &entry);
+ vcode = VLDB_GetEntryByIDU(*anewid, -1, &entry);
if (!vcode) {
fprintf(STDERR, "Volume ID %d already exists\n", *anewid);
return VVOLEXISTS;
/* set up the vldb entry for this volume */
strncpy(entry.name, aname, VOLSER_OLDMAXVOLNAME);
entry.nServers = 1;
- entry.serverNumber[0] = aserver; /* this should have another
+ entry.serverUnique[0] = aserver; /* this should have another
* level of indirection later */
entry.serverPartition[0] = apart; /* this should also have
* another indirection level */
entry.cloneId = 0;
/*map into right byte order, before passing to xdr, the stuff has to be in host
* byte order. Xdr converts it into network order */
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
/* create the vldb entry */
- vcode = VLDB_CreateEntry(&storeEntry);
+ vcode = VLDB_CreateEntryU(&storeEntry);
if (vcode) {
fprintf(STDERR,
"Could not create a VLDB entry for the volume %s %lu\n",
struct rx_connection *aconn;
afs_int32 error;
afs_int32 vcode;
- struct nvldbentry entry, storeEntry; /*the new vldb entry */
+ struct uvldbentry entry, storeEntry; /*the new vldb entry */
aconn = (struct rx_connection *)0;
error = 0;
/* set up the vldb entry for this volume */
strncpy(entry.name, aname, VOLSER_OLDMAXVOLNAME);
entry.nServers = 1;
- entry.serverNumber[0] = aserver; /* this should have another
+ entry.serverUnique[0] = aserver; /* this should have another
* level of indirection later */
entry.serverPartition[0] = apart; /* this should also have
* another indirection level */
entry.cloneId = 0;
/*map into right byte order, before passing to xdr, the stuff has to be in host
* byte order. Xdr converts it into network order */
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
/* create the vldb entry */
- vcode = VLDB_CreateEntry(&storeEntry);
+ vcode = VLDB_CreateEntryU(&storeEntry);
if (vcode) {
fprintf(STDERR,
"Could not create a VLDB entry for the volume %s %lu\n",
afs_int32 ttid = 0;
afs_int32 code, rcode;
afs_int32 error = 0;
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
int islocked = 0;
afs_int32 avoltype = -1, vtype;
int notondisk = 0, notinvldb = 0;
} else {
islocked = 1;
- code = VLDB_GetEntryByID(avolid, avoltype, &entry);
+ code = VLDB_GetEntryByIDU(avolid, avoltype, &entry);
EGOTO1(error_exit, code, "Could not fetch VLDB entry for volume %u\n",
avolid);
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
if (verbose)
- EnumerateEntry(&entry);
+ EnumerateEntryU(&entry);
}
/* Whether volume is in the VLDB or not. Delete the volume on disk */
/* Its a backup volume, modify the VLDB entry. Check that the
* backup volume is on the server/partition we asked to delete.
*/
- if (!(entry.flags & BACK_EXISTS) || !Lp_Match(aserver, apart, &entry)) {
+ if (!(entry.flags & BACK_EXISTS) || !Lp_MatchU(aserver, apart, &entry)) {
notinvldb = 2; /* Not on this server and partition */
ERROR_EXIT(0);
}
* If flags does not have RO_EIXSTS set, then this may mean the RO
* hasn't been released (and could exist in VLDB).
*/
- if (!Lp_ROMatch(aserver, apart, &entry)) {
+ if (!Lp_ROMatchU(aserver, apart, &entry)) {
notinvldb = 2; /* Not found on this server and partition */
ERROR_EXIT(0);
}
"Marking the readonly volume %lu deleted in the VLDB\n",
(unsigned long)avolid);
- Lp_SetROValue(&entry, aserver, apart, 0, 0); /* delete the site */
+ Lp_SetROValueU(&entry, aserver, apart, 0, 0); /* delete the site */
entry.nServers--;
- if (!Lp_ROMatch(0, 0, &entry))
+ if (!Lp_ROMatchU(0, 0, &entry))
entry.flags &= ~RO_EXISTS; /* This was the last ro volume */
vtype = ROVOL;
}
* Check that the readwrite volumes is on the server/partition we
* asked to delete.
*/
- if (!(entry.flags & RW_EXISTS) || !Lp_Match(aserver, apart, &entry)) {
+ if (!(entry.flags & RW_EXISTS) || !Lp_MatchU(aserver, apart, &entry)) {
notinvldb = 2; /* Not found on this server and partition */
ERROR_EXIT(0);
}
flags & BACK_EXISTS) ? ", and its backup volume," :
""));
- Lp_SetRWValue(&entry, aserver, apart, 0L, 0L);
+ Lp_SetRWValueU(&entry, aserver, apart, 0L, 0L);
entry.nServers--;
entry.flags &= ~(BACK_EXISTS | RW_EXISTS);
vtype = RWVOL;
"Could not delete the VLDB entry for the volume %u \n",
avolid);
} else {
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
code =
- VLDB_ReplaceEntry(avolid, vtype, &storeEntry,
+ VLDB_ReplaceEntryU(avolid, vtype, &storeEntry,
(LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP));
EGOTO1(error_exit, code,
struct volser_status tstatus;
struct destServer destination;
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
int i;
afs_int32 error;
char in, lf; /* for test code */
/* or drop through */
}
- vcode = VLDB_GetEntryByID(afromvol, -1, &entry);
+ vcode = VLDB_GetEntryByIDU(afromvol, -1, &entry);
EGOTO1(mfail, vcode,
"Could not fetch the entry for the volume %u from the VLDB \n",
afromvol);
EGOTO1(mfail, vcode, "Could not lock entry for volume %u \n", afromvol);
islocked = 1;
- vcode = VLDB_GetEntryByID(afromvol, RWVOL, &entry);
+ vcode = VLDB_GetEntryByIDU(afromvol, RWVOL, &entry);
EGOTO1(mfail, vcode,
"Could not fetch the entry for the volume %u from the VLDB \n",
afromvol);
backupId = entry.volumeId[BACKVOL];
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
- if (!Lp_Match(afromserver, afrompart, &entry)) {
+ if (!Lp_MatchU(afromserver, afrompart, &entry)) {
/* the from server and partition do not exist in the vldb entry corresponding to volid */
- if (!Lp_Match(atoserver, atopart, &entry)) {
+ if (!Lp_MatchU(atoserver, atopart, &entry)) {
/* the to server and partition do not exist in the vldb entry corresponding to volid */
fprintf(STDERR, "The volume %lu is not on the specified site. \n",
(unsigned long)afromvol);
char pname[10];
MapPartIdIntoName(entry.serverPartition[i], pname);
fprintf(STDERR, " server %s partition %s \n",
- noresolve ? afs_inet_ntoa_r(entry.serverNumber[i], hoststr) :
- hostutil_GetNameByINet(entry.serverNumber[i]),
+ noresolve ? afs_inet_ntoa_r(entry.serverUnique[i], hoststr) :
+ hostutil_GetNameByINet(entry.serverUnique[i]),
pname);
}
}
afromvol);
VDONE;
- Lp_SetRWValue(&entry, afromserver, afrompart, atoserver, atopart);
- MapNetworkToHost(&entry, &storeEntry);
+ Lp_SetRWValueU(&entry, afromserver, afrompart, atoserver, atopart);
+ MapNetworkToHostU(&entry, &storeEntry);
storeEntry.flags &= ~BACK_EXISTS;
if (TESTC) {
VPRINT1("Releasing lock on VLDB entry for volume %u ...", afromvol);
vcode =
- VLDB_ReplaceEntry(afromvol, -1, &storeEntry,
+ VLDB_ReplaceEntryU(afromvol, -1, &storeEntry,
(LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP));
if (vcode) {
}
VPRINT("Recovery: Accessing VLDB.\n");
- vcode = VLDB_GetEntryByID(afromvol, -1, &entry);
+ vcode = VLDB_GetEntryByIDU(afromvol, -1, &entry);
if (vcode) {
fprintf(STDOUT, "FATAL: VLDB access error: abort cleanup\n");
fflush(STDOUT);
goto done;
}
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
/* Delete either the volume on the source location or the target location.
* If the vldb entry still points to the source location, then we know the
* volume move didn't finish so we remove the volume from the target
* location. Otherwise, we remove the volume from the source location.
*/
- if (Lp_Match(afromserver, afrompart, &entry)) { /* didn't move - delete target volume */
+ if (Lp_MatchU(afromserver, afrompart, &entry)) { /* didn't move - delete target volume */
if (pntg) {
fprintf(STDOUT,
"move incomplete - attempt cleanup of target partition - no guarantee\n");
afs_int32 volflag;
struct volser_status tstatus;
struct destServer destination;
- struct nvldbentry entry, newentry, storeEntry;
+ struct uvldbentry entry, newentry, storeEntry;
afs_int32 error;
afs_int32 tmp;
afs_uint32 tmpVol;
goto mfail;
(void)signal(SIGINT, sigint_handler);
- vcode = VLDB_GetEntryByID(afromvol, -1, &entry);
+ vcode = VLDB_GetEntryByIDU(afromvol, -1, &entry);
EGOTO1(mfail, vcode,
"Could not fetch the entry for the volume %u from the VLDB \n",
afromvol);
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
pntg = 1;
toconn = UV_Bind(atoserver, AFSCONF_VOLUMEPORT); /* get connections to the servers */
/* create the vldb entry for the copied volume */
strncpy(newentry.name, atovolname, VOLSER_OLDMAXVOLNAME);
newentry.nServers = 1;
- newentry.serverNumber[0] = atoserver;
+ newentry.serverUnique[0] = atoserver;
newentry.serverPartition[0] = atopart;
newentry.flags = (flags & RV_RDONLY) ? RO_EXISTS : RW_EXISTS;
newentry.serverFlags[0] = (flags & RV_RDONLY) ? ITSROVOL : ITSRWVOL;
newentry.cloneId = 0;
/*map into right byte order, before passing to xdr, the stuff has to be in host
* byte order. Xdr converts it into network order */
- MapNetworkToHost(&newentry, &storeEntry);
+ MapNetworkToHostU(&newentry, &storeEntry);
/* create the vldb entry */
- vcode = VLDB_CreateEntry(&storeEntry);
+ vcode = VLDB_CreateEntryU(&storeEntry);
if (vcode) {
fprintf(STDERR,
"Could not create a VLDB entry for the volume %s %lu\n",
}
VPRINT("Recovery: Accessing VLDB.\n");
- vcode = VLDB_GetEntryByID(afromvol, -1, &entry);
+ vcode = VLDB_GetEntryByIDU(afromvol, -1, &entry);
if (vcode) {
fprintf(STDOUT, "FATAL: VLDB access error: abort cleanup\n");
fflush(STDOUT);
goto done;
}
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
/* common cleanup - delete local clone */
if (cloneVol) {
afs_uint32 backupID;
afs_int32 code = 0, rcode = 0;
char vname[VOLSER_MAXVOLNAME + 1];
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
afs_int32 error = 0;
int vldblocked = 0, vldbmod = 0, backexists = 1;
/* the calls to VLDB will succeed only if avolid is a RW volume,
* since we are following the RW hash chain for searching */
- code = VLDB_GetEntryByID(avolid, RWVOL, &entry);
+ code = VLDB_GetEntryByIDU(avolid, RWVOL, &entry);
if (code) {
fprintf(STDERR,
"Could not fetch the entry for the volume %lu from the VLDB \n",
error = code;
goto bfail;
}
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
/* These operations require the VLDB be locked since it means the VLDB
* will change or the vldb is already locked.
vldblocked = 1;
/* Reread the vldb entry */
- code = VLDB_GetEntryByID(avolid, RWVOL, &entry);
+ code = VLDB_GetEntryByIDU(avolid, RWVOL, &entry);
if (code) {
fprintf(STDERR,
"Could not fetch the entry for the volume %lu from the VLDB \n",
error = code;
goto bfail;
}
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
}
if (!ISNAMEVALID(entry.name)) {
/* Now update the vldb - if modified */
if (vldblocked) {
if (vldbmod) {
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
code =
- VLDB_ReplaceEntry(avolid, RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(avolid, RWVOL, &storeEntry,
(LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP));
if (code) {
* be made (0 if it's a new volume)
*/
static int
-GetTrans(struct nvldbentry *vldbEntryPtr, afs_int32 index,
+GetTrans(struct uvldbentry *vldbEntryPtr, afs_int32 index,
struct rx_connection **connPtr, afs_int32 * transPtr,
afs_uint32 * crtimePtr, afs_uint32 * uptimePtr,
afs_int32 *origflags)
*uptimePtr = 0;
/* get connection to the replication site */
- *connPtr = UV_Bind(vldbEntryPtr->serverNumber[index], AFSCONF_VOLUMEPORT);
+ *connPtr = UV_Bind(vldbEntryPtr->serverUnique[index], AFSCONF_VOLUMEPORT);
if (!*connPtr)
goto fail; /* server is down */
VPRINT1("Deleting extant RO_DONTUSE site on %s...",
noresolve ? afs_inet_ntoa_r(vldbEntryPtr->
- serverNumber[index], hoststr) :
+ serverUnique[index], hoststr) :
hostutil_GetNameByINet(vldbEntryPtr->
- serverNumber[index]));
+ serverUnique[index]));
code = AFSVolDeleteVolume(*connPtr, *transPtr);
if (code) {
"Creating new volume %lu on replication site %s: ",
(unsigned long)volid,
noresolve ? afs_inet_ntoa_r(vldbEntryPtr->
- serverNumber[index], hoststr) :
+ serverUnique[index], hoststr) :
hostutil_GetNameByINet(vldbEntryPtr->
- serverNumber[index]));
+ serverUnique[index]));
fflush(STDOUT);
}
else {
VPRINT2("Updating existing ro volume %u on %s ...\n", volid,
noresolve ? afs_inet_ntoa_r(vldbEntryPtr->
- serverNumber[index], hoststr) :
- hostutil_GetNameByINet(vldbEntryPtr->serverNumber[index]));
+ serverUnique[index], hoststr) :
+ hostutil_GetNameByINet(vldbEntryPtr->serverUnique[index]));
code = AFSVolGetStatus(*connPtr, *transPtr, &tstatus);
if (code) {
afs_int32 vcode, rcode, tcode;
afs_uint32 cloneVolId, roVolId;
struct replica *replicas = 0;
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
int i, volcount, m, fullrelease, vldbindex;
int failure;
struct restoreCookie cookie;
islocked = 1;
/* Get the vldb entry in readable format */
- vcode = VLDB_GetEntryByID(afromvol, RWVOL, &entry);
+ vcode = VLDB_GetEntryByIDU(afromvol, RWVOL, &entry);
ONERROR(vcode, afromvol,
"Could not fetch the entry for the volume %u from the VLDB.\n");
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
if (verbose)
- EnumerateEntry(&entry);
+ EnumerateEntryU(&entry);
if (!ISNAMEVALID(entry.name))
ONERROR(VOLSERBADOP, entry.name,
* on the same partition a clone instead of a complete copy.
*/
- roindex = Lp_ROMatch(afromserver, afrompart, &entry) - 1;
+ roindex = Lp_ROMatchU(afromserver, afrompart, &entry) - 1;
roclone = ((roindex == -1) ? 0 : 1);
- rwindex = Lp_GetRwIndex(&entry);
+ rwindex = Lp_GetRwIndexU(&entry);
if (rwindex < 0)
ONERROR0(VOLSERNOVOL, "There is no RW volume \n");
ONERROR(vcode, entry.name, "Cant allocate ID for RO volume of %s\n");
entry.volumeId[ROVOL] = roVolId;
- MapNetworkToHost(&entry, &storeEntry);
- vcode = VLDB_ReplaceEntry(afromvol, RWVOL, &storeEntry, 0);
+ MapNetworkToHostU(&entry, &storeEntry);
+ vcode = VLDB_ReplaceEntryU(afromvol, RWVOL, &storeEntry, 0);
ONERROR(vcode, entry.name, "Could not update vldb entry for %s.\n");
}
* up marking all the ROs as "old release" making the ROs
* temporarily unavailable.
*/
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
VPRINT1("Replacing VLDB entry for %s...", entry.name);
- vcode = VLDB_ReplaceEntry(afromvol, RWVOL, &storeEntry, 0);
+ vcode = VLDB_ReplaceEntryU(afromvol, RWVOL, &storeEntry, 0);
ONERROR(vcode, entry.name,
"Could not update vldb entry for %s.\n");
VDONE;
* volume). Each volume might have a different time.
*/
replicas[volcount].server.destHost =
- ntohl(entry.serverNumber[vldbindex]);
+ ntohl(entry.serverUnique[vldbindex]);
replicas[volcount].server.destPort = AFSCONF_VOLUMEPORT;
replicas[volcount].server.destSSID = 1;
times[volcount].vldbEntryIndex = vldbindex;
if (verbose) {
fprintf(STDOUT, "Starting ForwardMulti from %lu to %u on %s",
(unsigned long)cloneVolId, entry.volumeId[ROVOL],
- noresolve ? afs_inet_ntoa_r(entry.serverNumber[times[0].
+ noresolve ? afs_inet_ntoa_r(entry.serverUnique[times[0].
vldbEntryIndex], hoststr) :
hostutil_GetNameByINet(entry.
- serverNumber[times[0].
+ serverUnique[times[0].
vldbEntryIndex]));
for (s = 1; s < volcount; s++) {
fprintf(STDOUT, " and %s",
- noresolve ? afs_inet_ntoa_r(entry.serverNumber[times[s].
+ noresolve ? afs_inet_ntoa_r(entry.serverUnique[times[s].
vldbEntryIndex], hoststr) :
hostutil_GetNameByINet(entry.
- serverNumber[times[s].
+ serverUnique[times[s].
vldbEntryIndex]));
}
toconns[s] = 0;
}
- MapNetworkToHost(&entry, &storeEntry);
- vcode = VLDB_ReplaceEntry(afromvol, RWVOL, &storeEntry, 0);
+ MapNetworkToHostU(&entry, &storeEntry);
+ vcode = VLDB_ReplaceEntryU(afromvol, RWVOL, &storeEntry, 0);
ONERROR(vcode, afromvol,
" Could not update VLDB entry for volume %u\n");
} /* for each index in the vldb */
if (!(entry.serverFlags[i] & NEW_REPSITE)) {
MapPartIdIntoName(entry.serverPartition[i], pname);
fprintf(STDERR, "\t%35s %s\n",
- noresolve ? afs_inet_ntoa_r(entry.serverNumber[i], hoststr) :
- hostutil_GetNameByINet(entry.serverNumber[i]), pname);
+ noresolve ? afs_inet_ntoa_r(entry.serverUnique[i], hoststr) :
+ hostutil_GetNameByINet(entry.serverUnique[i]), pname);
}
}
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
vcode =
- VLDB_ReplaceEntry(afromvol, RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(afromvol, RWVOL, &storeEntry,
LOCKREL_TIMESTAMP);
ONERROR(vcode, afromvol,
" Could not update VLDB entry for volume %u\n");
/* Update the VLDB */
VPRINT("updating VLDB ...");
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
vcode =
- VLDB_ReplaceEntry(afromvol, RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(afromvol, RWVOL, &storeEntry,
LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
ONERROR(vcode, afromvol, " Could not update VLDB entry for volume %u\n");
VDONE;
}
-void
+static void
dump_sig_handler(int x)
{
fprintf(STDERR, "\nSignal handler: vos dump operation\n");
afs_uint32 pvolid;
afs_int32 temptid, pparentid;
int success;
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
afs_int32 error;
int islocked;
struct restoreCookie cookie;
pparentid = toparentid;
toconn = UV_Bind(toserver, AFSCONF_VOLUMEPORT);
if (pvolid == 0) { /*alot a new id if needed */
- vcode = VLDB_GetEntryByName(tovolname, &entry);
+ vcode = VLDB_GetEntryByNameU(tovolname, &entry);
if (vcode == VL_NOENT) {
vcode = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &pvolid);
if (vcode) {
/* Volume was restored on the file server, update the
* VLDB to reflect the change.
*/
- vcode = VLDB_GetEntryByID(pvolid, voltype, &entry);
+ vcode = VLDB_GetEntryByIDU(pvolid, voltype, &entry);
if (vcode && vcode != VL_NOENT && vcode != VL_ENTDELETED) {
fprintf(STDERR,
"Could not fetch the entry for volume number %lu from VLDB \n",
goto refail;
}
if (!vcode)
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
if (vcode == VL_NOENT) { /* it doesnot exist already */
/*make the vldb return this indication specifically */
VPRINT("------- Creating a new VLDB entry ------- \n");
strcpy(entry.name, tovolname);
entry.nServers = 1;
- entry.serverNumber[0] = toserver; /*should be indirect */
+ entry.serverUnique[0] = toserver; /*should be indirect */
entry.serverPartition[0] = topart;
entry.serverFlags[0] = (flags & RV_RDONLY) ? ITSROVOL : ITSRWVOL;
entry.flags = (flags & RV_RDONLY) ? RO_EXISTS : RW_EXISTS;
/*this should come from status info on the volume if non zero */
} else
entry.volumeId[BACKVOL] = INVALID_BID;
- MapNetworkToHost(&entry, &storeEntry);
- vcode = VLDB_CreateEntry(&storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
+ vcode = VLDB_CreateEntryU(&storeEntry);
if (vcode) {
fprintf(STDERR,
"Could not create the VLDB entry for volume number %lu \n",
}
islocked = 0;
if (verbose)
- EnumerateEntry(&entry);
+ EnumerateEntryU(&entry);
} else { /*update the existing entry */
if (verbose) {
fprintf(STDOUT, "Updating the existing VLDB entry\n");
fprintf(STDOUT, "------- Old entry -------\n");
- EnumerateEntry(&entry);
+ EnumerateEntryU(&entry);
fprintf(STDOUT, "------- New entry -------\n");
}
vcode =
/* Update the vlentry with the new information */
if (flags & RV_RDONLY)
- index = Lp_ROMatch(toserver, topart, &entry) - 1;
+ index = Lp_ROMatchU(toserver, topart, &entry) - 1;
else
- index = Lp_GetRwIndex(&entry);
+ index = Lp_GetRwIndexU(&entry);
if (index == -1) {
/* Add the new site for the volume being restored */
- entry.serverNumber[entry.nServers] = toserver;
+ entry.serverUnique[entry.nServers] = toserver;
entry.serverPartition[entry.nServers] = topart;
entry.serverFlags[entry.nServers] =
(flags & RV_RDONLY) ? ITSROVOL : ITSRWVOL;
* if its different from new site.
*/
same =
- VLDB_IsSameAddrs(toserver, entry.serverNumber[index],
+ VLDB_IsSameAddrs(toserver, entry.serverUnique[index],
&errcode);
if (errcode)
EPRINT2(errcode,
VPRINT2
("Not deleting the previous volume %u on server %s, ...",
pvolid,
- noresolve ? afs_inet_ntoa_r(entry.serverNumber[index], hoststr) :
- hostutil_GetNameByINet(entry.serverNumber[index]));
+ noresolve ? afs_inet_ntoa_r(entry.serverUnique[index], hoststr) :
+ hostutil_GetNameByINet(entry.serverUnique[index]));
} else {
tempconn =
- UV_Bind(entry.serverNumber[index],
+ UV_Bind(entry.serverUnique[index],
AFSCONF_VOLUMEPORT);
MapPartIdIntoName(entry.serverPartition[index],
VPRINT3
("Deleting the previous volume %u on server %s, partition %s ...",
pvolid,
- noresolve ? afs_inet_ntoa_r(entry.serverNumber[index], hoststr) :
- hostutil_GetNameByINet(entry.serverNumber[index]),
+ noresolve ? afs_inet_ntoa_r(entry.serverUnique[index], hoststr) :
+ hostutil_GetNameByINet(entry.serverUnique[index]),
apartName);
code =
AFSVolTransCreate_retry(tempconn, pvolid,
}
}
}
- entry.serverNumber[index] = toserver;
+ entry.serverUnique[index] = toserver;
entry.serverPartition[index] = topart;
}
entry.flags |= (flags & RV_RDONLY) ? RO_EXISTS : RW_EXISTS;
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
vcode =
- VLDB_ReplaceEntry(pvolid, voltype, &storeEntry,
+ VLDB_ReplaceEntryU(pvolid, voltype, &storeEntry,
LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP);
if (vcode) {
}
islocked = 0;
if (verbose)
- EnumerateEntry(&entry);
+ EnumerateEntryU(&entry);
}
afs_uint32 rovolid, afs_int32 valid)
{
int j, nro = 0, islocked = 0;
- struct nvldbentry entry, storeEntry, entry2;
+ struct uvldbentry entry, storeEntry, entry2;
afs_int32 vcode, error = 0;
char apartName[10];
}
islocked = 1;
- error = VLDB_GetEntryByID(volid, RWVOL, &entry);
+ error = VLDB_GetEntryByIDU(volid, RWVOL, &entry);
if (error) {
fprintf(STDERR,
"Could not fetch the VLDB entry for volume number %lu \n",
error = VOLSERBADOP;
goto asfail;
}
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
/* See if it's too many entries */
if (entry.nServers >= NMAXNSERVERS) {
for (j = 0; j < entry.nServers; j++) {
if (entry.serverFlags[j] & ITSROVOL) {
nro++;
- if (VLDB_IsSameAddrs(server, entry.serverNumber[j], &error)) {
+ if (VLDB_IsSameAddrs(server, entry.serverUnique[j], &error)) {
if (error) {
fprintf(STDERR,
"Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
*/
if (rovolid) {
if (entry.volumeId[ROVOL] == INVALID_BID) {
- vcode = VLDB_GetEntryByID(rovolid, -1, &entry2);
+ vcode = VLDB_GetEntryByIDU(rovolid, -1, &entry2);
if (!vcode) {
fprintf(STDERR, "Volume ID %d already exists\n", rovolid);
return VVOLEXISTS;
}
VPRINT("Adding a new site ...");
- entry.serverNumber[entry.nServers] = server;
+ entry.serverUnique[entry.nServers] = server;
entry.serverPartition[entry.nServers] = part;
if (!valid) {
entry.serverFlags[entry.nServers] = (ITSROVOL | RO_DONTUSE);
}
entry.nServers++;
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
error =
- VLDB_ReplaceEntry(volid, RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(volid, RWVOL, &storeEntry,
LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
if (error) {
fprintf(STDERR, "Could not update entry for volume %lu \n",
UV_RemoveSite(afs_uint32 server, afs_int32 part, afs_uint32 volid)
{
afs_int32 vcode;
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
vcode = ubik_VL_SetLock(cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
if (vcode) {
PrintError("", vcode);
return (vcode);
}
- vcode = VLDB_GetEntryByID(volid, RWVOL, &entry);
+ vcode = VLDB_GetEntryByIDU(volid, RWVOL, &entry);
if (vcode) {
fprintf(STDERR,
"Could not fetch the entry for volume number %lu from VLDB \n",
PrintError("", vcode);
return (vcode);
}
- MapHostToNetwork(&entry);
- if (!Lp_ROMatch(server, part, &entry)) {
+ MapHostToNetworkU(&entry);
+ if (!Lp_ROMatchU(server, part, &entry)) {
/*this site doesnot exist */
fprintf(STDERR, "This site is not a replication site \n");
vcode =
}
return VOLSERBADOP;
} else { /*remove the rep site */
- Lp_SetROValue(&entry, server, part, 0, 0);
+ Lp_SetROValueU(&entry, server, part, 0, 0);
entry.nServers--;
if ((entry.nServers == 1) && (entry.flags & RW_EXISTS))
entry.flags &= ~RO_EXISTS;
}
VDONE;
}
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
fprintf(STDOUT, "Deleting the replication site for volume %lu ...",
(unsigned long)volid);
fflush(STDOUT);
vcode =
- VLDB_ReplaceEntry(volid, RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(volid, RWVOL, &storeEntry,
LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP);
if (vcode) {
UV_ChangeLocation(afs_uint32 server, afs_int32 part, afs_uint32 volid)
{
afs_int32 vcode;
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
int index;
vcode = ubik_VL_SetLock(cstruct, 0, volid, RWVOL, VLOP_ADDSITE);
PrintError("", vcode);
return (vcode);
}
- vcode = VLDB_GetEntryByID(volid, RWVOL, &entry);
+ vcode = VLDB_GetEntryByIDU(volid, RWVOL, &entry);
if (vcode) {
fprintf(STDERR,
"Could not fetch the entry for volume number %lu from VLDB \n",
PrintError("", vcode);
return (vcode);
}
- MapHostToNetwork(&entry);
- index = Lp_GetRwIndex(&entry);
+ MapHostToNetworkU(&entry);
+ index = Lp_GetRwIndexU(&entry);
if (index < 0) {
/* no RW site exists */
fprintf(STDERR, "No existing RW site for volume %lu",
}
return VOLSERBADOP;
} else { /* change the RW site */
- entry.serverNumber[index] = server;
+ entry.serverUnique[index] = server;
entry.serverPartition[index] = part;
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
vcode =
- VLDB_ReplaceEntry(volid, RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(volid, RWVOL, &storeEntry,
LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP);
if (vcode) {
static afs_int32
CheckVolume(volintInfo * volumeinfo, afs_uint32 aserver, afs_int32 apart,
afs_int32 * modentry, afs_uint32 * maxvolid,
- struct nvldbentry *aentry)
+ struct uvldbentry *aentry)
{
int idx = 0;
int j;
afs_int32 code, error = 0;
- struct nvldbentry entry, storeEntry;
+ struct uvldbentry entry, storeEntry;
char pname[10];
int pass = 0, createentry, addvolume, modified, mod, doit = 1;
afs_uint32 rwvolid;
memcpy(&entry, aentry, sizeof(entry));
} else {
/* Read the entry from VLDB by its RW volume id */
- code = VLDB_GetEntryByID(rwvolid, RWVOL, &entry);
+ code = VLDB_GetEntryByIDU(rwvolid, RWVOL, &entry);
if (code) {
if (code != VL_NOENT) {
fprintf(STDOUT,
createentry = 1;
} else {
- MapHostToNetwork(&entry);
+ MapHostToNetworkU(&entry);
}
}
} else {
if ((entry.flags & RW_EXISTS) || (entry.flags & RO_EXISTS)
|| (entry.flags & BACK_EXISTS))
- EnumerateEntry(&entry);
+ EnumerateEntryU(&entry);
}
fprintf(STDOUT, "\n");
}
if (mod)
modified++;
- idx = Lp_GetRwIndex(&entry);
+ idx = Lp_GetRwIndexU(&entry);
if (idx == -1) { /* RW index not found in the VLDB entry */
idx = entry.nServers; /* put it into next index */
entry.nServers++;
addvolume++;
} else { /* RW index found in the VLDB entry. */
/* Verify if this volume's location matches where the VLDB says it is */
- if (!Lp_Match(aserver, apart, &entry)) {
+ if (!Lp_MatchU(aserver, apart, &entry)) {
if (entry.flags & RW_EXISTS) {
/* The RW volume exists elsewhere - report this one a duplicate */
if (pass == 1) {
fprintf(STDERR,
" VLDB reports RW volume %lu exists on %s %s\n",
(unsigned long)rwvolid,
- noresolve ?
- afs_inet_ntoa_r(entry.serverNumber[idx], hoststr) :
+ noresolve ?
+ afs_inet_ntoa_r(entry.serverUnique[idx], hoststr) :
hostutil_GetNameByINet(entry.
- serverNumber[idx]),
+ serverUnique[idx]),
pname);
}
} else {
"*** Warning: Orphaned BK volume %u exists on %s %s\n",
entry.volumeId[BACKVOL],
noresolve ?
- afs_inet_ntoa_r(entry.serverNumber[idx], hoststr) :
+ afs_inet_ntoa_r(entry.serverUnique[idx], hoststr) :
hostutil_GetNameByINet(entry.
- serverNumber
+ serverUnique
[idx]), pname);
MapPartIdIntoName(apart, pname);
fprintf(STDERR,
entry.volumeId[ROVOL] = volumeinfo->cloneID;
entry.serverFlags[idx] = ITSRWVOL;
- entry.serverNumber[idx] = aserver;
+ entry.serverUnique[idx] = aserver;
entry.serverPartition[idx] = apart;
strncpy(entry.name, volumeinfo->name, VOLSER_OLDMAXVOLNAME);
if (mod)
modified++;
- idx = Lp_GetRwIndex(&entry);
+ idx = Lp_GetRwIndexU(&entry);
if (idx == -1) { /* RW index not found in the VLDB entry */
idx = entry.nServers; /* Put it into next index */
entry.nServers++;
addvolume++;
} else { /* RW index found in the VLDB entry */
/* Verify if this volume's location matches where the VLDB says it is */
- if (!Lp_Match(aserver, apart, &entry)) {
+ if (!Lp_MatchU(aserver, apart, &entry)) {
/* VLDB says RW and/or BK is elsewhere - report this BK volume orphaned */
if (pass == 1) {
MapPartIdIntoName(apart, pname);
" VLDB reports its RW/BK volume %lu exists on %s %s\n",
(unsigned long)rwvolid,
noresolve ?
- afs_inet_ntoa_r(entry.serverNumber[idx], hoststr) :
+ afs_inet_ntoa_r(entry.serverUnique[idx], hoststr) :
hostutil_GetNameByINet(entry.
- serverNumber[idx]),
+ serverUnique[idx]),
pname);
}
} else {
entry.volumeId[RWVOL] = rwvolid;
entry.volumeId[BACKVOL] = volumeinfo->volid;
- entry.serverNumber[idx] = aserver;
+ entry.serverUnique[idx] = aserver;
entry.serverPartition[idx] = apart;
entry.serverFlags[idx] = ITSBACKVOL;
* VLDB so we avoid the CheckVldbRO() call (which checks if each
* RO volume listed in the VLDB exists).
*/
- idx = Lp_ROMatch(aserver, apart, &entry) - 1;
+ idx = Lp_ROMatchU(aserver, apart, &entry) - 1;
if (idx == -1) {
idx = entry.nServers;
entry.nServers++;
"*** Warning: Orphaned RO volume %u exists on %s %s\n",
entry.volumeId[ROVOL],
noresolve ?
- afs_inet_ntoa_r(entry.serverNumber[j], hoststr) :
+ afs_inet_ntoa_r(entry.serverUnique[j], hoststr) :
hostutil_GetNameByINet(entry.
- serverNumber[j]),
+ serverUnique[j]),
pname);
fprintf(STDERR,
" VLDB reports its RO volume ID is %lu\n",
(unsigned long)volumeinfo->volid);
}
- Lp_SetRWValue(&entry, entry.serverNumber[idx],
+ Lp_SetRWValueU(&entry, entry.serverUnique[idx],
entry.serverPartition[idx], 0L, 0L);
entry.nServers--;
modified++;
* and there exist RO volumes in the VLDB entry. See if any of them
* are this one. If not, then we add it.
*/
- idx = Lp_ROMatch(aserver, apart, &entry) - 1;
+ idx = Lp_ROMatchU(aserver, apart, &entry) - 1;
if (idx == -1) {
idx = entry.nServers;
entry.nServers++;
entry.volumeId[RWVOL] = rwvolid;
entry.volumeId[ROVOL] = volumeinfo->volid;
- entry.serverNumber[idx] = aserver;
+ entry.serverUnique[idx] = aserver;
entry.serverPartition[idx] = apart;
entry.serverFlags[idx] = ITSROVOL;
*maxvolid = entry.volumeId[RWVOL];
if (modified && doit) {
- MapNetworkToHost(&entry, &storeEntry);
+ MapNetworkToHostU(&entry, &storeEntry);
if (createentry) {
- code = VLDB_CreateEntry(&storeEntry);
+ code = VLDB_CreateEntryU(&storeEntry);
if (code) {
fprintf(STDOUT,
"Could not create a VLDB entry for the volume %lu\n",
if (pass == 1)
goto retry;
code =
- VLDB_ReplaceEntry(rwvolid, RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(rwvolid, RWVOL, &storeEntry,
LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP);
if (code) {
if (verbose) {
fprintf(STDOUT, "-- status after --\n");
if (modified)
- EnumerateEntry(&entry);
+ EnumerateEntryU(&entry);
else
fprintf(STDOUT, "\n**no change**\n");
}
return (error);
}
-int
+static int
sortVolumes(const void *a, const void *b)
{
volintInfo *v1 = (volintInfo *) a;
afs_int32 j, k, code, vcode, error = 0;
afs_int32 tverbose;
afs_int32 mod, modified = 0, deleted = 0;
- struct nvldbentry vldbentry;
+ struct uvldbentry vldbentry;
afs_uint32 volumeid = 0;
volEntries volumeInfo;
struct partList PartList;
}
/* Read the VLDB entry */
- vcode = VLDB_GetEntryByName(avolname, &vldbentry);
+ vcode = VLDB_GetEntryByNameU(avolname, &vldbentry);
if (vcode && (vcode != VL_NOENT)) {
fprintf(STDERR, "Could not access the VLDB for volume %s\n",
avolname);
ERROR_EXIT(vcode);
} else if (!vcode) {
- MapHostToNetwork(&vldbentry);
+ MapHostToNetworkU(&vldbentry);
}
if (tverbose) {
} else {
if ((vldbentry.flags & RW_EXISTS) || (vldbentry.flags & RO_EXISTS)
|| (vldbentry.flags & BACK_EXISTS))
- EnumerateEntry(&vldbentry);
+ EnumerateEntryU(&vldbentry);
}
fprintf(STDOUT, "\n");
}
if (deleted) {
fprintf(STDOUT, "\n**entry deleted**\n");
} else if (modified) {
- EnumerateEntry(&vldbentry);
+ EnumerateEntryU(&vldbentry);
} else {
fprintf(STDOUT, "\n**no change**\n");
}
* Some error codes mean the volume is unavailable but
* still exists - so we catch these error codes.
*/
-afs_int32
+static afs_int32
VolumeExists(afs_uint32 server, afs_int32 partition, afs_uint32 volumeid)
{
struct rx_connection *conn = (struct rx_connection *)0;
/* CheckVldbRWBK()
*
*/
-afs_int32
-CheckVldbRWBK(struct nvldbentry * entry, afs_int32 * modified)
+static afs_int32
+CheckVldbRWBK(struct uvldbentry * entry, afs_int32 * modified)
{
int modentry = 0;
int idx;
if (modified)
*modified = 0;
- idx = Lp_GetRwIndex(entry);
+ idx = Lp_GetRwIndexU(entry);
/* Check to see if the RW volume exists and set the RW_EXISTS
* flag accordingly.
}
} else {
code =
- VolumeExists(entry->serverNumber[idx],
+ VolumeExists(entry->serverUnique[idx],
entry->serverPartition[idx], entry->volumeId[RWVOL]);
if (code == 0) { /* RW volume exists */
if (!(entry->flags & RW_EXISTS)) { /* ... yet entry says RW does not exist */
"Transaction call failed for RW volume %u on server %s %s\n",
entry->volumeId[RWVOL],
noresolve ?
- afs_inet_ntoa_r(entry->serverNumber[idx], hoststr) :
- hostutil_GetNameByINet(entry->serverNumber[idx]),
+ afs_inet_ntoa_r(entry->serverUnique[idx], hoststr) :
+ hostutil_GetNameByINet(entry->serverUnique[idx]),
pname);
ERROR_EXIT(code);
}
}
} else { /* Found a RW entry */
code =
- VolumeExists(entry->serverNumber[idx],
+ VolumeExists(entry->serverUnique[idx],
entry->serverPartition[idx],
entry->volumeId[BACKVOL]);
if (code == 0) { /* BK volume exists */
"Transaction call failed for BK volume %u on server %s %s\n",
entry->volumeId[BACKVOL],
noresolve ?
- afs_inet_ntoa_r(entry->serverNumber[idx], hoststr) :
- hostutil_GetNameByINet(entry->serverNumber[idx]),
+ afs_inet_ntoa_r(entry->serverUnique[idx], hoststr) :
+ hostutil_GetNameByINet(entry->serverUnique[idx]),
pname);
ERROR_EXIT(code);
}
*/
if ((idx != -1) && !(entry->flags & RW_EXISTS)
&& !(entry->flags & BACK_EXISTS)) {
- Lp_SetRWValue(entry, entry->serverNumber[idx],
+ Lp_SetRWValueU(entry, entry->serverUnique[idx],
entry->serverPartition[idx], 0L, 0L);
entry->nServers--;
modentry++;
return (error);
}
-int
-CheckVldbRO(struct nvldbentry *entry, afs_int32 * modified)
+static int
+CheckVldbRO(struct uvldbentry *entry, afs_int32 * modified)
{
int idx;
int foundro = 0, modentry = 0;
}
code =
- VolumeExists(entry->serverNumber[idx],
+ VolumeExists(entry->serverUnique[idx],
entry->serverPartition[idx], entry->volumeId[ROVOL]);
if (code == 0) { /* RO volume exists */
foundro++;
} else if (code == ENODEV) { /* RW volume does not exist */
- Lp_SetROValue(entry, entry->serverNumber[idx],
+ Lp_SetROValueU(entry, entry->serverUnique[idx],
entry->serverPartition[idx], 0L, 0L);
entry->nServers--;
idx--;
"Transaction call failed for RO %u on server %s %s\n",
entry->volumeId[ROVOL],
noresolve ?
- afs_inet_ntoa_r(entry->serverNumber[idx], hoststr) :
- hostutil_GetNameByINet(entry->serverNumber[idx]), pname);
+ afs_inet_ntoa_r(entry->serverUnique[idx], hoststr) :
+ hostutil_GetNameByINet(entry->serverUnique[idx]), pname);
ERROR_EXIT(code);
}
}
/* CheckVldb()
* Ensure that <entry> matches with the info on file servers
*/
-afs_int32
-CheckVldb(struct nvldbentry * entry, afs_int32 * modified, afs_int32 * deleted)
+static afs_int32
+CheckVldb(struct uvldbentry * entry, afs_int32 * modified, afs_int32 * deleted)
{
afs_int32 code, error = 0;
- struct nvldbentry storeEntry;
+ struct uvldbentry storeEntry;
int islocked = 0, mod, modentry, delentry = 0;
int pass = 0, doit=1;
fprintf(STDOUT, "\n-- status before -- \n");
if ((entry->flags & RW_EXISTS) || (entry->flags & RO_EXISTS)
|| (entry->flags & BACK_EXISTS))
- EnumerateEntry(entry);
+ EnumerateEntryU(entry);
fprintf(STDOUT, "\n");
}
}
islocked = 1;
- code = VLDB_GetEntryByID(entry->volumeId[RWVOL], RWVOL, entry);
+ code = VLDB_GetEntryByIDU(entry->volumeId[RWVOL], RWVOL, entry);
if (code) {
fprintf(STDERR, "Could not read VLDB entry for volume %s\n",
entry->name);
ERROR_EXIT(code);
} else {
- MapHostToNetwork(entry);
+ MapHostToNetworkU(entry);
}
}
delentry = 1;
} else {
/* Replace old entry with our new one */
- MapNetworkToHost(entry, &storeEntry);
+ MapNetworkToHostU(entry, &storeEntry);
code =
- VLDB_ReplaceEntry(entry->volumeId[RWVOL], RWVOL, &storeEntry,
+ VLDB_ReplaceEntryU(entry->volumeId[RWVOL], RWVOL, &storeEntry,
(LOCKREL_OPCODE | LOCKREL_AFSID |
LOCKREL_TIMESTAMP));
if (code) {
if (delentry)
fprintf(STDOUT, "\n**entry deleted**\n");
else if (modentry)
- EnumerateEntry(entry);
+ EnumerateEntryU(entry);
else
fprintf(STDOUT, "\n**no change**\n");
}
afs_int32 code, error = 0;
afs_int32 nentries, tentries = 0;
struct VldbListByAttributes attributes;
- nbulkentries arrayEntries;
+ ubulkentries arrayEntries;
afs_int32 failures = 0, modified, modifications = 0;
- struct nvldbentry *vlentry;
+ struct uvldbentry *vlentry;
afs_int32 si, nsi, j;
if (flags & 2)
/* Collect set of VLDB entries */
code =
- VLDB_ListAttributesN2(&attributes, 0, si, &nentries,
+ VLDB_ListAttributesN2U(&attributes, 0, si, &nentries,
&arrayEntries, &nsi);
if (code == RXGEN_OPCODE) {
- code = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
+ code = VLDB_ListAttributesU(&attributes, &nentries, &arrayEntries);
nsi = -1;
}
if (code) {
tentries += nentries;
for (j = 0; j < nentries; j++) {
- vlentry = &arrayEntries.nbulkentries_val[j];
- MapHostToNetwork(vlentry);
+ vlentry = &arrayEntries.ubulkentries_val[j];
+ MapHostToNetworkU(vlentry);
VPRINT1("Processing VLDB entry %d ...\n", j + 1);
}
}
- if (arrayEntries.nbulkentries_val) {
- free(arrayEntries.nbulkentries_val);
- arrayEntries.nbulkentries_val = 0;
+ if (arrayEntries.ubulkentries_val) {
+ free(arrayEntries.ubulkentries_val);
+ arrayEntries.ubulkentries_val = 0;
}
}
error_exit:
if (aconn)
rx_DestroyConnection(aconn);
- if (arrayEntries.nbulkentries_val)
- free(arrayEntries.nbulkentries_val);
+ if (arrayEntries.ubulkentries_val)
+ free(arrayEntries.ubulkentries_val);
if (failures)
error = VOLSERFAILEDOP;
/*rename volume <oldname> to <newname>, changing the names of the related
*readonly and backup volumes. This operation is also idempotent.
*salvager is capable of recovering from rename operation stopping halfway.
- *to recover run syncserver on the affected machines,it will force renaming to completion. name clashes should have been detected before calling this proc */
+ *to recover run syncserver on the affected machines, it will force renaming
+ *to completion. name clashes should have been detected before calling this proc */
+int
+UV_RenameVolume(struct nvldbentry *entryp, char oldname[], char newname[])
+{
+ struct uvldbentry uentry;
+ int error;
+
+ nvlentry_to_uvlentry(entryp, &uentry);
+ error = UV_RenameVolumeU(&uentry, oldname, newname);
+ if (!error)
+ error = uvlentry_to_nvlentry(&uentry, entryp);
+
+ return error;
+}
+
int
-UV_RenameVolume(struct nvldbentry *entry, char oldname[], char newname[])
+UV_RenameVolumeU(struct uvldbentry *entry, char oldname[], char newname[])
{
- struct nvldbentry storeEntry;
+ struct uvldbentry storeEntry;
afs_int32 vcode, code, rcode, error;
int i, index;
char nameBuffer[256];
}
islocked = 1;
strncpy(entry->name, newname, VOLSER_OLDMAXVOLNAME);
- MapNetworkToHost(entry, &storeEntry);
- vcode = VLDB_ReplaceEntry(entry->volumeId[RWVOL], RWVOL, &storeEntry, 0);
+ MapNetworkToHostU(entry, &storeEntry);
+ vcode = VLDB_ReplaceEntryU(entry->volumeId[RWVOL], RWVOL, &storeEntry, 0);
if (vcode) {
fprintf(STDERR, "Could not update VLDB entry for %u\n",
entry->volumeId[RWVOL]);
/*at this stage the intent to rename is recorded in the vldb, as far as the vldb
* is concerned, oldname is lost */
if (entry->flags & RW_EXISTS) {
- index = Lp_GetRwIndex(entry);
+ index = Lp_GetRwIndexU(entry);
if (index == -1) { /* there is a serious discrepancy */
fprintf(STDERR,
"There is a serious discrepancy in VLDB entry for volume %u\n",
error = VOLSERVLDB_ERROR;
goto rvfail;
}
- aconn = UV_Bind(entry->serverNumber[index], AFSCONF_VOLUMEPORT);
+ aconn = UV_Bind(entry->serverUnique[index], AFSCONF_VOLUMEPORT);
code =
AFSVolTransCreate_retry(aconn, entry->volumeId[RWVOL],
entry->serverPartition[index], ITOffline, &tid);
}
/*end rw volume processing */
if (entry->flags & BACK_EXISTS) { /*process the backup volume */
- index = Lp_GetRwIndex(entry);
+ index = Lp_GetRwIndexU(entry);
if (index == -1) { /* there is a serious discrepancy */
fprintf(STDERR,
"There is a serious discrepancy in the VLDB entry for the backup volume %u\n",
error = VOLSERVLDB_ERROR;
goto rvfail;
}
- aconn = UV_Bind(entry->serverNumber[index], AFSCONF_VOLUMEPORT);
+ aconn = UV_Bind(entry->serverUnique[index], AFSCONF_VOLUMEPORT);
code =
AFSVolTransCreate_retry(aconn, entry->volumeId[BACKVOL],
entry->serverPartition[index], ITOffline, &tid);
if (entry->flags & RO_EXISTS) { /*process the ro volumes */
for (i = 0; i < entry->nServers; i++) {
if (entry->serverFlags[i] & ITSROVOL) {
- aconn = UV_Bind(entry->serverNumber[i], AFSCONF_VOLUMEPORT);
+ aconn = UV_Bind(entry->serverUnique[i], AFSCONF_VOLUMEPORT);
code =
AFSVolTransCreate_retry(aconn, entry->volumeId[ROVOL],
entry->serverPartition[i], ITOffline,
VPRINT2("Renamed RO volume %s on host %s\n",
nameBuffer,
noresolve ?
- afs_inet_ntoa_r(entry->serverNumber[i], hoststr) :
+ afs_inet_ntoa_r(entry->serverUnique[i], hoststr) :
hostutil_GetNameByINet(entry->
- serverNumber[i]));
+ serverUnique[i]));
code = AFSVolEndTrans(aconn, tid, &rcode);
tid = 0;
if (code) {
rx_DestroyConnection(aconn);
PrintError("", error);
return error;
-
}
/*report on all the active transactions on volser */
/*maps the host addresses in <old > (present in network byte order) to
that in< new> (present in host byte order )*/
void
+MapNetworkToHostU(struct uvldbentry *old, struct uvldbentry *new)
+{
+ int i, count;
+
+ /*copy all the fields */
+ strcpy(new->name, old->name);
+/* new->volumeType = old->volumeType;*/
+ new->nServers = old->nServers;
+ count = old->nServers;
+ if (count < NMAXNSERVERS)
+ count++;
+ for (i = 0; i < count; i++) {
+ new->serverUnique[i] = ntohl(old->serverUnique[i]);
+ new->serverPartition[i] = old->serverPartition[i];
+ new->serverFlags[i] = old->serverFlags[i];
+ }
+ new->volumeId[RWVOL] = old->volumeId[RWVOL];
+ new->volumeId[ROVOL] = old->volumeId[ROVOL];
+ new->volumeId[BACKVOL] = old->volumeId[BACKVOL];
+ new->cloneId = old->cloneId;
+ new->flags = old->flags;
+}
+
+void
MapNetworkToHost(struct nvldbentry *old, struct nvldbentry *new)
{
int i, count;
/*maps the host entries in <entry> which are present in host byte order to network byte order */
void
+MapHostToNetworkU(struct uvldbentry *entry)
+{
+ int i, count;
+
+ count = entry->nServers;
+ if (count < NMAXNSERVERS)
+ count++;
+ for (i = 0; i < count; i++) {
+ entry->serverUnique[i] = htonl(entry->serverUnique[i]);
+ }
+}
+
+void
MapHostToNetwork(struct nvldbentry *entry)
{
int i, count;
entry->serverNumber[i] = htonl(entry->serverNumber[i]);
}
}
+