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>
24 #include <sys/types.h>
25 #include <sys/socket.h>
27 #include <netinet/in.h>
28 #include <arpa/inet.h>
31 #include "afs_vosAdmin.h"
32 #include "../adminutil/afs_AdminInternal.h"
33 #include <afs/afs_utilAdmin.h>
34 #include <afs/vlserver.h>
35 #include <afs/volser.h>
36 #include <afs/volint.h>
37 #include <afs/partition.h>
41 #include "lockprocs.h"
43 typedef struct file_server {
46 struct rx_connection *serv;
48 } file_server_t, *file_server_p;
51 * IsValidServerHandle - test a server handle for validity.
55 * IN serverHandle - the serverHandle to be validated.
59 * No locks are obtained or released by this function
63 * Returns != 0 upon successful completion.
67 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
72 if (serverHandle == NULL) {
73 tst = ADMVOSSERVERHANDLENULL;
74 goto fail_IsValidServerHandle;
77 if (serverHandle->is_valid != 1) {
78 tst = ADMVOSSERVERHANDLEINVALID;
79 goto fail_IsValidServerHandle;
82 if ((serverHandle->begin_magic != BEGIN_MAGIC)
83 || (serverHandle->end_magic != END_MAGIC)) {
84 tst = ADMVOSSERVERHANDLEBADMAGIC;
85 goto fail_IsValidServerHandle;
89 fail_IsValidServerHandle:
99 * IsValidCellHandle - verify that a cell handle can be used to make vos
104 * IN cellHandle - the cellHandle to be validated.
108 * No locks are obtained or released by this function
112 * Returns != 0 upon successful completion.
116 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
119 afs_status_t tst = 0;
121 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
122 goto fail_IsValidCellHandle;
125 if (cellHandle->vos_valid == 0) {
126 tst = ADMVOSCELLHANDLEINVALIDVOS;
127 goto fail_IsValidCellHandle;
131 fail_IsValidCellHandle:
139 /* set <server> and <part> to the correct values depending on
140 * <voltype> and <entry> */
142 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
143 afs_int32 * part, int *previdx)
145 int i, istart, vtype;
150 /* Doesn't check for non-existance of backup volume */
151 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
153 istart = 0; /* seach the entire entry */
156 /* Seach from beginning of entry or pick up where we left off */
157 istart = ((*previdx < 0) ? 0 : *previdx + 1);
160 for (i = istart; i < entry->nServers; i++) {
161 if (entry->serverFlags[i] & vtype) {
162 *server = entry->serverNumber[i];
163 *part = entry->serverPartition[i];
169 /* Didn't find any, return -1 */
175 * vos_BackupVolumeCreate - create a backup volume for a volume.
179 * IN cellHandle - a previously opened cellHandle that corresponds
180 * to the cell where volume exists.
182 * IN callBack - a call back function pointer that may be called to report
183 * status information. Can be null.
185 * IN volumeId - the volume to create the back up for.
189 * No locks are obtained or released by this function
193 * Returns != 0 upon successful completion.
197 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
198 unsigned int volumeId, afs_status_p st)
201 afs_status_t tst = 0;
202 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
203 struct nvldbentry rw_vol_entry;
205 afs_int32 rw_partition;
206 afs_int32 rw_vol_type;
207 struct nvldbentry bk_vol_entry;
209 afs_int32 bk_partition;
210 afs_int32 bk_vol_type;
217 if (!IsValidCellHandle(c_handle, &tst)) {
218 goto fail_vos_BackupVolumeCreate;
222 * Get the volume information and verify that we've been passed
223 * a read write volume id
227 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
228 &rw_vol_type, &tst)) {
229 goto fail_vos_BackupVolumeCreate;
232 if (rw_vol_type != RWVOL) {
233 tst = ADMVOSMUSTBERWVOL;
234 goto fail_vos_BackupVolumeCreate;
238 * Check to see that if a backup volume exists, it exists on the
239 * same server as volumeId
242 if (rw_vol_entry.flags & BACK_EXISTS) {
244 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
245 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
246 goto fail_vos_BackupVolumeCreate;
248 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
249 goto fail_vos_BackupVolumeCreate;
252 tst = ADMVOSBACKUPVOLWRONGSERVER;
253 goto fail_vos_BackupVolumeCreate;
258 * Create the new backup volume
261 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
263 fail_vos_BackupVolumeCreate:
272 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
276 * IN cellHandle - a previously opened cellHandle that corresponds
277 * to the cell where the volumes exist.
279 * IN serverHandle - the server where the backups are to be created. Can be
282 * IN callBack - a call back function pointer that may be called to report
283 * status information. Can be null.
285 * IN partition - the partition where the backups are to be created. Can be
288 * IN volumePrefix - all volumes with this prefix will have backup volumes
289 * created. Can be null.
291 * IN excludePrefix - exclude the volumes that match volumePrefix.
295 * No locks are obtained or released by this function
299 * Returns != 0 upon successful completion.
303 vos_BackupVolumeCreateMultiple(const void *cellHandle,
304 const void *serverHandle,
305 vos_MessageCallBack_t callBack,
306 const unsigned int *partition,
307 const char *volumePrefix,
308 vos_exclude_t excludePrefix, afs_status_p st)
311 afs_status_t tst = 0;
312 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
313 file_server_p f_server = (file_server_p) serverHandle;
314 struct VldbListByAttributes attr;
317 size_t prefix_len = 0;
318 nbulkentries arrayEntries;
319 afs_int32 nentries = 0;
320 register struct nvldbentry *entry;
322 afs_int32 rw_volid, rw_server, rw_partition;
327 memset((void *)&attr, 0, sizeof(attr));
332 * The only required argument to this function is the cellHandle.
333 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
337 if (!IsValidCellHandle(c_handle, &tst)) {
338 goto fail_vos_BackupVolumeCreateMultiple;
341 if ((excludePrefix == VOS_EXCLUDE)
342 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
343 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
344 goto fail_vos_BackupVolumeCreateMultiple;
347 if (f_server != NULL) {
348 if (!IsValidServerHandle(f_server, &tst)) {
349 goto fail_vos_BackupVolumeCreateMultiple;
351 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
352 attr.Mask |= VLLIST_SERVER;
355 if (partition != NULL) {
356 if (*partition > VOLMAXPARTS) {
357 tst = ADMVOSPARTITIONTOOLARGE;
358 goto fail_vos_BackupVolumeCreateMultiple;
360 attr.partition = *partition;
361 attr.Mask |= VLLIST_PARTITION;
364 if (excludePrefix == VOS_EXCLUDE) {
368 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
370 prefix_len = strlen(volumePrefix);
373 memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
376 * Get a list of all the volumes in the cell
379 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
380 goto fail_vos_BackupVolumeCreateMultiple;
384 * Cycle through the list of volumes and see if we should create a backup
385 * for each individual volume
388 for (i = 0; i < nentries; i++) {
389 entry = &arrayEntries.nbulkentries_val[i];
392 * Skip entries that don't have a RW volume
395 if (!(entry->flags & RW_EXISTS)) {
396 if (callBack != NULL) {
397 const char *messageText;
398 if (util_AdminErrorCodeTranslate
399 (ADMVOSVOLUMENOREADWRITE, 0, &messageText, &tst)) {
400 sprintf(backbuf, "%s %s", messageText, entry->name);
401 (**callBack) (VOS_VERBOSE_MESSAGE, backbuf);
408 * See if we should skip this entry because of the prefix/exclude
409 * combination we've been passed
414 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
418 if (strncmp(entry->name, volumePrefix, prefix_len)) {
424 rw_volid = entry->volumeId[RWVOL];
425 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
427 if ((rw_server == -1) || (rw_partition == -1)) {
428 if (callBack != NULL) {
429 const char *messageText;
430 if (util_AdminErrorCodeTranslate
431 (ADMVOSVLDBBADENTRY, 0, &messageText, &tst)) {
432 sprintf(backbuf, "%s %s", messageText, entry->name);
433 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
440 * Check that the RW volume is on the same server that we were
444 if (serverHandle != NULL) {
445 if (!VLDB_IsSameAddrs
446 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
447 rw_server, &equal, &tst)) {
448 if (callBack != NULL) {
449 const char *messageText;
450 if (util_AdminErrorCodeTranslate
451 (ADMVOSVLDBBADSERVER, 0, &messageText, &tst)) {
452 sprintf(backbuf, "%s %x %d", messageText,
453 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
455 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
461 if (callBack != NULL) {
462 const char *messageText;
463 if (util_AdminErrorCodeTranslate
464 (ADMVOSVLDBDIFFERENTADDR, 0, &messageText, &tst)) {
465 sprintf(backbuf, "%s %s", messageText, entry->name);
466 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
474 * Check that the RW volume is on the same partition we were
478 if (partition != NULL) {
479 if (*partition != rw_partition) {
488 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid,
492 fail_vos_BackupVolumeCreateMultiple:
494 if (arrayEntries.nbulkentries_val) {
495 free(arrayEntries.nbulkentries_val);
505 * vos_PartitionGet - get information about a single partition.
509 * IN cellHandle - a previously opened cellHandle that corresponds
510 * to the cell where the server lives.
512 * IN serverHandle - a previously open vos server handle that holds
513 * the partition of interest.
515 * IN callBack - a call back function pointer that may be called to report
516 * status information. Can be null.
518 * IN partition - the integer that represents the partition of interest.
520 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
521 * completion contains information regarding the partition.
525 * No locks are obtained or released by this function
529 * Returns != 0 upon successful completion.
533 vos_PartitionGet(const void *cellHandle, const void *serverHandle,
534 vos_MessageCallBack_t callBack, unsigned int partition,
535 vos_partitionEntry_p partitionP, afs_status_p st)
538 afs_status_t tst = 0;
539 struct diskPartition part_info;
540 file_server_p f_server = (file_server_p) serverHandle;
541 char partitionName[10]; /* this rpc requires a character partition name */
547 if (!IsValidServerHandle(f_server, &tst)) {
548 goto fail_vos_PartitionGet;
551 if (partitionP == NULL) {
552 tst = ADMVOSPARTITIONPNULL;
553 goto fail_vos_PartitionGet;
556 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
557 goto fail_vos_PartitionGet;
560 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
562 goto fail_vos_PartitionGet;
564 strncpy(partitionP->name, part_info.name, VOS_MAX_PARTITION_NAME_LEN);
565 partitionP->name[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
566 strncpy(partitionP->deviceName, part_info.devName, VOS_MAX_PARTITION_NAME_LEN);
567 partitionP->deviceName[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
568 partitionP->lockFileDescriptor = part_info.lock_fd;
569 partitionP->totalSpace = part_info.minFree;
570 partitionP->totalFreeSpace = part_info.free;
573 fail_vos_PartitionGet:
582 * The iterator functions and data for the partition retrieval functions.
585 typedef struct partition_get {
586 afs_int32 total_received; /* the total number of valid partiions retrieved */
587 int number_processed; /* the number of valid paritions we've handed out */
588 int index; /* the current index into the part_list array */
589 struct partList part_list; /* the list of partitions */
590 vos_partitionEntry_t partition[CACHED_ITEMS]; /* the cache of partitions */
591 const void *server; /* the server where the parititions exist */
592 } partition_get_t, *partition_get_p;
595 GetPartitionInfoRPC(void *rpc_specific, int slot, int *last_item,
596 int *last_item_contains_data, afs_status_p st)
599 afs_status_t tst = 0;
600 partition_get_p part = (partition_get_p) rpc_specific;
601 vos_partitionEntry_p ptr = (vos_partitionEntry_p) & part->partition[slot];
604 * Skip partition entries that are not valid
607 while (!(part->part_list.partFlags[part->index] & PARTVALID)) {
612 * Get information for the next partition
615 if (!vos_PartitionGet
617 (unsigned int)part->part_list.partId[part->index], ptr, &tst)) {
618 goto fail_GetPartitionInfoRPC;
622 part->number_processed++;
624 if (part->number_processed == part->total_received) {
626 *last_item_contains_data = 1;
630 fail_GetPartitionInfoRPC:
639 GetPartitionInfoFromCache(void *rpc_specific, int slot, void *dest,
643 afs_status_t tst = 0;
644 partition_get_p part = (partition_get_p) rpc_specific;
646 memcpy(dest, (const void *)&part->partition[slot],
647 sizeof(vos_partitionEntry_t));
657 * vos_PartitionGetBegin - begin to iterate over the partitions at a
662 * IN cellHandle - a previously opened cellHandle that corresponds
663 * to the cell where the server exists.
665 * IN serverHandle - the server that houses the partitions of interest.
667 * IN callBack - a call back function pointer that may be called to report
668 * status information. Can be null.
670 * OUT iterationIdP - upon successful completion, contains an iterator that can
671 * be passed to vos_PartitionGetNext.
675 * No locks are obtained or released by this function
679 * Returns != 0 upon successful completion.
683 vos_PartitionGetBegin(const void *cellHandle, const void *serverHandle,
684 vos_MessageCallBack_t callBack, void **iterationIdP,
688 afs_status_t tst = 0;
689 file_server_p f_server = (file_server_p) serverHandle;
690 afs_admin_iterator_p iter =
691 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
692 partition_get_p part =
693 (partition_get_p) calloc(1, sizeof(partition_get_t));
699 if (!IsValidServerHandle(f_server, &tst)) {
700 goto fail_vos_PartitionGetBegin;
703 if (iterationIdP == NULL) {
704 goto fail_vos_PartitionGetBegin;
707 if ((iter == NULL) || (part == NULL)) {
709 goto fail_vos_PartitionGetBegin;
713 * Fill in the part structure
716 part->server = serverHandle;
717 if (!UV_ListPartitions
718 (f_server->serv, &part->part_list, &part->total_received, &tst)) {
719 goto fail_vos_PartitionGetBegin;
723 * If we didn't receive any partitions, don't spawn a background thread.
724 * Mark the iterator complete.
727 if (part->total_received == 0) {
728 if (!IteratorInit(iter, (void *)part, NULL, NULL, NULL, NULL, &tst)) {
729 goto fail_vos_PartitionGetBegin;
731 iter->done_iterating = 1;
732 iter->st = ADMITERATORDONE;
735 (iter, (void *)part, GetPartitionInfoRPC,
736 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
737 goto fail_vos_PartitionGetBegin;
740 *iterationIdP = (void *)iter;
743 fail_vos_PartitionGetBegin:
761 * vos_PartitionGetNext - get the next partition at a server.
765 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
767 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
768 * completion contains the next partition.
772 * The iterator is locked while the next parition is retrieved.
776 * Returns != 0 upon successful completion.
780 vos_PartitionGetNext(const void *iterationId, vos_partitionEntry_p partitionP,
784 afs_status_t tst = 0;
785 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
788 tst = ADMITERATORNULL;
789 goto fail_vos_PartitionGetNext;
792 if (partitionP == NULL) {
793 tst = ADMVOSPARTITIONPNULL;
794 goto fail_vos_PartitionGetNext;
797 rc = IteratorNext(iter, (void *)partitionP, &tst);
799 fail_vos_PartitionGetNext:
808 * vos_PartitionGetDone - finish using a partition iterator.
812 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
816 * The iterator is locked and then destroyed.
820 * Returns != 0 upon successful completion.
824 vos_PartitionGetDone(const void *iterationId, afs_status_p st)
827 afs_status_t tst = 0;
828 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
835 tst = ADMITERATORNULL;
836 goto fail_vos_PartitionGetDone;
839 rc = IteratorDone(iter, &tst);
841 fail_vos_PartitionGetDone:
850 * vos_ServerOpen - open a handle to an individual server for future
855 * IN cellHandle - a previously opened cellHandle that corresponds
856 * to the cell where the server lives.
858 * IN serverName - the machine name of the server
860 * OUT serverHandleP - a void pointer that upon successful completion
861 * contains a handle that is used in future operations upon the server.
865 * No locks are obtained or released by this function
869 * Returns != 0 upon successful completion.
873 vos_ServerOpen(const void *cellHandle, const char *serverName,
874 void **serverHandleP, afs_status_p st)
877 afs_status_t tst = 0;
878 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
879 file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
881 struct rx_securityClass *sc[3];
884 if (f_server == NULL) {
886 goto fail_vos_ServerOpen;
893 if (!IsValidCellHandle(c_handle, &tst)) {
894 goto fail_vos_ServerOpen;
897 if (!c_handle->tokens->afs_token_set) {
898 tst = ADMVOSCELLHANDLENOAFSTOKENS;
899 goto fail_vos_ServerOpen;
902 if (!util_AdminServerAddressGetFromName
903 (serverName, &server_address, &tst)) {
904 goto fail_vos_ServerOpen;
907 scIndex = c_handle->tokens->sc_index;
908 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
910 rx_GetCachedConnection(htonl(server_address),
911 htons(AFSCONF_VOLUMEPORT), VOLSERVICE_ID,
912 sc[scIndex], scIndex);
913 if (f_server->serv != NULL) {
914 f_server->begin_magic = BEGIN_MAGIC;
915 f_server->end_magic = END_MAGIC;
916 f_server->is_valid = 1;
917 *serverHandleP = (void *)f_server;
920 tst = ADMVOSSERVERNOCONNECTION;
921 goto fail_vos_ServerOpen;
933 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
937 * IN serverHandle - an existing server handle.
941 * No locks are obtained or released by this function
945 * Returns != 0 upon successful completion.
949 vos_ServerClose(const void *serverHandle, afs_status_p st)
952 afs_status_t tst = 0;
953 file_server_p f_server = (file_server_p) serverHandle;
955 if (!IsValidServerHandle(f_server, &tst)) {
956 goto fail_vos_ServerClose;
959 rx_ReleaseCachedConnection(f_server->serv);
960 f_server->is_valid = 0;
964 fail_vos_ServerClose:
973 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
978 * IN cellHandle - a previously opened cellHandle that corresponds
979 * to the cell where the server lives.
981 * IN serverHandle - a handle to the server machine.
983 * IN callBack - a call back function pointer that may be called to report
984 * status information. Can be null.
986 * IN partition - the partition to synchronize. Can be NULL.
988 * IN force - force deletion of bad volumes.
992 * No locks are obtained or released by this function
996 * Returns != 0 upon successful completion.
1000 vos_ServerSync(const void *cellHandle, const void *serverHandle,
1001 vos_MessageCallBack_t callBack, const unsigned int *partition,
1005 afs_status_t tst = 0;
1006 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1007 file_server_p f_server = (file_server_p) serverHandle;
1012 * Validate arguments
1015 if (!IsValidCellHandle(c_handle, &tst)) {
1016 goto fail_vos_ServerSync;
1019 if (!IsValidServerHandle(f_server, &tst)) {
1020 goto fail_vos_ServerSync;
1023 if (partition != NULL) {
1024 if (*partition > VOLMAXPARTS) {
1025 tst = ADMVOSPARTITIONTOOLARGE;
1026 goto fail_vos_ServerSync;
1028 part = (afs_int32) * partition;
1036 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1038 fail_vos_ServerSync:
1047 * vos_FileServerAddressChange - change an existing file server address.
1051 * IN cellHandle - a previously opened cellHandle that corresponds
1052 * to the cell where the address should be changed.
1054 * IN callBack - a call back function pointer that may be called to report
1055 * status information. Can be null.
1057 * IN oldAddress - the old server address in host byte order
1059 * IN newAddress - the new server address in host byte order
1063 * No locks are obtained or released by this function
1067 * Returns != 0 upon successful completion.
1071 vos_FileServerAddressChange(const void *cellHandle,
1072 vos_MessageCallBack_t callBack, int oldAddress,
1073 int newAddress, afs_status_p st)
1076 afs_status_t tst = 0;
1077 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1080 * Validate arguments
1083 if (!IsValidCellHandle(c_handle, &tst)) {
1084 goto fail_vos_FileServerAddressChange;
1088 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, oldAddress,
1091 goto fail_vos_FileServerAddressChange;
1095 fail_vos_FileServerAddressChange:
1104 * vos_FileServerAddressRemove - remove an existing file server address.
1108 * IN cellHandle - a previously opened cellHandle that corresponds
1109 * to the cell where the address should be removed.
1111 * IN callBack - a call back function pointer that may be called to report
1112 * status information. Can be null.
1114 * IN serverAddress - the server address to remove in host byte order.
1118 * No locks are obtained or released by this function
1122 * Returns != 0 upon successful completion.
1126 vos_FileServerAddressRemove(const void *cellHandle,
1127 vos_MessageCallBack_t callBack, int serverAddress,
1131 afs_status_t tst = 0;
1132 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1133 int dummyAddress = 0xffffffff;
1136 * Validate arguments
1139 if (!IsValidCellHandle(c_handle, &tst)) {
1140 goto fail_vos_FileServerAddressRemove;
1144 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, dummyAddress,
1147 goto fail_vos_FileServerAddressRemove;
1151 fail_vos_FileServerAddressRemove:
1160 * The iterator functions and data for the server retrieval functions.
1162 * These functions are very similar to the FileServerAddressGet
1163 * functions. The main difference being that instead of returning
1164 * a single address at a time for a server, we fill an array with
1165 * all the addresses of a server.
1168 typedef struct server_get {
1169 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1170 afs_int32 total_addresses; /* total number of addresses */
1171 bulkaddrs addresses; /* the list of addresses */
1172 int address_index; /* current index into address list */
1173 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1174 } server_get_t, *server_get_p;
1177 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1178 int *last_item_contains_data, afs_status_p st)
1181 afs_status_t tst = 0;
1182 server_get_p serv = (server_get_p) rpc_specific;
1183 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1184 afs_int32 base, index;
1187 ListAddrByAttributes m_attrs;
1188 afs_int32 total_multi;
1189 bulkaddrs addr_multi;
1193 * Check to see if this is a multihomed address server
1196 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1197 base = (*addrP >> 16) & 0xff;
1198 index = (*addrP) & 0xffff;
1200 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1201 && (index <= VL_MHSRV_PERBLK)) {
1204 * This is a multihomed server. Make an rpc to retrieve
1205 * all its addresses. Copy the addresses into the cache.
1208 m_attrs.Mask = VLADDR_INDEX;
1209 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1211 addr_multi.bulkaddrs_val = 0;
1212 addr_multi.bulkaddrs_len = 0;
1214 ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
1215 &m_unique, &total_multi, &addr_multi);
1217 goto fail_GetServerRPC;
1221 * Remove any bogus IP addresses which the user may have
1222 * been unable to remove.
1225 RemoveBadAddresses(&total_multi, &addr_multi);
1228 * Copy all the addresses into the cache
1231 for (i = 0; i < total_multi; i++) {
1232 serv->server[slot].serverAddress[i] =
1233 addr_multi.bulkaddrs_val[i];
1236 serv->server[slot].count = total_multi;
1237 serv->address_index++;
1238 free(addr_multi.bulkaddrs_val);
1242 * The next address is just a plain old address
1246 serv->server[slot].serverAddress[0] = *addrP;
1247 serv->server[slot].count = 1;
1248 serv->address_index++;
1252 * See if we've processed all the entries
1256 if (serv->address_index == serv->total_addresses) {
1258 *last_item_contains_data = 1;
1271 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1274 afs_status_t tst = 0;
1275 server_get_p serv = (server_get_p) rpc_specific;
1277 memcpy(dest, (const void *)&serv->server[slot],
1278 sizeof(vos_fileServerEntry_t));
1289 DestroyServer(void *rpc_specific, afs_status_p st)
1292 afs_status_t tst = 0;
1293 server_get_p serv = (server_get_p) rpc_specific;
1295 if (serv->addresses.bulkaddrs_val != NULL) {
1296 free(serv->addresses.bulkaddrs_val);
1307 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1311 * IN cellHandle - a previously opened cellHandle that corresponds
1312 * to the cell where the file servers exist.
1314 * IN callBack - a call back function pointer that may be called to report
1315 * status information. Can be null.
1317 * OUT iterationIdP - upon successful completion, contains an iterator that
1318 * can be passed to vos_FileServerGetNext.
1322 * No locks are obtained or released by this function
1326 * Returns != 0 upon successful completion.
1330 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1331 void **iterationIdP, afs_status_p st)
1334 afs_status_t tst = 0;
1335 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1336 afs_admin_iterator_p iter =
1337 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1338 server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
1339 struct VLCallBack unused;
1343 * Validate arguments
1346 if (!IsValidCellHandle(c_handle, &tst)) {
1347 goto fail_vos_FileServerGetBegin;
1350 if (iterationIdP == NULL) {
1351 goto fail_vos_FileServerGetBegin;
1354 if ((iter == NULL) || (serv == NULL)) {
1356 goto fail_vos_FileServerGetBegin;
1360 * Fill in the serv structure
1363 serv->vldb = c_handle->vos;
1365 ubik_Call_New(VL_GetAddrs, c_handle->vos, 0, 0, 0, &unused,
1366 &serv->total_addresses, &serv->addresses);
1369 goto fail_vos_FileServerGetBegin;
1373 * Remove any bogus IP addresses which the user may have
1374 * been unable to remove.
1377 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1379 if (serv->total_addresses == 0) {
1380 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1381 goto fail_vos_FileServerGetBegin;
1383 iter->done_iterating = 1;
1384 iter->st = ADMITERATORDONE;
1387 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1388 DestroyServer, &tst)) {
1389 goto fail_vos_FileServerGetBegin;
1392 *iterationIdP = (void *)iter;
1395 fail_vos_FileServerGetBegin:
1402 if (serv->addresses.bulkaddrs_val != NULL) {
1403 free(serv->addresses.bulkaddrs_val);
1416 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1420 * IN iterationId - an iterator previously returned by
1421 * vos_FileServerGetBegin
1423 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1424 * completion contains information about the next server in the cell.
1428 * The iterator is locked while the next server is retrieved.
1432 * Returns != 0 upon successful completion.
1436 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1440 afs_status_t tst = 0;
1441 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1444 tst = ADMITERATORNULL;
1445 goto fail_vos_FileServerGetNext;
1448 if (serverEntryP == NULL) {
1449 tst = ADMVOSSERVERENTRYPNULL;
1450 goto fail_vos_FileServerGetNext;
1453 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1455 fail_vos_FileServerGetNext:
1464 * vos_FileServerGetDone - finish using a partition iterator.
1468 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1472 * The iterator is locked and then destroyed.
1476 * Returns != 0 upon successful completion.
1480 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1483 afs_status_t tst = 0;
1484 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1487 * Validate arguments
1491 tst = ADMITERATORNULL;
1492 goto fail_vos_FileServerGetDone;
1495 rc = IteratorDone(iter, &tst);
1497 fail_vos_FileServerGetDone:
1506 * The iterator functions and data for the transation retrieval functions.
1509 typedef struct transaction_get {
1510 afs_int32 total; /* total number of transactions */
1511 afs_int32 index; /* index to the current transaction */
1512 transDebugInfo *cur; /* the current transaction */
1513 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1514 } transaction_get_t, *transaction_get_p;
1517 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1518 int *last_item_contains_data, afs_status_p st)
1521 afs_status_t tst = 0;
1522 transaction_get_p t = (transaction_get_p) rpc_specific;
1523 int index = t->index;
1526 * Copy the next transaction into the cache
1529 t->tran[slot].transactionId = t->cur[index].tid;
1530 t->tran[slot].lastActiveTime = t->cur[index].time;
1531 t->tran[slot].creationTime = t->cur[index].creationTime;
1532 t->tran[slot].errorCode = t->cur[index].returnCode;
1533 t->tran[slot].volumeId = t->cur[index].volid;
1534 t->tran[slot].partition = t->cur[index].partition;
1535 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1536 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1537 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1538 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1539 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1541 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1543 switch (t->cur[index].iflags) {
1545 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1548 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1551 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1554 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1557 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1561 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1563 switch (t->cur[index].vflags) {
1564 case VTDeleteOnSalvage:
1565 t->tran[slot].volumeActiveStatus =
1566 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1568 case VTOutOfService:
1569 t->tran[slot].volumeActiveStatus =
1570 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1573 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1577 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1579 if (t->cur[index].tflags) {
1580 t->tran[slot].volumeTransactionStatus =
1581 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1587 * See if we've processed all the entries
1591 if (t->index == t->total) {
1593 *last_item_contains_data = 1;
1604 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1608 afs_status_t tst = 0;
1609 transaction_get_p tran = (transaction_get_p) rpc_specific;
1611 memcpy(dest, (const void *)&tran->tran[slot],
1612 sizeof(vos_serverTransactionStatus_p));
1623 DestroyTransaction(void *rpc_specific, afs_status_p st)
1626 afs_status_t tst = 0;
1627 transaction_get_p tran = (transaction_get_p) rpc_specific;
1629 if (tran->cur != NULL) {
1641 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1642 * at a volume server.
1646 * IN cellHandle - a previously opened cellHandle that corresponds
1647 * to the cell where the volume server exists.
1649 * IN serverHandle - a handle to the server to query.
1651 * IN callBack - a call back function pointer that may be called to report
1652 * status information. Can be null.
1654 * OUT iterationIdP - upon successful completion, contains an iterator that
1655 * can be passed to vos_ServerTransactionStatusGetNext.
1659 * No locks are obtained or released by this function
1663 * Returns != 0 upon successful completion.
1667 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1668 const void *serverHandle,
1669 vos_MessageCallBack_t callBack,
1670 void **iterationIdP, afs_status_p st)
1673 afs_status_t tst = 0;
1674 file_server_p f_server = (file_server_p) serverHandle;
1675 afs_admin_iterator_p iter =
1676 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1677 transaction_get_p tran =
1678 (transaction_get_p) calloc(1, sizeof(transaction_get_t));
1682 * Validate arguments
1685 if (!IsValidServerHandle(f_server, &tst)) {
1686 goto fail_vos_ServerTransactionStatusGetBegin;
1689 if (iterationIdP == NULL) {
1690 goto fail_vos_ServerTransactionStatusGetBegin;
1693 if ((iter == NULL) || (tran == NULL)) {
1695 goto fail_vos_ServerTransactionStatusGetBegin;
1699 * Fill in the tran structure
1702 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1703 goto fail_vos_ServerTransactionStatusGetBegin;
1706 if (tran->total == 0) {
1707 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1708 goto fail_vos_ServerTransactionStatusGetBegin;
1710 iter->done_iterating = 1;
1711 iter->st = ADMITERATORDONE;
1714 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1715 NULL, DestroyTransaction, &tst)) {
1716 goto fail_vos_ServerTransactionStatusGetBegin;
1719 *iterationIdP = (void *)iter;
1722 fail_vos_ServerTransactionStatusGetBegin:
1729 if (tran->cur != NULL) {
1743 * vos_ServerTransactionStatusGetNext - get information about the next
1744 * active transaction.
1748 * IN iterationId - an iterator previously returned by
1749 * vos_ServerTransactionStatusGetBegin
1751 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1752 * that upon successful completion contains information about the
1757 * The iterator is locked while the next item is retrieved.
1761 * Returns != 0 upon successful completion.
1765 vos_ServerTransactionStatusGetNext(const void *iterationId,
1766 vos_serverTransactionStatus_p
1767 serverTransactionStatusP, afs_status_p st)
1770 afs_status_t tst = 0;
1771 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1774 tst = ADMITERATORNULL;
1775 goto fail_vos_ServerTransactionStatusGetNext;
1778 if (serverTransactionStatusP == NULL) {
1779 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1780 goto fail_vos_ServerTransactionStatusGetNext;
1783 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1785 fail_vos_ServerTransactionStatusGetNext:
1794 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1798 * IN iterationId - an iterator previously returned by
1799 * vos_ServerTransactionStatusGetBegin
1803 * The iterator is locked and then destroyed.
1807 * Returns != 0 upon successful completion.
1811 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1814 afs_status_t tst = 0;
1815 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1818 * Validate arguments
1822 tst = ADMITERATORNULL;
1823 goto fail_vos_ServerTransactionStatusGetDone;
1826 rc = IteratorDone(iter, &tst);
1828 fail_vos_ServerTransactionStatusGetDone:
1837 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1841 afs_status_t tst = 0;
1844 dest->numServers = source->nServers;
1845 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1846 dest->volumeId[i] = source->volumeId[i];
1848 dest->cloneId = source->cloneId;
1849 dest->status = VOS_VLDB_ENTRY_OK;
1850 if (source->flags & VLOP_ALLOPERS) {
1851 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1853 if (source->flags & VLOP_MOVE) {
1854 dest->status |= VOS_VLDB_ENTRY_MOVE;
1856 if (source->flags & VLOP_RELEASE) {
1857 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1859 if (source->flags & VLOP_BACKUP) {
1860 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1862 if (source->flags & VLOP_DELETE) {
1863 dest->status |= VOS_VLDB_ENTRY_DELETE;
1865 if (source->flags & VLOP_DUMP) {
1866 dest->status |= VOS_VLDB_ENTRY_DUMP;
1869 if (source->flags & VLF_RWEXISTS) {
1870 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1872 if (source->flags & VLF_ROEXISTS) {
1873 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1875 if (source->flags & VLF_BACKEXISTS) {
1876 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1879 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1880 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1881 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1882 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1883 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1884 dest->volumeSites[i].serverFlags = 0;
1886 if (source->serverFlags[i] & NEW_REPSITE) {
1887 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1889 if (source->serverFlags[i] & ITSROVOL) {
1890 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1892 if (source->serverFlags[i] & ITSRWVOL) {
1893 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1895 if (source->serverFlags[i] & ITSBACKVOL) {
1896 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1898 if (source->serverFlags[i] & RO_DONTUSE) {
1899 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1912 * vos_VLDBGet- get a volume's vldb entry.
1916 * IN cellHandle - a previously opened cellHandle that corresponds
1917 * to the cell where the volume entries exist.
1919 * IN callBack - a call back function pointer that may be called to report
1920 * status information. Can be null.
1922 * IN volumeId - the id of the volume to retrieve.
1924 * IN volumeName - the name of the volume to retrieve.
1926 * OUT vldbEntry - upon successful completion, contains the information regarding
1931 * No locks are obtained or released by this function
1935 * Returns != 0 upon successful completion.
1939 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1940 const unsigned int *volumeId, const char *volumeName,
1941 vos_vldbEntry_p vldbEntry, afs_status_p st)
1944 afs_status_t tst = 0;
1945 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1946 struct nvldbentry entry;
1950 * Validate arguments
1953 if (!IsValidCellHandle(c_handle, &tst)) {
1954 goto fail_vos_VLDBGet;
1957 if (vldbEntry == NULL) {
1958 tst = ADMVOSVLDBENTRYNULL;
1959 goto fail_vos_VLDBGet;
1962 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1963 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1964 goto fail_vos_VLDBGet;
1968 * Retrieve the entry
1971 if (!((volumeName == NULL) || (*volumeName == 0))) {
1972 if (!ValidateVolumeName(volumeName, &tst)) {
1973 goto fail_vos_VLDBGet;
1975 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1976 goto fail_vos_VLDBGet;
1979 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1980 goto fail_vos_VLDBGet;
1985 * Copy the entry into our structure
1988 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1989 goto fail_vos_VLDBGet;
2002 * The iterator functions and data for the vldb entry retrieval functions.
2005 typedef struct vldb_entry_get {
2006 afs_int32 total; /* total number of vldb entries */
2007 afs_int32 index; /* index to the current vldb entry */
2008 nbulkentries entries; /* the list of entries retrieved */
2009 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2010 } vldb_entry_get_t, *vldb_entry_get_p;
2013 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2014 int *last_item_contains_data, afs_status_p st)
2017 afs_status_t tst = 0;
2018 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2021 * Copy the next entry into the cache
2025 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2027 goto fail_GetVLDBEntryRPC;
2032 * See if we've processed all the entries
2036 if (entry->index == entry->total) {
2038 *last_item_contains_data = 1;
2042 fail_GetVLDBEntryRPC:
2051 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2055 afs_status_t tst = 0;
2056 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2058 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2069 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2072 afs_status_t tst = 0;
2073 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2075 if (entry->entries.nbulkentries_val != NULL) {
2076 free(entry->entries.nbulkentries_val);
2088 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2092 * IN cellHandle - a previously opened cellHandle that corresponds
2093 * to the cell where the volume entries exist.
2095 * IN serverHandle - a handle to the server whose entries should be listed.
2098 * IN callBack - a call back function pointer that may be called to report
2099 * status information. Can be null.
2101 * IN partition - the partition whose entries should be listed.
2104 * OUT iterationIdP - upon successful completion, contains an iterator that
2105 * can be passed to vos_VLDBGetNext.
2109 * No locks are obtained or released by this function
2113 * Returns != 0 upon successful completion.
2117 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2118 vos_MessageCallBack_t callBack, unsigned int *partition,
2119 void **iterationIdP, afs_status_p st)
2122 afs_status_t tst = 0;
2123 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2124 file_server_p f_server = (file_server_p) serverHandle;
2125 afs_admin_iterator_p iter =
2126 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2127 vldb_entry_get_p entry =
2128 (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2129 struct VldbListByAttributes attr;
2132 memset(&attr, 0, sizeof(attr));
2135 * Validate arguments
2138 if (!IsValidCellHandle(c_handle, &tst)) {
2139 goto fail_vos_VLDBGetBegin;
2142 if ((iter == NULL) || (entry == NULL)) {
2144 goto fail_vos_VLDBGetBegin;
2147 if (f_server != NULL) {
2148 if (!IsValidServerHandle(f_server, &tst)) {
2149 goto fail_vos_VLDBGetBegin;
2151 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2152 attr.Mask |= VLLIST_SERVER;
2155 if (partition != NULL) {
2156 if (*partition > VOLMAXPARTS) {
2157 tst = ADMVOSPARTITIONTOOLARGE;
2158 goto fail_vos_VLDBGetBegin;
2160 attr.partition = *partition;
2161 attr.Mask |= VLLIST_PARTITION;
2164 if (!VLDB_ListAttributes
2165 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2166 goto fail_vos_VLDBGetBegin;
2169 if (entry->total <= 0) {
2170 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2171 goto fail_vos_VLDBGetBegin;
2173 iter->done_iterating = 1;
2174 iter->st = ADMITERATORDONE;
2177 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2178 NULL, DestroyVLDBEntry, &tst)) {
2179 goto fail_vos_VLDBGetBegin;
2182 *iterationIdP = (void *)iter;
2185 fail_vos_VLDBGetBegin:
2191 if (entry->entries.nbulkentries_val != NULL) {
2192 free(entry->entries.nbulkentries_val);
2194 if (entry != NULL) {
2206 * vos_VLDBGetNext - get information about the next volume.
2210 * IN iterationId - an iterator previously returned by
2213 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2214 * that upon successful completion contains information about the
2219 * The iterator is locked while the next item is retrieved.
2223 * Returns != 0 upon successful completion.
2227 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2231 afs_status_t tst = 0;
2232 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2235 tst = ADMITERATORNULL;
2236 goto fail_vos_VLDBGetNext;
2239 if (vldbEntry == NULL) {
2240 tst = ADMVOSVLDBENTRYNULL;
2241 goto fail_vos_VLDBGetNext;
2244 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2246 fail_vos_VLDBGetNext:
2255 * vos_VLDBGetDone - finish using a volume iterator.
2259 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2263 * The iterator is locked and then destroyed.
2267 * Returns != 0 upon successful completion.
2271 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2274 afs_status_t tst = 0;
2275 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2278 * Validate arguments
2282 tst = ADMITERATORNULL;
2283 goto fail_vos_VLDBGetDone;
2286 rc = IteratorDone(iter, &tst);
2288 fail_vos_VLDBGetDone:
2297 * vos_VLDBEntryRemove - remove a vldb entry.
2301 * IN cellHandle - a previously opened cellHandle that corresponds
2302 * to the cell where the vldb entry exists.
2304 * IN serverHandle - a previously opened serverHandle that corresponds
2305 * to the server where the vldb entry exists. Can be null.
2307 * IN callBack - a call back function pointer that may be called to report
2308 * status information. Can be null.
2310 * IN partition - the partition where the vldb entry exists. Can be null.
2312 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2316 * No locks are obtained or released by this function
2320 * Returns != 0 upon successful completion.
2324 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2325 vos_MessageCallBack_t callBack,
2326 const unsigned int *partition, unsigned int *volumeId,
2330 afs_status_t tst = 0;
2331 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2332 file_server_p f_server = (file_server_p) serverHandle;
2333 struct VldbListByAttributes attr;
2334 nbulkentries entries;
2338 memset(&attr, 0, sizeof(attr));
2339 memset(&entries, 0, sizeof(entries));
2342 * Validate arguments
2345 if (!IsValidCellHandle(c_handle, &tst)) {
2346 goto fail_vos_VLDBEntryRemove;
2350 * If the volume is specified, just delete it
2353 if (volumeId != NULL) {
2354 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2356 goto fail_vos_VLDBEntryRemove;
2360 if (f_server != NULL) {
2361 if (!IsValidServerHandle(f_server, &tst)) {
2362 goto fail_vos_VLDBEntryRemove;
2364 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2365 attr.Mask |= VLLIST_SERVER;
2368 if (partition != NULL) {
2369 if (*partition > VOLMAXPARTS) {
2370 tst = ADMVOSPARTITIONTOOLARGE;
2371 goto fail_vos_VLDBEntryRemove;
2373 attr.partition = *partition;
2374 attr.Mask |= VLLIST_PARTITION;
2377 if ((f_server == NULL) && (partition == NULL)) {
2378 tst = ADMVOSVLDBDELETEALLNULL;
2379 goto fail_vos_VLDBEntryRemove;
2382 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2383 goto fail_vos_VLDBEntryRemove;
2386 if (nentries <= 0) {
2387 tst = ADMVOSVLDBNOENTRIES;
2388 goto fail_vos_VLDBEntryRemove;
2391 for (i = 0; i < nentries; i++) {
2392 ubik_VL_DeleteEntry(c_handle->vos, 0,
2393 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2397 fail_vos_VLDBEntryRemove:
2399 if (entries.nbulkentries_val) {
2400 free(entries.nbulkentries_val);
2410 * vos_VLDBUnlock - unlock vldb entries en masse.
2414 * IN cellHandle - a previously opened cellHandle that corresponds
2415 * to the cell where the vldb entries exist.
2417 * IN serverHandle - a previously opened serverHandle that corresponds
2418 * to the server where the vldb entries exist. Can be null.
2420 * IN callBack - a call back function pointer that may be called to report
2421 * status information. Can be null.
2423 * IN partition - the partition where the vldb entries exist. Can be null.
2427 * No locks are obtained or released by this function
2431 * Returns != 0 upon successful completion.
2435 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2436 vos_MessageCallBack_t callBack, const unsigned int *partition,
2440 afs_status_t tst = 0;
2441 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2442 file_server_p f_server = (file_server_p) serverHandle;
2443 struct VldbListByAttributes attr;
2444 nbulkentries entries;
2448 memset(&attr, 0, sizeof(attr));
2449 memset(&entries, 0, sizeof(entries));
2452 * Validate arguments
2455 if (!IsValidCellHandle(c_handle, &tst)) {
2456 goto fail_vos_VLDBUnlock;
2459 if (f_server != NULL) {
2460 if (!IsValidServerHandle(f_server, &tst)) {
2461 goto fail_vos_VLDBUnlock;
2463 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2464 attr.Mask |= VLLIST_SERVER;
2467 if (partition != NULL) {
2468 if (*partition > VOLMAXPARTS) {
2469 tst = ADMVOSPARTITIONTOOLARGE;
2470 goto fail_vos_VLDBUnlock;
2472 attr.partition = *partition;
2473 attr.Mask |= VLLIST_PARTITION;
2475 attr.flag = VLOP_ALLOPERS;
2476 attr.Mask |= VLLIST_FLAG;
2479 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2480 goto fail_vos_VLDBUnlock;
2483 if (nentries <= 0) {
2484 tst = ADMVOSVLDBNOENTRIES;
2485 goto fail_vos_VLDBUnlock;
2488 for (i = 0; i < nentries; i++) {
2489 vos_VLDBEntryUnlock(cellHandle, 0,
2490 entries.nbulkentries_val[i].volumeId[RWVOL],
2495 fail_vos_VLDBUnlock:
2497 if (entries.nbulkentries_val) {
2498 free(entries.nbulkentries_val);
2509 * vos_VLDBEntryLock - lock a vldb entry.
2513 * IN cellHandle - a previously opened cellHandle that corresponds
2514 * to the cell where the vldb entry exists.
2516 * IN callBack - a call back function pointer that may be called to report
2517 * status information. Can be null.
2519 * IN volumeId - the volume id of the vldb entry to be deleted.
2523 * No locks are obtained or released by this function
2527 * Returns != 0 upon successful completion.
2531 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2532 unsigned int volumeId, afs_status_p st)
2535 afs_status_t tst = 0;
2536 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2539 * Validate arguments
2542 if (!IsValidCellHandle(c_handle, &tst)) {
2543 goto fail_vos_VLDBEntryLock;
2546 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2548 goto fail_vos_VLDBEntryLock;
2552 fail_vos_VLDBEntryLock:
2561 * vos_VLDBEntryUnlock - unlock a vldb entry.
2565 * IN cellHandle - a previously opened cellHandle that corresponds
2566 * to the cell where the vldb entry exists.
2568 * IN callBack - a call back function pointer that may be called to report
2569 * status information. Can be null.
2571 * IN volumeId - the volume id of the vldb entry to be unlocked.
2575 * No locks are obtained or released by this function
2579 * Returns != 0 upon successful completion.
2583 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2584 unsigned int volumeId, afs_status_p st)
2587 afs_status_t tst = 0;
2588 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2591 * Validate arguments
2594 if (!IsValidCellHandle(c_handle, &tst)) {
2595 goto fail_vos_VLDBEntryUnlock;
2600 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2601 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2603 goto fail_vos_VLDBEntryUnlock;
2607 fail_vos_VLDBEntryUnlock:
2616 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2620 * IN cellHandle - a previously opened cellHandle that corresponds
2621 * to the cell where the volume exists.
2623 * IN serverHandle - a previously opened serverHandle that corresponds
2624 * to the server where the new volume should be created.
2626 * IN callBack - a call back function pointer that may be called to report
2627 * status information. Can be null.
2629 * IN partition - the partition where then new volume should be created.
2631 * IN volumeId - the volume id of the volume to be replicated.
2635 * No locks are obtained or released by this function
2639 * Returns != 0 upon successful completion.
2643 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2644 vos_MessageCallBack_t callBack,
2645 unsigned int partition, unsigned int volumeId,
2649 afs_status_t tst = 0;
2650 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2651 file_server_p f_server = (file_server_p) serverHandle;
2654 * Validate arguments
2657 if (!IsValidCellHandle(c_handle, &tst)) {
2658 goto fail_vos_VLDBReadOnlySiteCreate;
2661 if (!IsValidServerHandle(f_server, &tst)) {
2662 goto fail_vos_VLDBReadOnlySiteCreate;
2665 if (partition > VOLMAXPARTS) {
2666 tst = ADMVOSPARTITIONTOOLARGE;
2667 goto fail_vos_VLDBReadOnlySiteCreate;
2671 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2673 goto fail_vos_VLDBReadOnlySiteCreate;
2677 fail_vos_VLDBReadOnlySiteCreate:
2686 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2691 * IN cellHandle - a previously opened cellHandle that corresponds
2692 * to the cell where the volume exists.
2694 * IN serverHandle - a previously opened serverHandle that corresponds
2695 * to the server where the volume should be deleted.
2697 * IN callBack - a call back function pointer that may be called to report
2698 * status information. Can be null.
2700 * IN partition - the partition where then volume should be deleted.
2702 * IN volumeId - the volume id of the volume to be deleted.
2706 * No locks are obtained or released by this function
2710 * Returns != 0 upon successful completion.
2714 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2715 vos_MessageCallBack_t callBack,
2716 unsigned int partition, unsigned int volumeId,
2720 afs_status_t tst = 0;
2721 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2722 file_server_p f_server = (file_server_p) serverHandle;
2725 * Validate arguments
2728 if (!IsValidCellHandle(c_handle, &tst)) {
2729 goto fail_vos_VLDBReadOnlySiteDelete;
2732 if (!IsValidServerHandle(f_server, &tst)) {
2733 goto fail_vos_VLDBReadOnlySiteDelete;
2736 if (partition > VOLMAXPARTS) {
2737 tst = ADMVOSPARTITIONTOOLARGE;
2738 goto fail_vos_VLDBReadOnlySiteDelete;
2742 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2744 goto fail_vos_VLDBReadOnlySiteDelete;
2748 fail_vos_VLDBReadOnlySiteDelete:
2757 * vos_VLDBSync - synchronize the vldb with the fileserver.
2761 * IN cellHandle - a previously opened cellHandle that corresponds
2762 * to the cell where the sync should occur.
2764 * IN serverHandle - a previously opened serverHandle that corresponds
2765 * to the server where the sync should occur.
2767 * IN callBack - a call back function pointer that may be called to report
2768 * status information. Can be null.
2770 * IN partition - the partition where the sync should occur. Can be null.
2772 * IN force - force deletion of bad volumes.
2776 * No locks are obtained or released by this function
2780 * Returns != 0 upon successful completion.
2784 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2785 vos_MessageCallBack_t callBack, const unsigned int *partition,
2786 vos_force_t force, afs_status_p st)
2789 afs_status_t tst = 0;
2790 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2791 file_server_p f_server = (file_server_p) serverHandle;
2797 * Validate arguments
2800 if (!IsValidCellHandle(c_handle, &tst)) {
2801 goto fail_vos_VLDBSync;
2804 if (!IsValidServerHandle(f_server, &tst)) {
2805 goto fail_vos_VLDBSync;
2808 if (partition != NULL) {
2809 if (*partition > VOLMAXPARTS) {
2810 tst = ADMVOSPARTITIONTOOLARGE;
2811 goto fail_vos_VLDBSync;
2813 part = (afs_int32) * partition;
2817 if (force == VOS_FORCE) {
2825 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2836 * vos_VolumeCreate - create a new partition.
2840 * IN cellHandle - a previously opened cellHandle that corresponds
2841 * to the cell where the server lives.
2843 * IN serverHandle - a previously open vos server handle that holds
2844 * the partition where the volume should be create.
2846 * IN callBack - a call back function pointer that may be called to report
2847 * status information. Can be null.
2849 * IN partition - the integer that represents the partition that will
2850 * house the new volume.
2852 * IN volumeName - the name of the new volume.
2854 * IN quota - the quota of the new volume.
2856 * OUT volumeId - the volume id of the newly created volume.
2860 * No locks are obtained or released by this function
2864 * Returns != 0 upon successful completion.
2868 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2869 vos_MessageCallBack_t callBack, unsigned int partition,
2870 const char *volumeName, unsigned int quota,
2871 unsigned int *volumeId, afs_status_p st)
2874 afs_status_t tst = 0;
2875 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2876 file_server_p f_server = (file_server_p) serverHandle;
2877 vos_partitionEntry_t pinfo;
2878 struct nvldbentry vinfo;
2881 * Validate arguments
2884 if (!IsValidCellHandle(c_handle, &tst)) {
2885 goto fail_vos_VolumeCreate;
2888 if (!IsValidServerHandle(f_server, &tst)) {
2889 goto fail_vos_VolumeCreate;
2892 if (partition > VOLMAXPARTS) {
2893 tst = ADMVOSPARTITIONTOOLARGE;
2894 goto fail_vos_VolumeCreate;
2897 if (!ValidateVolumeName(volumeName, &tst)) {
2898 goto fail_vos_VolumeCreate;
2901 if (volumeId == NULL) {
2902 tst = ADMVOSVOLUMEID;
2903 goto fail_vos_VolumeCreate;
2907 * Check that partition is valid at the server
2910 if (!vos_PartitionGet
2911 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2912 goto fail_vos_VolumeCreate;
2916 * Check that the volume doesn't already exist
2919 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2920 tst = ADMVOSVOLUMENAMEDUP;
2921 goto fail_vos_VolumeCreate;
2925 * Create the new volume
2928 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2929 quota, volumeId, &tst);
2931 fail_vos_VolumeCreate:
2940 * vos_VolumeDelete - remove a volume.
2944 * IN cellHandle - a previously opened cellHandle that corresponds
2945 * to the cell where the volume exists.
2947 * IN serverHandle - a previously opened serverHandle that corresponds
2948 * to the server where the volume exists.
2950 * IN callBack - a call back function pointer that may be called to report
2951 * status information. Can be null.
2953 * IN partition - the partition where the volume exists.
2955 * IN volumeId - the volume id of the volume to be deleted.
2959 * No locks are obtained or released by this function
2963 * Returns != 0 upon successful completion.
2967 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2968 vos_MessageCallBack_t callBack, unsigned int partition,
2969 unsigned int volumeId, afs_status_p st)
2972 afs_status_t tst = 0;
2973 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2974 file_server_p f_server = (file_server_p) serverHandle;
2975 vos_partitionEntry_t pinfo;
2978 * Validate arguments
2981 if (!IsValidCellHandle(c_handle, &tst)) {
2982 goto fail_vos_VolumeDelete;
2985 if (!IsValidServerHandle(f_server, &tst)) {
2986 goto fail_vos_VolumeDelete;
2989 if (partition > VOLMAXPARTS) {
2990 tst = ADMVOSPARTITIONTOOLARGE;
2991 goto fail_vos_VolumeDelete;
2995 * Check that partition is valid at the server
2998 if (!vos_PartitionGet
2999 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
3000 goto fail_vos_VolumeDelete;
3003 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3005 fail_vos_VolumeDelete:
3014 * vos_VolumeRename - rename a volume.
3018 * IN cellHandle - a previously opened cellHandle that corresponds
3019 * to the cell where the volume exists.
3021 * IN serverHandle - a previously opened serverHandle that corresponds
3022 * to the server where the vldb entry exists. Can be null.
3024 * IN callBack - a call back function pointer that may be called to report
3025 * status information. Can be null.
3027 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3029 * IN newVolumeName - the new name.
3033 * No locks are obtained or released by this function
3037 * Returns != 0 upon successful completion.
3041 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3042 unsigned int readWriteVolumeId, const char *newVolumeName,
3046 afs_status_t tst = 0;
3047 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3048 struct nvldbentry entry;
3051 * Validate arguments
3054 if (!IsValidCellHandle(c_handle, &tst)) {
3055 goto fail_vos_VolumeRename;
3058 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3059 tst = ADMVOSNEWVOLUMENAMENULL;
3060 goto fail_vos_VolumeRename;
3064 * Retrieve the entry
3067 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3068 goto fail_vos_VolumeRename;
3071 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3073 fail_vos_VolumeRename:
3082 * vos_VolumeDump - dump a volume
3086 * IN cellHandle - a previously opened cellHandle that corresponds
3087 * to the cell where the volume exists.
3089 * IN serverHandle - a previously opened serverHandle that corresponds
3090 * to the server where the volume exists. Can be null.
3092 * IN callBack - a call back function pointer that may be called to report
3093 * status information. Can be null.
3095 * IN volumeId - the volume id of the volume to be dumped.
3097 * IN startTime - files with modification times >= this time will be dumped.
3099 * IN dumpFile - the file to dump the volume to.
3103 * No locks are obtained or released by this function
3107 * Returns != 0 upon successful completion.
3111 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3112 vos_MessageCallBack_t callBack, unsigned int *partition,
3113 unsigned int volumeId, unsigned int startTime,
3114 const char *dumpFile, afs_status_p st)
3117 afs_status_t tst = 0;
3118 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3119 file_server_p f_server = (file_server_p) serverHandle;
3120 afs_int32 server, part, voltype;
3121 struct nvldbentry entry;
3124 * Validate arguments
3127 if (!IsValidCellHandle(c_handle, &tst)) {
3128 goto fail_vos_VolumeDump;
3131 if (serverHandle != NULL) {
3132 if (!IsValidServerHandle(f_server, &tst)) {
3133 goto fail_vos_VolumeDump;
3138 * You must specify both the serverHandle and the partition
3141 if (serverHandle || partition) {
3142 if (!serverHandle || !partition) {
3143 tst = ADMVOSSERVERANDPARTITION;
3144 goto fail_vos_VolumeDump;
3146 if (*partition > VOLMAXPARTS) {
3147 tst = ADMVOSPARTITIONTOOLARGE;
3148 goto fail_vos_VolumeDump;
3150 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3155 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3156 goto fail_vos_VolumeDump;
3160 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3161 tst = ADMVOSDUMPFILENULL;
3162 goto fail_vos_VolumeDump;
3165 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3168 fail_vos_VolumeDump:
3177 * vos_VolumeRestore - restore a volume from a dump
3181 * IN cellHandle - a previously opened cellHandle that corresponds
3182 * to the cell where the volume exists.
3184 * IN serverHandle - a previously opened serverHandle that corresponds
3185 * to the server where the volume exists.
3187 * IN callBack - a call back function pointer that may be called to report
3188 * status information. Can be null.
3190 * IN partition - the partition where the volume exists.
3192 * IN volumeId - the volume id of the volume to be restored.
3194 * IN volumeName - the volume name of the volume to be restored.
3196 * IN dumpFile - the file from which to restore the volume.
3198 * IN dumpType - the type of dump to perform.
3202 * No locks are obtained or released by this function
3206 * Returns != 0 upon successful completion.
3210 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3211 vos_MessageCallBack_t callBack, unsigned int partition,
3212 unsigned int *volumeId, const char *volumeName,
3213 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3217 afs_status_t tst = 0;
3218 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3219 file_server_p f_server = (file_server_p) serverHandle;
3220 struct nvldbentry entry;
3221 afs_int32 volid, server;
3224 int restoreflags = 0;
3225 afs_int32 Oserver, Opart, Otype;
3226 struct nvldbentry Oentry;
3230 * Validate arguments
3233 if (!IsValidCellHandle(c_handle, &tst)) {
3234 goto fail_vos_VolumeRestore;
3237 if (serverHandle != NULL) {
3238 if (!IsValidServerHandle(f_server, &tst)) {
3239 goto fail_vos_VolumeRestore;
3244 * Must pass volumeName
3247 if ((volumeName == NULL) || (*volumeName == 0)) {
3248 tst = ADMVOSVOLUMENAMENULL;
3249 goto fail_vos_VolumeRestore;
3252 if (!ValidateVolumeName(volumeName, &tst)) {
3253 goto fail_vos_VolumeRestore;
3257 * If volumeId is passed, it must be a valid volume id
3260 if (volumeId != NULL) {
3261 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3262 goto fail_vos_VolumeRestore;
3269 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3271 if (partition > VOLMAXPARTS) {
3272 tst = ADMVOSPARTITIONTOOLARGE;
3273 goto fail_vos_VolumeRestore;
3277 * Check that dumpFile exists and can be accessed
3280 fd = open(dumpFile, 0);
3281 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3283 tst = ADMVOSDUMPFILEOPENFAIL;
3284 goto fail_vos_VolumeRestore;
3289 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3290 restoreflags = RV_FULLRST;
3291 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3292 restoreflags = RV_FULLRST;
3294 volid = entry.volumeId[RWVOL];
3295 } else if ((entry.volumeId[RWVOL] != 0)
3296 && (entry.volumeId[RWVOL] != volid)) {
3297 volid = entry.volumeId[RWVOL];
3302 volid = entry.volumeId[RWVOL];
3303 } else if ((entry.volumeId[RWVOL] != 0)
3304 && (entry.volumeId[RWVOL] != volid)) {
3305 volid = entry.volumeId[RWVOL];
3309 * If the vldb says the same volume exists somewhere else
3310 * the caller must specify a full restore, not an incremental
3313 if (dumpType == VOS_RESTORE_FULL) {
3314 restoreflags = RV_FULLRST;
3318 * Check to see if the volume exists where the caller said
3321 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3322 goto fail_vos_VolumeRestore;
3324 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3325 goto fail_vos_VolumeRestore;
3329 tst = ADMVOSRESTOREVOLEXIST;
3330 goto fail_vos_VolumeRestore;
3335 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3336 restoreflags, dumpFile, &tst);
3338 fail_vos_VolumeRestore:
3347 * vos_VolumeOnline - bring a volume online.
3351 * IN serverHandle - a previously opened serverHandle that corresponds
3352 * to the server where the volume exists.
3354 * IN callBack - a call back function pointer that may be called to report
3355 * status information. Can be null.
3357 * IN partition - the partition where the volume exists.
3359 * IN volumeId - the volume id of the volume to be brought online.
3363 * No locks are obtained or released by this function
3367 * Returns != 0 upon successful completion.
3371 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3372 unsigned int partition, unsigned int volumeId,
3373 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3377 afs_status_t tst = 0;
3378 file_server_p f_server = (file_server_p) serverHandle;
3382 * Validate arguments
3385 if (!IsValidServerHandle(f_server, &tst)) {
3386 goto fail_vos_VolumeOnline;
3389 if (partition > VOLMAXPARTS) {
3390 tst = ADMVOSPARTITIONIDTOOLARGE;
3391 goto fail_vos_VolumeOnline;
3394 if (volumeStatus == VOS_ONLINE_BUSY) {
3398 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3401 fail_vos_VolumeOnline:
3410 * vos_VolumeOffline - take a volume offline.
3414 * IN serverHandle - a previously opened serverHandle that corresponds
3415 * to the server where the volume exists.
3417 * IN callBack - a call back function pointer that may be called to report
3418 * status information. Can be null.
3420 * IN partition - the partition where the volume exists.
3422 * IN volumeId - the volume id of the volume to be taken offline.
3426 * No locks are obtained or released by this function
3430 * Returns != 0 upon successful completion.
3434 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3435 unsigned int partition, unsigned int volumeId,
3439 afs_status_t tst = 0;
3440 file_server_p f_server = (file_server_p) serverHandle;
3443 * Validate arguments
3446 if (!IsValidServerHandle(f_server, &tst)) {
3447 goto fail_vos_VolumeOffline;
3450 if (partition > VOLMAXPARTS) {
3451 tst = ADMVOSPARTITIONIDTOOLARGE;
3452 goto fail_vos_VolumeOffline;
3455 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3456 VTOutOfService, 0, &tst);
3458 fail_vos_VolumeOffline:
3467 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3471 * IN source - the volintXInfo structure to copy.
3473 * OUT dest - the vos_volumeEntry_t to fill
3477 * No locks are obtained or released by this function
3481 * Returns != 0 upon successful completion.
3485 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3489 afs_status_t tst = 0;
3493 * If the volume is not marked OK, all the other fields are invalid
3494 * We take the extra step of blanking out dest here to prevent the
3495 * user from seeing stale data from a previous call
3498 memset(dest, 0, sizeof(dest));
3500 switch (source->status) {
3502 dest->status = VOS_OK;
3505 dest->status = VOS_SALVAGE;
3508 dest->status = VOS_NO_VNODE;
3511 dest->status = VOS_NO_VOL;
3514 dest->status = VOS_VOL_EXISTS;
3517 dest->status = VOS_NO_SERVICE;
3520 dest->status = VOS_OFFLINE;
3523 dest->status = VOS_ONLINE;
3526 dest->status = VOS_DISK_FULL;
3529 dest->status = VOS_OVER_QUOTA;
3532 dest->status = VOS_BUSY;
3535 dest->status = VOS_MOVED;
3540 * Check to see if the entry is marked ok before copying all the
3544 if (dest->status == VOS_OK) {
3545 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3546 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3547 dest->id = source->volid;
3548 if (source->type == 0) {
3549 dest->type = VOS_READ_WRITE_VOLUME;
3550 } else if (source->type == 1) {
3551 dest->type = VOS_READ_ONLY_VOLUME;
3552 } else if (source->type == 2) {
3553 dest->type = VOS_BACKUP_VOLUME;
3555 dest->backupId = source->backupID;
3556 dest->readWriteId = source->parentID;
3557 dest->readOnlyId = source->cloneID;
3558 dest->copyCreationDate = source->copyDate;
3559 dest->creationDate = source->creationDate;
3560 dest->lastAccessDate = source->accessDate;
3561 dest->lastUpdateDate = source->updateDate;
3562 dest->lastBackupDate = source->backupDate;
3563 dest->accessesSinceMidnight = source->dayUse;
3564 dest->fileCount = source->filecount;
3565 dest->maxQuota = source->maxquota;
3566 dest->currentSize = source->size;
3567 if (source->inUse == 1) {
3568 dest->volumeDisposition = VOS_ONLINE;
3570 dest->volumeDisposition = VOS_OFFLINE;
3573 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3574 dest->readStats[i] = source->stat_reads[i];
3575 dest->writeStats[i] = source->stat_writes[i];
3578 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3579 dest->fileAuthorWriteSameNetwork[i] =
3580 source->stat_fileSameAuthor[i];
3581 dest->fileAuthorWriteDifferentNetwork[i] =
3582 source->stat_fileDiffAuthor[i];
3583 dest->dirAuthorWriteSameNetwork[i] =
3584 source->stat_dirSameAuthor[i];
3585 dest->dirAuthorWriteDifferentNetwork[i] =
3586 source->stat_dirDiffAuthor[i];
3599 * vos_VolumeGet - get information about a particular volume.
3603 * IN cellHandle - a previously opened cellHandle that corresponds
3604 * to the cell where the volume exists.
3606 * IN serverHandle - a previously opened serverHandle that corresponds
3607 * to the server where the volume exists.
3609 * IN callBack - a call back function pointer that may be called to report
3610 * status information. Can be null.
3612 * IN partition - the partition where the volume exists.
3614 * IN volumeId - the volume id of the volume to be retrieved.
3616 * OUT volumeP - upon successful completion, contains the information about the
3621 * No locks are obtained or released by this function
3625 * Returns != 0 upon successful completion.
3629 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3630 vos_MessageCallBack_t callBack, unsigned int partition,
3631 unsigned int volumeId, vos_volumeEntry_p volumeP,
3635 afs_status_t tst = 0;
3636 file_server_p f_server = (file_server_p) serverHandle;
3637 struct volintXInfo *info = NULL;
3640 * Validate arguments
3643 if (!IsValidServerHandle(f_server, &tst)) {
3644 goto fail_vos_VolumeGet;
3647 if (partition > VOLMAXPARTS) {
3648 tst = ADMVOSPARTITIONIDTOOLARGE;
3649 goto fail_vos_VolumeGet;
3652 if (volumeP == NULL) {
3653 tst = ADMVOSVOLUMEPNULL;
3654 goto fail_vos_VolumeGet;
3658 * Retrieve the information for the volume
3661 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3662 goto fail_vos_VolumeGet;
3666 * Copy the volume info to our structure
3669 if (!copyvolintXInfo(info, volumeP, &tst)) {
3670 goto fail_vos_VolumeGet;
3687 * The iterator functions and data for the volume retrieval functions.
3690 typedef struct volume_get {
3691 struct volintXInfo *vollist;
3692 afs_int32 total; /* total number of volumes at this partition */
3693 afs_int32 index; /* index to the current volume */
3694 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3695 } volume_get_t, *volume_get_p;
3698 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3699 int *last_item_contains_data, afs_status_p st)
3702 afs_status_t tst = 0;
3703 volume_get_p entry = (volume_get_p) rpc_specific;
3706 * Copy the next entry into the cache
3709 if (!copyvolintXInfo
3710 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3711 goto fail_GetVolumeRPC;
3716 * See if we've processed all the entries
3720 if (entry->index == entry->total) {
3722 *last_item_contains_data = 1;
3735 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3738 afs_status_t tst = 0;
3739 volume_get_p entry = (volume_get_p) rpc_specific;
3741 memcpy(dest, (const void *)&entry->entry[slot],
3742 sizeof(vos_volumeEntry_t));
3753 DestroyVolume(void *rpc_specific, afs_status_p st)
3756 afs_status_t tst = 0;
3757 volume_get_p entry = (volume_get_p) rpc_specific;
3759 if (entry->vollist != NULL) {
3760 free(entry->vollist);
3772 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3776 * IN cellHandle - a previously opened cellHandle that corresponds
3777 * to the cell where the volumes exist.
3779 * IN serverHandle - a handle to the server where the volumes exist.
3781 * IN callBack - a call back function pointer that may be called to report
3782 * status information. Can be null.
3784 * IN partition - the partition whose volumes should be listed. Can be null.
3786 * OUT iterationIdP - upon successful completion, contains an iterator that
3787 * can be passed to vos_VolumeGetBegin.
3791 * No locks are obtained or released by this function
3795 * Returns != 0 upon successful completion.
3799 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3800 vos_MessageCallBack_t callBack, unsigned int partition,
3801 void **iterationIdP, afs_status_p st)
3804 afs_status_t tst = 0;
3805 file_server_p f_server = (file_server_p) serverHandle;
3806 afs_admin_iterator_p iter =
3807 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3808 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3811 * Validate arguments
3814 if (!IsValidServerHandle(f_server, &tst)) {
3815 goto fail_vos_VolumeGetBegin;
3818 if (partition > VOLMAXPARTS) {
3819 tst = ADMVOSPARTITIONIDTOOLARGE;
3820 goto fail_vos_VolumeGetBegin;
3823 if ((iter == NULL) || (entry == NULL)) {
3825 goto fail_vos_VolumeGetBegin;
3829 * Get a list of all the volumes contained in the partition at the
3833 if (!UV_XListVolumes
3834 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3836 goto fail_vos_VolumeGetBegin;
3839 if (entry->total == 0) {
3840 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3841 goto fail_vos_VolumeGetBegin;
3843 iter->done_iterating = 1;
3844 iter->st = ADMITERATORDONE;
3847 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3848 DestroyVolume, &tst)) {
3849 goto fail_vos_VolumeGetBegin;
3852 *iterationIdP = (void *)iter;
3855 fail_vos_VolumeGetBegin:
3861 if (entry != NULL) {
3873 * vos_VolumeGetNext - get information about the next volume.
3877 * IN iterationId - an iterator previously returned by
3878 * vos_VolumeGetBegin
3880 * OUT volumeP - a pointer to a vos_volumeEntry_t
3881 * that upon successful completion contains information about the
3886 * The iterator is locked while the next item is retrieved.
3890 * Returns != 0 upon successful completion.
3894 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3898 afs_status_t tst = 0;
3899 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3902 tst = ADMITERATORNULL;
3903 goto fail_vos_VolumeGetNext;
3906 if (volumeP == NULL) {
3907 tst = ADMVOSVOLUMEPNULL;
3908 goto fail_vos_VolumeGetNext;
3911 rc = IteratorNext(iter, (void *)volumeP, &tst);
3913 fail_vos_VolumeGetNext:
3922 * vos_VolumeGetDone - finish using a volume iterator.
3926 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3930 * The iterator is locked and then destroyed.
3934 * Returns != 0 upon successful completion.
3938 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3941 afs_status_t tst = 0;
3942 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3945 * Validate arguments
3949 tst = ADMITERATORNULL;
3950 goto fail_vos_VolumeGetDone;
3953 rc = IteratorDone(iter, &tst);
3955 fail_vos_VolumeGetDone:
3964 * vos_VolumeMove - move a volume from one server to another.
3968 * IN cellHandle - a previously opened cellHandle that corresponds
3969 * to the cell where the volume exists.
3971 * IN callBack - a call back function pointer that may be called to report
3972 * status information. Can be null.
3974 * IN volumeId - the volume id of the volume to be moved.
3976 * IN fromServer - a previously opened serverHandle that corresponds
3977 * to the server where the volume currently resides.
3979 * IN fromPartition - the partition where the volume currently resides.
3981 * IN toServer - a previously opened serverHandle that corresponds
3982 * to the server where the volume will be moved.
3984 * IN toPartition - the partition where the volume will be moved.
3988 * No locks are obtained or released by this function
3992 * Returns != 0 upon successful completion.
3996 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
3997 unsigned int volumeId, const void *fromServer,
3998 unsigned int fromPartition, const void *toServer,
3999 unsigned int toPartition, afs_status_p st)
4002 afs_status_t tst = 0;
4003 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4004 file_server_p from_server = (file_server_p) fromServer;
4005 file_server_p to_server = (file_server_p) toServer;
4006 afs_int32 from_server_addr =
4007 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4008 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4009 afs_int32 from_partition = fromPartition;
4010 afs_int32 to_partition = toPartition;
4013 * Validate arguments
4016 if (!IsValidCellHandle(c_handle, &tst)) {
4017 goto fail_vos_VolumeMove;
4020 if (!IsValidServerHandle(from_server, &tst)) {
4021 goto fail_vos_VolumeMove;
4024 if (!IsValidServerHandle(to_server, &tst)) {
4025 goto fail_vos_VolumeMove;
4028 if (fromPartition > VOLMAXPARTS) {
4029 tst = ADMVOSPARTITIONIDTOOLARGE;
4030 goto fail_vos_VolumeMove;
4033 if (toPartition > VOLMAXPARTS) {
4034 tst = ADMVOSPARTITIONIDTOOLARGE;
4035 goto fail_vos_VolumeMove;
4042 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4043 to_server_addr, to_partition, &tst);
4045 fail_vos_VolumeMove:
4054 * vos_VolumeRelease - release a volume.
4058 * IN cellHandle - a previously opened cellHandle that corresponds
4059 * to the cell where the volume exists.
4061 * IN callBack - a call back function pointer that may be called to report
4062 * status information. Can be null.
4064 * IN volumeId - the volume to be released.
4066 * IN force - force a complete release.
4070 * No locks are obtained or released by this function
4074 * Returns != 0 upon successful completion.
4078 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4079 unsigned int volumeId, vos_force_t force, afs_status_p st)
4082 afs_status_t tst = 0;
4083 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4084 afs_int32 server, part, forc = 0, voltype, volume;
4085 struct nvldbentry entry;
4088 * Validate arguments
4091 if (!IsValidCellHandle(c_handle, &tst)) {
4092 goto fail_vos_VolumeRelease;
4096 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4097 goto fail_vos_VolumeRelease;
4100 if (force == VOS_FORCE) {
4105 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4107 fail_vos_VolumeRelease:
4116 * vos_VolumeZap - forcibly delete a volume.
4120 * IN cellHandle - a previously opened cellHandle that corresponds
4121 * to the cell where the volume exists.
4123 * IN serverHandle - a previously opened serverHandle that corresponds
4124 * to the server where the volume exists.
4126 * IN callBack - a call back function pointer that may be called to report
4127 * status information. Can be null.
4129 * IN partition - the partition where the volume exists.
4131 * IN volumeId - the volume id of the vldb entry to be deleted.
4133 * IN force - force the deletion of bad volumes.
4137 * No locks are obtained or released by this function
4141 * Returns != 0 upon successful completion.
4145 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4146 vos_MessageCallBack_t callBack, unsigned int partition,
4147 unsigned int volumeId, vos_force_t force, afs_status_p st)
4150 afs_status_t tst = 0;
4151 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4152 file_server_p f_server = (file_server_p) serverHandle;
4155 * Verify that the cellHandle is capable of making vos rpc's
4158 if (!IsValidCellHandle(c_handle, &tst)) {
4159 goto fail_vos_VolumeZap;
4162 if (!IsValidServerHandle(f_server, &tst)) {
4163 goto fail_vos_VolumeZap;
4166 if (force == VOS_FORCE) {
4167 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4170 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4183 * vos_PartitionNameToId - translate a string representing a partition
4188 * IN partitionName - a string representing a partition. Must be of
4191 * OUT partitionId - a number containing the partition id upon successful
4196 * No locks are obtained or released by this function
4200 * Returns != 0 upon successful completion.
4204 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4208 afs_status_t tst = 0;
4209 size_t partition_name_len;
4213 * Validate arguments
4216 if (partitionName == NULL) {
4217 tst = ADMVOSPARTITIONNAMENULL;
4218 goto fail_vos_PartitionNameToId;
4221 if (partitionId == NULL) {
4222 tst = ADMVOSPARTITIONIDNULL;
4223 goto fail_vos_PartitionNameToId;
4227 * Check that string begins with /vicep
4230 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4231 tst = ADMVOSPARTITIONNAMEINVALID;
4232 goto fail_vos_PartitionNameToId;
4236 * Check that the string is either one or two characters
4237 * longer than VICE_PREFIX_SIZE
4240 partition_name_len = strlen(partitionName);
4242 if (partition_name_len == VICE_PREFIX_SIZE) {
4243 tst = ADMVOSPARTITIONNAMETOOSHORT;
4244 goto fail_vos_PartitionNameToId;
4247 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4248 tst = ADMVOSPARTITIONNAMETOOLONG;
4249 goto fail_vos_PartitionNameToId;
4253 * Check that all characters past the prefix are lower case
4256 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4257 if (!islower(partitionName[i])) {
4258 tst = ADMVOSPARTITIONNAMENOTLOWER;
4259 goto fail_vos_PartitionNameToId;
4264 * Convert the name to a number
4267 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4268 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4271 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4272 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4275 if (*partitionId > VOLMAXPARTS) {
4276 tst = ADMVOSPARTITIONIDTOOLARGE;
4277 goto fail_vos_PartitionNameToId;
4281 fail_vos_PartitionNameToId:
4290 * vos_PartitionIdToName - translate a number representing a partition
4291 * to a character string.
4295 * IN partitionId - an integer representing the partition.
4297 * OUT partitionName - a string containing the converted partition ID
4298 * upon successful completion.
4302 * No locks are obtained or released by this function
4306 * Returns != 0 upon successful completion.
4310 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4314 afs_status_t tst = 0;
4316 if (partitionId > VOLMAXPARTS) {
4317 tst = ADMVOSPARTITIONIDTOOLARGE;
4318 goto fail_vos_PartitionIdToName;
4321 if (partitionName == NULL) {
4322 tst = ADMVOSPARTITIONNAMENULL;
4323 goto fail_vos_PartitionIdToName;
4326 if (partitionId < 26) {
4327 strcpy(partitionName, VICE_PARTITION_PREFIX);
4328 partitionName[6] = partitionId + 'a';
4329 partitionName[7] = '\0';
4331 strcpy(partitionName, VICE_PARTITION_PREFIX);
4333 partitionName[6] = 'a' + (partitionId / 26);
4334 partitionName[7] = 'a' + (partitionId % 26);
4335 partitionName[8] = '\0';
4339 fail_vos_PartitionIdToName:
4348 * vos_VolumeQuotaChange - change the quota of a volume.
4352 * IN cellHandle - a previously opened cellHandle that corresponds
4353 * to the cell where the volume exists.
4355 * IN serverHandle - a previously opened serverHandle that corresponds
4356 * to the server where the volume exists.
4358 * IN callBack - a call back function pointer that may be called to report
4359 * status information. Can be null.
4361 * IN partition - the partition where the volume exists.
4363 * IN volumeId - the volume id of the volume to be modified.
4365 * IN volumeQuota - the new volume quota.
4369 * No locks are obtained or released by this function
4373 * Returns != 0 upon successful completion.
4377 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4378 vos_MessageCallBack_t callBack, unsigned int partition,
4379 unsigned int volumeId, unsigned int volumeQuota,
4383 afs_status_t tst = 0;
4384 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4385 file_server_p f_server = (file_server_p) serverHandle;
4388 struct volintInfo tstatus;
4389 int active_trans = 0;
4392 * Verify that the cellHandle is capable of making vos rpc's
4395 if (!IsValidCellHandle(c_handle, &tst)) {
4396 goto fail_vos_VolumeQuotaChange;
4399 if (!IsValidServerHandle(f_server, &tst)) {
4400 goto fail_vos_VolumeQuotaChange;
4403 memset((void *)&tstatus, 0, sizeof(tstatus));
4404 tstatus.dayUse = -1;
4405 tstatus.spare2 = -1;
4406 tstatus.maxquota = volumeQuota;
4410 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4412 goto fail_vos_VolumeQuotaChange;
4416 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4418 goto fail_vos_VolumeQuotaChange;
4422 fail_vos_VolumeQuotaChange:
4425 afs_status_t tst2 = 0;
4426 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4447 * vos_VolumeGet2 - get information about a particular volume.
4451 * IN cellHandle - a previously opened cellHandle that corresponds
4452 * to the cell where the volume exists.
4454 * IN serverHandle - a previously opened serverHandle that corresponds
4455 * to the server where the volume exists.
4457 * IN callBack - a call back function pointer that may be called to report
4458 * status information. Can be null.
4460 * IN partition - the partition where the volume exists.
4462 * IN volumeId - the volume id of the volume to be retrieved.
4464 * OUT pinfo - upon successful completion, contains the information about the
4469 * No locks are obtained or released by this function
4473 * Returns != 0 upon successful completion.
4477 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4478 vos_MessageCallBack_t callBack, unsigned int partition,
4479 unsigned int volumeId, volintInfo* pinfo,
4483 afs_status_t tst = 0;
4484 file_server_p f_server = (file_server_p) serverHandle;
4485 volintInfo *pinfo_=0;
4488 * Validate arguments
4491 if (!IsValidServerHandle(f_server, &tst)) {
4492 goto fail_vos_VolumeGet2;
4495 if (partition > VOLMAXPARTS) {
4496 tst = ADMVOSPARTITIONIDTOOLARGE;
4497 goto fail_vos_VolumeGet2;
4500 if (pinfo == NULL) {
4501 tst = ADMVOSVOLUMEPNULL;
4502 goto fail_vos_VolumeGet2;
4506 * Retrieve the information for the volume
4509 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4510 goto fail_vos_VolumeGet2;
4516 fail_vos_VolumeGet2:
4518 if (pinfo_ != NULL) {
4519 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4530 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4534 * IN cellHandle - a previously opened cellHandle that corresponds
4535 * to the cell where the volume exists.
4537 * IN serverHandle - a previously opened serverHandle that corresponds
4538 * to the server where the volume exists.
4540 * IN partition - the partition where the volume exists.
4542 * IN volumeId - the volume id of the volume to be retrieved.
4546 * No locks are obtained or released by this function
4550 * Returns != 0 upon successful completion.
4554 vos_ClearVolUpdateCounter(const void *cellHandle,
4555 const void *serverHandle,
4556 unsigned int partition,
4557 unsigned int volumeId,
4561 afs_status_t tst = 0;
4562 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4563 file_server_p f_server = (file_server_p) serverHandle;
4566 struct volintInfo tstatus;
4567 int active_trans = 0;
4570 * Verify that the cellHandle is capable of making vos rpc's
4573 if (!IsValidCellHandle(c_handle, &tst)) {
4574 goto fail_vos_ClearVolUpdateCounter;
4577 if (!IsValidServerHandle(f_server, &tst)) {
4578 goto fail_vos_ClearVolUpdateCounter;
4581 memset((void *)&tstatus, 0, sizeof(tstatus));
4582 tstatus.maxquota = -1;
4583 tstatus.dayUse = -1;
4584 tstatus.creationDate = -1;
4585 tstatus.updateDate = -1;
4587 tstatus.spare0 = -1;
4588 tstatus.spare1 = -1;
4590 tstatus.spare3 = -1;
4593 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4595 goto fail_vos_ClearVolUpdateCounter;
4599 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4601 goto fail_vos_ClearVolUpdateCounter;
4605 fail_vos_ClearVolUpdateCounter:
4608 afs_status_t tst2 = 0;
4609 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);