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 extern int VL_GetAddrsU();
51 typedef struct file_server {
54 struct rx_connection *serv;
56 } file_server_t, *file_server_p;
59 * IsValidServerHandle - test a server handle for validity.
63 * IN serverHandle - the serverHandle to be validated.
67 * No locks are obtained or released by this function
71 * Returns != 0 upon successful completion.
75 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
80 if (serverHandle == NULL) {
81 tst = ADMVOSSERVERHANDLENULL;
82 goto fail_IsValidServerHandle;
85 if (serverHandle->is_valid != 1) {
86 tst = ADMVOSSERVERHANDLEINVALID;
87 goto fail_IsValidServerHandle;
90 if ((serverHandle->begin_magic != BEGIN_MAGIC)
91 || (serverHandle->end_magic != END_MAGIC)) {
92 tst = ADMVOSSERVERHANDLEBADMAGIC;
93 goto fail_IsValidServerHandle;
97 fail_IsValidServerHandle:
107 * IsValidCellHandle - verify that a cell handle can be used to make vos
112 * IN cellHandle - the cellHandle to be validated.
116 * No locks are obtained or released by this function
120 * Returns != 0 upon successful completion.
124 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
127 afs_status_t tst = 0;
129 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
130 goto fail_IsValidCellHandle;
133 if (cellHandle->vos_valid == 0) {
134 tst = ADMVOSCELLHANDLEINVALIDVOS;
135 goto fail_IsValidCellHandle;
139 fail_IsValidCellHandle:
147 /* set <server> and <part> to the correct values depending on
148 * <voltype> and <entry> */
150 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
151 afs_int32 * part, int *previdx)
153 int i, istart, vtype;
158 /* Doesn't check for non-existance of backup volume */
159 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
161 istart = 0; /* seach the entire entry */
164 /* Seach from beginning of entry or pick up where we left off */
165 istart = ((*previdx < 0) ? 0 : *previdx + 1);
168 for (i = istart; i < entry->nServers; i++) {
169 if (entry->serverFlags[i] & vtype) {
170 *server = entry->serverNumber[i];
171 *part = entry->serverPartition[i];
177 /* Didn't find any, return -1 */
183 * vos_BackupVolumeCreate - create a backup volume for a volume.
187 * IN cellHandle - a previously opened cellHandle that corresponds
188 * to the cell where volume exists.
190 * IN callBack - a call back function pointer that may be called to report
191 * status information. Can be null.
193 * IN volumeId - the volume to create the back up for.
197 * No locks are obtained or released by this function
201 * Returns != 0 upon successful completion.
205 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
206 unsigned int volumeId, afs_status_p st)
209 afs_status_t tst = 0;
210 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
211 struct nvldbentry rw_vol_entry;
213 afs_int32 rw_partition;
214 afs_int32 rw_vol_type;
215 struct nvldbentry bk_vol_entry;
217 afs_int32 bk_partition;
218 afs_int32 bk_vol_type;
225 if (!IsValidCellHandle(c_handle, &tst)) {
226 goto fail_vos_BackupVolumeCreate;
230 * Get the volume information and verify that we've been passed
231 * a read write volume id
235 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
236 &rw_vol_type, &tst)) {
237 goto fail_vos_BackupVolumeCreate;
240 if (rw_vol_type != RWVOL) {
241 tst = ADMVOSMUSTBERWVOL;
242 goto fail_vos_BackupVolumeCreate;
246 * Check to see that if a backup volume exists, it exists on the
247 * same server as volumeId
250 if (rw_vol_entry.flags & BACK_EXISTS) {
252 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
253 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
254 goto fail_vos_BackupVolumeCreate;
256 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
257 goto fail_vos_BackupVolumeCreate;
260 tst = ADMVOSBACKUPVOLWRONGSERVER;
261 goto fail_vos_BackupVolumeCreate;
266 * Create the new backup volume
269 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
271 fail_vos_BackupVolumeCreate:
280 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
284 * IN cellHandle - a previously opened cellHandle that corresponds
285 * to the cell where the volumes exist.
287 * IN serverHandle - the server where the backups are to be created. Can be
290 * IN callBack - a call back function pointer that may be called to report
291 * status information. Can be null.
293 * IN partition - the partition where the backups are to be created. Can be
296 * IN volumePrefix - all volumes with this prefix will have backup volumes
297 * created. Can be null.
299 * IN excludePrefix - exclude the volumes that match volumePrefix.
303 * No locks are obtained or released by this function
307 * Returns != 0 upon successful completion.
311 vos_BackupVolumeCreateMultiple(const void *cellHandle,
312 const void *serverHandle,
313 vos_MessageCallBack_t callBack,
314 const unsigned int *partition,
315 const char *volumePrefix,
316 vos_exclude_t excludePrefix, afs_status_p st)
319 afs_status_t tst = 0;
320 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
321 file_server_p f_server = (file_server_p) serverHandle;
322 struct VldbListByAttributes attr;
325 size_t prefix_len = 0;
326 nbulkentries arrayEntries;
327 afs_int32 nentries = 0;
328 register struct nvldbentry *entry;
330 afs_int32 rw_volid, rw_server, rw_partition;
335 memset((void *)&attr, 0, sizeof(attr));
340 * The only required argument to this function is the cellHandle.
341 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
345 if (!IsValidCellHandle(c_handle, &tst)) {
346 goto fail_vos_BackupVolumeCreateMultiple;
349 if ((excludePrefix == VOS_EXCLUDE)
350 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
351 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
352 goto fail_vos_BackupVolumeCreateMultiple;
355 if (f_server != NULL) {
356 if (!IsValidServerHandle(f_server, &tst)) {
357 goto fail_vos_BackupVolumeCreateMultiple;
359 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
360 attr.Mask |= VLLIST_SERVER;
363 if (partition != NULL) {
364 if (*partition > VOLMAXPARTS) {
365 tst = ADMVOSPARTITIONTOOLARGE;
366 goto fail_vos_BackupVolumeCreateMultiple;
368 attr.partition = *partition;
369 attr.Mask |= VLLIST_PARTITION;
372 if (excludePrefix == VOS_EXCLUDE) {
376 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
378 prefix_len = strlen(volumePrefix);
381 memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
384 * Get a list of all the volumes in the cell
387 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
388 goto fail_vos_BackupVolumeCreateMultiple;
392 * Cycle through the list of volumes and see if we should create a backup
393 * for each individual volume
396 for (i = 0; i < nentries; i++) {
397 entry = &arrayEntries.nbulkentries_val[i];
400 * Skip entries that don't have a RW volume
403 if (!(entry->flags & RW_EXISTS)) {
404 if (callBack != NULL) {
405 const char *messageText;
406 if (util_AdminErrorCodeTranslate
407 (ADMVOSVOLUMENOREADWRITE, 0, &messageText, &tst)) {
408 sprintf(backbuf, "%s %s", messageText, entry->name);
409 (**callBack) (VOS_VERBOSE_MESSAGE, backbuf);
416 * See if we should skip this entry because of the prefix/exclude
417 * combination we've been passed
422 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
426 if (strncmp(entry->name, volumePrefix, prefix_len)) {
432 rw_volid = entry->volumeId[RWVOL];
433 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
435 if ((rw_server == -1) || (rw_partition == -1)) {
436 if (callBack != NULL) {
437 const char *messageText;
438 if (util_AdminErrorCodeTranslate
439 (ADMVOSVLDBBADENTRY, 0, &messageText, &tst)) {
440 sprintf(backbuf, "%s %s", messageText, entry->name);
441 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
448 * Check that the RW volume is on the same server that we were
452 if (serverHandle != NULL) {
453 if (!VLDB_IsSameAddrs
454 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
455 rw_server, &equal, &tst)) {
456 if (callBack != NULL) {
457 const char *messageText;
458 if (util_AdminErrorCodeTranslate
459 (ADMVOSVLDBBADSERVER, 0, &messageText, &tst)) {
460 sprintf(backbuf, "%s %x %d", messageText,
461 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
463 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
469 if (callBack != NULL) {
470 const char *messageText;
471 if (util_AdminErrorCodeTranslate
472 (ADMVOSVLDBDIFFERENTADDR, 0, &messageText, &tst)) {
473 sprintf(backbuf, "%s %s", messageText, entry->name);
474 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
482 * Check that the RW volume is on the same partition we were
486 if (partition != NULL) {
487 if (*partition != rw_partition) {
496 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid,
500 fail_vos_BackupVolumeCreateMultiple:
502 if (arrayEntries.nbulkentries_val) {
503 free(arrayEntries.nbulkentries_val);
513 * vos_PartitionGet - get information about a single partition.
517 * IN cellHandle - a previously opened cellHandle that corresponds
518 * to the cell where the server lives.
520 * IN serverHandle - a previously open vos server handle that holds
521 * the partition of interest.
523 * IN callBack - a call back function pointer that may be called to report
524 * status information. Can be null.
526 * IN partition - the integer that represents the partition of interest.
528 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
529 * completion contains information regarding the partition.
533 * No locks are obtained or released by this function
537 * Returns != 0 upon successful completion.
541 vos_PartitionGet(const void *cellHandle, const void *serverHandle,
542 vos_MessageCallBack_t callBack, unsigned int partition,
543 vos_partitionEntry_p partitionP, afs_status_p st)
546 afs_status_t tst = 0;
547 struct diskPartition part_info;
548 file_server_p f_server = (file_server_p) serverHandle;
549 char partitionName[10]; /* this rpc requires a character partition name */
555 if (!IsValidServerHandle(f_server, &tst)) {
556 goto fail_vos_PartitionGet;
559 if (partitionP == NULL) {
560 tst = ADMVOSPARTITIONPNULL;
561 goto fail_vos_PartitionGet;
564 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
565 goto fail_vos_PartitionGet;
568 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
570 goto fail_vos_PartitionGet;
572 strcpy(partitionP->name, part_info.name);
573 strcpy(partitionP->deviceName, part_info.devName);
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_Call(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 strcpy(dest->name, source->name);
1886 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1887 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1888 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1889 dest->volumeSites[i].serverFlags = 0;
1891 if (source->serverFlags[i] & NEW_REPSITE) {
1892 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1894 if (source->serverFlags[i] & ITSROVOL) {
1895 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1897 if (source->serverFlags[i] & ITSRWVOL) {
1898 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1900 if (source->serverFlags[i] & ITSBACKVOL) {
1901 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1903 if (source->serverFlags[i] & RO_DONTUSE) {
1904 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1917 * vos_VLDBGet- get a volume's vldb entry.
1921 * IN cellHandle - a previously opened cellHandle that corresponds
1922 * to the cell where the volume entries exist.
1924 * IN callBack - a call back function pointer that may be called to report
1925 * status information. Can be null.
1927 * IN volumeId - the id of the volume to retrieve.
1929 * IN volumeName - the name of the volume to retrieve.
1931 * OUT vldbEntry - upon successful completion, contains the information regarding
1936 * No locks are obtained or released by this function
1940 * Returns != 0 upon successful completion.
1944 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1945 const unsigned int *volumeId, const char *volumeName,
1946 vos_vldbEntry_p vldbEntry, afs_status_p st)
1949 afs_status_t tst = 0;
1950 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1951 struct nvldbentry entry;
1955 * Validate arguments
1958 if (!IsValidCellHandle(c_handle, &tst)) {
1959 goto fail_vos_VLDBGet;
1962 if (vldbEntry == NULL) {
1963 tst = ADMVOSVLDBENTRYNULL;
1964 goto fail_vos_VLDBGet;
1967 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1968 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1969 goto fail_vos_VLDBGet;
1973 * Retrieve the entry
1976 if (!((volumeName == NULL) || (*volumeName == 0))) {
1977 if (!ValidateVolumeName(volumeName, &tst)) {
1978 goto fail_vos_VLDBGet;
1980 if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1981 goto fail_vos_VLDBGet;
1984 if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1985 goto fail_vos_VLDBGet;
1990 * Copy the entry into our structure
1993 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1994 goto fail_vos_VLDBGet;
2007 * The iterator functions and data for the vldb entry retrieval functions.
2010 typedef struct vldb_entry_get {
2011 afs_int32 total; /* total number of vldb entries */
2012 afs_int32 index; /* index to the current vldb entry */
2013 nbulkentries entries; /* the list of entries retrieved */
2014 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2015 } vldb_entry_get_t, *vldb_entry_get_p;
2018 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2019 int *last_item_contains_data, afs_status_p st)
2022 afs_status_t tst = 0;
2023 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2026 * Copy the next entry into the cache
2030 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2032 goto fail_GetVLDBEntryRPC;
2037 * See if we've processed all the entries
2041 if (entry->index == entry->total) {
2043 *last_item_contains_data = 1;
2047 fail_GetVLDBEntryRPC:
2056 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2060 afs_status_t tst = 0;
2061 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2063 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2074 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2077 afs_status_t tst = 0;
2078 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2080 if (entry->entries.nbulkentries_val != NULL) {
2081 free(entry->entries.nbulkentries_val);
2093 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2097 * IN cellHandle - a previously opened cellHandle that corresponds
2098 * to the cell where the volume entries exist.
2100 * IN serverHandle - a handle to the server whose entries should be listed.
2103 * IN callBack - a call back function pointer that may be called to report
2104 * status information. Can be null.
2106 * IN partition - the partition whose entries should be listed.
2109 * OUT iterationIdP - upon successful completion, contains an iterator that
2110 * can be passed to vos_VLDBGetNext.
2114 * No locks are obtained or released by this function
2118 * Returns != 0 upon successful completion.
2122 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2123 vos_MessageCallBack_t callBack, unsigned int *partition,
2124 void **iterationIdP, afs_status_p st)
2127 afs_status_t tst = 0;
2128 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2129 file_server_p f_server = (file_server_p) serverHandle;
2130 afs_admin_iterator_p iter =
2131 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2132 vldb_entry_get_p entry =
2133 (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2134 struct VldbListByAttributes attr;
2137 memset(&attr, 0, sizeof(attr));
2140 * Validate arguments
2143 if (!IsValidCellHandle(c_handle, &tst)) {
2144 goto fail_vos_VLDBGetBegin;
2147 if ((iter == NULL) || (entry == NULL)) {
2149 goto fail_vos_VLDBGetBegin;
2152 if (f_server != NULL) {
2153 if (!IsValidServerHandle(f_server, &tst)) {
2154 goto fail_vos_VLDBGetBegin;
2156 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2157 attr.Mask |= VLLIST_SERVER;
2160 if (partition != NULL) {
2161 if (*partition > VOLMAXPARTS) {
2162 tst = ADMVOSPARTITIONTOOLARGE;
2163 goto fail_vos_VLDBGetBegin;
2165 attr.partition = *partition;
2166 attr.Mask |= VLLIST_PARTITION;
2169 if (!VLDB_ListAttributes
2170 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2171 goto fail_vos_VLDBGetBegin;
2174 if (entry->total <= 0) {
2175 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2176 goto fail_vos_VLDBGetBegin;
2178 iter->done_iterating = 1;
2179 iter->st = ADMITERATORDONE;
2182 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2183 NULL, DestroyVLDBEntry, &tst)) {
2184 goto fail_vos_VLDBGetBegin;
2187 *iterationIdP = (void *)iter;
2190 fail_vos_VLDBGetBegin:
2196 if (entry->entries.nbulkentries_val != NULL) {
2197 free(entry->entries.nbulkentries_val);
2199 if (entry != NULL) {
2211 * vos_VLDBGetNext - get information about the next volume.
2215 * IN iterationId - an iterator previously returned by
2218 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2219 * that upon successful completion contains information about the
2224 * The iterator is locked while the next item is retrieved.
2228 * Returns != 0 upon successful completion.
2232 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2236 afs_status_t tst = 0;
2237 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2240 tst = ADMITERATORNULL;
2241 goto fail_vos_VLDBGetNext;
2244 if (vldbEntry == NULL) {
2245 tst = ADMVOSVLDBENTRYNULL;
2246 goto fail_vos_VLDBGetNext;
2249 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2251 fail_vos_VLDBGetNext:
2260 * vos_VLDBGetDone - finish using a volume iterator.
2264 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2268 * The iterator is locked and then destroyed.
2272 * Returns != 0 upon successful completion.
2276 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2279 afs_status_t tst = 0;
2280 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2283 * Validate arguments
2287 tst = ADMITERATORNULL;
2288 goto fail_vos_VLDBGetDone;
2291 rc = IteratorDone(iter, &tst);
2293 fail_vos_VLDBGetDone:
2302 * vos_VLDBEntryRemove - remove a vldb entry.
2306 * IN cellHandle - a previously opened cellHandle that corresponds
2307 * to the cell where the vldb entry exists.
2309 * IN serverHandle - a previously opened serverHandle that corresponds
2310 * to the server where the vldb entry exists. Can be null.
2312 * IN callBack - a call back function pointer that may be called to report
2313 * status information. Can be null.
2315 * IN partition - the partition where the vldb entry exists. Can be null.
2317 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2321 * No locks are obtained or released by this function
2325 * Returns != 0 upon successful completion.
2329 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2330 vos_MessageCallBack_t callBack,
2331 const unsigned int *partition, unsigned int *volumeId,
2335 afs_status_t tst = 0;
2336 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2337 file_server_p f_server = (file_server_p) serverHandle;
2338 struct VldbListByAttributes attr;
2339 nbulkentries entries;
2343 memset(&attr, 0, sizeof(attr));
2344 memset(&entries, 0, sizeof(entries));
2347 * Validate arguments
2350 if (!IsValidCellHandle(c_handle, &tst)) {
2351 goto fail_vos_VLDBEntryRemove;
2355 * If the volume is specified, just delete it
2358 if (volumeId != NULL) {
2359 tst = ubik_Call(VL_DeleteEntry, c_handle->vos, 0, *volumeId, -1);
2361 goto fail_vos_VLDBEntryRemove;
2365 if (f_server != NULL) {
2366 if (!IsValidServerHandle(f_server, &tst)) {
2367 goto fail_vos_VLDBEntryRemove;
2369 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2370 attr.Mask |= VLLIST_SERVER;
2373 if (partition != NULL) {
2374 if (*partition > VOLMAXPARTS) {
2375 tst = ADMVOSPARTITIONTOOLARGE;
2376 goto fail_vos_VLDBEntryRemove;
2378 attr.partition = *partition;
2379 attr.Mask |= VLLIST_PARTITION;
2382 if ((f_server == NULL) && (partition == NULL)) {
2383 tst = ADMVOSVLDBDELETEALLNULL;
2384 goto fail_vos_VLDBEntryRemove;
2387 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2388 goto fail_vos_VLDBEntryRemove;
2391 if (nentries <= 0) {
2392 tst = ADMVOSVLDBNOENTRIES;
2393 goto fail_vos_VLDBEntryRemove;
2396 for (i = 0; i < nentries; i++) {
2397 ubik_Call(VL_DeleteEntry, c_handle->vos, 0,
2398 entries.nbulkentries_val[i].volumeId[RWVOL]);
2402 fail_vos_VLDBEntryRemove:
2404 if (entries.nbulkentries_val) {
2405 free(entries.nbulkentries_val);
2415 * vos_VLDBUnlock - unlock vldb entries en masse.
2419 * IN cellHandle - a previously opened cellHandle that corresponds
2420 * to the cell where the vldb entries exist.
2422 * IN serverHandle - a previously opened serverHandle that corresponds
2423 * to the server where the vldb entries exist. Can be null.
2425 * IN callBack - a call back function pointer that may be called to report
2426 * status information. Can be null.
2428 * IN partition - the partition where the vldb entries exist. Can be null.
2432 * No locks are obtained or released by this function
2436 * Returns != 0 upon successful completion.
2440 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2441 vos_MessageCallBack_t callBack, const unsigned int *partition,
2445 afs_status_t tst = 0;
2446 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2447 file_server_p f_server = (file_server_p) serverHandle;
2448 struct VldbListByAttributes attr;
2449 nbulkentries entries;
2453 memset(&attr, 0, sizeof(attr));
2454 memset(&entries, 0, sizeof(entries));
2457 * Validate arguments
2460 if (!IsValidCellHandle(c_handle, &tst)) {
2461 goto fail_vos_VLDBUnlock;
2464 if (f_server != NULL) {
2465 if (!IsValidServerHandle(f_server, &tst)) {
2466 goto fail_vos_VLDBUnlock;
2468 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2469 attr.Mask |= VLLIST_SERVER;
2472 if (partition != NULL) {
2473 if (*partition > VOLMAXPARTS) {
2474 tst = ADMVOSPARTITIONTOOLARGE;
2475 goto fail_vos_VLDBUnlock;
2477 attr.partition = *partition;
2478 attr.Mask |= VLLIST_PARTITION;
2480 attr.flag = VLOP_ALLOPERS;
2481 attr.Mask |= VLLIST_FLAG;
2484 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2485 goto fail_vos_VLDBUnlock;
2488 if (nentries <= 0) {
2489 tst = ADMVOSVLDBNOENTRIES;
2490 goto fail_vos_VLDBUnlock;
2493 for (i = 0; i < nentries; i++) {
2494 vos_VLDBEntryUnlock(cellHandle, 0,
2495 entries.nbulkentries_val[i].volumeId[RWVOL],
2500 fail_vos_VLDBUnlock:
2502 if (entries.nbulkentries_val) {
2503 free(entries.nbulkentries_val);
2514 * vos_VLDBEntryLock - lock a vldb entry.
2518 * IN cellHandle - a previously opened cellHandle that corresponds
2519 * to the cell where the vldb entry exists.
2521 * IN callBack - a call back function pointer that may be called to report
2522 * status information. Can be null.
2524 * IN volumeId - the volume id of the vldb entry to be deleted.
2528 * No locks are obtained or released by this function
2532 * Returns != 0 upon successful completion.
2536 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2537 unsigned int volumeId, afs_status_p st)
2540 afs_status_t tst = 0;
2541 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2544 * Validate arguments
2547 if (!IsValidCellHandle(c_handle, &tst)) {
2548 goto fail_vos_VLDBEntryLock;
2551 tst = ubik_Call(VL_SetLock, c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2553 goto fail_vos_VLDBEntryLock;
2557 fail_vos_VLDBEntryLock:
2566 * vos_VLDBEntryUnlock - unlock a vldb entry.
2570 * IN cellHandle - a previously opened cellHandle that corresponds
2571 * to the cell where the vldb entry exists.
2573 * IN callBack - a call back function pointer that may be called to report
2574 * status information. Can be null.
2576 * IN volumeId - the volume id of the vldb entry to be unlocked.
2580 * No locks are obtained or released by this function
2584 * Returns != 0 upon successful completion.
2588 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2589 unsigned int volumeId, afs_status_p st)
2592 afs_status_t tst = 0;
2593 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2596 * Validate arguments
2599 if (!IsValidCellHandle(c_handle, &tst)) {
2600 goto fail_vos_VLDBEntryUnlock;
2605 ubik_Call(VL_ReleaseLock, c_handle->vos, 0, volumeId, -1,
2606 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2608 goto fail_vos_VLDBEntryUnlock;
2612 fail_vos_VLDBEntryUnlock:
2621 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2625 * IN cellHandle - a previously opened cellHandle that corresponds
2626 * to the cell where the volume exists.
2628 * IN serverHandle - a previously opened serverHandle that corresponds
2629 * to the server where the new volume should be created.
2631 * IN callBack - a call back function pointer that may be called to report
2632 * status information. Can be null.
2634 * IN partition - the partition where then new volume should be created.
2636 * IN volumeId - the volume id of the volume to be replicated.
2640 * No locks are obtained or released by this function
2644 * Returns != 0 upon successful completion.
2648 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2649 vos_MessageCallBack_t callBack,
2650 unsigned int partition, unsigned int volumeId,
2654 afs_status_t tst = 0;
2655 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2656 file_server_p f_server = (file_server_p) serverHandle;
2659 * Validate arguments
2662 if (!IsValidCellHandle(c_handle, &tst)) {
2663 goto fail_vos_VLDBReadOnlySiteCreate;
2666 if (!IsValidServerHandle(f_server, &tst)) {
2667 goto fail_vos_VLDBReadOnlySiteCreate;
2670 if (partition > VOLMAXPARTS) {
2671 tst = ADMVOSPARTITIONTOOLARGE;
2672 goto fail_vos_VLDBReadOnlySiteCreate;
2676 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2678 goto fail_vos_VLDBReadOnlySiteCreate;
2682 fail_vos_VLDBReadOnlySiteCreate:
2691 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2696 * IN cellHandle - a previously opened cellHandle that corresponds
2697 * to the cell where the volume exists.
2699 * IN serverHandle - a previously opened serverHandle that corresponds
2700 * to the server where the volume should be deleted.
2702 * IN callBack - a call back function pointer that may be called to report
2703 * status information. Can be null.
2705 * IN partition - the partition where then volume should be deleted.
2707 * IN volumeId - the volume id of the volume to be deleted.
2711 * No locks are obtained or released by this function
2715 * Returns != 0 upon successful completion.
2719 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2720 vos_MessageCallBack_t callBack,
2721 unsigned int partition, unsigned int volumeId,
2725 afs_status_t tst = 0;
2726 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2727 file_server_p f_server = (file_server_p) serverHandle;
2730 * Validate arguments
2733 if (!IsValidCellHandle(c_handle, &tst)) {
2734 goto fail_vos_VLDBReadOnlySiteDelete;
2737 if (!IsValidServerHandle(f_server, &tst)) {
2738 goto fail_vos_VLDBReadOnlySiteDelete;
2741 if (partition > VOLMAXPARTS) {
2742 tst = ADMVOSPARTITIONTOOLARGE;
2743 goto fail_vos_VLDBReadOnlySiteDelete;
2747 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2749 goto fail_vos_VLDBReadOnlySiteDelete;
2753 fail_vos_VLDBReadOnlySiteDelete:
2762 * vos_VLDBSync - synchronize the vldb with the fileserver.
2766 * IN cellHandle - a previously opened cellHandle that corresponds
2767 * to the cell where the sync should occur.
2769 * IN serverHandle - a previously opened serverHandle that corresponds
2770 * to the server where the sync should occur.
2772 * IN callBack - a call back function pointer that may be called to report
2773 * status information. Can be null.
2775 * IN partition - the partition where the sync should occur. Can be null.
2777 * IN force - force deletion of bad volumes.
2781 * No locks are obtained or released by this function
2785 * Returns != 0 upon successful completion.
2789 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2790 vos_MessageCallBack_t callBack, const unsigned int *partition,
2791 vos_force_t force, afs_status_p st)
2794 afs_status_t tst = 0;
2795 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2796 file_server_p f_server = (file_server_p) serverHandle;
2802 * Validate arguments
2805 if (!IsValidCellHandle(c_handle, &tst)) {
2806 goto fail_vos_VLDBSync;
2809 if (!IsValidServerHandle(f_server, &tst)) {
2810 goto fail_vos_VLDBSync;
2813 if (partition != NULL) {
2814 if (*partition > VOLMAXPARTS) {
2815 tst = ADMVOSPARTITIONTOOLARGE;
2816 goto fail_vos_VLDBSync;
2818 part = (afs_int32) * partition;
2822 if (force == VOS_FORCE) {
2830 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2841 * vos_VolumeCreate - create a new partition.
2845 * IN cellHandle - a previously opened cellHandle that corresponds
2846 * to the cell where the server lives.
2848 * IN serverHandle - a previously open vos server handle that holds
2849 * the partition where the volume should be create.
2851 * IN callBack - a call back function pointer that may be called to report
2852 * status information. Can be null.
2854 * IN partition - the integer that represents the partition that will
2855 * house the new volume.
2857 * IN volumeName - the name of the new volume.
2859 * IN quota - the quota of the new volume.
2861 * OUT volumeId - the volume id of the newly created volume.
2865 * No locks are obtained or released by this function
2869 * Returns != 0 upon successful completion.
2873 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2874 vos_MessageCallBack_t callBack, unsigned int partition,
2875 const char *volumeName, unsigned int quota,
2876 unsigned int *volumeId, afs_status_p st)
2879 afs_status_t tst = 0;
2880 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2881 file_server_p f_server = (file_server_p) serverHandle;
2882 vos_partitionEntry_t pinfo;
2883 struct nvldbentry vinfo;
2886 * Validate arguments
2889 if (!IsValidCellHandle(c_handle, &tst)) {
2890 goto fail_vos_VolumeCreate;
2893 if (!IsValidServerHandle(f_server, &tst)) {
2894 goto fail_vos_VolumeCreate;
2897 if (partition > VOLMAXPARTS) {
2898 tst = ADMVOSPARTITIONTOOLARGE;
2899 goto fail_vos_VolumeCreate;
2902 if (!ValidateVolumeName(volumeName, &tst)) {
2903 goto fail_vos_VolumeCreate;
2906 if (volumeId == NULL) {
2907 tst = ADMVOSVOLUMEID;
2908 goto fail_vos_VolumeCreate;
2912 * Check that partition is valid at the server
2915 if (!vos_PartitionGet
2916 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2917 goto fail_vos_VolumeCreate;
2921 * Check that the volume doesn't already exist
2924 if (VLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2925 tst = ADMVOSVOLUMENAMEDUP;
2926 goto fail_vos_VolumeCreate;
2930 * Create the new volume
2933 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2934 quota, volumeId, &tst);
2936 fail_vos_VolumeCreate:
2945 * vos_VolumeDelete - remove a volume.
2949 * IN cellHandle - a previously opened cellHandle that corresponds
2950 * to the cell where the volume exists.
2952 * IN serverHandle - a previously opened serverHandle that corresponds
2953 * to the server where the volume exists.
2955 * IN callBack - a call back function pointer that may be called to report
2956 * status information. Can be null.
2958 * IN partition - the partition where the volume exists.
2960 * IN volumeId - the volume id of the volume to be deleted.
2964 * No locks are obtained or released by this function
2968 * Returns != 0 upon successful completion.
2972 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2973 vos_MessageCallBack_t callBack, unsigned int partition,
2974 unsigned int volumeId, afs_status_p st)
2977 afs_status_t tst = 0;
2978 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2979 file_server_p f_server = (file_server_p) serverHandle;
2980 vos_partitionEntry_t pinfo;
2983 * Validate arguments
2986 if (!IsValidCellHandle(c_handle, &tst)) {
2987 goto fail_vos_VolumeDelete;
2990 if (!IsValidServerHandle(f_server, &tst)) {
2991 goto fail_vos_VolumeDelete;
2994 if (partition > VOLMAXPARTS) {
2995 tst = ADMVOSPARTITIONTOOLARGE;
2996 goto fail_vos_VolumeDelete;
3000 * Check that partition is valid at the server
3003 if (!vos_PartitionGet
3004 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
3005 goto fail_vos_VolumeDelete;
3008 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3010 fail_vos_VolumeDelete:
3019 * vos_VolumeRename - rename a volume.
3023 * IN cellHandle - a previously opened cellHandle that corresponds
3024 * to the cell where the volume exists.
3026 * IN serverHandle - a previously opened serverHandle that corresponds
3027 * to the server where the vldb entry exists. Can be null.
3029 * IN callBack - a call back function pointer that may be called to report
3030 * status information. Can be null.
3032 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3034 * IN newVolumeName - the new name.
3038 * No locks are obtained or released by this function
3042 * Returns != 0 upon successful completion.
3046 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3047 unsigned int readWriteVolumeId, const char *newVolumeName,
3051 afs_status_t tst = 0;
3052 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3053 struct nvldbentry entry;
3056 * Validate arguments
3059 if (!IsValidCellHandle(c_handle, &tst)) {
3060 goto fail_vos_VolumeRename;
3063 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3064 tst = ADMVOSNEWVOLUMENAMENULL;
3065 goto fail_vos_VolumeRename;
3069 * Retrieve the entry
3072 if (!VLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3073 goto fail_vos_VolumeRename;
3076 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3078 fail_vos_VolumeRename:
3087 * vos_VolumeDump - dump a volume
3091 * IN cellHandle - a previously opened cellHandle that corresponds
3092 * to the cell where the volume exists.
3094 * IN serverHandle - a previously opened serverHandle that corresponds
3095 * to the server where the volume exists. Can be null.
3097 * IN callBack - a call back function pointer that may be called to report
3098 * status information. Can be null.
3100 * IN volumeId - the volume id of the volume to be dumped.
3102 * IN startTime - files with modification times >= this time will be dumped.
3104 * IN dumpFile - the file to dump the volume to.
3108 * No locks are obtained or released by this function
3112 * Returns != 0 upon successful completion.
3116 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3117 vos_MessageCallBack_t callBack, unsigned int *partition,
3118 unsigned int volumeId, unsigned int startTime,
3119 const char *dumpFile, afs_status_p st)
3122 afs_status_t tst = 0;
3123 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3124 file_server_p f_server = (file_server_p) serverHandle;
3125 afs_int32 server, part, voltype;
3126 struct nvldbentry entry;
3129 * Validate arguments
3132 if (!IsValidCellHandle(c_handle, &tst)) {
3133 goto fail_vos_VolumeDump;
3136 if (serverHandle != NULL) {
3137 if (!IsValidServerHandle(f_server, &tst)) {
3138 goto fail_vos_VolumeDump;
3143 * You must specify both the serverHandle and the partition
3146 if (serverHandle || partition) {
3147 if (!serverHandle || !partition) {
3148 tst = ADMVOSSERVERANDPARTITION;
3149 goto fail_vos_VolumeDump;
3151 if (*partition > VOLMAXPARTS) {
3152 tst = ADMVOSPARTITIONTOOLARGE;
3153 goto fail_vos_VolumeDump;
3155 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3160 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3161 goto fail_vos_VolumeDump;
3165 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3166 tst = ADMVOSDUMPFILENULL;
3167 goto fail_vos_VolumeDump;
3170 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3173 fail_vos_VolumeDump:
3182 * vos_VolumeRestore - restore a volume from a dump
3186 * IN cellHandle - a previously opened cellHandle that corresponds
3187 * to the cell where the volume exists.
3189 * IN serverHandle - a previously opened serverHandle that corresponds
3190 * to the server where the volume exists.
3192 * IN callBack - a call back function pointer that may be called to report
3193 * status information. Can be null.
3195 * IN partition - the partition where the volume exists.
3197 * IN volumeId - the volume id of the volume to be restored.
3199 * IN volumeName - the volume name of the volume to be restored.
3201 * IN dumpFile - the file from which to restore the volume.
3203 * IN dumpType - the type of dump to perform.
3207 * No locks are obtained or released by this function
3211 * Returns != 0 upon successful completion.
3215 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3216 vos_MessageCallBack_t callBack, unsigned int partition,
3217 unsigned int *volumeId, const char *volumeName,
3218 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3222 afs_status_t tst = 0;
3223 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3224 file_server_p f_server = (file_server_p) serverHandle;
3225 struct nvldbentry entry;
3226 afs_int32 volid, server;
3229 int restoreflags = 0;
3230 afs_int32 Oserver, Opart, Otype;
3231 struct nvldbentry Oentry;
3235 * Validate arguments
3238 if (!IsValidCellHandle(c_handle, &tst)) {
3239 goto fail_vos_VolumeRestore;
3242 if (serverHandle != NULL) {
3243 if (!IsValidServerHandle(f_server, &tst)) {
3244 goto fail_vos_VolumeRestore;
3249 * Must pass volumeName
3252 if ((volumeName == NULL) || (*volumeName == 0)) {
3253 tst = ADMVOSVOLUMENAMENULL;
3254 goto fail_vos_VolumeRestore;
3257 if (!ValidateVolumeName(volumeName, &tst)) {
3258 goto fail_vos_VolumeRestore;
3262 * If volumeId is passed, it must be a valid volume id
3265 if (volumeId != NULL) {
3266 if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3267 goto fail_vos_VolumeRestore;
3274 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3276 if (partition > VOLMAXPARTS) {
3277 tst = ADMVOSPARTITIONTOOLARGE;
3278 goto fail_vos_VolumeRestore;
3282 * Check that dumpFile exists and can be accessed
3285 fd = open(dumpFile, 0);
3286 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3288 tst = ADMVOSDUMPFILEOPENFAIL;
3289 goto fail_vos_VolumeRestore;
3294 if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3295 restoreflags = RV_FULLRST;
3296 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3297 restoreflags = RV_FULLRST;
3299 volid = entry.volumeId[RWVOL];
3300 } else if ((entry.volumeId[RWVOL] != 0)
3301 && (entry.volumeId[RWVOL] != volid)) {
3302 volid = entry.volumeId[RWVOL];
3307 volid = entry.volumeId[RWVOL];
3308 } else if ((entry.volumeId[RWVOL] != 0)
3309 && (entry.volumeId[RWVOL] != volid)) {
3310 volid = entry.volumeId[RWVOL];
3314 * If the vldb says the same volume exists somewhere else
3315 * the caller must specify a full restore, not an incremental
3318 if (dumpType == VOS_RESTORE_FULL) {
3319 restoreflags = RV_FULLRST;
3323 * Check to see if the volume exists where the caller said
3326 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3327 goto fail_vos_VolumeRestore;
3329 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3330 goto fail_vos_VolumeRestore;
3334 tst = ADMVOSRESTOREVOLEXIST;
3335 goto fail_vos_VolumeRestore;
3340 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3341 restoreflags, dumpFile, &tst);
3343 fail_vos_VolumeRestore:
3352 * vos_VolumeOnline - bring a volume online.
3356 * IN serverHandle - a previously opened serverHandle that corresponds
3357 * to the server where the volume exists.
3359 * IN callBack - a call back function pointer that may be called to report
3360 * status information. Can be null.
3362 * IN partition - the partition where the volume exists.
3364 * IN volumeId - the volume id of the volume to be brought online.
3368 * No locks are obtained or released by this function
3372 * Returns != 0 upon successful completion.
3376 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3377 unsigned int partition, unsigned int volumeId,
3378 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3382 afs_status_t tst = 0;
3383 file_server_p f_server = (file_server_p) serverHandle;
3387 * Validate arguments
3390 if (!IsValidServerHandle(f_server, &tst)) {
3391 goto fail_vos_VolumeOnline;
3394 if (partition > VOLMAXPARTS) {
3395 tst = ADMVOSPARTITIONIDTOOLARGE;
3396 goto fail_vos_VolumeOnline;
3399 if (volumeStatus == VOS_ONLINE_BUSY) {
3403 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3406 fail_vos_VolumeOnline:
3415 * vos_VolumeOffline - take a volume offline.
3419 * IN serverHandle - a previously opened serverHandle that corresponds
3420 * to the server where the volume exists.
3422 * IN callBack - a call back function pointer that may be called to report
3423 * status information. Can be null.
3425 * IN partition - the partition where the volume exists.
3427 * IN volumeId - the volume id of the volume to be taken offline.
3431 * No locks are obtained or released by this function
3435 * Returns != 0 upon successful completion.
3439 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3440 unsigned int partition, unsigned int volumeId,
3444 afs_status_t tst = 0;
3445 file_server_p f_server = (file_server_p) serverHandle;
3448 * Validate arguments
3451 if (!IsValidServerHandle(f_server, &tst)) {
3452 goto fail_vos_VolumeOffline;
3455 if (partition > VOLMAXPARTS) {
3456 tst = ADMVOSPARTITIONIDTOOLARGE;
3457 goto fail_vos_VolumeOffline;
3460 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3461 VTOutOfService, 0, &tst);
3463 fail_vos_VolumeOffline:
3472 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3476 * IN source - the volintXInfo structure to copy.
3478 * OUT dest - the vos_volumeEntry_t to fill
3482 * No locks are obtained or released by this function
3486 * Returns != 0 upon successful completion.
3490 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3494 afs_status_t tst = 0;
3498 * If the volume is not marked OK, all the other fields are invalid
3499 * We take the extra step of blanking out dest here to prevent the
3500 * user from seeing stale data from a previous call
3503 memset(dest, 0, sizeof(dest));
3505 switch (source->status) {
3507 dest->status = VOS_OK;
3510 dest->status = VOS_SALVAGE;
3513 dest->status = VOS_NO_VNODE;
3516 dest->status = VOS_NO_VOL;
3519 dest->status = VOS_VOL_EXISTS;
3522 dest->status = VOS_NO_SERVICE;
3525 dest->status = VOS_OFFLINE;
3528 dest->status = VOS_ONLINE;
3531 dest->status = VOS_DISK_FULL;
3534 dest->status = VOS_OVER_QUOTA;
3537 dest->status = VOS_BUSY;
3540 dest->status = VOS_MOVED;
3545 * Check to see if the entry is marked ok before copying all the
3549 if (dest->status == VOS_OK) {
3550 strcpy(dest->name, source->name);
3551 dest->id = source->volid;
3552 if (source->type == 0) {
3553 dest->type = VOS_READ_WRITE_VOLUME;
3554 } else if (source->type == 1) {
3555 dest->type = VOS_READ_ONLY_VOLUME;
3556 } else if (source->type == 2) {
3557 dest->type = VOS_BACKUP_VOLUME;
3559 dest->backupId = source->backupID;
3560 dest->readWriteId = source->parentID;
3561 dest->readOnlyId = source->cloneID;
3562 dest->copyCreationDate = source->copyDate;
3563 dest->creationDate = source->creationDate;
3564 dest->lastAccessDate = source->accessDate;
3565 dest->lastUpdateDate = source->updateDate;
3566 dest->lastBackupDate = source->backupDate;
3567 dest->accessesSinceMidnight = source->dayUse;
3568 dest->fileCount = source->filecount;
3569 dest->maxQuota = source->maxquota;
3570 dest->currentSize = source->size;
3571 if (source->inUse == 1) {
3572 dest->volumeDisposition = VOS_ONLINE;
3574 dest->volumeDisposition = VOS_OFFLINE;
3577 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3578 dest->readStats[i] = source->stat_reads[i];
3579 dest->writeStats[i] = source->stat_writes[i];
3582 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3583 dest->fileAuthorWriteSameNetwork[i] =
3584 source->stat_fileSameAuthor[i];
3585 dest->fileAuthorWriteDifferentNetwork[i] =
3586 source->stat_fileDiffAuthor[i];
3587 dest->dirAuthorWriteSameNetwork[i] =
3588 source->stat_dirSameAuthor[i];
3589 dest->dirAuthorWriteDifferentNetwork[i] =
3590 source->stat_dirDiffAuthor[i];
3603 * vos_VolumeGet - get information about a particular volume.
3607 * IN cellHandle - a previously opened cellHandle that corresponds
3608 * to the cell where the volume exists.
3610 * IN serverHandle - a previously opened serverHandle that corresponds
3611 * to the server where the volume exists.
3613 * IN callBack - a call back function pointer that may be called to report
3614 * status information. Can be null.
3616 * IN partition - the partition where the volume exists.
3618 * IN volumeId - the volume id of the volume to be retrieved.
3620 * OUT volumeP - upon successful completion, contains the information about the
3625 * No locks are obtained or released by this function
3629 * Returns != 0 upon successful completion.
3633 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3634 vos_MessageCallBack_t callBack, unsigned int partition,
3635 unsigned int volumeId, vos_volumeEntry_p volumeP,
3639 afs_status_t tst = 0;
3640 file_server_p f_server = (file_server_p) serverHandle;
3641 struct volintXInfo *info = NULL;
3644 * Validate arguments
3647 if (!IsValidServerHandle(f_server, &tst)) {
3648 goto fail_vos_VolumeGet;
3651 if (partition > VOLMAXPARTS) {
3652 tst = ADMVOSPARTITIONIDTOOLARGE;
3653 goto fail_vos_VolumeGet;
3656 if (volumeP == NULL) {
3657 tst = ADMVOSVOLUMEPNULL;
3658 goto fail_vos_VolumeGet;
3662 * Retrieve the information for the volume
3665 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3666 goto fail_vos_VolumeGet;
3670 * Copy the volume info to our structure
3673 if (!copyvolintXInfo(info, volumeP, &tst)) {
3674 goto fail_vos_VolumeGet;
3691 * The iterator functions and data for the volume retrieval functions.
3694 typedef struct volume_get {
3695 struct volintXInfo *vollist;
3696 afs_int32 total; /* total number of volumes at this partition */
3697 afs_int32 index; /* index to the current volume */
3698 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3699 } volume_get_t, *volume_get_p;
3702 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3703 int *last_item_contains_data, afs_status_p st)
3706 afs_status_t tst = 0;
3707 volume_get_p entry = (volume_get_p) rpc_specific;
3710 * Copy the next entry into the cache
3713 if (!copyvolintXInfo
3714 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3715 goto fail_GetVolumeRPC;
3720 * See if we've processed all the entries
3724 if (entry->index == entry->total) {
3726 *last_item_contains_data = 1;
3739 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3742 afs_status_t tst = 0;
3743 volume_get_p entry = (volume_get_p) rpc_specific;
3745 memcpy(dest, (const void *)&entry->entry[slot],
3746 sizeof(vos_volumeEntry_t));
3757 DestroyVolume(void *rpc_specific, afs_status_p st)
3760 afs_status_t tst = 0;
3761 volume_get_p entry = (volume_get_p) rpc_specific;
3763 if (entry->vollist != NULL) {
3764 free(entry->vollist);
3776 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3780 * IN cellHandle - a previously opened cellHandle that corresponds
3781 * to the cell where the volumes exist.
3783 * IN serverHandle - a handle to the server where the volumes exist.
3785 * IN callBack - a call back function pointer that may be called to report
3786 * status information. Can be null.
3788 * IN partition - the partition whose volumes should be listed. Can be null.
3790 * OUT iterationIdP - upon successful completion, contains an iterator that
3791 * can be passed to vos_VolumeGetBegin.
3795 * No locks are obtained or released by this function
3799 * Returns != 0 upon successful completion.
3803 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3804 vos_MessageCallBack_t callBack, unsigned int partition,
3805 void **iterationIdP, afs_status_p st)
3808 afs_status_t tst = 0;
3809 file_server_p f_server = (file_server_p) serverHandle;
3810 afs_admin_iterator_p iter =
3811 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3812 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3815 * Validate arguments
3818 if (!IsValidServerHandle(f_server, &tst)) {
3819 goto fail_vos_VolumeGetBegin;
3822 if (partition > VOLMAXPARTS) {
3823 tst = ADMVOSPARTITIONIDTOOLARGE;
3824 goto fail_vos_VolumeGetBegin;
3827 if ((iter == NULL) || (entry == NULL)) {
3829 goto fail_vos_VolumeGetBegin;
3833 * Get a list of all the volumes contained in the partition at the
3837 if (!UV_XListVolumes
3838 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3840 goto fail_vos_VolumeGetBegin;
3843 if (entry->total == 0) {
3844 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3845 goto fail_vos_VolumeGetBegin;
3847 iter->done_iterating = 1;
3848 iter->st = ADMITERATORDONE;
3851 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3852 DestroyVolume, &tst)) {
3853 goto fail_vos_VolumeGetBegin;
3856 *iterationIdP = (void *)iter;
3859 fail_vos_VolumeGetBegin:
3865 if (entry != NULL) {
3877 * vos_VolumeGetNext - get information about the next volume.
3881 * IN iterationId - an iterator previously returned by
3882 * vos_VolumeGetBegin
3884 * OUT volumeP - a pointer to a vos_volumeEntry_t
3885 * that upon successful completion contains information about the
3890 * The iterator is locked while the next item is retrieved.
3894 * Returns != 0 upon successful completion.
3898 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3902 afs_status_t tst = 0;
3903 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3906 tst = ADMITERATORNULL;
3907 goto fail_vos_VolumeGetNext;
3910 if (volumeP == NULL) {
3911 tst = ADMVOSVOLUMEPNULL;
3912 goto fail_vos_VolumeGetNext;
3915 rc = IteratorNext(iter, (void *)volumeP, &tst);
3917 fail_vos_VolumeGetNext:
3926 * vos_VolumeGetDone - finish using a volume iterator.
3930 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3934 * The iterator is locked and then destroyed.
3938 * Returns != 0 upon successful completion.
3942 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3945 afs_status_t tst = 0;
3946 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3949 * Validate arguments
3953 tst = ADMITERATORNULL;
3954 goto fail_vos_VolumeGetDone;
3957 rc = IteratorDone(iter, &tst);
3959 fail_vos_VolumeGetDone:
3968 * vos_VolumeMove - move a volume from one server to another.
3972 * IN cellHandle - a previously opened cellHandle that corresponds
3973 * to the cell where the volume exists.
3975 * IN callBack - a call back function pointer that may be called to report
3976 * status information. Can be null.
3978 * IN volumeId - the volume id of the volume to be moved.
3980 * IN fromServer - a previously opened serverHandle that corresponds
3981 * to the server where the volume currently resides.
3983 * IN fromPartition - the partition where the volume currently resides.
3985 * IN toServer - a previously opened serverHandle that corresponds
3986 * to the server where the volume will be moved.
3988 * IN toPartition - the partition where the volume will be moved.
3992 * No locks are obtained or released by this function
3996 * Returns != 0 upon successful completion.
4000 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
4001 unsigned int volumeId, const void *fromServer,
4002 unsigned int fromPartition, const void *toServer,
4003 unsigned int toPartition, afs_status_p st)
4006 afs_status_t tst = 0;
4007 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4008 file_server_p from_server = (file_server_p) fromServer;
4009 file_server_p to_server = (file_server_p) toServer;
4010 afs_int32 from_server_addr =
4011 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4012 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4013 afs_int32 from_partition = fromPartition;
4014 afs_int32 to_partition = toPartition;
4017 * Validate arguments
4020 if (!IsValidCellHandle(c_handle, &tst)) {
4021 goto fail_vos_VolumeMove;
4024 if (!IsValidServerHandle(from_server, &tst)) {
4025 goto fail_vos_VolumeMove;
4028 if (!IsValidServerHandle(to_server, &tst)) {
4029 goto fail_vos_VolumeMove;
4032 if (fromPartition > VOLMAXPARTS) {
4033 tst = ADMVOSPARTITIONIDTOOLARGE;
4034 goto fail_vos_VolumeMove;
4037 if (toPartition > VOLMAXPARTS) {
4038 tst = ADMVOSPARTITIONIDTOOLARGE;
4039 goto fail_vos_VolumeMove;
4046 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4047 to_server_addr, to_partition, &tst);
4049 fail_vos_VolumeMove:
4058 * vos_VolumeRelease - release a volume.
4062 * IN cellHandle - a previously opened cellHandle that corresponds
4063 * to the cell where the volume exists.
4065 * IN callBack - a call back function pointer that may be called to report
4066 * status information. Can be null.
4068 * IN volumeId - the volume to be released.
4070 * IN force - force a complete release.
4074 * No locks are obtained or released by this function
4078 * Returns != 0 upon successful completion.
4082 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4083 unsigned int volumeId, vos_force_t force, afs_status_p st)
4086 afs_status_t tst = 0;
4087 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4088 afs_int32 server, part, forc = 0, voltype, volume;
4089 struct nvldbentry entry;
4092 * Validate arguments
4095 if (!IsValidCellHandle(c_handle, &tst)) {
4096 goto fail_vos_VolumeRelease;
4100 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4101 goto fail_vos_VolumeRelease;
4104 if (force == VOS_FORCE) {
4109 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4111 fail_vos_VolumeRelease:
4120 * vos_VolumeZap - forcibly delete a volume.
4124 * IN cellHandle - a previously opened cellHandle that corresponds
4125 * to the cell where the volume exists.
4127 * IN serverHandle - a previously opened serverHandle that corresponds
4128 * to the server where the volume exists.
4130 * IN callBack - a call back function pointer that may be called to report
4131 * status information. Can be null.
4133 * IN partition - the partition where the volume exists.
4135 * IN volumeId - the volume id of the vldb entry to be deleted.
4137 * IN force - force the deletion of bad volumes.
4141 * No locks are obtained or released by this function
4145 * Returns != 0 upon successful completion.
4149 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4150 vos_MessageCallBack_t callBack, unsigned int partition,
4151 unsigned int volumeId, vos_force_t force, afs_status_p st)
4154 afs_status_t tst = 0;
4155 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4156 file_server_p f_server = (file_server_p) serverHandle;
4159 * Verify that the cellHandle is capable of making vos rpc's
4162 if (!IsValidCellHandle(c_handle, &tst)) {
4163 goto fail_vos_VolumeZap;
4166 if (!IsValidServerHandle(f_server, &tst)) {
4167 goto fail_vos_VolumeZap;
4170 if (force == VOS_FORCE) {
4171 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4174 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4187 * vos_PartitionNameToId - translate a string representing a partition
4192 * IN partitionName - a string representing a partition. Must be of
4195 * OUT partitionId - a number containing the partition id upon successful
4200 * No locks are obtained or released by this function
4204 * Returns != 0 upon successful completion.
4208 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4212 afs_status_t tst = 0;
4213 size_t partition_name_len;
4217 * Validate arguments
4220 if (partitionName == NULL) {
4221 tst = ADMVOSPARTITIONNAMENULL;
4222 goto fail_vos_PartitionNameToId;
4225 if (partitionId == NULL) {
4226 tst = ADMVOSPARTITIONIDNULL;
4227 goto fail_vos_PartitionNameToId;
4231 * Check that string begins with /vicep
4234 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4235 tst = ADMVOSPARTITIONNAMEINVALID;
4236 goto fail_vos_PartitionNameToId;
4240 * Check that the string is either one or two characters
4241 * longer than VICE_PREFIX_SIZE
4244 partition_name_len = strlen(partitionName);
4246 if (partition_name_len == VICE_PREFIX_SIZE) {
4247 tst = ADMVOSPARTITIONNAMETOOSHORT;
4248 goto fail_vos_PartitionNameToId;
4251 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4252 tst = ADMVOSPARTITIONNAMETOOLONG;
4253 goto fail_vos_PartitionNameToId;
4257 * Check that all characters past the prefix are lower case
4260 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4261 if (!islower(partitionName[i])) {
4262 tst = ADMVOSPARTITIONNAMENOTLOWER;
4263 goto fail_vos_PartitionNameToId;
4268 * Convert the name to a number
4271 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4272 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4275 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4276 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4279 if (*partitionId > VOLMAXPARTS) {
4280 tst = ADMVOSPARTITIONIDTOOLARGE;
4281 goto fail_vos_PartitionNameToId;
4285 fail_vos_PartitionNameToId:
4294 * vos_PartitionIdToName - translate a number representing a partition
4295 * to a character string.
4299 * IN partitionId - an integer representing the partition.
4301 * OUT partitionName - a string containing the converted partition ID
4302 * upon successful completion.
4306 * No locks are obtained or released by this function
4310 * Returns != 0 upon successful completion.
4314 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4318 afs_status_t tst = 0;
4320 if (partitionId > VOLMAXPARTS) {
4321 tst = ADMVOSPARTITIONIDTOOLARGE;
4322 goto fail_vos_PartitionIdToName;
4325 if (partitionName == NULL) {
4326 tst = ADMVOSPARTITIONNAMENULL;
4327 goto fail_vos_PartitionIdToName;
4330 if (partitionId < 26) {
4331 strcpy(partitionName, VICE_PARTITION_PREFIX);
4332 partitionName[6] = partitionId + 'a';
4333 partitionName[7] = '\0';
4335 strcpy(partitionName, VICE_PARTITION_PREFIX);
4337 partitionName[6] = 'a' + (partitionId / 26);
4338 partitionName[7] = 'a' + (partitionId % 26);
4339 partitionName[8] = '\0';
4343 fail_vos_PartitionIdToName:
4352 * vos_VolumeQuotaChange - change the quota of a volume.
4356 * IN cellHandle - a previously opened cellHandle that corresponds
4357 * to the cell where the volume exists.
4359 * IN serverHandle - a previously opened serverHandle that corresponds
4360 * to the server where the volume exists.
4362 * IN callBack - a call back function pointer that may be called to report
4363 * status information. Can be null.
4365 * IN partition - the partition where the volume exists.
4367 * IN volumeId - the volume id of the volume to be modified.
4369 * IN volumeQuota - the new volume quota.
4373 * No locks are obtained or released by this function
4377 * Returns != 0 upon successful completion.
4381 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4382 vos_MessageCallBack_t callBack, unsigned int partition,
4383 unsigned int volumeId, unsigned int volumeQuota,
4387 afs_status_t tst = 0;
4388 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4389 file_server_p f_server = (file_server_p) serverHandle;
4392 struct volintInfo tstatus;
4393 int active_trans = 0;
4396 * Verify that the cellHandle is capable of making vos rpc's
4399 if (!IsValidCellHandle(c_handle, &tst)) {
4400 goto fail_vos_VolumeQuotaChange;
4403 if (!IsValidServerHandle(f_server, &tst)) {
4404 goto fail_vos_VolumeQuotaChange;
4407 memset((void *)&tstatus, 0, sizeof(tstatus));
4408 tstatus.dayUse = -1;
4409 tstatus.maxquota = volumeQuota;
4412 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4414 goto fail_vos_VolumeQuotaChange;
4418 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4420 goto fail_vos_VolumeQuotaChange;
4424 fail_vos_VolumeQuotaChange:
4427 afs_status_t tst2 = 0;
4428 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);