2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
30 #include <sys/types.h>
31 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #include <arpa/inet.h>
37 #include "afs_vosAdmin.h"
38 #include "../adminutil/afs_AdminInternal.h"
39 #include <afs/afs_utilAdmin.h>
40 #include <afs/vlserver.h>
41 #include <afs/volser.h>
42 #include <afs/volint.h>
43 #include <afs/partition.h>
47 #include "lockprocs.h"
49 typedef struct file_server {
52 struct rx_connection *serv;
54 } file_server_t, *file_server_p;
57 * IsValidServerHandle - test a server handle for validity.
61 * IN serverHandle - the serverHandle to be validated.
65 * No locks are obtained or released by this function
69 * Returns != 0 upon successful completion.
73 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
78 if (serverHandle == NULL) {
79 tst = ADMVOSSERVERHANDLENULL;
80 goto fail_IsValidServerHandle;
83 if (serverHandle->is_valid != 1) {
84 tst = ADMVOSSERVERHANDLEINVALID;
85 goto fail_IsValidServerHandle;
88 if ((serverHandle->begin_magic != BEGIN_MAGIC)
89 || (serverHandle->end_magic != END_MAGIC)) {
90 tst = ADMVOSSERVERHANDLEBADMAGIC;
91 goto fail_IsValidServerHandle;
95 fail_IsValidServerHandle:
105 * IsValidCellHandle - verify that a cell handle can be used to make vos
110 * IN cellHandle - the cellHandle to be validated.
114 * No locks are obtained or released by this function
118 * Returns != 0 upon successful completion.
122 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
125 afs_status_t tst = 0;
127 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
128 goto fail_IsValidCellHandle;
131 if (cellHandle->vos_valid == 0) {
132 tst = ADMVOSCELLHANDLEINVALIDVOS;
133 goto fail_IsValidCellHandle;
137 fail_IsValidCellHandle:
145 /* set <server> and <part> to the correct values depending on
146 * <voltype> and <entry> */
148 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
149 afs_int32 * part, int *previdx)
151 int i, istart, vtype;
156 /* Doesn't check for non-existance of backup volume */
157 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
159 istart = 0; /* seach the entire entry */
162 /* Seach from beginning of entry or pick up where we left off */
163 istart = ((*previdx < 0) ? 0 : *previdx + 1);
166 for (i = istart; i < entry->nServers; i++) {
167 if (entry->serverFlags[i] & vtype) {
168 *server = entry->serverNumber[i];
169 *part = entry->serverPartition[i];
175 /* Didn't find any, return -1 */
181 * vos_BackupVolumeCreate - create a backup volume for a volume.
185 * IN cellHandle - a previously opened cellHandle that corresponds
186 * to the cell where volume exists.
188 * IN callBack - a call back function pointer that may be called to report
189 * status information. Can be null.
191 * IN volumeId - the volume to create the back up for.
195 * No locks are obtained or released by this function
199 * Returns != 0 upon successful completion.
203 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
204 unsigned int volumeId, afs_status_p st)
207 afs_status_t tst = 0;
208 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
209 struct nvldbentry rw_vol_entry;
211 afs_int32 rw_partition;
212 afs_int32 rw_vol_type;
213 struct nvldbentry bk_vol_entry;
215 afs_int32 bk_partition;
216 afs_int32 bk_vol_type;
223 if (!IsValidCellHandle(c_handle, &tst)) {
224 goto fail_vos_BackupVolumeCreate;
228 * Get the volume information and verify that we've been passed
229 * a read write volume id
233 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
234 &rw_vol_type, &tst)) {
235 goto fail_vos_BackupVolumeCreate;
238 if (rw_vol_type != RWVOL) {
239 tst = ADMVOSMUSTBERWVOL;
240 goto fail_vos_BackupVolumeCreate;
244 * Check to see that if a backup volume exists, it exists on the
245 * same server as volumeId
248 if (rw_vol_entry.flags & BACK_EXISTS) {
250 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
251 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
252 goto fail_vos_BackupVolumeCreate;
254 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
255 goto fail_vos_BackupVolumeCreate;
258 tst = ADMVOSBACKUPVOLWRONGSERVER;
259 goto fail_vos_BackupVolumeCreate;
264 * Create the new backup volume
267 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
269 fail_vos_BackupVolumeCreate:
278 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
282 * IN cellHandle - a previously opened cellHandle that corresponds
283 * to the cell where the volumes exist.
285 * IN serverHandle - the server where the backups are to be created. Can be
288 * IN callBack - a call back function pointer that may be called to report
289 * status information. Can be null.
291 * IN partition - the partition where the backups are to be created. Can be
294 * IN volumePrefix - all volumes with this prefix will have backup volumes
295 * created. Can be null.
297 * IN excludePrefix - exclude the volumes that match volumePrefix.
301 * No locks are obtained or released by this function
305 * Returns != 0 upon successful completion.
309 vos_BackupVolumeCreateMultiple(const void *cellHandle,
310 const void *serverHandle,
311 vos_MessageCallBack_t callBack,
312 const unsigned int *partition,
313 const char *volumePrefix,
314 vos_exclude_t excludePrefix, afs_status_p st)
317 afs_status_t tst = 0;
318 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
319 file_server_p f_server = (file_server_p) serverHandle;
320 struct VldbListByAttributes attr;
323 size_t prefix_len = 0;
324 nbulkentries arrayEntries;
325 afs_int32 nentries = 0;
326 register struct nvldbentry *entry;
328 afs_int32 rw_volid, rw_server, rw_partition;
333 memset((void *)&attr, 0, sizeof(attr));
338 * The only required argument to this function is the cellHandle.
339 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
343 if (!IsValidCellHandle(c_handle, &tst)) {
344 goto fail_vos_BackupVolumeCreateMultiple;
347 if ((excludePrefix == VOS_EXCLUDE)
348 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
349 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
350 goto fail_vos_BackupVolumeCreateMultiple;
353 if (f_server != NULL) {
354 if (!IsValidServerHandle(f_server, &tst)) {
355 goto fail_vos_BackupVolumeCreateMultiple;
357 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
358 attr.Mask |= VLLIST_SERVER;
361 if (partition != NULL) {
362 if (*partition > VOLMAXPARTS) {
363 tst = ADMVOSPARTITIONTOOLARGE;
364 goto fail_vos_BackupVolumeCreateMultiple;
366 attr.partition = *partition;
367 attr.Mask |= VLLIST_PARTITION;
370 if (excludePrefix == VOS_EXCLUDE) {
374 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
376 prefix_len = strlen(volumePrefix);
379 memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
382 * Get a list of all the volumes in the cell
385 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
386 goto fail_vos_BackupVolumeCreateMultiple;
390 * Cycle through the list of volumes and see if we should create a backup
391 * for each individual volume
394 for (i = 0; i < nentries; i++) {
395 entry = &arrayEntries.nbulkentries_val[i];
398 * Skip entries that don't have a RW volume
401 if (!(entry->flags & RW_EXISTS)) {
402 if (callBack != NULL) {
403 const char *messageText;
404 if (util_AdminErrorCodeTranslate
405 (ADMVOSVOLUMENOREADWRITE, 0, &messageText, &tst)) {
406 sprintf(backbuf, "%s %s", messageText, entry->name);
407 (**callBack) (VOS_VERBOSE_MESSAGE, backbuf);
414 * See if we should skip this entry because of the prefix/exclude
415 * combination we've been passed
420 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
424 if (strncmp(entry->name, volumePrefix, prefix_len)) {
430 rw_volid = entry->volumeId[RWVOL];
431 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
433 if ((rw_server == -1) || (rw_partition == -1)) {
434 if (callBack != NULL) {
435 const char *messageText;
436 if (util_AdminErrorCodeTranslate
437 (ADMVOSVLDBBADENTRY, 0, &messageText, &tst)) {
438 sprintf(backbuf, "%s %s", messageText, entry->name);
439 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
446 * Check that the RW volume is on the same server that we were
450 if (serverHandle != NULL) {
451 if (!VLDB_IsSameAddrs
452 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
453 rw_server, &equal, &tst)) {
454 if (callBack != NULL) {
455 const char *messageText;
456 if (util_AdminErrorCodeTranslate
457 (ADMVOSVLDBBADSERVER, 0, &messageText, &tst)) {
458 sprintf(backbuf, "%s %x %d", messageText,
459 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
461 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
467 if (callBack != NULL) {
468 const char *messageText;
469 if (util_AdminErrorCodeTranslate
470 (ADMVOSVLDBDIFFERENTADDR, 0, &messageText, &tst)) {
471 sprintf(backbuf, "%s %s", messageText, entry->name);
472 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
480 * Check that the RW volume is on the same partition we were
484 if (partition != NULL) {
485 if (*partition != rw_partition) {
494 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid,
498 fail_vos_BackupVolumeCreateMultiple:
500 if (arrayEntries.nbulkentries_val) {
501 free(arrayEntries.nbulkentries_val);
511 * vos_PartitionGet - get information about a single partition.
515 * IN cellHandle - a previously opened cellHandle that corresponds
516 * to the cell where the server lives.
518 * IN serverHandle - a previously open vos server handle that holds
519 * the partition of interest.
521 * IN callBack - a call back function pointer that may be called to report
522 * status information. Can be null.
524 * IN partition - the integer that represents the partition of interest.
526 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
527 * completion contains information regarding the partition.
531 * No locks are obtained or released by this function
535 * Returns != 0 upon successful completion.
539 vos_PartitionGet(const void *cellHandle, const void *serverHandle,
540 vos_MessageCallBack_t callBack, unsigned int partition,
541 vos_partitionEntry_p partitionP, afs_status_p st)
544 afs_status_t tst = 0;
545 struct diskPartition part_info;
546 file_server_p f_server = (file_server_p) serverHandle;
547 char partitionName[10]; /* this rpc requires a character partition name */
553 if (!IsValidServerHandle(f_server, &tst)) {
554 goto fail_vos_PartitionGet;
557 if (partitionP == NULL) {
558 tst = ADMVOSPARTITIONPNULL;
559 goto fail_vos_PartitionGet;
562 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
563 goto fail_vos_PartitionGet;
566 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
568 goto fail_vos_PartitionGet;
570 strncpy(partitionP->name, part_info.name, VOS_MAX_PARTITION_NAME_LEN);
571 partitionP->name[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
572 strncpy(partitionP->deviceName, part_info.devName, VOS_MAX_PARTITION_NAME_LEN);
573 partitionP->deviceName[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
574 partitionP->lockFileDescriptor = part_info.lock_fd;
575 partitionP->totalSpace = part_info.minFree;
576 partitionP->totalFreeSpace = part_info.free;
579 fail_vos_PartitionGet:
588 * The iterator functions and data for the partition retrieval functions.
591 typedef struct partition_get {
592 afs_int32 total_received; /* the total number of valid partiions retrieved */
593 int number_processed; /* the number of valid paritions we've handed out */
594 int index; /* the current index into the part_list array */
595 struct partList part_list; /* the list of partitions */
596 vos_partitionEntry_t partition[CACHED_ITEMS]; /* the cache of partitions */
597 const void *server; /* the server where the parititions exist */
598 } partition_get_t, *partition_get_p;
601 GetPartitionInfoRPC(void *rpc_specific, int slot, int *last_item,
602 int *last_item_contains_data, afs_status_p st)
605 afs_status_t tst = 0;
606 partition_get_p part = (partition_get_p) rpc_specific;
607 vos_partitionEntry_p ptr = (vos_partitionEntry_p) & part->partition[slot];
610 * Skip partition entries that are not valid
613 while (!(part->part_list.partFlags[part->index] & PARTVALID)) {
618 * Get information for the next partition
621 if (!vos_PartitionGet
623 (unsigned int)part->part_list.partId[part->index], ptr, &tst)) {
624 goto fail_GetPartitionInfoRPC;
628 part->number_processed++;
630 if (part->number_processed == part->total_received) {
632 *last_item_contains_data = 1;
636 fail_GetPartitionInfoRPC:
645 GetPartitionInfoFromCache(void *rpc_specific, int slot, void *dest,
649 afs_status_t tst = 0;
650 partition_get_p part = (partition_get_p) rpc_specific;
652 memcpy(dest, (const void *)&part->partition[slot],
653 sizeof(vos_partitionEntry_t));
663 * vos_PartitionGetBegin - begin to iterate over the partitions at a
668 * IN cellHandle - a previously opened cellHandle that corresponds
669 * to the cell where the server exists.
671 * IN serverHandle - the server that houses the partitions of interest.
673 * IN callBack - a call back function pointer that may be called to report
674 * status information. Can be null.
676 * OUT iterationIdP - upon successful completion, contains an iterator that can
677 * be passed to vos_PartitionGetNext.
681 * No locks are obtained or released by this function
685 * Returns != 0 upon successful completion.
689 vos_PartitionGetBegin(const void *cellHandle, const void *serverHandle,
690 vos_MessageCallBack_t callBack, void **iterationIdP,
694 afs_status_t tst = 0;
695 file_server_p f_server = (file_server_p) serverHandle;
696 afs_admin_iterator_p iter =
697 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
698 partition_get_p part =
699 (partition_get_p) calloc(1, sizeof(partition_get_t));
705 if (!IsValidServerHandle(f_server, &tst)) {
706 goto fail_vos_PartitionGetBegin;
709 if (iterationIdP == NULL) {
710 goto fail_vos_PartitionGetBegin;
713 if ((iter == NULL) || (part == NULL)) {
715 goto fail_vos_PartitionGetBegin;
719 * Fill in the part structure
722 part->server = serverHandle;
723 if (!UV_ListPartitions
724 (f_server->serv, &part->part_list, &part->total_received, &tst)) {
725 goto fail_vos_PartitionGetBegin;
729 * If we didn't receive any partitions, don't spawn a background thread.
730 * Mark the iterator complete.
733 if (part->total_received == 0) {
734 if (!IteratorInit(iter, (void *)part, NULL, NULL, NULL, NULL, &tst)) {
735 goto fail_vos_PartitionGetBegin;
737 iter->done_iterating = 1;
738 iter->st = ADMITERATORDONE;
741 (iter, (void *)part, GetPartitionInfoRPC,
742 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
743 goto fail_vos_PartitionGetBegin;
746 *iterationIdP = (void *)iter;
749 fail_vos_PartitionGetBegin:
767 * vos_PartitionGetNext - get the next partition at a server.
771 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
773 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
774 * completion contains the next partition.
778 * The iterator is locked while the next parition is retrieved.
782 * Returns != 0 upon successful completion.
786 vos_PartitionGetNext(const void *iterationId, vos_partitionEntry_p partitionP,
790 afs_status_t tst = 0;
791 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
794 tst = ADMITERATORNULL;
795 goto fail_vos_PartitionGetNext;
798 if (partitionP == NULL) {
799 tst = ADMVOSPARTITIONPNULL;
800 goto fail_vos_PartitionGetNext;
803 rc = IteratorNext(iter, (void *)partitionP, &tst);
805 fail_vos_PartitionGetNext:
814 * vos_PartitionGetDone - finish using a partition iterator.
818 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
822 * The iterator is locked and then destroyed.
826 * Returns != 0 upon successful completion.
830 vos_PartitionGetDone(const void *iterationId, afs_status_p st)
833 afs_status_t tst = 0;
834 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
841 tst = ADMITERATORNULL;
842 goto fail_vos_PartitionGetDone;
845 rc = IteratorDone(iter, &tst);
847 fail_vos_PartitionGetDone:
856 * vos_ServerOpen - open a handle to an individual server for future
861 * IN cellHandle - a previously opened cellHandle that corresponds
862 * to the cell where the server lives.
864 * IN serverName - the machine name of the server
866 * OUT serverHandleP - a void pointer that upon successful completion
867 * contains a handle that is used in future operations upon the server.
871 * No locks are obtained or released by this function
875 * Returns != 0 upon successful completion.
879 vos_ServerOpen(const void *cellHandle, const char *serverName,
880 void **serverHandleP, afs_status_p st)
883 afs_status_t tst = 0;
884 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
885 file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
887 struct rx_securityClass *sc[3];
890 if (f_server == NULL) {
892 goto fail_vos_ServerOpen;
899 if (!IsValidCellHandle(c_handle, &tst)) {
900 goto fail_vos_ServerOpen;
903 if (!c_handle->tokens->afs_token_set) {
904 tst = ADMVOSCELLHANDLENOAFSTOKENS;
905 goto fail_vos_ServerOpen;
908 if (!util_AdminServerAddressGetFromName
909 (serverName, &server_address, &tst)) {
910 goto fail_vos_ServerOpen;
913 scIndex = c_handle->tokens->sc_index;
914 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
916 rx_GetCachedConnection(htonl(server_address),
917 htons(AFSCONF_VOLUMEPORT), VOLSERVICE_ID,
918 sc[scIndex], scIndex);
919 if (f_server->serv != NULL) {
920 f_server->begin_magic = BEGIN_MAGIC;
921 f_server->end_magic = END_MAGIC;
922 f_server->is_valid = 1;
923 *serverHandleP = (void *)f_server;
926 tst = ADMVOSSERVERNOCONNECTION;
927 goto fail_vos_ServerOpen;
939 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
943 * IN serverHandle - an existing server handle.
947 * No locks are obtained or released by this function
951 * Returns != 0 upon successful completion.
955 vos_ServerClose(const void *serverHandle, afs_status_p st)
958 afs_status_t tst = 0;
959 file_server_p f_server = (file_server_p) serverHandle;
961 if (!IsValidServerHandle(f_server, &tst)) {
962 goto fail_vos_ServerClose;
965 rx_ReleaseCachedConnection(f_server->serv);
966 f_server->is_valid = 0;
970 fail_vos_ServerClose:
979 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
984 * IN cellHandle - a previously opened cellHandle that corresponds
985 * to the cell where the server lives.
987 * IN serverHandle - a handle to the server machine.
989 * IN callBack - a call back function pointer that may be called to report
990 * status information. Can be null.
992 * IN partition - the partition to synchronize. Can be NULL.
994 * IN force - force deletion of bad volumes.
998 * No locks are obtained or released by this function
1002 * Returns != 0 upon successful completion.
1006 vos_ServerSync(const void *cellHandle, const void *serverHandle,
1007 vos_MessageCallBack_t callBack, const unsigned int *partition,
1011 afs_status_t tst = 0;
1012 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1013 file_server_p f_server = (file_server_p) serverHandle;
1018 * Validate arguments
1021 if (!IsValidCellHandle(c_handle, &tst)) {
1022 goto fail_vos_ServerSync;
1025 if (!IsValidServerHandle(f_server, &tst)) {
1026 goto fail_vos_ServerSync;
1029 if (partition != NULL) {
1030 if (*partition > VOLMAXPARTS) {
1031 tst = ADMVOSPARTITIONTOOLARGE;
1032 goto fail_vos_ServerSync;
1034 part = (afs_int32) * partition;
1042 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1044 fail_vos_ServerSync:
1053 * vos_FileServerAddressChange - change an existing file server address.
1057 * IN cellHandle - a previously opened cellHandle that corresponds
1058 * to the cell where the address should be changed.
1060 * IN callBack - a call back function pointer that may be called to report
1061 * status information. Can be null.
1063 * IN oldAddress - the old server address in host byte order
1065 * IN newAddress - the new server address in host byte order
1069 * No locks are obtained or released by this function
1073 * Returns != 0 upon successful completion.
1077 vos_FileServerAddressChange(const void *cellHandle,
1078 vos_MessageCallBack_t callBack, int oldAddress,
1079 int newAddress, afs_status_p st)
1082 afs_status_t tst = 0;
1083 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1086 * Validate arguments
1089 if (!IsValidCellHandle(c_handle, &tst)) {
1090 goto fail_vos_FileServerAddressChange;
1094 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, oldAddress,
1097 goto fail_vos_FileServerAddressChange;
1101 fail_vos_FileServerAddressChange:
1110 * vos_FileServerAddressRemove - remove an existing file server address.
1114 * IN cellHandle - a previously opened cellHandle that corresponds
1115 * to the cell where the address should be removed.
1117 * IN callBack - a call back function pointer that may be called to report
1118 * status information. Can be null.
1120 * IN serverAddress - the server address to remove in host byte order.
1124 * No locks are obtained or released by this function
1128 * Returns != 0 upon successful completion.
1132 vos_FileServerAddressRemove(const void *cellHandle,
1133 vos_MessageCallBack_t callBack, int serverAddress,
1137 afs_status_t tst = 0;
1138 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1139 int dummyAddress = 0xffffffff;
1142 * Validate arguments
1145 if (!IsValidCellHandle(c_handle, &tst)) {
1146 goto fail_vos_FileServerAddressRemove;
1150 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, dummyAddress,
1153 goto fail_vos_FileServerAddressRemove;
1157 fail_vos_FileServerAddressRemove:
1166 * The iterator functions and data for the server retrieval functions.
1168 * These functions are very similar to the FileServerAddressGet
1169 * functions. The main difference being that instead of returning
1170 * a single address at a time for a server, we fill an array with
1171 * all the addresses of a server.
1174 typedef struct server_get {
1175 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1176 afs_int32 total_addresses; /* total number of addresses */
1177 bulkaddrs addresses; /* the list of addresses */
1178 int address_index; /* current index into address list */
1179 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1180 } server_get_t, *server_get_p;
1183 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1184 int *last_item_contains_data, afs_status_p st)
1187 afs_status_t tst = 0;
1188 server_get_p serv = (server_get_p) rpc_specific;
1189 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1190 afs_int32 base, index;
1193 ListAddrByAttributes m_attrs;
1194 afs_int32 total_multi;
1195 bulkaddrs addr_multi;
1199 * Check to see if this is a multihomed address server
1202 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1203 base = (*addrP >> 16) & 0xff;
1204 index = (*addrP) & 0xffff;
1206 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1207 && (index <= VL_MHSRV_PERBLK)) {
1210 * This is a multihomed server. Make an rpc to retrieve
1211 * all its addresses. Copy the addresses into the cache.
1214 m_attrs.Mask = VLADDR_INDEX;
1215 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1217 addr_multi.bulkaddrs_val = 0;
1218 addr_multi.bulkaddrs_len = 0;
1220 ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
1221 &m_unique, &total_multi, &addr_multi);
1223 goto fail_GetServerRPC;
1227 * Remove any bogus IP addresses which the user may have
1228 * been unable to remove.
1231 RemoveBadAddresses(&total_multi, &addr_multi);
1234 * Copy all the addresses into the cache
1237 for (i = 0; i < total_multi; i++) {
1238 serv->server[slot].serverAddress[i] =
1239 addr_multi.bulkaddrs_val[i];
1242 serv->server[slot].count = total_multi;
1243 serv->address_index++;
1244 free(addr_multi.bulkaddrs_val);
1248 * The next address is just a plain old address
1252 serv->server[slot].serverAddress[0] = *addrP;
1253 serv->server[slot].count = 1;
1254 serv->address_index++;
1258 * See if we've processed all the entries
1262 if (serv->address_index == serv->total_addresses) {
1264 *last_item_contains_data = 1;
1277 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1280 afs_status_t tst = 0;
1281 server_get_p serv = (server_get_p) rpc_specific;
1283 memcpy(dest, (const void *)&serv->server[slot],
1284 sizeof(vos_fileServerEntry_t));
1295 DestroyServer(void *rpc_specific, afs_status_p st)
1298 afs_status_t tst = 0;
1299 server_get_p serv = (server_get_p) rpc_specific;
1301 if (serv->addresses.bulkaddrs_val != NULL) {
1302 free(serv->addresses.bulkaddrs_val);
1313 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1317 * IN cellHandle - a previously opened cellHandle that corresponds
1318 * to the cell where the file servers exist.
1320 * IN callBack - a call back function pointer that may be called to report
1321 * status information. Can be null.
1323 * OUT iterationIdP - upon successful completion, contains an iterator that
1324 * can be passed to vos_FileServerGetNext.
1328 * No locks are obtained or released by this function
1332 * Returns != 0 upon successful completion.
1336 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1337 void **iterationIdP, afs_status_p st)
1340 afs_status_t tst = 0;
1341 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1342 afs_admin_iterator_p iter =
1343 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1344 server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
1345 struct VLCallBack unused;
1349 * Validate arguments
1352 if (!IsValidCellHandle(c_handle, &tst)) {
1353 goto fail_vos_FileServerGetBegin;
1356 if (iterationIdP == NULL) {
1357 goto fail_vos_FileServerGetBegin;
1360 if ((iter == NULL) || (serv == NULL)) {
1362 goto fail_vos_FileServerGetBegin;
1366 * Fill in the serv structure
1369 serv->vldb = c_handle->vos;
1371 ubik_Call_New(VL_GetAddrs, c_handle->vos, 0, 0, 0, &unused,
1372 &serv->total_addresses, &serv->addresses);
1375 goto fail_vos_FileServerGetBegin;
1379 * Remove any bogus IP addresses which the user may have
1380 * been unable to remove.
1383 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1385 if (serv->total_addresses == 0) {
1386 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1387 goto fail_vos_FileServerGetBegin;
1389 iter->done_iterating = 1;
1390 iter->st = ADMITERATORDONE;
1393 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1394 DestroyServer, &tst)) {
1395 goto fail_vos_FileServerGetBegin;
1398 *iterationIdP = (void *)iter;
1401 fail_vos_FileServerGetBegin:
1408 if (serv->addresses.bulkaddrs_val != NULL) {
1409 free(serv->addresses.bulkaddrs_val);
1422 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1426 * IN iterationId - an iterator previously returned by
1427 * vos_FileServerGetBegin
1429 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1430 * completion contains information about the next server in the cell.
1434 * The iterator is locked while the next server is retrieved.
1438 * Returns != 0 upon successful completion.
1442 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1446 afs_status_t tst = 0;
1447 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1450 tst = ADMITERATORNULL;
1451 goto fail_vos_FileServerGetNext;
1454 if (serverEntryP == NULL) {
1455 tst = ADMVOSSERVERENTRYPNULL;
1456 goto fail_vos_FileServerGetNext;
1459 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1461 fail_vos_FileServerGetNext:
1470 * vos_FileServerGetDone - finish using a partition iterator.
1474 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1478 * The iterator is locked and then destroyed.
1482 * Returns != 0 upon successful completion.
1486 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1489 afs_status_t tst = 0;
1490 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1493 * Validate arguments
1497 tst = ADMITERATORNULL;
1498 goto fail_vos_FileServerGetDone;
1501 rc = IteratorDone(iter, &tst);
1503 fail_vos_FileServerGetDone:
1512 * The iterator functions and data for the transation retrieval functions.
1515 typedef struct transaction_get {
1516 afs_int32 total; /* total number of transactions */
1517 afs_int32 index; /* index to the current transaction */
1518 transDebugInfo *cur; /* the current transaction */
1519 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1520 } transaction_get_t, *transaction_get_p;
1523 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1524 int *last_item_contains_data, afs_status_p st)
1527 afs_status_t tst = 0;
1528 transaction_get_p t = (transaction_get_p) rpc_specific;
1529 int index = t->index;
1532 * Copy the next transaction into the cache
1535 t->tran[slot].transactionId = t->cur[index].tid;
1536 t->tran[slot].lastActiveTime = t->cur[index].time;
1537 t->tran[slot].creationTime = t->cur[index].creationTime;
1538 t->tran[slot].errorCode = t->cur[index].returnCode;
1539 t->tran[slot].volumeId = t->cur[index].volid;
1540 t->tran[slot].partition = t->cur[index].partition;
1541 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1542 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1543 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1544 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1545 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1547 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1549 switch (t->cur[index].iflags) {
1551 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1554 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1557 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1560 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1563 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1567 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1569 switch (t->cur[index].vflags) {
1570 case VTDeleteOnSalvage:
1571 t->tran[slot].volumeActiveStatus =
1572 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1574 case VTOutOfService:
1575 t->tran[slot].volumeActiveStatus =
1576 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1579 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1583 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1585 if (t->cur[index].tflags) {
1586 t->tran[slot].volumeTransactionStatus =
1587 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1593 * See if we've processed all the entries
1597 if (t->index == t->total) {
1599 *last_item_contains_data = 1;
1610 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1614 afs_status_t tst = 0;
1615 transaction_get_p tran = (transaction_get_p) rpc_specific;
1617 memcpy(dest, (const void *)&tran->tran[slot],
1618 sizeof(vos_serverTransactionStatus_p));
1629 DestroyTransaction(void *rpc_specific, afs_status_p st)
1632 afs_status_t tst = 0;
1633 transaction_get_p tran = (transaction_get_p) rpc_specific;
1635 if (tran->cur != NULL) {
1647 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1648 * at a volume server.
1652 * IN cellHandle - a previously opened cellHandle that corresponds
1653 * to the cell where the volume server exists.
1655 * IN serverHandle - a handle to the server to query.
1657 * IN callBack - a call back function pointer that may be called to report
1658 * status information. Can be null.
1660 * OUT iterationIdP - upon successful completion, contains an iterator that
1661 * can be passed to vos_ServerTransactionStatusGetNext.
1665 * No locks are obtained or released by this function
1669 * Returns != 0 upon successful completion.
1673 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1674 const void *serverHandle,
1675 vos_MessageCallBack_t callBack,
1676 void **iterationIdP, afs_status_p st)
1679 afs_status_t tst = 0;
1680 file_server_p f_server = (file_server_p) serverHandle;
1681 afs_admin_iterator_p iter =
1682 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1683 transaction_get_p tran =
1684 (transaction_get_p) calloc(1, sizeof(transaction_get_t));
1688 * Validate arguments
1691 if (!IsValidServerHandle(f_server, &tst)) {
1692 goto fail_vos_ServerTransactionStatusGetBegin;
1695 if (iterationIdP == NULL) {
1696 goto fail_vos_ServerTransactionStatusGetBegin;
1699 if ((iter == NULL) || (tran == NULL)) {
1701 goto fail_vos_ServerTransactionStatusGetBegin;
1705 * Fill in the tran structure
1708 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1709 goto fail_vos_ServerTransactionStatusGetBegin;
1712 if (tran->total == 0) {
1713 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1714 goto fail_vos_ServerTransactionStatusGetBegin;
1716 iter->done_iterating = 1;
1717 iter->st = ADMITERATORDONE;
1720 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1721 NULL, DestroyTransaction, &tst)) {
1722 goto fail_vos_ServerTransactionStatusGetBegin;
1725 *iterationIdP = (void *)iter;
1728 fail_vos_ServerTransactionStatusGetBegin:
1735 if (tran->cur != NULL) {
1749 * vos_ServerTransactionStatusGetNext - get information about the next
1750 * active transaction.
1754 * IN iterationId - an iterator previously returned by
1755 * vos_ServerTransactionStatusGetBegin
1757 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1758 * that upon successful completion contains information about the
1763 * The iterator is locked while the next item is retrieved.
1767 * Returns != 0 upon successful completion.
1771 vos_ServerTransactionStatusGetNext(const void *iterationId,
1772 vos_serverTransactionStatus_p
1773 serverTransactionStatusP, afs_status_p st)
1776 afs_status_t tst = 0;
1777 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1780 tst = ADMITERATORNULL;
1781 goto fail_vos_ServerTransactionStatusGetNext;
1784 if (serverTransactionStatusP == NULL) {
1785 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1786 goto fail_vos_ServerTransactionStatusGetNext;
1789 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1791 fail_vos_ServerTransactionStatusGetNext:
1800 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1804 * IN iterationId - an iterator previously returned by
1805 * vos_ServerTransactionStatusGetBegin
1809 * The iterator is locked and then destroyed.
1813 * Returns != 0 upon successful completion.
1817 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1820 afs_status_t tst = 0;
1821 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1824 * Validate arguments
1828 tst = ADMITERATORNULL;
1829 goto fail_vos_ServerTransactionStatusGetDone;
1832 rc = IteratorDone(iter, &tst);
1834 fail_vos_ServerTransactionStatusGetDone:
1843 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1847 afs_status_t tst = 0;
1850 dest->numServers = source->nServers;
1851 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1852 dest->volumeId[i] = source->volumeId[i];
1854 dest->cloneId = source->cloneId;
1855 dest->status = VOS_VLDB_ENTRY_OK;
1856 if (source->flags & VLOP_ALLOPERS) {
1857 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1859 if (source->flags & VLOP_MOVE) {
1860 dest->status |= VOS_VLDB_ENTRY_MOVE;
1862 if (source->flags & VLOP_RELEASE) {
1863 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1865 if (source->flags & VLOP_BACKUP) {
1866 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1868 if (source->flags & VLOP_DELETE) {
1869 dest->status |= VOS_VLDB_ENTRY_DELETE;
1871 if (source->flags & VLOP_DUMP) {
1872 dest->status |= VOS_VLDB_ENTRY_DUMP;
1875 if (source->flags & VLF_RWEXISTS) {
1876 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1878 if (source->flags & VLF_ROEXISTS) {
1879 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1881 if (source->flags & VLF_BACKEXISTS) {
1882 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1885 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1886 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1887 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1888 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1889 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1890 dest->volumeSites[i].serverFlags = 0;
1892 if (source->serverFlags[i] & NEW_REPSITE) {
1893 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1895 if (source->serverFlags[i] & ITSROVOL) {
1896 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1898 if (source->serverFlags[i] & ITSRWVOL) {
1899 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1901 if (source->serverFlags[i] & ITSBACKVOL) {
1902 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1904 if (source->serverFlags[i] & RO_DONTUSE) {
1905 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1918 * vos_VLDBGet- get a volume's vldb entry.
1922 * IN cellHandle - a previously opened cellHandle that corresponds
1923 * to the cell where the volume entries exist.
1925 * IN callBack - a call back function pointer that may be called to report
1926 * status information. Can be null.
1928 * IN volumeId - the id of the volume to retrieve.
1930 * IN volumeName - the name of the volume to retrieve.
1932 * OUT vldbEntry - upon successful completion, contains the information regarding
1937 * No locks are obtained or released by this function
1941 * Returns != 0 upon successful completion.
1945 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1946 const unsigned int *volumeId, const char *volumeName,
1947 vos_vldbEntry_p vldbEntry, afs_status_p st)
1950 afs_status_t tst = 0;
1951 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1952 struct nvldbentry entry;
1956 * Validate arguments
1959 if (!IsValidCellHandle(c_handle, &tst)) {
1960 goto fail_vos_VLDBGet;
1963 if (vldbEntry == NULL) {
1964 tst = ADMVOSVLDBENTRYNULL;
1965 goto fail_vos_VLDBGet;
1968 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1969 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1970 goto fail_vos_VLDBGet;
1974 * Retrieve the entry
1977 if (!((volumeName == NULL) || (*volumeName == 0))) {
1978 if (!ValidateVolumeName(volumeName, &tst)) {
1979 goto fail_vos_VLDBGet;
1981 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1982 goto fail_vos_VLDBGet;
1985 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1986 goto fail_vos_VLDBGet;
1991 * Copy the entry into our structure
1994 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1995 goto fail_vos_VLDBGet;
2008 * The iterator functions and data for the vldb entry retrieval functions.
2011 typedef struct vldb_entry_get {
2012 afs_int32 total; /* total number of vldb entries */
2013 afs_int32 index; /* index to the current vldb entry */
2014 nbulkentries entries; /* the list of entries retrieved */
2015 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2016 } vldb_entry_get_t, *vldb_entry_get_p;
2019 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2020 int *last_item_contains_data, afs_status_p st)
2023 afs_status_t tst = 0;
2024 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2027 * Copy the next entry into the cache
2031 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2033 goto fail_GetVLDBEntryRPC;
2038 * See if we've processed all the entries
2042 if (entry->index == entry->total) {
2044 *last_item_contains_data = 1;
2048 fail_GetVLDBEntryRPC:
2057 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2061 afs_status_t tst = 0;
2062 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2064 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2075 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2078 afs_status_t tst = 0;
2079 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2081 if (entry->entries.nbulkentries_val != NULL) {
2082 free(entry->entries.nbulkentries_val);
2094 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2098 * IN cellHandle - a previously opened cellHandle that corresponds
2099 * to the cell where the volume entries exist.
2101 * IN serverHandle - a handle to the server whose entries should be listed.
2104 * IN callBack - a call back function pointer that may be called to report
2105 * status information. Can be null.
2107 * IN partition - the partition whose entries should be listed.
2110 * OUT iterationIdP - upon successful completion, contains an iterator that
2111 * can be passed to vos_VLDBGetNext.
2115 * No locks are obtained or released by this function
2119 * Returns != 0 upon successful completion.
2123 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2124 vos_MessageCallBack_t callBack, unsigned int *partition,
2125 void **iterationIdP, afs_status_p st)
2128 afs_status_t tst = 0;
2129 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2130 file_server_p f_server = (file_server_p) serverHandle;
2131 afs_admin_iterator_p iter =
2132 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2133 vldb_entry_get_p entry =
2134 (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2135 struct VldbListByAttributes attr;
2138 memset(&attr, 0, sizeof(attr));
2141 * Validate arguments
2144 if (!IsValidCellHandle(c_handle, &tst)) {
2145 goto fail_vos_VLDBGetBegin;
2148 if ((iter == NULL) || (entry == NULL)) {
2150 goto fail_vos_VLDBGetBegin;
2153 if (f_server != NULL) {
2154 if (!IsValidServerHandle(f_server, &tst)) {
2155 goto fail_vos_VLDBGetBegin;
2157 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2158 attr.Mask |= VLLIST_SERVER;
2161 if (partition != NULL) {
2162 if (*partition > VOLMAXPARTS) {
2163 tst = ADMVOSPARTITIONTOOLARGE;
2164 goto fail_vos_VLDBGetBegin;
2166 attr.partition = *partition;
2167 attr.Mask |= VLLIST_PARTITION;
2170 if (!VLDB_ListAttributes
2171 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2172 goto fail_vos_VLDBGetBegin;
2175 if (entry->total <= 0) {
2176 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2177 goto fail_vos_VLDBGetBegin;
2179 iter->done_iterating = 1;
2180 iter->st = ADMITERATORDONE;
2183 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2184 NULL, DestroyVLDBEntry, &tst)) {
2185 goto fail_vos_VLDBGetBegin;
2188 *iterationIdP = (void *)iter;
2191 fail_vos_VLDBGetBegin:
2197 if (entry->entries.nbulkentries_val != NULL) {
2198 free(entry->entries.nbulkentries_val);
2200 if (entry != NULL) {
2212 * vos_VLDBGetNext - get information about the next volume.
2216 * IN iterationId - an iterator previously returned by
2219 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2220 * that upon successful completion contains information about the
2225 * The iterator is locked while the next item is retrieved.
2229 * Returns != 0 upon successful completion.
2233 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2237 afs_status_t tst = 0;
2238 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2241 tst = ADMITERATORNULL;
2242 goto fail_vos_VLDBGetNext;
2245 if (vldbEntry == NULL) {
2246 tst = ADMVOSVLDBENTRYNULL;
2247 goto fail_vos_VLDBGetNext;
2250 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2252 fail_vos_VLDBGetNext:
2261 * vos_VLDBGetDone - finish using a volume iterator.
2265 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2269 * The iterator is locked and then destroyed.
2273 * Returns != 0 upon successful completion.
2277 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2280 afs_status_t tst = 0;
2281 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2284 * Validate arguments
2288 tst = ADMITERATORNULL;
2289 goto fail_vos_VLDBGetDone;
2292 rc = IteratorDone(iter, &tst);
2294 fail_vos_VLDBGetDone:
2303 * vos_VLDBEntryRemove - remove a vldb entry.
2307 * IN cellHandle - a previously opened cellHandle that corresponds
2308 * to the cell where the vldb entry exists.
2310 * IN serverHandle - a previously opened serverHandle that corresponds
2311 * to the server where the vldb entry exists. Can be null.
2313 * IN callBack - a call back function pointer that may be called to report
2314 * status information. Can be null.
2316 * IN partition - the partition where the vldb entry exists. Can be null.
2318 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2322 * No locks are obtained or released by this function
2326 * Returns != 0 upon successful completion.
2330 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2331 vos_MessageCallBack_t callBack,
2332 const unsigned int *partition, unsigned int *volumeId,
2336 afs_status_t tst = 0;
2337 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2338 file_server_p f_server = (file_server_p) serverHandle;
2339 struct VldbListByAttributes attr;
2340 nbulkentries entries;
2344 memset(&attr, 0, sizeof(attr));
2345 memset(&entries, 0, sizeof(entries));
2348 * Validate arguments
2351 if (!IsValidCellHandle(c_handle, &tst)) {
2352 goto fail_vos_VLDBEntryRemove;
2356 * If the volume is specified, just delete it
2359 if (volumeId != NULL) {
2360 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2362 goto fail_vos_VLDBEntryRemove;
2366 if (f_server != NULL) {
2367 if (!IsValidServerHandle(f_server, &tst)) {
2368 goto fail_vos_VLDBEntryRemove;
2370 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2371 attr.Mask |= VLLIST_SERVER;
2374 if (partition != NULL) {
2375 if (*partition > VOLMAXPARTS) {
2376 tst = ADMVOSPARTITIONTOOLARGE;
2377 goto fail_vos_VLDBEntryRemove;
2379 attr.partition = *partition;
2380 attr.Mask |= VLLIST_PARTITION;
2383 if ((f_server == NULL) && (partition == NULL)) {
2384 tst = ADMVOSVLDBDELETEALLNULL;
2385 goto fail_vos_VLDBEntryRemove;
2388 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2389 goto fail_vos_VLDBEntryRemove;
2392 if (nentries <= 0) {
2393 tst = ADMVOSVLDBNOENTRIES;
2394 goto fail_vos_VLDBEntryRemove;
2397 for (i = 0; i < nentries; i++) {
2398 ubik_VL_DeleteEntry(c_handle->vos, 0,
2399 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2403 fail_vos_VLDBEntryRemove:
2405 if (entries.nbulkentries_val) {
2406 free(entries.nbulkentries_val);
2416 * vos_VLDBUnlock - unlock vldb entries en masse.
2420 * IN cellHandle - a previously opened cellHandle that corresponds
2421 * to the cell where the vldb entries exist.
2423 * IN serverHandle - a previously opened serverHandle that corresponds
2424 * to the server where the vldb entries exist. Can be null.
2426 * IN callBack - a call back function pointer that may be called to report
2427 * status information. Can be null.
2429 * IN partition - the partition where the vldb entries exist. Can be null.
2433 * No locks are obtained or released by this function
2437 * Returns != 0 upon successful completion.
2441 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2442 vos_MessageCallBack_t callBack, const unsigned int *partition,
2446 afs_status_t tst = 0;
2447 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2448 file_server_p f_server = (file_server_p) serverHandle;
2449 struct VldbListByAttributes attr;
2450 nbulkentries entries;
2454 memset(&attr, 0, sizeof(attr));
2455 memset(&entries, 0, sizeof(entries));
2458 * Validate arguments
2461 if (!IsValidCellHandle(c_handle, &tst)) {
2462 goto fail_vos_VLDBUnlock;
2465 if (f_server != NULL) {
2466 if (!IsValidServerHandle(f_server, &tst)) {
2467 goto fail_vos_VLDBUnlock;
2469 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2470 attr.Mask |= VLLIST_SERVER;
2473 if (partition != NULL) {
2474 if (*partition > VOLMAXPARTS) {
2475 tst = ADMVOSPARTITIONTOOLARGE;
2476 goto fail_vos_VLDBUnlock;
2478 attr.partition = *partition;
2479 attr.Mask |= VLLIST_PARTITION;
2481 attr.flag = VLOP_ALLOPERS;
2482 attr.Mask |= VLLIST_FLAG;
2485 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2486 goto fail_vos_VLDBUnlock;
2489 if (nentries <= 0) {
2490 tst = ADMVOSVLDBNOENTRIES;
2491 goto fail_vos_VLDBUnlock;
2494 for (i = 0; i < nentries; i++) {
2495 vos_VLDBEntryUnlock(cellHandle, 0,
2496 entries.nbulkentries_val[i].volumeId[RWVOL],
2501 fail_vos_VLDBUnlock:
2503 if (entries.nbulkentries_val) {
2504 free(entries.nbulkentries_val);
2515 * vos_VLDBEntryLock - lock a vldb entry.
2519 * IN cellHandle - a previously opened cellHandle that corresponds
2520 * to the cell where the vldb entry exists.
2522 * IN callBack - a call back function pointer that may be called to report
2523 * status information. Can be null.
2525 * IN volumeId - the volume id of the vldb entry to be deleted.
2529 * No locks are obtained or released by this function
2533 * Returns != 0 upon successful completion.
2537 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2538 unsigned int volumeId, afs_status_p st)
2541 afs_status_t tst = 0;
2542 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2545 * Validate arguments
2548 if (!IsValidCellHandle(c_handle, &tst)) {
2549 goto fail_vos_VLDBEntryLock;
2552 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2554 goto fail_vos_VLDBEntryLock;
2558 fail_vos_VLDBEntryLock:
2567 * vos_VLDBEntryUnlock - unlock a vldb entry.
2571 * IN cellHandle - a previously opened cellHandle that corresponds
2572 * to the cell where the vldb entry exists.
2574 * IN callBack - a call back function pointer that may be called to report
2575 * status information. Can be null.
2577 * IN volumeId - the volume id of the vldb entry to be unlocked.
2581 * No locks are obtained or released by this function
2585 * Returns != 0 upon successful completion.
2589 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2590 unsigned int volumeId, afs_status_p st)
2593 afs_status_t tst = 0;
2594 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2597 * Validate arguments
2600 if (!IsValidCellHandle(c_handle, &tst)) {
2601 goto fail_vos_VLDBEntryUnlock;
2606 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2607 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2609 goto fail_vos_VLDBEntryUnlock;
2613 fail_vos_VLDBEntryUnlock:
2622 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2626 * IN cellHandle - a previously opened cellHandle that corresponds
2627 * to the cell where the volume exists.
2629 * IN serverHandle - a previously opened serverHandle that corresponds
2630 * to the server where the new volume should be created.
2632 * IN callBack - a call back function pointer that may be called to report
2633 * status information. Can be null.
2635 * IN partition - the partition where then new volume should be created.
2637 * IN volumeId - the volume id of the volume to be replicated.
2641 * No locks are obtained or released by this function
2645 * Returns != 0 upon successful completion.
2649 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2650 vos_MessageCallBack_t callBack,
2651 unsigned int partition, unsigned int volumeId,
2655 afs_status_t tst = 0;
2656 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2657 file_server_p f_server = (file_server_p) serverHandle;
2660 * Validate arguments
2663 if (!IsValidCellHandle(c_handle, &tst)) {
2664 goto fail_vos_VLDBReadOnlySiteCreate;
2667 if (!IsValidServerHandle(f_server, &tst)) {
2668 goto fail_vos_VLDBReadOnlySiteCreate;
2671 if (partition > VOLMAXPARTS) {
2672 tst = ADMVOSPARTITIONTOOLARGE;
2673 goto fail_vos_VLDBReadOnlySiteCreate;
2677 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2679 goto fail_vos_VLDBReadOnlySiteCreate;
2683 fail_vos_VLDBReadOnlySiteCreate:
2692 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2697 * IN cellHandle - a previously opened cellHandle that corresponds
2698 * to the cell where the volume exists.
2700 * IN serverHandle - a previously opened serverHandle that corresponds
2701 * to the server where the volume should be deleted.
2703 * IN callBack - a call back function pointer that may be called to report
2704 * status information. Can be null.
2706 * IN partition - the partition where then volume should be deleted.
2708 * IN volumeId - the volume id of the volume to be deleted.
2712 * No locks are obtained or released by this function
2716 * Returns != 0 upon successful completion.
2720 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2721 vos_MessageCallBack_t callBack,
2722 unsigned int partition, unsigned int volumeId,
2726 afs_status_t tst = 0;
2727 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2728 file_server_p f_server = (file_server_p) serverHandle;
2731 * Validate arguments
2734 if (!IsValidCellHandle(c_handle, &tst)) {
2735 goto fail_vos_VLDBReadOnlySiteDelete;
2738 if (!IsValidServerHandle(f_server, &tst)) {
2739 goto fail_vos_VLDBReadOnlySiteDelete;
2742 if (partition > VOLMAXPARTS) {
2743 tst = ADMVOSPARTITIONTOOLARGE;
2744 goto fail_vos_VLDBReadOnlySiteDelete;
2748 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2750 goto fail_vos_VLDBReadOnlySiteDelete;
2754 fail_vos_VLDBReadOnlySiteDelete:
2763 * vos_VLDBSync - synchronize the vldb with the fileserver.
2767 * IN cellHandle - a previously opened cellHandle that corresponds
2768 * to the cell where the sync should occur.
2770 * IN serverHandle - a previously opened serverHandle that corresponds
2771 * to the server where the sync should occur.
2773 * IN callBack - a call back function pointer that may be called to report
2774 * status information. Can be null.
2776 * IN partition - the partition where the sync should occur. Can be null.
2778 * IN force - force deletion of bad volumes.
2782 * No locks are obtained or released by this function
2786 * Returns != 0 upon successful completion.
2790 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2791 vos_MessageCallBack_t callBack, const unsigned int *partition,
2792 vos_force_t force, afs_status_p st)
2795 afs_status_t tst = 0;
2796 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2797 file_server_p f_server = (file_server_p) serverHandle;
2803 * Validate arguments
2806 if (!IsValidCellHandle(c_handle, &tst)) {
2807 goto fail_vos_VLDBSync;
2810 if (!IsValidServerHandle(f_server, &tst)) {
2811 goto fail_vos_VLDBSync;
2814 if (partition != NULL) {
2815 if (*partition > VOLMAXPARTS) {
2816 tst = ADMVOSPARTITIONTOOLARGE;
2817 goto fail_vos_VLDBSync;
2819 part = (afs_int32) * partition;
2823 if (force == VOS_FORCE) {
2831 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2842 * vos_VolumeCreate - create a new partition.
2846 * IN cellHandle - a previously opened cellHandle that corresponds
2847 * to the cell where the server lives.
2849 * IN serverHandle - a previously open vos server handle that holds
2850 * the partition where the volume should be create.
2852 * IN callBack - a call back function pointer that may be called to report
2853 * status information. Can be null.
2855 * IN partition - the integer that represents the partition that will
2856 * house the new volume.
2858 * IN volumeName - the name of the new volume.
2860 * IN quota - the quota of the new volume.
2862 * OUT volumeId - the volume id of the newly created volume.
2866 * No locks are obtained or released by this function
2870 * Returns != 0 upon successful completion.
2874 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2875 vos_MessageCallBack_t callBack, unsigned int partition,
2876 const char *volumeName, unsigned int quota,
2877 unsigned int *volumeId, afs_status_p st)
2880 afs_status_t tst = 0;
2881 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2882 file_server_p f_server = (file_server_p) serverHandle;
2883 vos_partitionEntry_t pinfo;
2884 struct nvldbentry vinfo;
2887 * Validate arguments
2890 if (!IsValidCellHandle(c_handle, &tst)) {
2891 goto fail_vos_VolumeCreate;
2894 if (!IsValidServerHandle(f_server, &tst)) {
2895 goto fail_vos_VolumeCreate;
2898 if (partition > VOLMAXPARTS) {
2899 tst = ADMVOSPARTITIONTOOLARGE;
2900 goto fail_vos_VolumeCreate;
2903 if (!ValidateVolumeName(volumeName, &tst)) {
2904 goto fail_vos_VolumeCreate;
2907 if (volumeId == NULL) {
2908 tst = ADMVOSVOLUMEID;
2909 goto fail_vos_VolumeCreate;
2913 * Check that partition is valid at the server
2916 if (!vos_PartitionGet
2917 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2918 goto fail_vos_VolumeCreate;
2922 * Check that the volume doesn't already exist
2925 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2926 tst = ADMVOSVOLUMENAMEDUP;
2927 goto fail_vos_VolumeCreate;
2931 * Create the new volume
2934 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2935 quota, volumeId, &tst);
2937 fail_vos_VolumeCreate:
2946 * vos_VolumeDelete - remove a volume.
2950 * IN cellHandle - a previously opened cellHandle that corresponds
2951 * to the cell where the volume exists.
2953 * IN serverHandle - a previously opened serverHandle that corresponds
2954 * to the server where the volume exists.
2956 * IN callBack - a call back function pointer that may be called to report
2957 * status information. Can be null.
2959 * IN partition - the partition where the volume exists.
2961 * IN volumeId - the volume id of the volume to be deleted.
2965 * No locks are obtained or released by this function
2969 * Returns != 0 upon successful completion.
2973 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2974 vos_MessageCallBack_t callBack, unsigned int partition,
2975 unsigned int volumeId, afs_status_p st)
2978 afs_status_t tst = 0;
2979 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2980 file_server_p f_server = (file_server_p) serverHandle;
2981 vos_partitionEntry_t pinfo;
2984 * Validate arguments
2987 if (!IsValidCellHandle(c_handle, &tst)) {
2988 goto fail_vos_VolumeDelete;
2991 if (!IsValidServerHandle(f_server, &tst)) {
2992 goto fail_vos_VolumeDelete;
2995 if (partition > VOLMAXPARTS) {
2996 tst = ADMVOSPARTITIONTOOLARGE;
2997 goto fail_vos_VolumeDelete;
3001 * Check that partition is valid at the server
3004 if (!vos_PartitionGet
3005 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
3006 goto fail_vos_VolumeDelete;
3009 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3011 fail_vos_VolumeDelete:
3020 * vos_VolumeRename - rename a volume.
3024 * IN cellHandle - a previously opened cellHandle that corresponds
3025 * to the cell where the volume exists.
3027 * IN serverHandle - a previously opened serverHandle that corresponds
3028 * to the server where the vldb entry exists. Can be null.
3030 * IN callBack - a call back function pointer that may be called to report
3031 * status information. Can be null.
3033 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3035 * IN newVolumeName - the new name.
3039 * No locks are obtained or released by this function
3043 * Returns != 0 upon successful completion.
3047 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3048 unsigned int readWriteVolumeId, const char *newVolumeName,
3052 afs_status_t tst = 0;
3053 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3054 struct nvldbentry entry;
3057 * Validate arguments
3060 if (!IsValidCellHandle(c_handle, &tst)) {
3061 goto fail_vos_VolumeRename;
3064 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3065 tst = ADMVOSNEWVOLUMENAMENULL;
3066 goto fail_vos_VolumeRename;
3070 * Retrieve the entry
3073 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3074 goto fail_vos_VolumeRename;
3077 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3079 fail_vos_VolumeRename:
3088 * vos_VolumeDump - dump a volume
3092 * IN cellHandle - a previously opened cellHandle that corresponds
3093 * to the cell where the volume exists.
3095 * IN serverHandle - a previously opened serverHandle that corresponds
3096 * to the server where the volume exists. Can be null.
3098 * IN callBack - a call back function pointer that may be called to report
3099 * status information. Can be null.
3101 * IN volumeId - the volume id of the volume to be dumped.
3103 * IN startTime - files with modification times >= this time will be dumped.
3105 * IN dumpFile - the file to dump the volume to.
3109 * No locks are obtained or released by this function
3113 * Returns != 0 upon successful completion.
3117 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3118 vos_MessageCallBack_t callBack, unsigned int *partition,
3119 unsigned int volumeId, unsigned int startTime,
3120 const char *dumpFile, afs_status_p st)
3123 afs_status_t tst = 0;
3124 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3125 file_server_p f_server = (file_server_p) serverHandle;
3126 afs_int32 server, part, voltype;
3127 struct nvldbentry entry;
3130 * Validate arguments
3133 if (!IsValidCellHandle(c_handle, &tst)) {
3134 goto fail_vos_VolumeDump;
3137 if (serverHandle != NULL) {
3138 if (!IsValidServerHandle(f_server, &tst)) {
3139 goto fail_vos_VolumeDump;
3144 * You must specify both the serverHandle and the partition
3147 if (serverHandle || partition) {
3148 if (!serverHandle || !partition) {
3149 tst = ADMVOSSERVERANDPARTITION;
3150 goto fail_vos_VolumeDump;
3152 if (*partition > VOLMAXPARTS) {
3153 tst = ADMVOSPARTITIONTOOLARGE;
3154 goto fail_vos_VolumeDump;
3156 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3161 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3162 goto fail_vos_VolumeDump;
3166 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3167 tst = ADMVOSDUMPFILENULL;
3168 goto fail_vos_VolumeDump;
3171 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3174 fail_vos_VolumeDump:
3183 * vos_VolumeRestore - restore a volume from a dump
3187 * IN cellHandle - a previously opened cellHandle that corresponds
3188 * to the cell where the volume exists.
3190 * IN serverHandle - a previously opened serverHandle that corresponds
3191 * to the server where the volume exists.
3193 * IN callBack - a call back function pointer that may be called to report
3194 * status information. Can be null.
3196 * IN partition - the partition where the volume exists.
3198 * IN volumeId - the volume id of the volume to be restored.
3200 * IN volumeName - the volume name of the volume to be restored.
3202 * IN dumpFile - the file from which to restore the volume.
3204 * IN dumpType - the type of dump to perform.
3208 * No locks are obtained or released by this function
3212 * Returns != 0 upon successful completion.
3216 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3217 vos_MessageCallBack_t callBack, unsigned int partition,
3218 unsigned int *volumeId, const char *volumeName,
3219 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3223 afs_status_t tst = 0;
3224 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3225 file_server_p f_server = (file_server_p) serverHandle;
3226 struct nvldbentry entry;
3227 afs_int32 volid, server;
3230 int restoreflags = 0;
3231 afs_int32 Oserver, Opart, Otype;
3232 struct nvldbentry Oentry;
3236 * Validate arguments
3239 if (!IsValidCellHandle(c_handle, &tst)) {
3240 goto fail_vos_VolumeRestore;
3243 if (serverHandle != NULL) {
3244 if (!IsValidServerHandle(f_server, &tst)) {
3245 goto fail_vos_VolumeRestore;
3250 * Must pass volumeName
3253 if ((volumeName == NULL) || (*volumeName == 0)) {
3254 tst = ADMVOSVOLUMENAMENULL;
3255 goto fail_vos_VolumeRestore;
3258 if (!ValidateVolumeName(volumeName, &tst)) {
3259 goto fail_vos_VolumeRestore;
3263 * If volumeId is passed, it must be a valid volume id
3266 if (volumeId != NULL) {
3267 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3268 goto fail_vos_VolumeRestore;
3275 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3277 if (partition > VOLMAXPARTS) {
3278 tst = ADMVOSPARTITIONTOOLARGE;
3279 goto fail_vos_VolumeRestore;
3283 * Check that dumpFile exists and can be accessed
3286 fd = open(dumpFile, 0);
3287 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3289 tst = ADMVOSDUMPFILEOPENFAIL;
3290 goto fail_vos_VolumeRestore;
3295 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3296 restoreflags = RV_FULLRST;
3297 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3298 restoreflags = RV_FULLRST;
3300 volid = entry.volumeId[RWVOL];
3301 } else if ((entry.volumeId[RWVOL] != 0)
3302 && (entry.volumeId[RWVOL] != volid)) {
3303 volid = entry.volumeId[RWVOL];
3308 volid = entry.volumeId[RWVOL];
3309 } else if ((entry.volumeId[RWVOL] != 0)
3310 && (entry.volumeId[RWVOL] != volid)) {
3311 volid = entry.volumeId[RWVOL];
3315 * If the vldb says the same volume exists somewhere else
3316 * the caller must specify a full restore, not an incremental
3319 if (dumpType == VOS_RESTORE_FULL) {
3320 restoreflags = RV_FULLRST;
3324 * Check to see if the volume exists where the caller said
3327 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3328 goto fail_vos_VolumeRestore;
3330 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3331 goto fail_vos_VolumeRestore;
3335 tst = ADMVOSRESTOREVOLEXIST;
3336 goto fail_vos_VolumeRestore;
3341 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3342 restoreflags, dumpFile, &tst);
3344 fail_vos_VolumeRestore:
3353 * vos_VolumeOnline - bring a volume online.
3357 * IN serverHandle - a previously opened serverHandle that corresponds
3358 * to the server where the volume exists.
3360 * IN callBack - a call back function pointer that may be called to report
3361 * status information. Can be null.
3363 * IN partition - the partition where the volume exists.
3365 * IN volumeId - the volume id of the volume to be brought online.
3369 * No locks are obtained or released by this function
3373 * Returns != 0 upon successful completion.
3377 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3378 unsigned int partition, unsigned int volumeId,
3379 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3383 afs_status_t tst = 0;
3384 file_server_p f_server = (file_server_p) serverHandle;
3388 * Validate arguments
3391 if (!IsValidServerHandle(f_server, &tst)) {
3392 goto fail_vos_VolumeOnline;
3395 if (partition > VOLMAXPARTS) {
3396 tst = ADMVOSPARTITIONIDTOOLARGE;
3397 goto fail_vos_VolumeOnline;
3400 if (volumeStatus == VOS_ONLINE_BUSY) {
3404 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3407 fail_vos_VolumeOnline:
3416 * vos_VolumeOffline - take a volume offline.
3420 * IN serverHandle - a previously opened serverHandle that corresponds
3421 * to the server where the volume exists.
3423 * IN callBack - a call back function pointer that may be called to report
3424 * status information. Can be null.
3426 * IN partition - the partition where the volume exists.
3428 * IN volumeId - the volume id of the volume to be taken offline.
3432 * No locks are obtained or released by this function
3436 * Returns != 0 upon successful completion.
3440 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3441 unsigned int partition, unsigned int volumeId,
3445 afs_status_t tst = 0;
3446 file_server_p f_server = (file_server_p) serverHandle;
3449 * Validate arguments
3452 if (!IsValidServerHandle(f_server, &tst)) {
3453 goto fail_vos_VolumeOffline;
3456 if (partition > VOLMAXPARTS) {
3457 tst = ADMVOSPARTITIONIDTOOLARGE;
3458 goto fail_vos_VolumeOffline;
3461 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3462 VTOutOfService, 0, &tst);
3464 fail_vos_VolumeOffline:
3473 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3477 * IN source - the volintXInfo structure to copy.
3479 * OUT dest - the vos_volumeEntry_t to fill
3483 * No locks are obtained or released by this function
3487 * Returns != 0 upon successful completion.
3491 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3495 afs_status_t tst = 0;
3499 * If the volume is not marked OK, all the other fields are invalid
3500 * We take the extra step of blanking out dest here to prevent the
3501 * user from seeing stale data from a previous call
3504 memset(dest, 0, sizeof(dest));
3506 switch (source->status) {
3508 dest->status = VOS_OK;
3511 dest->status = VOS_SALVAGE;
3514 dest->status = VOS_NO_VNODE;
3517 dest->status = VOS_NO_VOL;
3520 dest->status = VOS_VOL_EXISTS;
3523 dest->status = VOS_NO_SERVICE;
3526 dest->status = VOS_OFFLINE;
3529 dest->status = VOS_ONLINE;
3532 dest->status = VOS_DISK_FULL;
3535 dest->status = VOS_OVER_QUOTA;
3538 dest->status = VOS_BUSY;
3541 dest->status = VOS_MOVED;
3546 * Check to see if the entry is marked ok before copying all the
3550 if (dest->status == VOS_OK) {
3551 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3552 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3553 dest->id = source->volid;
3554 if (source->type == 0) {
3555 dest->type = VOS_READ_WRITE_VOLUME;
3556 } else if (source->type == 1) {
3557 dest->type = VOS_READ_ONLY_VOLUME;
3558 } else if (source->type == 2) {
3559 dest->type = VOS_BACKUP_VOLUME;
3561 dest->backupId = source->backupID;
3562 dest->readWriteId = source->parentID;
3563 dest->readOnlyId = source->cloneID;
3564 dest->copyCreationDate = source->copyDate;
3565 dest->creationDate = source->creationDate;
3566 dest->lastAccessDate = source->accessDate;
3567 dest->lastUpdateDate = source->updateDate;
3568 dest->lastBackupDate = source->backupDate;
3569 dest->accessesSinceMidnight = source->dayUse;
3570 dest->fileCount = source->filecount;
3571 dest->maxQuota = source->maxquota;
3572 dest->currentSize = source->size;
3573 if (source->inUse == 1) {
3574 dest->volumeDisposition = VOS_ONLINE;
3576 dest->volumeDisposition = VOS_OFFLINE;
3579 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3580 dest->readStats[i] = source->stat_reads[i];
3581 dest->writeStats[i] = source->stat_writes[i];
3584 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3585 dest->fileAuthorWriteSameNetwork[i] =
3586 source->stat_fileSameAuthor[i];
3587 dest->fileAuthorWriteDifferentNetwork[i] =
3588 source->stat_fileDiffAuthor[i];
3589 dest->dirAuthorWriteSameNetwork[i] =
3590 source->stat_dirSameAuthor[i];
3591 dest->dirAuthorWriteDifferentNetwork[i] =
3592 source->stat_dirDiffAuthor[i];
3605 * vos_VolumeGet - get information about a particular volume.
3609 * IN cellHandle - a previously opened cellHandle that corresponds
3610 * to the cell where the volume exists.
3612 * IN serverHandle - a previously opened serverHandle that corresponds
3613 * to the server where the volume exists.
3615 * IN callBack - a call back function pointer that may be called to report
3616 * status information. Can be null.
3618 * IN partition - the partition where the volume exists.
3620 * IN volumeId - the volume id of the volume to be retrieved.
3622 * OUT volumeP - upon successful completion, contains the information about the
3627 * No locks are obtained or released by this function
3631 * Returns != 0 upon successful completion.
3635 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3636 vos_MessageCallBack_t callBack, unsigned int partition,
3637 unsigned int volumeId, vos_volumeEntry_p volumeP,
3641 afs_status_t tst = 0;
3642 file_server_p f_server = (file_server_p) serverHandle;
3643 struct volintXInfo *info = NULL;
3646 * Validate arguments
3649 if (!IsValidServerHandle(f_server, &tst)) {
3650 goto fail_vos_VolumeGet;
3653 if (partition > VOLMAXPARTS) {
3654 tst = ADMVOSPARTITIONIDTOOLARGE;
3655 goto fail_vos_VolumeGet;
3658 if (volumeP == NULL) {
3659 tst = ADMVOSVOLUMEPNULL;
3660 goto fail_vos_VolumeGet;
3664 * Retrieve the information for the volume
3667 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3668 goto fail_vos_VolumeGet;
3672 * Copy the volume info to our structure
3675 if (!copyvolintXInfo(info, volumeP, &tst)) {
3676 goto fail_vos_VolumeGet;
3693 * The iterator functions and data for the volume retrieval functions.
3696 typedef struct volume_get {
3697 struct volintXInfo *vollist;
3698 afs_int32 total; /* total number of volumes at this partition */
3699 afs_int32 index; /* index to the current volume */
3700 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3701 } volume_get_t, *volume_get_p;
3704 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3705 int *last_item_contains_data, afs_status_p st)
3708 afs_status_t tst = 0;
3709 volume_get_p entry = (volume_get_p) rpc_specific;
3712 * Copy the next entry into the cache
3715 if (!copyvolintXInfo
3716 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3717 goto fail_GetVolumeRPC;
3722 * See if we've processed all the entries
3726 if (entry->index == entry->total) {
3728 *last_item_contains_data = 1;
3741 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3744 afs_status_t tst = 0;
3745 volume_get_p entry = (volume_get_p) rpc_specific;
3747 memcpy(dest, (const void *)&entry->entry[slot],
3748 sizeof(vos_volumeEntry_t));
3759 DestroyVolume(void *rpc_specific, afs_status_p st)
3762 afs_status_t tst = 0;
3763 volume_get_p entry = (volume_get_p) rpc_specific;
3765 if (entry->vollist != NULL) {
3766 free(entry->vollist);
3778 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3782 * IN cellHandle - a previously opened cellHandle that corresponds
3783 * to the cell where the volumes exist.
3785 * IN serverHandle - a handle to the server where the volumes exist.
3787 * IN callBack - a call back function pointer that may be called to report
3788 * status information. Can be null.
3790 * IN partition - the partition whose volumes should be listed. Can be null.
3792 * OUT iterationIdP - upon successful completion, contains an iterator that
3793 * can be passed to vos_VolumeGetBegin.
3797 * No locks are obtained or released by this function
3801 * Returns != 0 upon successful completion.
3805 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3806 vos_MessageCallBack_t callBack, unsigned int partition,
3807 void **iterationIdP, afs_status_p st)
3810 afs_status_t tst = 0;
3811 file_server_p f_server = (file_server_p) serverHandle;
3812 afs_admin_iterator_p iter =
3813 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3814 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3817 * Validate arguments
3820 if (!IsValidServerHandle(f_server, &tst)) {
3821 goto fail_vos_VolumeGetBegin;
3824 if (partition > VOLMAXPARTS) {
3825 tst = ADMVOSPARTITIONIDTOOLARGE;
3826 goto fail_vos_VolumeGetBegin;
3829 if ((iter == NULL) || (entry == NULL)) {
3831 goto fail_vos_VolumeGetBegin;
3835 * Get a list of all the volumes contained in the partition at the
3839 if (!UV_XListVolumes
3840 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3842 goto fail_vos_VolumeGetBegin;
3845 if (entry->total == 0) {
3846 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3847 goto fail_vos_VolumeGetBegin;
3849 iter->done_iterating = 1;
3850 iter->st = ADMITERATORDONE;
3853 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3854 DestroyVolume, &tst)) {
3855 goto fail_vos_VolumeGetBegin;
3858 *iterationIdP = (void *)iter;
3861 fail_vos_VolumeGetBegin:
3867 if (entry != NULL) {
3879 * vos_VolumeGetNext - get information about the next volume.
3883 * IN iterationId - an iterator previously returned by
3884 * vos_VolumeGetBegin
3886 * OUT volumeP - a pointer to a vos_volumeEntry_t
3887 * that upon successful completion contains information about the
3892 * The iterator is locked while the next item is retrieved.
3896 * Returns != 0 upon successful completion.
3900 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3904 afs_status_t tst = 0;
3905 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3908 tst = ADMITERATORNULL;
3909 goto fail_vos_VolumeGetNext;
3912 if (volumeP == NULL) {
3913 tst = ADMVOSVOLUMEPNULL;
3914 goto fail_vos_VolumeGetNext;
3917 rc = IteratorNext(iter, (void *)volumeP, &tst);
3919 fail_vos_VolumeGetNext:
3928 * vos_VolumeGetDone - finish using a volume iterator.
3932 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3936 * The iterator is locked and then destroyed.
3940 * Returns != 0 upon successful completion.
3944 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3947 afs_status_t tst = 0;
3948 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3951 * Validate arguments
3955 tst = ADMITERATORNULL;
3956 goto fail_vos_VolumeGetDone;
3959 rc = IteratorDone(iter, &tst);
3961 fail_vos_VolumeGetDone:
3970 * vos_VolumeMove - move a volume from one server to another.
3974 * IN cellHandle - a previously opened cellHandle that corresponds
3975 * to the cell where the volume exists.
3977 * IN callBack - a call back function pointer that may be called to report
3978 * status information. Can be null.
3980 * IN volumeId - the volume id of the volume to be moved.
3982 * IN fromServer - a previously opened serverHandle that corresponds
3983 * to the server where the volume currently resides.
3985 * IN fromPartition - the partition where the volume currently resides.
3987 * IN toServer - a previously opened serverHandle that corresponds
3988 * to the server where the volume will be moved.
3990 * IN toPartition - the partition where the volume will be moved.
3994 * No locks are obtained or released by this function
3998 * Returns != 0 upon successful completion.
4002 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
4003 unsigned int volumeId, const void *fromServer,
4004 unsigned int fromPartition, const void *toServer,
4005 unsigned int toPartition, afs_status_p st)
4008 afs_status_t tst = 0;
4009 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4010 file_server_p from_server = (file_server_p) fromServer;
4011 file_server_p to_server = (file_server_p) toServer;
4012 afs_int32 from_server_addr =
4013 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4014 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4015 afs_int32 from_partition = fromPartition;
4016 afs_int32 to_partition = toPartition;
4019 * Validate arguments
4022 if (!IsValidCellHandle(c_handle, &tst)) {
4023 goto fail_vos_VolumeMove;
4026 if (!IsValidServerHandle(from_server, &tst)) {
4027 goto fail_vos_VolumeMove;
4030 if (!IsValidServerHandle(to_server, &tst)) {
4031 goto fail_vos_VolumeMove;
4034 if (fromPartition > VOLMAXPARTS) {
4035 tst = ADMVOSPARTITIONIDTOOLARGE;
4036 goto fail_vos_VolumeMove;
4039 if (toPartition > VOLMAXPARTS) {
4040 tst = ADMVOSPARTITIONIDTOOLARGE;
4041 goto fail_vos_VolumeMove;
4048 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4049 to_server_addr, to_partition, &tst);
4051 fail_vos_VolumeMove:
4060 * vos_VolumeRelease - release a volume.
4064 * IN cellHandle - a previously opened cellHandle that corresponds
4065 * to the cell where the volume exists.
4067 * IN callBack - a call back function pointer that may be called to report
4068 * status information. Can be null.
4070 * IN volumeId - the volume to be released.
4072 * IN force - force a complete release.
4076 * No locks are obtained or released by this function
4080 * Returns != 0 upon successful completion.
4084 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4085 unsigned int volumeId, vos_force_t force, afs_status_p st)
4088 afs_status_t tst = 0;
4089 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4090 afs_int32 server, part, forc = 0, voltype, volume;
4091 struct nvldbentry entry;
4094 * Validate arguments
4097 if (!IsValidCellHandle(c_handle, &tst)) {
4098 goto fail_vos_VolumeRelease;
4102 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4103 goto fail_vos_VolumeRelease;
4106 if (force == VOS_FORCE) {
4111 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4113 fail_vos_VolumeRelease:
4122 * vos_VolumeZap - forcibly delete a volume.
4126 * IN cellHandle - a previously opened cellHandle that corresponds
4127 * to the cell where the volume exists.
4129 * IN serverHandle - a previously opened serverHandle that corresponds
4130 * to the server where the volume exists.
4132 * IN callBack - a call back function pointer that may be called to report
4133 * status information. Can be null.
4135 * IN partition - the partition where the volume exists.
4137 * IN volumeId - the volume id of the vldb entry to be deleted.
4139 * IN force - force the deletion of bad volumes.
4143 * No locks are obtained or released by this function
4147 * Returns != 0 upon successful completion.
4151 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4152 vos_MessageCallBack_t callBack, unsigned int partition,
4153 unsigned int volumeId, vos_force_t force, afs_status_p st)
4156 afs_status_t tst = 0;
4157 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4158 file_server_p f_server = (file_server_p) serverHandle;
4161 * Verify that the cellHandle is capable of making vos rpc's
4164 if (!IsValidCellHandle(c_handle, &tst)) {
4165 goto fail_vos_VolumeZap;
4168 if (!IsValidServerHandle(f_server, &tst)) {
4169 goto fail_vos_VolumeZap;
4172 if (force == VOS_FORCE) {
4173 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4176 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4189 * vos_PartitionNameToId - translate a string representing a partition
4194 * IN partitionName - a string representing a partition. Must be of
4197 * OUT partitionId - a number containing the partition id upon successful
4202 * No locks are obtained or released by this function
4206 * Returns != 0 upon successful completion.
4210 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4214 afs_status_t tst = 0;
4215 size_t partition_name_len;
4219 * Validate arguments
4222 if (partitionName == NULL) {
4223 tst = ADMVOSPARTITIONNAMENULL;
4224 goto fail_vos_PartitionNameToId;
4227 if (partitionId == NULL) {
4228 tst = ADMVOSPARTITIONIDNULL;
4229 goto fail_vos_PartitionNameToId;
4233 * Check that string begins with /vicep
4236 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4237 tst = ADMVOSPARTITIONNAMEINVALID;
4238 goto fail_vos_PartitionNameToId;
4242 * Check that the string is either one or two characters
4243 * longer than VICE_PREFIX_SIZE
4246 partition_name_len = strlen(partitionName);
4248 if (partition_name_len == VICE_PREFIX_SIZE) {
4249 tst = ADMVOSPARTITIONNAMETOOSHORT;
4250 goto fail_vos_PartitionNameToId;
4253 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4254 tst = ADMVOSPARTITIONNAMETOOLONG;
4255 goto fail_vos_PartitionNameToId;
4259 * Check that all characters past the prefix are lower case
4262 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4263 if (!islower(partitionName[i])) {
4264 tst = ADMVOSPARTITIONNAMENOTLOWER;
4265 goto fail_vos_PartitionNameToId;
4270 * Convert the name to a number
4273 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4274 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4277 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4278 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4281 if (*partitionId > VOLMAXPARTS) {
4282 tst = ADMVOSPARTITIONIDTOOLARGE;
4283 goto fail_vos_PartitionNameToId;
4287 fail_vos_PartitionNameToId:
4296 * vos_PartitionIdToName - translate a number representing a partition
4297 * to a character string.
4301 * IN partitionId - an integer representing the partition.
4303 * OUT partitionName - a string containing the converted partition ID
4304 * upon successful completion.
4308 * No locks are obtained or released by this function
4312 * Returns != 0 upon successful completion.
4316 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4320 afs_status_t tst = 0;
4322 if (partitionId > VOLMAXPARTS) {
4323 tst = ADMVOSPARTITIONIDTOOLARGE;
4324 goto fail_vos_PartitionIdToName;
4327 if (partitionName == NULL) {
4328 tst = ADMVOSPARTITIONNAMENULL;
4329 goto fail_vos_PartitionIdToName;
4332 if (partitionId < 26) {
4333 strcpy(partitionName, VICE_PARTITION_PREFIX);
4334 partitionName[6] = partitionId + 'a';
4335 partitionName[7] = '\0';
4337 strcpy(partitionName, VICE_PARTITION_PREFIX);
4339 partitionName[6] = 'a' + (partitionId / 26);
4340 partitionName[7] = 'a' + (partitionId % 26);
4341 partitionName[8] = '\0';
4345 fail_vos_PartitionIdToName:
4354 * vos_VolumeQuotaChange - change the quota of a volume.
4358 * IN cellHandle - a previously opened cellHandle that corresponds
4359 * to the cell where the volume exists.
4361 * IN serverHandle - a previously opened serverHandle that corresponds
4362 * to the server where the volume exists.
4364 * IN callBack - a call back function pointer that may be called to report
4365 * status information. Can be null.
4367 * IN partition - the partition where the volume exists.
4369 * IN volumeId - the volume id of the volume to be modified.
4371 * IN volumeQuota - the new volume quota.
4375 * No locks are obtained or released by this function
4379 * Returns != 0 upon successful completion.
4383 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4384 vos_MessageCallBack_t callBack, unsigned int partition,
4385 unsigned int volumeId, unsigned int volumeQuota,
4389 afs_status_t tst = 0;
4390 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4391 file_server_p f_server = (file_server_p) serverHandle;
4394 struct volintInfo tstatus;
4395 int active_trans = 0;
4398 * Verify that the cellHandle is capable of making vos rpc's
4401 if (!IsValidCellHandle(c_handle, &tst)) {
4402 goto fail_vos_VolumeQuotaChange;
4405 if (!IsValidServerHandle(f_server, &tst)) {
4406 goto fail_vos_VolumeQuotaChange;
4409 memset((void *)&tstatus, 0, sizeof(tstatus));
4410 tstatus.dayUse = -1;
4411 tstatus.spare2 = -1;
4412 tstatus.maxquota = volumeQuota;
4416 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4418 goto fail_vos_VolumeQuotaChange;
4422 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4424 goto fail_vos_VolumeQuotaChange;
4428 fail_vos_VolumeQuotaChange:
4431 afs_status_t tst2 = 0;
4432 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4453 * vos_VolumeGet2 - get information about a particular volume.
4457 * IN cellHandle - a previously opened cellHandle that corresponds
4458 * to the cell where the volume exists.
4460 * IN serverHandle - a previously opened serverHandle that corresponds
4461 * to the server where the volume exists.
4463 * IN callBack - a call back function pointer that may be called to report
4464 * status information. Can be null.
4466 * IN partition - the partition where the volume exists.
4468 * IN volumeId - the volume id of the volume to be retrieved.
4470 * OUT pinfo - upon successful completion, contains the information about the
4475 * No locks are obtained or released by this function
4479 * Returns != 0 upon successful completion.
4483 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4484 vos_MessageCallBack_t callBack, unsigned int partition,
4485 unsigned int volumeId, volintInfo* pinfo,
4489 afs_status_t tst = 0;
4490 file_server_p f_server = (file_server_p) serverHandle;
4491 volintInfo *pinfo_=0;
4494 * Validate arguments
4497 if (!IsValidServerHandle(f_server, &tst)) {
4498 goto fail_vos_VolumeGet2;
4501 if (partition > VOLMAXPARTS) {
4502 tst = ADMVOSPARTITIONIDTOOLARGE;
4503 goto fail_vos_VolumeGet2;
4506 if (pinfo == NULL) {
4507 tst = ADMVOSVOLUMEPNULL;
4508 goto fail_vos_VolumeGet2;
4512 * Retrieve the information for the volume
4515 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4516 goto fail_vos_VolumeGet2;
4522 fail_vos_VolumeGet2:
4524 if (pinfo_ != NULL) {
4525 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4536 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4540 * IN cellHandle - a previously opened cellHandle that corresponds
4541 * to the cell where the volume exists.
4543 * IN serverHandle - a previously opened serverHandle that corresponds
4544 * to the server where the volume exists.
4546 * IN partition - the partition where the volume exists.
4548 * IN volumeId - the volume id of the volume to be retrieved.
4552 * No locks are obtained or released by this function
4556 * Returns != 0 upon successful completion.
4560 vos_ClearVolUpdateCounter(const void *cellHandle,
4561 const void *serverHandle,
4562 unsigned int partition,
4563 unsigned int volumeId,
4567 afs_status_t tst = 0;
4568 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4569 file_server_p f_server = (file_server_p) serverHandle;
4572 struct volintInfo tstatus;
4573 int active_trans = 0;
4576 * Verify that the cellHandle is capable of making vos rpc's
4579 if (!IsValidCellHandle(c_handle, &tst)) {
4580 goto fail_vos_ClearVolUpdateCounter;
4583 if (!IsValidServerHandle(f_server, &tst)) {
4584 goto fail_vos_ClearVolUpdateCounter;
4587 memset((void *)&tstatus, 0, sizeof(tstatus));
4588 tstatus.maxquota = -1;
4589 tstatus.dayUse = -1;
4590 tstatus.creationDate = -1;
4591 tstatus.updateDate = -1;
4593 tstatus.spare0 = -1;
4594 tstatus.spare1 = -1;
4596 tstatus.spare3 = -1;
4599 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4601 goto fail_vos_ClearVolUpdateCounter;
4605 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4607 goto fail_vos_ClearVolUpdateCounter;
4611 fail_vos_ClearVolUpdateCounter:
4614 afs_status_t tst2 = 0;
4615 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);