#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
+#include <roken.h>
+
+#include <afs/afs_AdminErrors.h>
#include "vsprocs.h"
#include "vosutils.h"
#include "lockprocs.h"
#include "../adminutil/afs_AdminInternal.h"
-#include <afs/afs_AdminErrors.h>
#include "afs_vosAdmin.h"
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef AFS_NT40_ENV
-#include <io.h>
-#endif
-static afs_int32 GroupEntries();
+static afs_int32 GroupEntries(struct rx_connection *server, volintInfo * pntr, afs_int32 count,
+ struct qHead *myQueue, afs_int32 apart);
struct release {
afs_int32 time;
* start a transaction, delete the <delvol> */
static afs_int32
CheckAndDeleteVolume(struct rx_connection *aconn, afs_int32 apart,
- afs_int32 okvol, afs_int32 delvol)
+ afs_uint32 okvol, afs_uint32 delvol)
{
afs_int32 error, code, tid, rcode;
error = 0;
- code = 0;
if (okvol == 0) {
code = AFSVolTransCreate(aconn, delvol, apart, ITOffline, &tid);
/* forcibly remove a volume. Very dangerous call */
int
UV_NukeVolume(afs_cell_handle_p cellHandle, struct rx_connection *server,
- unsigned int partition, unsigned int volumeId, afs_status_p st)
+ unsigned int partition, afs_uint32 volumeId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
* back new vol id in <anewid>*/
int
UV_CreateVolume(afs_cell_handle_p cellHandle, struct rx_connection *server,
- unsigned int partition, const char *volumeName,
- unsigned int quota, unsigned int *volumeId, afs_status_p st)
+ unsigned int partition, char *volumeName,
+ unsigned int quota, afs_uint32 *volumeId, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
entry.nServers = 1;
entry.serverNumber[0] = ntohl(rx_HostOf(rx_PeerOf(server)));
entry.serverPartition[0] = partition;
- entry.flags = RW_EXISTS;
- entry.serverFlags[0] = ITSRWVOL;
+ entry.flags = VLF_RWEXISTS;
+ entry.serverFlags[0] = VLSF_RWVOL;
entry.volumeId[RWVOL] = *volumeId;
entry.volumeId[ROVOL] = *volumeId + 1;
entry.volumeId[BACKVOL] = *volumeId + 2;
*/
int
UV_DeleteVolume(afs_cell_handle_p cellHandle, struct rx_connection *server,
- unsigned int partition, unsigned int volumeId,
+ unsigned int partition, afs_uint32 volumeId,
afs_status_p st)
{
int rc = 0;
}
if (volumeId == entry.volumeId[BACKVOL]) {
- if (!(entry.flags & BACK_EXISTS)
+ if (!(entry.flags & VLF_BACKEXISTS)
|| !Lp_Match(cellHandle, &entry, serverAddr, partition, &tst)) {
notinvldb = 2;
goto fail_UV_DeleteVolume;
}
- entry.flags &= ~BACK_EXISTS;
+ entry.flags &= ~VLF_BACKEXISTS;
vtype = BACKVOL;
}
Lp_SetROValue(cellHandle, &entry, serverAddr, partition, 0, 0);
entry.nServers--;
if (!Lp_ROMatch(cellHandle, &entry, 0, 0, &tst)) {
- entry.flags &= ~RO_EXISTS;
+ entry.flags &= ~VLF_ROEXISTS;
}
vtype = ROVOL;
}
else if (volumeId == entry.volumeId[RWVOL]) {
- if (!(entry.flags & RW_EXISTS)
+ if (!(entry.flags & VLF_RWEXISTS)
|| !Lp_Match(cellHandle, &entry, serverAddr, partition, &tst)) {
notinvldb = 2;
goto fail_UV_DeleteVolume;
Lp_SetRWValue(cellHandle, &entry, serverAddr, partition, 0L, 0L);
entry.nServers--;
- entry.flags &= ~(BACK_EXISTS | RW_EXISTS);
+ entry.flags &= ~(VLF_BACKEXISTS | VLF_RWEXISTS);
vtype = RWVOL;
}
goto fail_UV_DeleteVolume;
}
- if ((entry.nServers <= 0) || !(entry.flags & (RO_EXISTS | RW_EXISTS))) {
+ if ((entry.nServers <= 0) || !(entry.flags & (VLF_ROEXISTS | VLF_RWEXISTS))) {
tst = ubik_VL_DeleteEntry(cellHandle->vos, 0, volumeId, vtype);
if (tst) {
goto fail_UV_DeleteVolume;
*/
int
-UV_MoveVolume(afs_cell_handle_p cellHandle, afs_int32 afromvol,
+UV_MoveVolume(afs_cell_handle_p cellHandle, afs_uint32 afromvol,
afs_int32 afromserver, afs_int32 afrompart, afs_int32 atoserver,
afs_int32 atopart, afs_status_p st)
{
afs_int32 rcode;
afs_int32 fromDate;
struct restoreCookie cookie;
- afs_int32 newVol, volid, backupId;
+ afs_uint32 newVol, volid, backupId;
struct volser_status tstatus;
struct destServer destination;
struct nvldbentry entry;
- int islocked, pntg;
- afs_int32 error;
+ int islocked;
int same;
afs_int32 store_flags;
fromtid = 0;
totid = 0;
clonetid = 0;
- error = 0;
volid = 0;
- pntg = 0;
backupId = 0;
newVol = 0;
*/
fromconn = UV_Bind(cellHandle, afromserver, AFSCONF_VOLUMEPORT);
fromtid = 0;
- pntg = 1;
tst =
AFSVolTransCreate(fromconn, afromvol, afrompart, ITOffline,
}
fromtid = 0;
- error = 0;
goto fail_UV_MoveVolume;
}
}
}
- pntg = 1;
toconn = UV_Bind(cellHandle, atoserver, AFSCONF_VOLUMEPORT); /* get connections to the servers */
fromconn = UV_Bind(cellHandle, afromserver, AFSCONF_VOLUMEPORT);
fromtid = totid = 0; /* initialize to uncreated */
Lp_SetRWValue(cellHandle, &entry, afromserver, afrompart, atoserver,
atopart);
store_flags = entry.flags;
- entry.flags &= ~BACK_EXISTS;
+ entry.flags &= ~VLF_BACKEXISTS;
if (!VLDB_ReplaceEntry
(cellHandle, afromvol, -1, &entry,
int
UV_BackupVolume(afs_cell_handle_p cellHandle, afs_int32 aserver,
- afs_int32 apart, afs_int32 avolid, afs_status_p st)
+ afs_int32 apart, afs_uint32 avolid, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0, temp = 0;
afs_int32 ttid = 0, btid = 0;
- afs_int32 backupID;
+ afs_uint32 backupID;
afs_int32 rcode = 0;
char vname[VOLSER_MAXVOLNAME + 1];
struct nvldbentry entry;
/* These operations require the VLDB be locked since it means the VLDB
* will change or the vldb is already locked.
*/
- if (!(entry.flags & BACK_EXISTS) || /* backup volume doesnt exist */
+ if (!(entry.flags & VLF_BACKEXISTS) || /* backup volume doesnt exist */
(entry.flags & VLOP_ALLOPERS) || /* vldb lock already held */
(entry.volumeId[BACKVOL] == INVALID_BID)) {
/* no assigned backup volume id */
}
/* Mork vldb as backup exists */
- if (!(entry.flags & BACK_EXISTS)) {
- entry.flags |= BACK_EXISTS;
+ if (!(entry.flags & VLF_BACKEXISTS)) {
+ entry.flags |= VLF_BACKEXISTS;
vldbmod = 1;
}
}
static int
-DelVol(struct rx_connection *conn, afs_int32 vid, afs_int32 part,
+DelVol(struct rx_connection *conn, afs_uint32 vid, afs_int32 part,
afs_int32 flags)
{
- afs_int32 acode, ccode, rcode, tid;
- ccode = rcode = tid = 0;
+ afs_int32 acode, rcode, tid;
+ rcode = tid = 0;
acode = AFSVolTransCreate(conn, vid, part, flags, &tid);
if (!acode) { /* It really was there */
acode = AFSVolDeleteVolume(conn, tid);
- ccode = AFSVolEndTrans(conn, tid, &rcode);
- if (!ccode)
- ccode = rcode;
+ AFSVolEndTrans(conn, tid, &rcode);
}
return acode;
#if 0 /* doesn't appear to be used, why compile it */
static int
CloneVol(afs_cell_handle_p cellHandle, struct rx_connection *conn,
- afs_int32 rwvid, afs_int32 part, afs_int32 * rovidp, int nottemp,
+ afs_uint32 rwvid, afs_int32 part, afs_uint32 * rovidp, int nottemp,
struct nvldbentry *entry, afs_int32 * vidCreateDate, afs_status_p st)
{
int rc = 0;
afs_int32 * transPtr, afs_int32 * timePtr, afs_status_p st)
{
int rc = 0;
- afs_status_t tst = 0, etst = 0;
- afs_int32 volid;
+ afs_status_t tst = 0;
+ afs_uint32 volid;
struct volser_status tstatus;
int rcode;
/* If the volume does not exist, create it */
if (!volid || tst) {
- char volname[64];
+ char volname[VL_MAXNAMELEN];
if (volid && (tst != VNOVOL)) {
goto fail_GetTrans;
}
- strcpy(volname, vldbEntryPtr->name);
- strcat(volname, ".readonly");
+ strlcpy(volname, vldbEntryPtr->name, sizeof(volname));
+ if (strlcat(volname, ".readonly", sizeof(volname))
+ >= sizeof(volname)) {
+ tst = ENOMEM;
+ goto fail_GetTrans;
+ }
tst =
AFSVolCreateVolume(*connPtr, vldbEntryPtr->serverPartition[index],
fail_GetTrans:
if ((rc == 0) && (*transPtr)) {
- etst = AFSVolEndTrans(*connPtr, *transPtr, &rcode);
+ AFSVolEndTrans(*connPtr, *transPtr, &rcode);
*transPtr = 0;
- if (!etst)
- etst = rcode;
}
if (st != NULL) {
* sites if forceflag is 1.If its 0 complete the release if the previous
* release aborted else start a new release */
int
-UV_ReleaseVolume(afs_cell_handle_p cellHandle, afs_int32 afromvol,
+UV_ReleaseVolume(afs_cell_handle_p cellHandle, afs_uint32 afromvol,
afs_int32 afromserver, afs_int32 afrompart, int forceflag,
afs_status_p st)
{
char vname[64];
afs_int32 rcode;
- afs_int32 cloneVolId, roVolId;
+ afs_uint32 cloneVolId, roVolId;
struct replica *replicas = 0;
struct nvldbentry entry;
int i, volcount, m, fullrelease, vldbindex;
int releasecount = 0;
struct volser_status volstatus;
- memset((char *)remembertime, 0, sizeof(remembertime));
- memset((char *)&results, 0, sizeof(results));
+ memset(remembertime, 0, sizeof(remembertime));
+ memset(&results, 0, sizeof(results));
tst =
ubik_VL_SetLock(cellHandle->vos, 0, afromvol, RWVOL,
/* Will we be completing a previously unfinished release. -force overrides */
for (fullrelease = 1, i = 0; (fullrelease && (i < entry.nServers)); i++) {
- if (entry.serverFlags[i] & NEW_REPSITE)
+ if (entry.serverFlags[i] & VLSF_NEWREPSITE)
fullrelease = 0;
}
if (forceflag && !fullrelease)
* want to "reclone" a temporary RO clone.
*/
if (roexists
- && (!roclone || (entry.serverFlags[roindex] & RO_DONTUSE))) {
+ && (!roclone || (entry.serverFlags[roindex] & VLSF_DONTUSE))) {
tst = DelVol(fromconn, cloneVolId, afrompart, ITOffline);
if (tst && (tst != VNOVOL)) {
goto fail_UV_ReleaseVolume;
* RO volume is released (temp RO clones don't count).
*/
for (i = 0; i < entry.nServers; i++) {
- entry.serverFlags[i] &= ~NEW_REPSITE;
- entry.serverFlags[i] |= RO_DONTUSE;
+ entry.serverFlags[i] &= ~VLSF_NEWREPSITE;
+ entry.serverFlags[i] |= VLSF_DONTUSE;
}
- entry.serverFlags[rwindex] |= NEW_REPSITE;
- entry.serverFlags[rwindex] &= ~RO_DONTUSE;
+ entry.serverFlags[rwindex] |= VLSF_NEWREPSITE;
+ entry.serverFlags[rwindex] &= ~VLSF_DONTUSE;
/* Begin transaction on RW and mark it busy while we clone it */
tst =
sleep(5);
/* Mark the RO clone in the VLDB as a good site (already released) */
- entry.serverFlags[roindex] |= NEW_REPSITE;
- entry.serverFlags[roindex] &= ~RO_DONTUSE;
- entry.flags |= RO_EXISTS;
+ entry.serverFlags[roindex] |= VLSF_NEWREPSITE;
+ entry.serverFlags[roindex] &= ~VLSF_DONTUSE;
+ entry.flags |= VLF_ROEXISTS;
releasecount++;
cookie.clone = 0;
nservers = entry.nServers / 2; /* how many to do at once, excluding clone */
- replicas =
- (struct replica *)malloc(sizeof(struct replica) * nservers + 1);
- times = (struct release *)malloc(sizeof(struct release) * nservers + 1);
- toconns =
- (struct rx_connection **)malloc(sizeof(struct rx_connection *) *
- nservers + 1);
- results.manyResults_val =
- (afs_int32 *) malloc(sizeof(afs_int32) * nservers + 1);
+ replicas = calloc(nservers + 1, sizeof(struct replica));
+ times = calloc(nservers + 1, sizeof(struct release));
+ toconns = calloc(nservers + 1, sizeof(struct rx_connection *));
+ results.manyResults_val = calloc(nservers + 1, sizeof(afs_int32));
if (!replicas || !times || !!!results.manyResults_val || !toconns) {
tst = ADMNOMEM;
goto fail_UV_ReleaseVolume;
}
- memset(replicas, 0, (sizeof(struct replica) * nservers + 1));
- memset(times, 0, (sizeof(struct release) * nservers + 1));
- memset(toconns, 0, (sizeof(struct rx_connection *) * nservers + 1));
- memset(results.manyResults_val, 0, (sizeof(afs_int32) * nservers + 1));
-
/* Create a transaction on the cloned volume */
tst =
AFSVolTransCreate(fromconn, cloneVolId, afrompart, ITBusy, &fromtid);
if (vldbindex == roindex)
continue; /* the clone */
- if ((entry.serverFlags[vldbindex] & NEW_REPSITE)
- && !(entry.serverFlags[vldbindex] & RO_DONTUSE))
+ if ((entry.serverFlags[vldbindex] & VLSF_NEWREPSITE)
+ && !(entry.serverFlags[vldbindex] & VLSF_DONTUSE))
continue;
- if (!(entry.serverFlags[vldbindex] & ITSROVOL))
+ if (!(entry.serverFlags[vldbindex] & VLSF_ROVOL))
continue; /* not a RO vol */
continue;
}
- entry.serverFlags[times[m].vldbEntryIndex] |= NEW_REPSITE;
- entry.serverFlags[times[m].vldbEntryIndex] &= ~RO_DONTUSE;
- entry.flags |= RO_EXISTS;
+ entry.serverFlags[times[m].vldbEntryIndex] |= VLSF_NEWREPSITE;
+ entry.serverFlags[times[m].vldbEntryIndex] &= ~VLSF_DONTUSE;
+ entry.flags |= VLF_ROEXISTS;
releasecount++;
}
}
/* Figure out if any volume were not released and say so */
for (failure = 0, i = 0; i < entry.nServers; i++) {
- if (!(entry.serverFlags[i] & NEW_REPSITE))
+ if (!(entry.serverFlags[i] & VLSF_NEWREPSITE))
failure++;
}
if (failure) {
entry.cloneId = 0;
for (i = 0; i < entry.nServers; i++)
- entry.serverFlags[i] &= ~NEW_REPSITE;
+ entry.serverFlags[i] &= ~VLSF_NEWREPSITE;
/* Update the VLDB */
if (!VLDB_ReplaceEntry
}
static int
-ReceiveFile(register int fd, register struct rx_call *call,
- register struct stat *status)
+ReceiveFile(int fd, struct rx_call *call,
+ struct stat *status)
{
- register char *buffer = (char *)0;
- register int blockSize;
+ char *buffer = (char *)0;
+ int blockSize;
afs_int32 bytesread, nbytes, bytesleft, w;
fd_set out;
afs_int32 error = 0;
}
#endif
nbytes = blockSize;
- buffer = (char *)malloc(blockSize);
+ buffer = malloc(blockSize);
if (!buffer) {
return ADMNOMEM;
}
afs_int32 error, code;
error = 0;
- fd = -1;
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666);
if (fd < 0 || fstat(fd, &status) < 0) {
* DumpFunction does the real work behind the scenes after
* extracting parameters from the rock */
int
-UV_DumpVolume(afs_cell_handle_p cellHandle, afs_int32 afromvol,
+UV_DumpVolume(afs_cell_handle_p cellHandle, afs_uint32 afromvol,
afs_int32 afromserver, afs_int32 afrompart, afs_int32 fromdate,
const char *filename, afs_status_p st)
{
struct rx_connection *fromconn;
struct rx_call *fromcall;
afs_int32 fromtid;
- afs_int32 rxError;
afs_int32 rcode;
struct nvldbentry entry;
- afs_int32 error;
int islocked;
islocked = 0;
- error = 0;
- rxError = 0;
- fromcall = (struct rx_call *)0;
fromconn = (struct rx_connection *)0;
fromtid = 0;
fromcall = (struct rx_call *)0;
- islocked = 0;
if (!aVLDB_GetEntryByID(cellHandle, afromvol, -1, &entry, &tst)) {
goto fail_UV_DumpVolume;
}
if ((tst = DumpFunction(fromcall, filename))) {
goto fail_UV_DumpVolume;
}
- tst = rx_EndCall(fromcall, rxError);
+ tst = rx_EndCall(fromcall, 0);
fromcall = (struct rx_call *)0;
if (tst) {
goto fail_UV_DumpVolume;
}
if (fromcall) {
- etst = rx_EndCall(fromcall, rxError);
+ etst = rx_EndCall(fromcall, 0);
if (etst) {
if (!tst)
tst = etst;
}
int
-SendFile(register int fd, register struct rx_call *call,
- register struct stat *status)
+SendFile(int fd, struct rx_call *call,
+ struct stat *status)
{
char *buffer = (char *)0;
int blockSize;
fd_set in;
afs_int32 error = 0;
- int done = 0;
int nbytes;
#ifdef AFS_NT40_ENV
blockSize = 4096;
}
#endif
- buffer = (char *)malloc(blockSize);
+ buffer = malloc(blockSize);
if (!buffer) {
return ADMNOMEM;
}
- while (!error && !done) {
+ while (!error) {
FD_ZERO(&in);
FD_SET(fd, &in);
#ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
error = ADMVOSRESTOREFILEREADFAIL;
break;
}
- if (nbytes == 0) {
- done = 1;
+
+ if (nbytes == 0)
break;
- }
+
if (rx_Write(call, buffer, nbytes) != nbytes) {
error = ADMVOSRESTOREFILEWRITEFAIL;
break;
afs_int32 error, code;
error = 0;
- fd = -1;
fd = open(filename, 0);
if (fd < 0 || fstat(fd, &status) < 0) {
*/
int
UV_RestoreVolume(afs_cell_handle_p cellHandle, afs_int32 toserver,
- afs_int32 topart, afs_int32 tovolid, const char *tovolname,
+ afs_int32 topart, afs_uint32 tovolid, char *tovolname,
int flags, const char *dumpFile, afs_status_p st)
{
int rc = 0;
struct rx_connection *toconn, *tempconn;
struct rx_call *tocall;
afs_int32 totid, rcode;
- afs_int32 rxError = 0;
struct volser_status tstatus;
char partName[10];
- afs_int32 pvolid;
+ afs_uint32 pvolid;
afs_int32 temptid;
int success;
struct nvldbentry entry;
- afs_int32 error;
int islocked;
struct restoreCookie cookie;
int reuseID;
memset(&cookie, 0, sizeof(cookie));
islocked = 0;
- success = 0;
- error = 0;
reuseID = 1;
tocall = (struct rx_call *)0;
- toconn = (struct rx_connection *)0;
tempconn = (struct rx_connection *)0;
totid = 0;
temptid = 0;
if (tst) {
goto fail_UV_RestoreVolume;
}
- tst = rx_EndCall(tocall, rxError);
+ tst = rx_EndCall(tocall, 0);
tocall = (struct rx_call *)0;
if (tst) {
goto fail_UV_RestoreVolume;
entry.nServers = 1;
entry.serverNumber[0] = toserver; /*should be indirect */
entry.serverPartition[0] = topart;
- entry.serverFlags[0] = ITSRWVOL;
- entry.flags = RW_EXISTS;
+ entry.serverFlags[0] = VLSF_RWVOL;
+ entry.flags = VLF_RWEXISTS;
if (tstatus.cloneID != 0) {
entry.volumeId[ROVOL] = tstatus.cloneID; /*this should come from status info on the volume if non zero */
} else
/* Add the rw site for the volume being restored */
entry.serverNumber[entry.nServers] = toserver;
entry.serverPartition[entry.nServers] = topart;
- entry.serverFlags[entry.nServers] = ITSRWVOL;
+ entry.serverFlags[entry.nServers] = VLSF_RWVOL;
entry.nServers++;
} else {
/* This volume should be deleted on the old site
entry.serverPartition[index] = topart;
}
- entry.flags |= RW_EXISTS;
+ entry.flags |= VLF_RWEXISTS;
if (!VLDB_ReplaceEntry
(cellHandle, pvolid, RWVOL, &entry,
LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP, &tst)) {
fail_UV_RestoreVolume:
if (tocall) {
- etst = rx_EndCall(tocall, rxError);
+ etst = rx_EndCall(tocall, 0);
if (!tst)
tst = etst;
}
*in vldb */
int
UV_AddSite(afs_cell_handle_p cellHandle, afs_int32 server, afs_int32 part,
- afs_int32 volid, afs_status_p st)
+ afs_uint32 volid, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
/* See if it's on the same server */
for (j = 0; j < entry.nServers; j++) {
- if (entry.serverFlags[j] & ITSROVOL) {
+ if (entry.serverFlags[j] & VLSF_ROVOL) {
nro++;
if (!VLDB_IsSameAddrs
(cellHandle, server, entry.serverNumber[j], &same, &tst)) {
entry.serverNumber[entry.nServers] = server;
entry.serverPartition[entry.nServers] = part;
- entry.serverFlags[entry.nServers] = (ITSROVOL | RO_DONTUSE);
+ entry.serverFlags[entry.nServers] = (VLSF_ROVOL | VLSF_DONTUSE);
entry.nServers++;
if (!VLDB_ReplaceEntry
/*removes <server> <part> as read only site for <volid> from the vldb */
int
UV_RemoveSite(afs_cell_handle_p cellHandle, afs_int32 server, afs_int32 part,
- afs_int32 volid, afs_status_p st)
+ afs_uint32 volid, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
} else { /*remove the rep site */
Lp_SetROValue(cellHandle, &entry, server, part, 0, 0);
entry.nServers--;
- if ((entry.nServers == 1) && (entry.flags & RW_EXISTS))
- entry.flags &= ~RO_EXISTS;
+ if ((entry.nServers == 1) && (entry.flags & VLF_RWEXISTS))
+ entry.flags &= ~VLF_ROEXISTS;
if (entry.nServers < 1) { /*this is the last ref */
tst = ubik_VL_DeleteEntry(cellHandle->vos, 0, volid, ROVOL);
if (tst) {
afs_status_t tst = 0;
struct pIDs partIds;
struct partEntries partEnts;
- register int i, j = 0;
+ int i, j = 0;
*cntp = 0;
int
UV_XListOneVolume(struct rx_connection *server, afs_int32 a_partID,
- afs_int32 a_volID, struct volintXInfo **a_resultPP,
+ afs_uint32 a_volID, struct volintXInfo **a_resultPP,
afs_status_p st)
{
int rc = 0;
*------------------------------------------------------------------------*/
int UV_ListOneVolume(struct rx_connection *server, afs_int32 a_partID,
- afs_int32 a_volID, struct volintInfo **a_resultPP,
+ afs_uint32 a_volID, struct volintInfo **a_resultPP,
afs_status_p st)
{
- int rc = 0;
+ int rc = 0;
afs_status_t tst = 0;
volEntries volumeInfo; /*Area for returned info */
struct rx_connection *server, afs_int32 apart, afs_int32 force)
{
struct aqueue elem;
- int success, temp, temp1, temp2;
- afs_int32 vcode, maxVolid = 0;
+ int success, temp;
+ afs_uint32 temp2;
+ afs_int32 vcode;
+ afs_uint32 maxVolid = 0;
struct nvldbentry entry;
int noError = 1, error, same;
int totalC, totalU, totalCE, totalUE, totalG;
continue;
}
if (maxVolid <= elem.ids[RWVOL]) {
- temp1 = maxVolid;
temp2 = elem.ids[RWVOL] - maxVolid + 1;
maxVolid = 0;
- vcode =
- ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
- &maxVolid);
- maxVolid += temp2;
-
+ vcode = ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
+ &maxVolid);
+ if (vcode)
+ return vcode;
+ maxVolid += temp2;
}
if (maxVolid <= elem.ids[ROVOL]) {
-
- temp1 = maxVolid;
temp2 = elem.ids[ROVOL] - maxVolid + 1;
maxVolid = 0;
- vcode =
- ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
- &maxVolid);
- maxVolid += temp2;
+ vcode = ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
+ &maxVolid);
+ if (vcode)
+ return vcode;
+ maxVolid += temp2;
}
if (maxVolid <= elem.ids[BACKVOL]) {
- temp1 = maxVolid;
- temp2 = elem.ids[BACKVOL] - temp1 + 1;
+ temp2 = elem.ids[BACKVOL] - maxVolid + 1;
maxVolid = 0;
- vcode =
- ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
- &maxVolid);
- maxVolid += temp2;
+ vcode = ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
+ &maxVolid);
+ if (vcode)
+ return vcode;
+ maxVolid += temp2;
}
aVLDB_GetEntryByID(cellHandle, elem.ids[RWVOL], RWVOL, &entry, &tst);
if (tst && (tst != VL_NOENT)) {
memset(&entry, 0, sizeof(entry));
strncpy(entry.name, elem.name, VOLSER_OLDMAXVOLNAME);
if (elem.isValid[RWVOL]) { /*rw exists */
- entry.flags |= RW_EXISTS;
- entry.serverFlags[entry.nServers] = ITSRWVOL;
+ entry.flags |= VLF_RWEXISTS;
+ entry.serverFlags[entry.nServers] = VLSF_RWVOL;
entry.serverNumber[entry.nServers] = aserver;
entry.serverPartition[entry.nServers] = apart;
entry.nServers += 1;
entry.volumeId[BACKVOL] = elem.ids[BACKVOL];
}
if (elem.isValid[ROVOL]) { /*ro volume exists */
- entry.flags |= RO_EXISTS;
- entry.serverFlags[entry.nServers] = ITSROVOL;
+ entry.flags |= VLF_ROEXISTS;
+ entry.serverFlags[entry.nServers] = VLSF_ROVOL;
entry.serverNumber[entry.nServers] = aserver;
entry.serverPartition[entry.nServers] = apart;
entry.nServers += 1;
}
if (elem.isValid[BACKVOL]) { /*backup volume exists */
- entry.flags |= BACK_EXISTS;
- if (!(entry.flags & RW_EXISTS)) { /*this helps to check for a stray backup if parent moves */
- entry.serverFlags[entry.nServers] = ITSRWVOL;
+ entry.flags |= VLF_BACKEXISTS;
+ if (!(entry.flags & VLF_RWEXISTS)) { /*this helps to check for a stray backup if parent moves */
+ entry.serverFlags[entry.nServers] = VLSF_RWVOL;
entry.serverNumber[entry.nServers] = aserver;
entry.serverPartition[entry.nServers] = apart;
entry.nServers += 1;
if (temp == -1) {
/* A RW index is not found in the VLDB entry - will add it */
- entry.flags |= RW_EXISTS;
+ entry.flags |= VLF_RWEXISTS;
entry.serverNumber[entry.nServers] = aserver;
entry.serverPartition[entry.nServers] = apart;
- entry.serverFlags[entry.nServers] = ITSRWVOL;
+ entry.serverFlags[entry.nServers] = VLSF_RWVOL;
entry.nServers++;
} else {
/* A RW index is found in the VLDB entry.
entry.serverPartition[temp] = apart;
}
- entry.flags |= RW_EXISTS;
+ entry.flags |= VLF_RWEXISTS;
}
if ((elem.ids[BACKVOL] != 0) && elem.isValid[BACKVOL])
entry.volumeId[BACKVOL] = elem.ids[BACKVOL];
count = entry.nServers;
rwsite = -1;
for (j = 0; j < count; j++) {
- if (entry.serverFlags[j] & ITSROVOL) {
+ if (entry.serverFlags[j] & VLSF_ROVOL) {
/*delete the site */
entry.serverNumber[j] = 0;
entry.serverPartition[j] = 0;
entry.serverFlags[j] = 0;
- } else if (entry.serverFlags[j] & ITSRWVOL)
+ } else if (entry.serverFlags[j] & VLSF_RWVOL)
rwsite = j;
}
entry.nServers = 0;
}
entry.serverNumber[entry.nServers] = aserver;
entry.serverPartition[entry.nServers] = apart;
- entry.serverFlags[entry.nServers] = ITSROVOL;
+ entry.serverFlags[entry.nServers] = VLSF_ROVOL;
entry.nServers++;
entry.volumeId[ROVOL] = elem.ids[ROVOL];
- entry.flags |= RO_EXISTS;
+ entry.flags |= VLF_ROEXISTS;
} else if (elem.ids[ROVOL] < entry.volumeId[ROVOL]) {
- if (!(entry.flags & RO_EXISTS)) {
+ if (!(entry.flags & VLF_ROEXISTS)) {
entry.volumeId[ROVOL] = elem.ids[ROVOL];
entry.serverNumber[entry.nServers] = aserver;
entry.serverPartition[entry.nServers] = apart;
- entry.serverFlags[entry.nServers] = ITSROVOL;
+ entry.serverFlags[entry.nServers] = VLSF_ROVOL;
entry.nServers++;
- entry.flags |= RO_EXISTS;
+ entry.flags |= VLF_ROEXISTS;
}
}
else if (elem.ids[ROVOL] == entry.volumeId[ROVOL]) {
entry.serverNumber[entry.nServers] = aserver;
entry.serverPartition[entry.nServers] = apart;
- entry.serverFlags[entry.nServers] = ITSROVOL;
+ entry.serverFlags[entry.nServers] = VLSF_ROVOL;
entry.nServers++;
- entry.flags |= RO_EXISTS;
+ entry.flags |= VLF_ROEXISTS;
entry.volumeId[ROVOL] = elem.ids[ROVOL];
}
}
} else {
/*tackle the backup volume */
entry.volumeId[BACKVOL] = elem.ids[BACKVOL];
- entry.flags |= BACK_EXISTS;
+ entry.flags |= VLF_BACKEXISTS;
}
if (entry.volumeId[BACKVOL] == INVALID_BID)
entry.volumeId[BACKVOL] = elem.ids[BACKVOL];
*modified = 0;
idx = Lp_GetRwIndex(cellHandle, entry, 0);
- /* Check to see if the RW volume exists and set the RW_EXISTS
+ /* Check to see if the RW volume exists and set the VLF_RWEXISTS
* flag accordingly.
*/
if (idx == -1) { /* Did not find a RW entry */
- if (entry->flags & RW_EXISTS) { /* ... yet entry says RW exists */
- entry->flags &= ~RW_EXISTS; /* ... so say RW does not exist */
+ if (entry->flags & VLF_RWEXISTS) { /* ... yet entry says RW exists */
+ entry->flags &= ~VLF_RWEXISTS; /* ... so say RW does not exist */
modentry++;
}
} else {
if (VolumeExists
(cellHandle, entry->serverNumber[idx],
entry->serverPartition[idx], entry->volumeId[RWVOL], &tst)) {
- if (!(entry->flags & RW_EXISTS)) { /* ... yet entry says RW does no
+ if (!(entry->flags & VLF_RWEXISTS)) { /* ... yet entry says RW does no
* t exist */
- entry->flags |= RW_EXISTS; /* ... so say RW does exist */
+ entry->flags |= VLF_RWEXISTS; /* ... so say RW does exist */
modentry++;
}
} else if (tst == ENODEV) { /* RW volume does not exist */
- if (entry->flags & RW_EXISTS) { /* ... yet entry says RW exists
+ if (entry->flags & VLF_RWEXISTS) { /* ... yet entry says RW exists
*/
- entry->flags &= ~RW_EXISTS; /* ... so say RW does not exist
+ entry->flags &= ~VLF_RWEXISTS; /* ... so say RW does not exist
*/
modentry++;
}
} else {
/* If VLDB says it didn't exist, then ignore error */
- if (entry->flags & RW_EXISTS) {
+ if (entry->flags & VLF_RWEXISTS) {
goto fail_CheckVldbRWBK;
}
}
}
- /* Check to see if the BK volume exists and set the BACK_EXISTS
+ /* Check to see if the BK volume exists and set the VLF_BACKEXISTS
* flag accordingly. idx already ponts to the RW entry.
*/
if (idx == -1) { /* Did not find a RW entry */
- if (entry->flags & BACK_EXISTS) { /* ... yet entry says BK exists */
- entry->flags &= ~BACK_EXISTS; /* ... so say BK does not exist */
+ if (entry->flags & VLF_BACKEXISTS) { /* ... yet entry says BK exists */
+ entry->flags &= ~VLF_BACKEXISTS; /* ... so say BK does not exist */
modentry++;
}
} else { /* Found a RW entry */
if (VolumeExists
(cellHandle, entry->serverNumber[idx],
entry->serverPartition[idx], entry->volumeId[BACKVOL], &tst)) {
- if (!(entry->flags & BACK_EXISTS)) { /* ... yet entry says BK does n
+ if (!(entry->flags & VLF_BACKEXISTS)) { /* ... yet entry says BK does n
* ot exist */
- entry->flags |= BACK_EXISTS; /* ... so say BK does exist */
+ entry->flags |= VLF_BACKEXISTS; /* ... so say BK does exist */
modentry++;
}
} else if (tst == ENODEV) { /* BK volume does not exist */
- if (entry->flags & BACK_EXISTS) { /* ... yet entry says BK exists
+ if (entry->flags & VLF_BACKEXISTS) { /* ... yet entry says BK exists
*/
- entry->flags &= ~BACK_EXISTS; /* ... so say BK does not exist
+ entry->flags &= ~VLF_BACKEXISTS; /* ... so say BK does not exist
*/
modentry++;
}
} else {
/* If VLDB says it didn't exist, then ignore error */
- if (entry->flags & BACK_EXISTS) {
+ if (entry->flags & VLF_BACKEXISTS) {
goto fail_CheckVldbRWBK;
}
}
/* If there is an idx but the BK and RW volumes no
* longer exist, then remove the RW entry.
*/
- if ((idx != -1) && !(entry->flags & RW_EXISTS)
- && !(entry->flags & BACK_EXISTS)) {
+ if ((idx != -1) && !(entry->flags & VLF_RWEXISTS)
+ && !(entry->flags & VLF_BACKEXISTS)) {
Lp_SetRWValue(cellHandle, entry, entry->serverNumber[idx],
entry->serverPartition[idx], 0L, 0L);
entry->nServers--;
if (modified)
*modified = 0;
- /* Check to see if the RO volumes exist and set the RO_EXISTS
+ /* Check to see if the RO volumes exist and set the VLF_ROEXISTS
* flag accordingly.
*/
for (idx = 0; idx < entry->nServers; idx++) {
- if (!(entry->serverFlags[idx] & ITSROVOL)) {
+ if (!(entry->serverFlags[idx] & VLSF_ROVOL)) {
continue; /* not a RO */
}
}
if (foundro) { /* A RO volume exists */
- if (!(entry->flags & RO_EXISTS)) { /* ... yet entry says RW does not e
+ if (!(entry->flags & VLF_ROEXISTS)) { /* ... yet entry says RW does not e
* xist */
- entry->flags |= RO_EXISTS; /* ... so say RW does exist */
+ entry->flags |= VLF_ROEXISTS; /* ... so say RW does exist */
modentry++;
}
} else { /* A RO volume does not exist */
- if (entry->flags & RO_EXISTS) { /* ... yet entry says RO exists */
- entry->flags &= ~RO_EXISTS; /* ... so say RO does not exist */
+ if (entry->flags & VLF_ROEXISTS) { /* ... yet entry says RO exists */
+ entry->flags &= ~VLF_ROEXISTS; /* ... so say RO does not exist */
modentry++;
}
}
int islocked = 0;
int pass = 0;
afs_int32 modentry = 0;
- afs_int32 delentry = 0;
if (modified) {
*modified = 0;
if (pass == 1)
goto retry;
- if (!(entry->flags & RW_EXISTS) && !(entry->flags & BACK_EXISTS)
- && !(entry->flags & RO_EXISTS)) {
+ if (!(entry->flags & VLF_RWEXISTS) && !(entry->flags & VLF_BACKEXISTS)
+ && !(entry->flags & VLF_ROEXISTS)) {
/* The RW, BK, nor RO volumes do not exist. Delete the VLDB entry */
tst =
ubik_VL_DeleteEntry(cellHandle->vos, 0,
if (tst) {
goto fail_CheckVldb;
}
- delentry = 1;
} else {
/* Replace old entry with our new one */
if (!VLDB_ReplaceEntry
if (islocked) {
vcode =
ubik_VL_ReleaseLock(cellHandle->vos, 0,
- entry->volumeId[RWVOL], RWVOL,
- (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP),
- &tst);
+ entry->volumeId[RWVOL], RWVOL,
+ (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
if (vcode) {
if (!tst)
tst = vcode;
{
int rc = 0;
afs_status_t tst = 0;
- afs_int32 code, vcode;
int noError;
afs_int32 nentries, tentries = 0;
struct VldbListByAttributes attributes;
nbulkentries arrayEntries;
int totalF;
- register struct nvldbentry *vllist;
- register int j;
+ struct nvldbentry *vllist;
+ int j;
afs_int32 si, nsi;
afs_int32 modified = 0;
- code = 0;
- vcode = 0;
noError = 1;
arrayEntries.nbulkentries_val = 0;
+ memset(&attributes, 0, sizeof(attributes));
/* Set up attributes to search VLDB */
attributes.server = ntohl(rx_HostOf(rx_PeerOf(server)));
return rc;
}
-/*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 */
+/* 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
+ */
int
UV_RenameVolume(afs_cell_handle_p cellHandle, struct nvldbentry *entry,
- const char *newname, afs_status_p st)
+ char *newname, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_status_t etst = 0;
- afs_int32 rcode, error;
+ afs_int32 rcode;
int i, index;
char nameBuffer[256];
afs_int32 tid;
struct rx_connection *aconn;
int islocked;
- error = 0;
aconn = (struct rx_connection *)0;
tid = 0;
islocked = 0;
/*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) {
+ if (entry->flags & VLF_RWEXISTS) {
index = Lp_GetRwIndex(cellHandle, entry, 0);
if (index == -1) { /* there is a serious discrepancy */
tst = VOLSERVLDB_ERROR;
aconn = (struct rx_connection *)0;
}
/*end rw volume processing */
- if (entry->flags & BACK_EXISTS) { /*process the backup volume */
+ if (entry->flags & VLF_BACKEXISTS) { /*process the backup volume */
index = Lp_GetRwIndex(cellHandle, entry, 0);
if (index == -1) { /* there is a serious discrepancy */
tst = VOLSERVLDB_ERROR;
if (aconn)
rx_ReleaseCachedConnection(aconn);
aconn = (struct rx_connection *)0;
- if (entry->flags & RO_EXISTS) { /*process the ro volumes */
+ if (entry->flags & VLF_ROEXISTS) { /*process the ro volumes */
for (i = 0; i < entry->nServers; i++) {
- if (entry->serverFlags[i] & ITSROVOL) {
+ if (entry->serverFlags[i] & VLSF_ROVOL) {
aconn =
UV_Bind(cellHandle, entry->serverNumber[i],
AFSCONF_VOLUMEPORT);
error = VOLSERBADOP;
}
} else { /*create a fresh entry */
- qPtr = (struct aqueue *)malloc(sizeof(struct aqueue));
+ qPtr = malloc(sizeof(struct aqueue));
if (pntr->type == RWVOL) {
qPtr->isValid[RWVOL] = 1;
qPtr->isValid[BACKVOL] = 0;
/*delete the volume without interacting with the vldb */
int
UV_VolumeZap(afs_cell_handle_p cellHandle, struct rx_connection *server,
- unsigned int partition, unsigned int volumeId, afs_status_p st)
+ unsigned int partition, afs_uint32 volumeId, afs_status_p st)
{
- afs_int32 rcode, ttid, error, code;
+ afs_int32 rcode, ttid;
int rc = 0;
afs_status_t tst = 0;
- code = 0;
- error = 0;
ttid = 0;
tst = AFSVolTransCreate(server, volumeId, partition, ITOffline, &ttid);
int
UV_SetVolume(struct rx_connection *server, afs_int32 partition,
- afs_int32 volid, afs_int32 transflag, afs_int32 setflag,
+ afs_uint32 volid, afs_int32 transflag, afs_int32 setflag,
unsigned int sleepTime, afs_status_p st)
{
int rc = 0;
if (tid) {
etst = AFSVolEndTrans(server, tid, &rcode);
- /* FIXME: this looks like a typo */
- if (etst || etst) {
+ if (etst || rcode) {
if (!tst)
tst = (etst ? etst : rcode);
}