afs_int32 aspare2, afs_int32 aspare3,
afs_int32 aspare4, afs_uint32 * anewid,
afs_uint32 * aroid, afs_uint32 * abkid);
-extern int UV_AddVLDBEntry(afs_uint32 aserver, afs_int32 apart, char *aname,
- afs_uint32 aid);
extern int UV_MoveVolume(afs_uint32 afromvol, afs_uint32 afromserver,
afs_int32 afrompart, afs_uint32 atoserver,
afs_int32 atopart);
afs_uint32 volid);
extern int UV_ListPartitions(afs_uint32 aserver, struct partList *ptrPartList,
afs_int32 * cntp);
-extern int UV_ZapVolumeClones(afs_uint32 aserver, afs_int32 apart,
- struct volDescription *volPtr,
- afs_int32 arraySize);
-extern int UV_GenerateVolumeClones(afs_uint32 aserver, afs_int32 apart,
- struct volDescription *volPtr,
- afs_int32 arraySize);
extern int UV_ListVolumes(afs_uint32 aserver, afs_int32 apart, int all,
struct volintInfo **resultPtr, afs_int32 * size);
extern int UV_XListVolumes(afs_uint32 a_serverID, afs_int32 a_partID,
return error;
}
-/* create a volume, given a server, partition number, volume name --> sends
-* back new vol id in <anewid>*/
-int
-UV_AddVLDBEntry(afs_uint32 aserver, afs_int32 apart, char *aname,
- afs_uint32 aid)
-{
- struct rx_connection *aconn;
- afs_int32 error;
- afs_int32 vcode;
- struct nvldbentry entry, storeEntry; /*the new vldb entry */
-
- memset(&storeEntry, 0, sizeof(struct nvldbentry));
-
- 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
- * level of indirection later */
- entry.serverPartition[0] = apart; /* this should also have
- * another indirection level */
- entry.flags = VLF_RWEXISTS; /* this records that rw volume exists */
- entry.serverFlags[0] = VLSF_RWVOL; /*this rep site has rw vol */
- entry.volumeId[RWVOL] = aid;
- entry.volumeId[ROVOL] = 0;
- entry.volumeId[BACKVOL] = 0;
- 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);
- /* create the vldb entry */
- vcode = VLDB_CreateEntry(&storeEntry);
- if (vcode) {
- fprintf(STDERR,
- "Could not create a VLDB entry for the volume %s %lu\n",
- aname, (unsigned long)aid);
- error = vcode;
- goto cfail;
- }
- VPRINT2("Created the VLDB entry for the volume %s %u\n", aname, aid);
-
- cfail:
- if (aconn)
- rx_DestroyConnection(aconn);
- PrintError("", error);
- return error;
-}
-
/* Delete the volume <volid>on <aserver> <apart>
* the physical entry gets removed from the vldb only if the ref count
* becomes zero
return code;
}
-
-/*zap the list of volumes specified by volPtrArray (the volCloneId field).
- This is used by the backup system */
-int
-UV_ZapVolumeClones(afs_uint32 aserver, afs_int32 apart,
- struct volDescription *volPtr, afs_int32 arraySize)
-{
- struct rx_connection *aconn;
- struct volDescription *curPtr;
- int curPos;
- afs_int32 code = 0;
- afs_int32 success = 1;
-
- aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
- curPos = 0;
- for (curPtr = volPtr; curPos < arraySize; curPtr++) {
- if (curPtr->volFlags & CLONEVALID) {
- curPtr->volFlags &= ~CLONEZAPPED;
- success = 1;
-
- code = DoVolDelete(aconn, curPtr->volCloneId, apart,
- "clone", 0, NULL, NULL);
- if (code)
- success = 0;
-
- if (success)
- curPtr->volFlags |= CLONEZAPPED;
- if (!success)
- fprintf(STDERR, "Could not zap volume %lu\n",
- (unsigned long)curPtr->volCloneId);
- if (success)
- VPRINT2("Clone of %s %u deleted\n", curPtr->volName,
- curPtr->volCloneId);
- curPos++;
- }
- }
- if (aconn)
- rx_DestroyConnection(aconn);
- return 0;
-}
-
-/*return a list of clones of the volumes specified by volPtrArray. Used by the
- backup system */
-int
-UV_GenerateVolumeClones(afs_uint32 aserver, afs_int32 apart,
- struct volDescription *volPtr, afs_int32 arraySize)
-{
- struct rx_connection *aconn;
- struct volDescription *curPtr;
- int curPos;
- afs_int32 code = 0;
- afs_int32 rcode = 0;
- afs_int32 tid;
- int reuseCloneId = 0;
- afs_uint32 curCloneId = 0;
- char cloneName[256]; /*max vol name */
-
- aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
- curPos = 0;
- if ((volPtr->volFlags & REUSECLONEID) && (volPtr->volFlags & ENTRYVALID))
- reuseCloneId = 1;
- else { /*get a bunch of id's from vldb */
- code =
- ubik_VL_GetNewVolumeId(cstruct, 0, arraySize, &curCloneId);
- if (code) {
- fprintf(STDERR, "Could not get ID's for the clone from VLDB\n");
- PrintError("", code);
- return code;
- }
- }
-
- for (curPtr = volPtr; curPos < arraySize; curPtr++) {
- if (curPtr->volFlags & ENTRYVALID) {
-
- curPtr->volFlags |= CLONEVALID;
- /*make a clone of curParentId and record as curPtr->volCloneId */
- code =
- AFSVolTransCreate_retry(aconn, curPtr->volId, apart, ITOffline,
- &tid);
- if (code)
- VPRINT2("Clone for volume %s %u failed \n", curPtr->volName,
- curPtr->volId);
- if (code) {
- curPtr->volFlags &= ~CLONEVALID; /* can't clone */
- curPos++;
- continue;
- }
- if (strlen(curPtr->volName) < (VOLSER_OLDMAXVOLNAME - 9)) {
- strcpy(cloneName, curPtr->volName);
- strcat(cloneName, "-tmpClone-");
- } else
- strcpy(cloneName, "-tmpClone");
- if (reuseCloneId) {
- curPtr->volCloneId = curCloneId;
- curCloneId++;
- }
-
- code =
- AFSVolClone(aconn, tid, 0, readonlyVolume, cloneName,
- &(curPtr->volCloneId));
- if (code) {
- curPtr->volFlags &= ~CLONEVALID;
- curPos++;
- fprintf(STDERR, "Could not clone %s due to error %lu\n",
- curPtr->volName, (unsigned long)code);
- code = AFSVolEndTrans(aconn, tid, &rcode);
- if (code)
- fprintf(STDERR, "WARNING: could not end transaction\n");
- continue;
- }
- VPRINT2("********** Cloned %s temporary %u\n", cloneName,
- curPtr->volCloneId);
- code = AFSVolEndTrans(aconn, tid, &rcode);
- if (code || rcode) {
- curPtr->volFlags &= ~CLONEVALID;
- curPos++;
- continue;
- }
-
- curPos++;
- }
- }
- if (aconn)
- rx_DestroyConnection(aconn);
- return 0;
-}
-
-
/*list all the volumes on <aserver> and <apart>. If all = 1, then all the
* relevant fields of the volume are also returned. This is a heavy weight operation.*/
int