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>
18 #include <afs/vlserver.h>
19 #include <afs/afsint.h>
20 #include <afs/volser.h>
21 #include <afs/volint.h>
23 #include "afs_vosAdmin.h"
24 #include "../adminutil/afs_AdminInternal.h"
26 /* File descriptors are HANDLE's on NT. The following typedef helps catch
27 * type errors. Duplicated from vol/ihandle.h
34 #define INVALID_FD ((FD_t)-1)
36 #include <afs/partition.h>
38 #include <rx/rxstat.h>
39 #include <afs/afs_utilAdmin.h>
42 #include "lockprocs.h"
44 typedef struct file_server {
47 struct rx_connection *serv;
49 } file_server_t, *file_server_p;
52 * IsValidServerHandle - test a server handle for validity.
56 * IN serverHandle - the serverHandle to be validated.
60 * No locks are obtained or released by this function
64 * Returns != 0 upon successful completion.
68 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
73 if (serverHandle == NULL) {
74 tst = ADMVOSSERVERHANDLENULL;
75 goto fail_IsValidServerHandle;
78 if (serverHandle->is_valid != 1) {
79 tst = ADMVOSSERVERHANDLEINVALID;
80 goto fail_IsValidServerHandle;
83 if ((serverHandle->begin_magic != BEGIN_MAGIC)
84 || (serverHandle->end_magic != END_MAGIC)) {
85 tst = ADMVOSSERVERHANDLEBADMAGIC;
86 goto fail_IsValidServerHandle;
90 fail_IsValidServerHandle:
100 * IsValidCellHandle - verify that a cell handle can be used to make vos
105 * IN cellHandle - the cellHandle to be validated.
109 * No locks are obtained or released by this function
113 * Returns != 0 upon successful completion.
117 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
120 afs_status_t tst = 0;
122 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
123 goto fail_IsValidCellHandle;
126 if (cellHandle->vos_valid == 0) {
127 tst = ADMVOSCELLHANDLEINVALIDVOS;
128 goto fail_IsValidCellHandle;
132 fail_IsValidCellHandle:
140 /* set <server> and <part> to the correct values depending on
141 * <voltype> and <entry> */
143 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
144 afs_int32 * part, int *previdx)
146 int i, istart, vtype;
151 /* Doesn't check for non-existance of backup volume */
152 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
154 istart = 0; /* seach the entire entry */
157 /* Seach from beginning of entry or pick up where we left off */
158 istart = ((*previdx < 0) ? 0 : *previdx + 1);
161 for (i = istart; i < entry->nServers; i++) {
162 if (entry->serverFlags[i] & vtype) {
163 *server = entry->serverNumber[i];
164 *part = entry->serverPartition[i];
170 /* Didn't find any, return -1 */
176 * vos_BackupVolumeCreate - create a backup volume for a volume.
180 * IN cellHandle - a previously opened cellHandle that corresponds
181 * to the cell where volume exists.
183 * IN callBack - a call back function pointer that may be called to report
184 * status information. Can be null.
186 * IN volumeId - the volume to create the back up for.
190 * No locks are obtained or released by this function
194 * Returns != 0 upon successful completion.
198 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
199 unsigned int volumeId, afs_status_p st)
202 afs_status_t tst = 0;
203 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
204 struct nvldbentry rw_vol_entry;
206 afs_int32 rw_partition;
207 afs_int32 rw_vol_type;
208 struct nvldbentry bk_vol_entry;
210 afs_int32 bk_partition;
211 afs_int32 bk_vol_type;
218 if (!IsValidCellHandle(c_handle, &tst)) {
219 goto fail_vos_BackupVolumeCreate;
223 * Get the volume information and verify that we've been passed
224 * a read write volume id
228 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
229 &rw_vol_type, &tst)) {
230 goto fail_vos_BackupVolumeCreate;
233 if (rw_vol_type != RWVOL) {
234 tst = ADMVOSMUSTBERWVOL;
235 goto fail_vos_BackupVolumeCreate;
239 * Check to see that if a backup volume exists, it exists on the
240 * same server as volumeId
243 if (rw_vol_entry.flags & VLF_BACKEXISTS) {
245 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
246 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
247 goto fail_vos_BackupVolumeCreate;
249 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
250 goto fail_vos_BackupVolumeCreate;
253 tst = ADMVOSBACKUPVOLWRONGSERVER;
254 goto fail_vos_BackupVolumeCreate;
259 * Create the new backup volume
262 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
264 fail_vos_BackupVolumeCreate:
273 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
277 * IN cellHandle - a previously opened cellHandle that corresponds
278 * to the cell where the volumes exist.
280 * IN serverHandle - the server where the backups are to be created. Can be
283 * IN callBack - a call back function pointer that may be called to report
284 * status information. Can be null.
286 * IN partition - the partition where the backups are to be created. Can be
289 * IN volumePrefix - all volumes with this prefix will have backup volumes
290 * created. Can be null.
292 * IN excludePrefix - exclude the volumes that match volumePrefix.
296 * No locks are obtained or released by this function
300 * Returns != 0 upon successful completion.
304 vos_BackupVolumeCreateMultiple(const void *cellHandle,
305 const void *serverHandle,
306 vos_MessageCallBack_t callBack,
307 const unsigned int *partition,
308 const char *volumePrefix,
309 vos_exclude_t excludePrefix, afs_status_p st)
312 afs_status_t tst = 0;
313 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
314 file_server_p f_server = (file_server_p) serverHandle;
315 struct VldbListByAttributes attr;
318 size_t prefix_len = 0;
319 nbulkentries arrayEntries;
320 afs_int32 nentries = 0;
321 struct nvldbentry *entry;
323 afs_int32 rw_volid, rw_server, rw_partition;
328 memset(&attr, 0, sizeof(attr));
329 memset(&arrayEntries, 0, sizeof(arrayEntries));
334 * The only required argument to this function is the cellHandle.
335 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
339 if (!IsValidCellHandle(c_handle, &tst)) {
340 goto fail_vos_BackupVolumeCreateMultiple;
343 if ((excludePrefix == VOS_EXCLUDE)
344 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
345 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
346 goto fail_vos_BackupVolumeCreateMultiple;
349 if (f_server != NULL) {
350 if (!IsValidServerHandle(f_server, &tst)) {
351 goto fail_vos_BackupVolumeCreateMultiple;
353 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
354 attr.Mask |= VLLIST_SERVER;
357 if (partition != NULL) {
358 if (*partition > VOLMAXPARTS) {
359 tst = ADMVOSPARTITIONTOOLARGE;
360 goto fail_vos_BackupVolumeCreateMultiple;
362 attr.partition = *partition;
363 attr.Mask |= VLLIST_PARTITION;
366 if (excludePrefix == VOS_EXCLUDE) {
370 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
372 prefix_len = strlen(volumePrefix);
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 & VLF_RWEXISTS)) {
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 = malloc(sizeof(afs_admin_iterator_t));
691 partition_get_p part = calloc(1, sizeof(partition_get_t));
697 if (!IsValidServerHandle(f_server, &tst)) {
698 goto fail_vos_PartitionGetBegin;
701 if (iterationIdP == NULL) {
702 goto fail_vos_PartitionGetBegin;
705 if ((iter == NULL) || (part == NULL)) {
707 goto fail_vos_PartitionGetBegin;
711 * Fill in the part structure
714 part->server = serverHandle;
715 if (!UV_ListPartitions
716 (f_server->serv, &part->part_list, &part->total_received, &tst)) {
717 goto fail_vos_PartitionGetBegin;
721 * If we didn't receive any partitions, don't spawn a background thread.
722 * Mark the iterator complete.
725 if (part->total_received == 0) {
726 if (!IteratorInit(iter, (void *)part, NULL, NULL, NULL, NULL, &tst)) {
727 goto fail_vos_PartitionGetBegin;
729 iter->done_iterating = 1;
730 iter->st = ADMITERATORDONE;
733 (iter, (void *)part, GetPartitionInfoRPC,
734 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
735 goto fail_vos_PartitionGetBegin;
738 *iterationIdP = (void *)iter;
741 fail_vos_PartitionGetBegin:
759 * vos_PartitionGetNext - get the next partition at a server.
763 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
765 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
766 * completion contains the next partition.
770 * The iterator is locked while the next parition is retrieved.
774 * Returns != 0 upon successful completion.
778 vos_PartitionGetNext(const void *iterationId, vos_partitionEntry_p partitionP,
782 afs_status_t tst = 0;
783 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
786 tst = ADMITERATORNULL;
787 goto fail_vos_PartitionGetNext;
790 if (partitionP == NULL) {
791 tst = ADMVOSPARTITIONPNULL;
792 goto fail_vos_PartitionGetNext;
795 rc = IteratorNext(iter, (void *)partitionP, &tst);
797 fail_vos_PartitionGetNext:
806 * vos_PartitionGetDone - finish using a partition iterator.
810 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
814 * The iterator is locked and then destroyed.
818 * Returns != 0 upon successful completion.
822 vos_PartitionGetDone(const void *iterationId, afs_status_p st)
825 afs_status_t tst = 0;
826 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
833 tst = ADMITERATORNULL;
834 goto fail_vos_PartitionGetDone;
837 rc = IteratorDone(iter, &tst);
839 fail_vos_PartitionGetDone:
848 * vos_ServerOpen - open a handle to an individual server for future
853 * IN cellHandle - a previously opened cellHandle that corresponds
854 * to the cell where the server lives.
856 * IN serverName - the machine name of the server
858 * OUT serverHandleP - a void pointer that upon successful completion
859 * contains a handle that is used in future operations upon the server.
863 * No locks are obtained or released by this function
867 * Returns != 0 upon successful completion.
871 vos_ServerOpen(const void *cellHandle, const char *serverName,
872 void **serverHandleP, afs_status_p st)
875 afs_status_t tst = 0;
876 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
877 file_server_p f_server = malloc(sizeof(file_server_t));
879 struct rx_securityClass *sc[3];
882 if (f_server == NULL) {
884 goto fail_vos_ServerOpen;
891 if (!IsValidCellHandle(c_handle, &tst)) {
892 goto fail_vos_ServerOpen;
895 if (!c_handle->tokens->afs_token_set) {
896 tst = ADMVOSCELLHANDLENOAFSTOKENS;
897 goto fail_vos_ServerOpen;
900 if (!util_AdminServerAddressGetFromName
901 (serverName, &server_address, &tst)) {
902 goto fail_vos_ServerOpen;
905 scIndex = c_handle->tokens->sc_index;
906 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
908 rx_GetCachedConnection(htonl(server_address),
909 htons(AFSCONF_VOLUMEPORT), VOLSERVICE_ID,
910 sc[scIndex], scIndex);
911 if (f_server->serv != NULL) {
912 f_server->begin_magic = BEGIN_MAGIC;
913 f_server->end_magic = END_MAGIC;
914 f_server->is_valid = 1;
915 *serverHandleP = (void *)f_server;
918 tst = ADMVOSSERVERNOCONNECTION;
919 goto fail_vos_ServerOpen;
931 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
935 * IN serverHandle - an existing server handle.
939 * No locks are obtained or released by this function
943 * Returns != 0 upon successful completion.
947 vos_ServerClose(const void *serverHandle, afs_status_p st)
950 afs_status_t tst = 0;
951 file_server_p f_server = (file_server_p) serverHandle;
953 if (!IsValidServerHandle(f_server, &tst)) {
954 goto fail_vos_ServerClose;
957 rx_ReleaseCachedConnection(f_server->serv);
958 f_server->is_valid = 0;
962 fail_vos_ServerClose:
971 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
976 * IN cellHandle - a previously opened cellHandle that corresponds
977 * to the cell where the server lives.
979 * IN serverHandle - a handle to the server machine.
981 * IN callBack - a call back function pointer that may be called to report
982 * status information. Can be null.
984 * IN partition - the partition to synchronize. Can be NULL.
986 * IN force - force deletion of bad volumes.
990 * No locks are obtained or released by this function
994 * Returns != 0 upon successful completion.
998 vos_ServerSync(const void *cellHandle, const void *serverHandle,
999 vos_MessageCallBack_t callBack, const unsigned int *partition,
1003 afs_status_t tst = 0;
1004 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1005 file_server_p f_server = (file_server_p) serverHandle;
1010 * Validate arguments
1013 if (!IsValidCellHandle(c_handle, &tst)) {
1014 goto fail_vos_ServerSync;
1017 if (!IsValidServerHandle(f_server, &tst)) {
1018 goto fail_vos_ServerSync;
1021 if (partition != NULL) {
1022 if (*partition > VOLMAXPARTS) {
1023 tst = ADMVOSPARTITIONTOOLARGE;
1024 goto fail_vos_ServerSync;
1026 part = (afs_int32) * partition;
1034 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1036 fail_vos_ServerSync:
1045 * vos_FileServerAddressChange - change an existing file server address.
1049 * IN cellHandle - a previously opened cellHandle that corresponds
1050 * to the cell where the address should be changed.
1052 * IN callBack - a call back function pointer that may be called to report
1053 * status information. Can be null.
1055 * IN oldAddress - the old server address in host byte order
1057 * IN newAddress - the new server address in host byte order
1061 * No locks are obtained or released by this function
1065 * Returns != 0 upon successful completion.
1069 vos_FileServerAddressChange(const void *cellHandle,
1070 vos_MessageCallBack_t callBack,
1071 unsigned int oldAddress,
1072 unsigned int newAddress, afs_status_p st)
1075 afs_status_t tst = 0;
1076 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1079 * Validate arguments
1082 if (!IsValidCellHandle(c_handle, &tst)) {
1083 goto fail_vos_FileServerAddressChange;
1087 ubik_VL_ChangeAddr(c_handle->vos, 0, oldAddress, newAddress);
1089 goto fail_vos_FileServerAddressChange;
1093 fail_vos_FileServerAddressChange:
1102 * vos_FileServerAddressRemove - remove an existing file server address.
1106 * IN cellHandle - a previously opened cellHandle that corresponds
1107 * to the cell where the address should be removed.
1109 * IN callBack - a call back function pointer that may be called to report
1110 * status information. Can be null.
1112 * IN serverAddress - the server address to remove in host byte order.
1116 * No locks are obtained or released by this function
1120 * Returns != 0 upon successful completion.
1124 vos_FileServerAddressRemove(const void *cellHandle,
1125 vos_MessageCallBack_t callBack,
1126 unsigned int serverAddress,
1130 afs_status_t tst = 0;
1131 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1132 unsigned int dummyAddress = 0xffffffff;
1135 * Validate arguments
1138 if (!IsValidCellHandle(c_handle, &tst)) {
1139 goto fail_vos_FileServerAddressRemove;
1143 ubik_VL_ChangeAddr(c_handle->vos, 0, dummyAddress,
1146 goto fail_vos_FileServerAddressRemove;
1150 fail_vos_FileServerAddressRemove:
1159 * The iterator functions and data for the server retrieval functions.
1161 * These functions are very similar to the FileServerAddressGet
1162 * functions. The main difference being that instead of returning
1163 * a single address at a time for a server, we fill an array with
1164 * all the addresses of a server.
1167 typedef struct server_get {
1168 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1169 afs_int32 total_addresses; /* total number of addresses */
1170 bulkaddrs addresses; /* the list of addresses */
1171 int address_index; /* current index into address list */
1172 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1173 } server_get_t, *server_get_p;
1176 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1177 int *last_item_contains_data, afs_status_p st)
1180 afs_status_t tst = 0;
1181 server_get_p serv = (server_get_p) rpc_specific;
1182 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1183 afs_int32 base, index;
1186 ListAddrByAttributes m_attrs;
1187 afs_int32 total_multi;
1188 bulkaddrs addr_multi;
1191 memset(&m_attrs, 0, sizeof(m_attrs));
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 = malloc(sizeof(afs_admin_iterator_t));
1337 server_get_p serv = calloc(1, sizeof(server_get_t));
1338 struct VLCallBack unused;
1342 * Validate arguments
1345 if (!IsValidCellHandle(c_handle, &tst)) {
1346 goto fail_vos_FileServerGetBegin;
1349 if (iterationIdP == NULL) {
1350 goto fail_vos_FileServerGetBegin;
1353 if ((iter == NULL) || (serv == NULL)) {
1355 goto fail_vos_FileServerGetBegin;
1359 * Fill in the serv structure
1362 serv->vldb = c_handle->vos;
1364 ubik_VL_GetAddrs(c_handle->vos, 0, 0, 0, &unused,
1365 &serv->total_addresses, &serv->addresses);
1368 goto fail_vos_FileServerGetBegin;
1372 * Remove any bogus IP addresses which the user may have
1373 * been unable to remove.
1376 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1378 if (serv->total_addresses == 0) {
1379 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1380 goto fail_vos_FileServerGetBegin;
1382 iter->done_iterating = 1;
1383 iter->st = ADMITERATORDONE;
1386 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1387 DestroyServer, &tst)) {
1388 goto fail_vos_FileServerGetBegin;
1391 *iterationIdP = (void *)iter;
1394 fail_vos_FileServerGetBegin:
1401 if (serv->addresses.bulkaddrs_val != NULL) {
1402 free(serv->addresses.bulkaddrs_val);
1415 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1419 * IN iterationId - an iterator previously returned by
1420 * vos_FileServerGetBegin
1422 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1423 * completion contains information about the next server in the cell.
1427 * The iterator is locked while the next server is retrieved.
1431 * Returns != 0 upon successful completion.
1435 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1439 afs_status_t tst = 0;
1440 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1443 tst = ADMITERATORNULL;
1444 goto fail_vos_FileServerGetNext;
1447 if (serverEntryP == NULL) {
1448 tst = ADMVOSSERVERENTRYPNULL;
1449 goto fail_vos_FileServerGetNext;
1452 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1454 fail_vos_FileServerGetNext:
1463 * vos_FileServerGetDone - finish using a partition iterator.
1467 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1471 * The iterator is locked and then destroyed.
1475 * Returns != 0 upon successful completion.
1479 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1482 afs_status_t tst = 0;
1483 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1486 * Validate arguments
1490 tst = ADMITERATORNULL;
1491 goto fail_vos_FileServerGetDone;
1494 rc = IteratorDone(iter, &tst);
1496 fail_vos_FileServerGetDone:
1505 * The iterator functions and data for the transation retrieval functions.
1508 typedef struct transaction_get {
1509 afs_int32 total; /* total number of transactions */
1510 afs_int32 index; /* index to the current transaction */
1511 transDebugInfo *cur; /* the current transaction */
1512 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1513 } transaction_get_t, *transaction_get_p;
1516 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1517 int *last_item_contains_data, afs_status_p st)
1520 afs_status_t tst = 0;
1521 transaction_get_p t = (transaction_get_p) rpc_specific;
1522 int index = t->index;
1525 * Copy the next transaction into the cache
1528 t->tran[slot].transactionId = t->cur[index].tid;
1529 t->tran[slot].lastActiveTime = t->cur[index].time;
1530 t->tran[slot].creationTime = t->cur[index].creationTime;
1531 t->tran[slot].errorCode = t->cur[index].returnCode;
1532 t->tran[slot].volumeId = t->cur[index].volid;
1533 t->tran[slot].partition = t->cur[index].partition;
1534 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1535 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1536 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1537 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1538 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1540 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1542 switch (t->cur[index].iflags) {
1544 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1547 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1550 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1553 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1556 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1560 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1562 switch (t->cur[index].vflags) {
1563 case VTDeleteOnSalvage:
1564 t->tran[slot].volumeActiveStatus =
1565 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1567 case VTOutOfService:
1568 t->tran[slot].volumeActiveStatus =
1569 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1572 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1576 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1578 if (t->cur[index].tflags) {
1579 t->tran[slot].volumeTransactionStatus =
1580 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1586 * See if we've processed all the entries
1590 if (t->index == t->total) {
1592 *last_item_contains_data = 1;
1603 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1607 afs_status_t tst = 0;
1608 transaction_get_p tran = (transaction_get_p) rpc_specific;
1610 memcpy(dest, (const void *)&tran->tran[slot],
1611 sizeof(vos_serverTransactionStatus_p));
1622 DestroyTransaction(void *rpc_specific, afs_status_p st)
1625 afs_status_t tst = 0;
1626 transaction_get_p tran = (transaction_get_p) rpc_specific;
1628 if (tran->cur != NULL) {
1640 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1641 * at a volume server.
1645 * IN cellHandle - a previously opened cellHandle that corresponds
1646 * to the cell where the volume server exists.
1648 * IN serverHandle - a handle to the server to query.
1650 * IN callBack - a call back function pointer that may be called to report
1651 * status information. Can be null.
1653 * OUT iterationIdP - upon successful completion, contains an iterator that
1654 * can be passed to vos_ServerTransactionStatusGetNext.
1658 * No locks are obtained or released by this function
1662 * Returns != 0 upon successful completion.
1666 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1667 const void *serverHandle,
1668 vos_MessageCallBack_t callBack,
1669 void **iterationIdP, afs_status_p st)
1672 afs_status_t tst = 0;
1673 file_server_p f_server = (file_server_p) serverHandle;
1674 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
1675 transaction_get_p tran = calloc(1, sizeof(transaction_get_t));
1679 * Validate arguments
1682 if (!IsValidServerHandle(f_server, &tst)) {
1683 goto fail_vos_ServerTransactionStatusGetBegin;
1686 if (iterationIdP == NULL) {
1687 goto fail_vos_ServerTransactionStatusGetBegin;
1690 if ((iter == NULL) || (tran == NULL)) {
1692 goto fail_vos_ServerTransactionStatusGetBegin;
1696 * Fill in the tran structure
1699 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1700 goto fail_vos_ServerTransactionStatusGetBegin;
1703 if (tran->total == 0) {
1704 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1705 goto fail_vos_ServerTransactionStatusGetBegin;
1707 iter->done_iterating = 1;
1708 iter->st = ADMITERATORDONE;
1711 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1712 NULL, DestroyTransaction, &tst)) {
1713 goto fail_vos_ServerTransactionStatusGetBegin;
1716 *iterationIdP = (void *)iter;
1719 fail_vos_ServerTransactionStatusGetBegin:
1726 if (tran->cur != NULL) {
1740 * vos_ServerTransactionStatusGetNext - get information about the next
1741 * active transaction.
1745 * IN iterationId - an iterator previously returned by
1746 * vos_ServerTransactionStatusGetBegin
1748 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1749 * that upon successful completion contains information about the
1754 * The iterator is locked while the next item is retrieved.
1758 * Returns != 0 upon successful completion.
1762 vos_ServerTransactionStatusGetNext(const void *iterationId,
1763 vos_serverTransactionStatus_p
1764 serverTransactionStatusP, afs_status_p st)
1767 afs_status_t tst = 0;
1768 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1771 tst = ADMITERATORNULL;
1772 goto fail_vos_ServerTransactionStatusGetNext;
1775 if (serverTransactionStatusP == NULL) {
1776 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1777 goto fail_vos_ServerTransactionStatusGetNext;
1780 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1782 fail_vos_ServerTransactionStatusGetNext:
1791 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1795 * IN iterationId - an iterator previously returned by
1796 * vos_ServerTransactionStatusGetBegin
1800 * The iterator is locked and then destroyed.
1804 * Returns != 0 upon successful completion.
1808 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1811 afs_status_t tst = 0;
1812 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1815 * Validate arguments
1819 tst = ADMITERATORNULL;
1820 goto fail_vos_ServerTransactionStatusGetDone;
1823 rc = IteratorDone(iter, &tst);
1825 fail_vos_ServerTransactionStatusGetDone:
1834 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1838 afs_status_t tst = 0;
1841 dest->numServers = source->nServers;
1842 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1843 dest->volumeId[i] = source->volumeId[i];
1845 dest->cloneId = source->cloneId;
1846 dest->status = VOS_VLDB_ENTRY_OK;
1847 if (source->flags & VLOP_ALLOPERS) {
1848 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1850 if (source->flags & VLOP_MOVE) {
1851 dest->status |= VOS_VLDB_ENTRY_MOVE;
1853 if (source->flags & VLOP_RELEASE) {
1854 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1856 if (source->flags & VLOP_BACKUP) {
1857 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1859 if (source->flags & VLOP_DELETE) {
1860 dest->status |= VOS_VLDB_ENTRY_DELETE;
1862 if (source->flags & VLOP_DUMP) {
1863 dest->status |= VOS_VLDB_ENTRY_DUMP;
1866 if (source->flags & VLF_RWEXISTS) {
1867 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1869 if (source->flags & VLF_ROEXISTS) {
1870 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1872 if (source->flags & VLF_BACKEXISTS) {
1873 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1876 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1877 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1878 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1879 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1880 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1881 dest->volumeSites[i].serverFlags = 0;
1883 if (source->serverFlags[i] & VLSF_NEWREPSITE) {
1884 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1886 if (source->serverFlags[i] & VLSF_ROVOL) {
1887 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1889 if (source->serverFlags[i] & VLSF_RWVOL) {
1890 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1892 if (source->serverFlags[i] & VLSF_BACKVOL) {
1893 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1895 if (source->serverFlags[i] & VLSF_DONTUSE) {
1896 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1909 * vos_VLDBGet- get a volume's vldb entry.
1913 * IN cellHandle - a previously opened cellHandle that corresponds
1914 * to the cell where the volume entries exist.
1916 * IN callBack - a call back function pointer that may be called to report
1917 * status information. Can be null.
1919 * IN volumeId - the id of the volume to retrieve.
1921 * IN volumeName - the name of the volume to retrieve.
1923 * OUT vldbEntry - upon successful completion, contains the information regarding
1928 * No locks are obtained or released by this function
1932 * Returns != 0 upon successful completion.
1936 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1937 const unsigned int *volumeId, char *volumeName,
1938 vos_vldbEntry_p vldbEntry, afs_status_p st)
1941 afs_status_t tst = 0;
1942 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1943 struct nvldbentry entry;
1947 * Validate arguments
1950 if (!IsValidCellHandle(c_handle, &tst)) {
1951 goto fail_vos_VLDBGet;
1954 if (vldbEntry == NULL) {
1955 tst = ADMVOSVLDBENTRYNULL;
1956 goto fail_vos_VLDBGet;
1959 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1960 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1961 goto fail_vos_VLDBGet;
1965 * Retrieve the entry
1968 if (!((volumeName == NULL) || (*volumeName == 0))) {
1969 if (!ValidateVolumeName(volumeName, &tst)) {
1970 goto fail_vos_VLDBGet;
1972 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1973 goto fail_vos_VLDBGet;
1976 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1977 goto fail_vos_VLDBGet;
1982 * Copy the entry into our structure
1985 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1986 goto fail_vos_VLDBGet;
1999 * The iterator functions and data for the vldb entry retrieval functions.
2002 typedef struct vldb_entry_get {
2003 afs_int32 total; /* total number of vldb entries */
2004 afs_int32 index; /* index to the current vldb entry */
2005 nbulkentries entries; /* the list of entries retrieved */
2006 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2007 } vldb_entry_get_t, *vldb_entry_get_p;
2010 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2011 int *last_item_contains_data, afs_status_p st)
2014 afs_status_t tst = 0;
2015 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2018 * Copy the next entry into the cache
2022 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2024 goto fail_GetVLDBEntryRPC;
2029 * See if we've processed all the entries
2033 if (entry->index == entry->total) {
2035 *last_item_contains_data = 1;
2039 fail_GetVLDBEntryRPC:
2048 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2052 afs_status_t tst = 0;
2053 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2055 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2066 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2069 afs_status_t tst = 0;
2070 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2072 if (entry->entries.nbulkentries_val != NULL) {
2073 free(entry->entries.nbulkentries_val);
2085 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2089 * IN cellHandle - a previously opened cellHandle that corresponds
2090 * to the cell where the volume entries exist.
2092 * IN serverHandle - a handle to the server whose entries should be listed.
2095 * IN callBack - a call back function pointer that may be called to report
2096 * status information. Can be null.
2098 * IN partition - the partition whose entries should be listed.
2101 * OUT iterationIdP - upon successful completion, contains an iterator that
2102 * can be passed to vos_VLDBGetNext.
2106 * No locks are obtained or released by this function
2110 * Returns != 0 upon successful completion.
2114 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2115 vos_MessageCallBack_t callBack, unsigned int *partition,
2116 void **iterationIdP, afs_status_p st)
2119 afs_status_t tst = 0;
2120 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2121 file_server_p f_server = (file_server_p) serverHandle;
2122 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
2123 vldb_entry_get_p entry = calloc(1, sizeof(vldb_entry_get_t));
2124 struct VldbListByAttributes attr;
2127 memset(&attr, 0, sizeof(attr));
2130 * Validate arguments
2133 if (!IsValidCellHandle(c_handle, &tst)) {
2134 goto fail_vos_VLDBGetBegin;
2137 if ((iter == NULL) || (entry == NULL)) {
2139 goto fail_vos_VLDBGetBegin;
2142 if (f_server != NULL) {
2143 if (!IsValidServerHandle(f_server, &tst)) {
2144 goto fail_vos_VLDBGetBegin;
2146 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2147 attr.Mask |= VLLIST_SERVER;
2150 if (partition != NULL) {
2151 if (*partition > VOLMAXPARTS) {
2152 tst = ADMVOSPARTITIONTOOLARGE;
2153 goto fail_vos_VLDBGetBegin;
2155 attr.partition = *partition;
2156 attr.Mask |= VLLIST_PARTITION;
2159 if (!VLDB_ListAttributes
2160 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2161 goto fail_vos_VLDBGetBegin;
2164 if (entry->total <= 0) {
2165 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2166 goto fail_vos_VLDBGetBegin;
2168 iter->done_iterating = 1;
2169 iter->st = ADMITERATORDONE;
2172 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2173 NULL, DestroyVLDBEntry, &tst)) {
2174 goto fail_vos_VLDBGetBegin;
2177 *iterationIdP = (void *)iter;
2180 fail_vos_VLDBGetBegin:
2186 if (entry->entries.nbulkentries_val != NULL) {
2187 free(entry->entries.nbulkentries_val);
2189 if (entry != NULL) {
2201 * vos_VLDBGetNext - get information about the next volume.
2205 * IN iterationId - an iterator previously returned by
2208 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2209 * that upon successful completion contains information about the
2214 * The iterator is locked while the next item is retrieved.
2218 * Returns != 0 upon successful completion.
2222 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2226 afs_status_t tst = 0;
2227 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2230 tst = ADMITERATORNULL;
2231 goto fail_vos_VLDBGetNext;
2234 if (vldbEntry == NULL) {
2235 tst = ADMVOSVLDBENTRYNULL;
2236 goto fail_vos_VLDBGetNext;
2239 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2241 fail_vos_VLDBGetNext:
2250 * vos_VLDBGetDone - finish using a volume iterator.
2254 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2258 * The iterator is locked and then destroyed.
2262 * Returns != 0 upon successful completion.
2266 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2269 afs_status_t tst = 0;
2270 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2273 * Validate arguments
2277 tst = ADMITERATORNULL;
2278 goto fail_vos_VLDBGetDone;
2281 rc = IteratorDone(iter, &tst);
2283 fail_vos_VLDBGetDone:
2292 * vos_VLDBEntryRemove - remove a vldb entry.
2296 * IN cellHandle - a previously opened cellHandle that corresponds
2297 * to the cell where the vldb entry exists.
2299 * IN serverHandle - a previously opened serverHandle that corresponds
2300 * to the server where the vldb entry exists. Can be null.
2302 * IN callBack - a call back function pointer that may be called to report
2303 * status information. Can be null.
2305 * IN partition - the partition where the vldb entry exists. Can be null.
2307 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2311 * No locks are obtained or released by this function
2315 * Returns != 0 upon successful completion.
2319 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2320 vos_MessageCallBack_t callBack,
2321 const unsigned int *partition, unsigned int *volumeId,
2325 afs_status_t tst = 0;
2326 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2327 file_server_p f_server = (file_server_p) serverHandle;
2328 struct VldbListByAttributes attr;
2329 nbulkentries entries;
2333 memset(&attr, 0, sizeof(attr));
2334 memset(&entries, 0, sizeof(entries));
2337 * Validate arguments
2340 if (!IsValidCellHandle(c_handle, &tst)) {
2341 goto fail_vos_VLDBEntryRemove;
2345 * If the volume is specified, just delete it
2348 if (volumeId != NULL) {
2349 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2351 goto fail_vos_VLDBEntryRemove;
2355 if (f_server != NULL) {
2356 if (!IsValidServerHandle(f_server, &tst)) {
2357 goto fail_vos_VLDBEntryRemove;
2359 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2360 attr.Mask |= VLLIST_SERVER;
2363 if (partition != NULL) {
2364 if (*partition > VOLMAXPARTS) {
2365 tst = ADMVOSPARTITIONTOOLARGE;
2366 goto fail_vos_VLDBEntryRemove;
2368 attr.partition = *partition;
2369 attr.Mask |= VLLIST_PARTITION;
2372 if ((f_server == NULL) && (partition == NULL)) {
2373 tst = ADMVOSVLDBDELETEALLNULL;
2374 goto fail_vos_VLDBEntryRemove;
2377 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2378 goto fail_vos_VLDBEntryRemove;
2381 if (nentries <= 0) {
2382 tst = ADMVOSVLDBNOENTRIES;
2383 goto fail_vos_VLDBEntryRemove;
2386 for (i = 0; i < nentries; i++) {
2387 ubik_VL_DeleteEntry(c_handle->vos, 0,
2388 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2392 fail_vos_VLDBEntryRemove:
2394 if (entries.nbulkentries_val) {
2395 free(entries.nbulkentries_val);
2405 * vos_VLDBUnlock - unlock vldb entries en masse.
2409 * IN cellHandle - a previously opened cellHandle that corresponds
2410 * to the cell where the vldb entries exist.
2412 * IN serverHandle - a previously opened serverHandle that corresponds
2413 * to the server where the vldb entries exist. Can be null.
2415 * IN callBack - a call back function pointer that may be called to report
2416 * status information. Can be null.
2418 * IN partition - the partition where the vldb entries exist. Can be null.
2422 * No locks are obtained or released by this function
2426 * Returns != 0 upon successful completion.
2430 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2431 vos_MessageCallBack_t callBack, const unsigned int *partition,
2435 afs_status_t tst = 0;
2436 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2437 file_server_p f_server = (file_server_p) serverHandle;
2438 struct VldbListByAttributes attr;
2439 nbulkentries entries;
2443 memset(&attr, 0, sizeof(attr));
2444 memset(&entries, 0, sizeof(entries));
2447 * Validate arguments
2450 if (!IsValidCellHandle(c_handle, &tst)) {
2451 goto fail_vos_VLDBUnlock;
2454 if (f_server != NULL) {
2455 if (!IsValidServerHandle(f_server, &tst)) {
2456 goto fail_vos_VLDBUnlock;
2458 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2459 attr.Mask |= VLLIST_SERVER;
2462 if (partition != NULL) {
2463 if (*partition > VOLMAXPARTS) {
2464 tst = ADMVOSPARTITIONTOOLARGE;
2465 goto fail_vos_VLDBUnlock;
2467 attr.partition = *partition;
2468 attr.Mask |= VLLIST_PARTITION;
2470 attr.flag = VLOP_ALLOPERS;
2471 attr.Mask |= VLLIST_FLAG;
2474 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2475 goto fail_vos_VLDBUnlock;
2478 if (nentries <= 0) {
2479 tst = ADMVOSVLDBNOENTRIES;
2480 goto fail_vos_VLDBUnlock;
2483 for (i = 0; i < nentries; i++) {
2484 vos_VLDBEntryUnlock(cellHandle, 0,
2485 entries.nbulkentries_val[i].volumeId[RWVOL],
2490 fail_vos_VLDBUnlock:
2492 if (entries.nbulkentries_val) {
2493 free(entries.nbulkentries_val);
2504 * vos_VLDBEntryLock - lock a vldb entry.
2508 * IN cellHandle - a previously opened cellHandle that corresponds
2509 * to the cell where the vldb entry exists.
2511 * IN callBack - a call back function pointer that may be called to report
2512 * status information. Can be null.
2514 * IN volumeId - the volume id of the vldb entry to be deleted.
2518 * No locks are obtained or released by this function
2522 * Returns != 0 upon successful completion.
2526 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2527 unsigned int volumeId, afs_status_p st)
2530 afs_status_t tst = 0;
2531 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2534 * Validate arguments
2537 if (!IsValidCellHandle(c_handle, &tst)) {
2538 goto fail_vos_VLDBEntryLock;
2541 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2543 goto fail_vos_VLDBEntryLock;
2547 fail_vos_VLDBEntryLock:
2556 * vos_VLDBEntryUnlock - unlock a vldb entry.
2560 * IN cellHandle - a previously opened cellHandle that corresponds
2561 * to the cell where the vldb entry exists.
2563 * IN callBack - a call back function pointer that may be called to report
2564 * status information. Can be null.
2566 * IN volumeId - the volume id of the vldb entry to be unlocked.
2570 * No locks are obtained or released by this function
2574 * Returns != 0 upon successful completion.
2578 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2579 unsigned int volumeId, afs_status_p st)
2582 afs_status_t tst = 0;
2583 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2586 * Validate arguments
2589 if (!IsValidCellHandle(c_handle, &tst)) {
2590 goto fail_vos_VLDBEntryUnlock;
2595 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2596 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2598 goto fail_vos_VLDBEntryUnlock;
2602 fail_vos_VLDBEntryUnlock:
2611 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2615 * IN cellHandle - a previously opened cellHandle that corresponds
2616 * to the cell where the volume exists.
2618 * IN serverHandle - a previously opened serverHandle that corresponds
2619 * to the server where the new volume should be created.
2621 * IN callBack - a call back function pointer that may be called to report
2622 * status information. Can be null.
2624 * IN partition - the partition where then new volume should be created.
2626 * IN volumeId - the volume id of the volume to be replicated.
2630 * No locks are obtained or released by this function
2634 * Returns != 0 upon successful completion.
2638 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2639 vos_MessageCallBack_t callBack,
2640 unsigned int partition, unsigned int volumeId,
2644 afs_status_t tst = 0;
2645 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2646 file_server_p f_server = (file_server_p) serverHandle;
2649 * Validate arguments
2652 if (!IsValidCellHandle(c_handle, &tst)) {
2653 goto fail_vos_VLDBReadOnlySiteCreate;
2656 if (!IsValidServerHandle(f_server, &tst)) {
2657 goto fail_vos_VLDBReadOnlySiteCreate;
2660 if (partition > VOLMAXPARTS) {
2661 tst = ADMVOSPARTITIONTOOLARGE;
2662 goto fail_vos_VLDBReadOnlySiteCreate;
2666 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2668 goto fail_vos_VLDBReadOnlySiteCreate;
2672 fail_vos_VLDBReadOnlySiteCreate:
2681 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2686 * IN cellHandle - a previously opened cellHandle that corresponds
2687 * to the cell where the volume exists.
2689 * IN serverHandle - a previously opened serverHandle that corresponds
2690 * to the server where the volume should be deleted.
2692 * IN callBack - a call back function pointer that may be called to report
2693 * status information. Can be null.
2695 * IN partition - the partition where then volume should be deleted.
2697 * IN volumeId - the volume id of the volume to be deleted.
2701 * No locks are obtained or released by this function
2705 * Returns != 0 upon successful completion.
2709 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2710 vos_MessageCallBack_t callBack,
2711 unsigned int partition, unsigned int volumeId,
2715 afs_status_t tst = 0;
2716 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2717 file_server_p f_server = (file_server_p) serverHandle;
2720 * Validate arguments
2723 if (!IsValidCellHandle(c_handle, &tst)) {
2724 goto fail_vos_VLDBReadOnlySiteDelete;
2727 if (!IsValidServerHandle(f_server, &tst)) {
2728 goto fail_vos_VLDBReadOnlySiteDelete;
2731 if (partition > VOLMAXPARTS) {
2732 tst = ADMVOSPARTITIONTOOLARGE;
2733 goto fail_vos_VLDBReadOnlySiteDelete;
2737 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2739 goto fail_vos_VLDBReadOnlySiteDelete;
2743 fail_vos_VLDBReadOnlySiteDelete:
2752 * vos_VLDBSync - synchronize the vldb with the fileserver.
2756 * IN cellHandle - a previously opened cellHandle that corresponds
2757 * to the cell where the sync should occur.
2759 * IN serverHandle - a previously opened serverHandle that corresponds
2760 * to the server where the sync should occur.
2762 * IN callBack - a call back function pointer that may be called to report
2763 * status information. Can be null.
2765 * IN partition - the partition where the sync should occur. Can be null.
2767 * IN force - force deletion of bad volumes.
2771 * No locks are obtained or released by this function
2775 * Returns != 0 upon successful completion.
2779 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2780 vos_MessageCallBack_t callBack, const unsigned int *partition,
2781 vos_force_t force, afs_status_p st)
2784 afs_status_t tst = 0;
2785 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2786 file_server_p f_server = (file_server_p) serverHandle;
2792 * Validate arguments
2795 if (!IsValidCellHandle(c_handle, &tst)) {
2796 goto fail_vos_VLDBSync;
2799 if (!IsValidServerHandle(f_server, &tst)) {
2800 goto fail_vos_VLDBSync;
2803 if (partition != NULL) {
2804 if (*partition > VOLMAXPARTS) {
2805 tst = ADMVOSPARTITIONTOOLARGE;
2806 goto fail_vos_VLDBSync;
2808 part = (afs_int32) * partition;
2812 if (force == VOS_FORCE) {
2820 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2831 * vos_VolumeCreate - create a new partition.
2835 * IN cellHandle - a previously opened cellHandle that corresponds
2836 * to the cell where the server lives.
2838 * IN serverHandle - a previously open vos server handle that holds
2839 * the partition where the volume should be create.
2841 * IN callBack - a call back function pointer that may be called to report
2842 * status information. Can be null.
2844 * IN partition - the integer that represents the partition that will
2845 * house the new volume.
2847 * IN volumeName - the name of the new volume.
2849 * IN quota - the quota of the new volume.
2851 * OUT volumeId - the volume id of the newly created volume.
2855 * No locks are obtained or released by this function
2859 * Returns != 0 upon successful completion.
2863 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2864 vos_MessageCallBack_t callBack, unsigned int partition,
2865 char *volumeName, unsigned int quota,
2866 unsigned int *volumeId, afs_status_p st)
2869 afs_status_t tst = 0;
2870 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2871 file_server_p f_server = (file_server_p) serverHandle;
2872 vos_partitionEntry_t pinfo;
2873 struct nvldbentry vinfo;
2876 * Validate arguments
2879 if (!IsValidCellHandle(c_handle, &tst)) {
2880 goto fail_vos_VolumeCreate;
2883 if (!IsValidServerHandle(f_server, &tst)) {
2884 goto fail_vos_VolumeCreate;
2887 if (partition > VOLMAXPARTS) {
2888 tst = ADMVOSPARTITIONTOOLARGE;
2889 goto fail_vos_VolumeCreate;
2892 if (!ValidateVolumeName(volumeName, &tst)) {
2893 goto fail_vos_VolumeCreate;
2896 if (volumeId == NULL) {
2897 tst = ADMVOSVOLUMEID;
2898 goto fail_vos_VolumeCreate;
2902 * Check that partition is valid at the server
2905 if (!vos_PartitionGet
2906 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2907 goto fail_vos_VolumeCreate;
2911 * Check that the volume doesn't already exist
2914 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2915 tst = ADMVOSVOLUMENAMEDUP;
2916 goto fail_vos_VolumeCreate;
2920 * Create the new volume
2923 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2924 quota, volumeId, &tst);
2926 fail_vos_VolumeCreate:
2935 * vos_VolumeDelete - remove a volume.
2939 * IN cellHandle - a previously opened cellHandle that corresponds
2940 * to the cell where the volume exists.
2942 * IN serverHandle - a previously opened serverHandle that corresponds
2943 * to the server where the volume exists.
2945 * IN callBack - a call back function pointer that may be called to report
2946 * status information. Can be null.
2948 * IN partition - the partition where the volume exists.
2950 * IN volumeId - the volume id of the volume to be deleted.
2954 * No locks are obtained or released by this function
2958 * Returns != 0 upon successful completion.
2962 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2963 vos_MessageCallBack_t callBack, unsigned int partition,
2964 unsigned int volumeId, afs_status_p st)
2967 afs_status_t tst = 0;
2968 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2969 file_server_p f_server = (file_server_p) serverHandle;
2970 vos_partitionEntry_t pinfo;
2973 * Validate arguments
2976 if (!IsValidCellHandle(c_handle, &tst)) {
2977 goto fail_vos_VolumeDelete;
2980 if (!IsValidServerHandle(f_server, &tst)) {
2981 goto fail_vos_VolumeDelete;
2984 if (partition > VOLMAXPARTS) {
2985 tst = ADMVOSPARTITIONTOOLARGE;
2986 goto fail_vos_VolumeDelete;
2990 * Check that partition is valid at the server
2993 if (!vos_PartitionGet
2994 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2995 goto fail_vos_VolumeDelete;
2998 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3000 fail_vos_VolumeDelete:
3009 * vos_VolumeRename - rename a volume.
3013 * IN cellHandle - a previously opened cellHandle that corresponds
3014 * to the cell where the volume exists.
3016 * IN serverHandle - a previously opened serverHandle that corresponds
3017 * to the server where the vldb entry exists. Can be null.
3019 * IN callBack - a call back function pointer that may be called to report
3020 * status information. Can be null.
3022 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3024 * IN newVolumeName - the new name.
3028 * No locks are obtained or released by this function
3032 * Returns != 0 upon successful completion.
3036 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3037 unsigned int readWriteVolumeId, char *newVolumeName,
3041 afs_status_t tst = 0;
3042 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3043 struct nvldbentry entry;
3046 * Validate arguments
3049 if (!IsValidCellHandle(c_handle, &tst)) {
3050 goto fail_vos_VolumeRename;
3053 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3054 tst = ADMVOSNEWVOLUMENAMENULL;
3055 goto fail_vos_VolumeRename;
3059 * Retrieve the entry
3062 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3063 goto fail_vos_VolumeRename;
3066 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3068 fail_vos_VolumeRename:
3077 * vos_VolumeDump - dump a volume
3081 * IN cellHandle - a previously opened cellHandle that corresponds
3082 * to the cell where the volume exists.
3084 * IN serverHandle - a previously opened serverHandle that corresponds
3085 * to the server where the volume exists. Can be null.
3087 * IN callBack - a call back function pointer that may be called to report
3088 * status information. Can be null.
3090 * IN volumeId - the volume id of the volume to be dumped.
3092 * IN startTime - files with modification times >= this time will be dumped.
3094 * IN dumpFile - the file to dump the volume to.
3098 * No locks are obtained or released by this function
3102 * Returns != 0 upon successful completion.
3106 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3107 vos_MessageCallBack_t callBack, unsigned int *partition,
3108 unsigned int volumeId, unsigned int startTime,
3109 const char *dumpFile, afs_status_p st)
3112 afs_status_t tst = 0;
3113 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3114 file_server_p f_server = (file_server_p) serverHandle;
3115 afs_int32 server, part, voltype;
3116 struct nvldbentry entry;
3119 * Validate arguments
3122 if (!IsValidCellHandle(c_handle, &tst)) {
3123 goto fail_vos_VolumeDump;
3126 if (serverHandle != NULL) {
3127 if (!IsValidServerHandle(f_server, &tst)) {
3128 goto fail_vos_VolumeDump;
3133 * You must specify both the serverHandle and the partition
3136 if (serverHandle || partition) {
3137 if (!serverHandle || !partition) {
3138 tst = ADMVOSSERVERANDPARTITION;
3139 goto fail_vos_VolumeDump;
3141 if (*partition > VOLMAXPARTS) {
3142 tst = ADMVOSPARTITIONTOOLARGE;
3143 goto fail_vos_VolumeDump;
3145 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3150 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3151 goto fail_vos_VolumeDump;
3155 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3156 tst = ADMVOSDUMPFILENULL;
3157 goto fail_vos_VolumeDump;
3160 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3163 fail_vos_VolumeDump:
3172 * vos_VolumeRestore - restore a volume from a dump
3176 * IN cellHandle - a previously opened cellHandle that corresponds
3177 * to the cell where the volume exists.
3179 * IN serverHandle - a previously opened serverHandle that corresponds
3180 * to the server where the volume exists.
3182 * IN callBack - a call back function pointer that may be called to report
3183 * status information. Can be null.
3185 * IN partition - the partition where the volume exists.
3187 * IN volumeId - the volume id of the volume to be restored.
3189 * IN volumeName - the volume name of the volume to be restored.
3191 * IN dumpFile - the file from which to restore the volume.
3193 * IN dumpType - the type of dump to perform.
3197 * No locks are obtained or released by this function
3201 * Returns != 0 upon successful completion.
3205 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3206 vos_MessageCallBack_t callBack, unsigned int partition,
3207 unsigned int *volumeId, char *volumeName,
3208 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3212 afs_status_t tst = 0;
3213 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3214 file_server_p f_server = (file_server_p) serverHandle;
3215 struct nvldbentry entry;
3216 afs_int32 volid, server;
3219 int restoreflags = 0;
3220 afs_int32 Oserver, Opart, Otype;
3221 struct nvldbentry Oentry;
3225 * Validate arguments
3228 if (!IsValidCellHandle(c_handle, &tst)) {
3229 goto fail_vos_VolumeRestore;
3232 if (serverHandle != NULL) {
3233 if (!IsValidServerHandle(f_server, &tst)) {
3234 goto fail_vos_VolumeRestore;
3239 * Must pass volumeName
3242 if ((volumeName == NULL) || (*volumeName == 0)) {
3243 tst = ADMVOSVOLUMENAMENULL;
3244 goto fail_vos_VolumeRestore;
3247 if (!ValidateVolumeName(volumeName, &tst)) {
3248 goto fail_vos_VolumeRestore;
3252 * If volumeId is passed, it must be a valid volume id
3255 if (volumeId != NULL) {
3256 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3257 goto fail_vos_VolumeRestore;
3264 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3266 if (partition > VOLMAXPARTS) {
3267 tst = ADMVOSPARTITIONTOOLARGE;
3268 goto fail_vos_VolumeRestore;
3272 * Check that dumpFile exists and can be accessed
3275 fd = open(dumpFile, 0);
3276 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3278 tst = ADMVOSDUMPFILEOPENFAIL;
3279 goto fail_vos_VolumeRestore;
3284 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3285 restoreflags = RV_FULLRST;
3286 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3287 restoreflags = RV_FULLRST;
3289 volid = entry.volumeId[RWVOL];
3290 } else if ((entry.volumeId[RWVOL] != 0)
3291 && (entry.volumeId[RWVOL] != volid)) {
3292 volid = entry.volumeId[RWVOL];
3297 volid = entry.volumeId[RWVOL];
3298 } else if ((entry.volumeId[RWVOL] != 0)
3299 && (entry.volumeId[RWVOL] != volid)) {
3300 volid = entry.volumeId[RWVOL];
3304 * If the vldb says the same volume exists somewhere else
3305 * the caller must specify a full restore, not an incremental
3308 if (dumpType == VOS_RESTORE_FULL) {
3309 restoreflags = RV_FULLRST;
3313 * Check to see if the volume exists where the caller said
3316 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3317 goto fail_vos_VolumeRestore;
3319 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3320 goto fail_vos_VolumeRestore;
3324 tst = ADMVOSRESTOREVOLEXIST;
3325 goto fail_vos_VolumeRestore;
3330 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3331 restoreflags, dumpFile, &tst);
3333 fail_vos_VolumeRestore:
3342 * vos_VolumeOnline - bring a volume online.
3346 * IN serverHandle - a previously opened serverHandle that corresponds
3347 * to the server where the volume exists.
3349 * IN callBack - a call back function pointer that may be called to report
3350 * status information. Can be null.
3352 * IN partition - the partition where the volume exists.
3354 * IN volumeId - the volume id of the volume to be brought online.
3358 * No locks are obtained or released by this function
3362 * Returns != 0 upon successful completion.
3366 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3367 unsigned int partition, unsigned int volumeId,
3368 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3372 afs_status_t tst = 0;
3373 file_server_p f_server = (file_server_p) serverHandle;
3377 * Validate arguments
3380 if (!IsValidServerHandle(f_server, &tst)) {
3381 goto fail_vos_VolumeOnline;
3384 if (partition > VOLMAXPARTS) {
3385 tst = ADMVOSPARTITIONIDTOOLARGE;
3386 goto fail_vos_VolumeOnline;
3389 if (volumeStatus == VOS_ONLINE_BUSY) {
3393 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3396 fail_vos_VolumeOnline:
3405 * vos_VolumeOffline - take a volume offline.
3409 * IN serverHandle - a previously opened serverHandle that corresponds
3410 * to the server where the volume exists.
3412 * IN callBack - a call back function pointer that may be called to report
3413 * status information. Can be null.
3415 * IN partition - the partition where the volume exists.
3417 * IN volumeId - the volume id of the volume to be taken offline.
3421 * No locks are obtained or released by this function
3425 * Returns != 0 upon successful completion.
3429 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3430 unsigned int partition, unsigned int volumeId,
3434 afs_status_t tst = 0;
3435 file_server_p f_server = (file_server_p) serverHandle;
3438 * Validate arguments
3441 if (!IsValidServerHandle(f_server, &tst)) {
3442 goto fail_vos_VolumeOffline;
3445 if (partition > VOLMAXPARTS) {
3446 tst = ADMVOSPARTITIONIDTOOLARGE;
3447 goto fail_vos_VolumeOffline;
3450 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3451 VTOutOfService, 0, &tst);
3453 fail_vos_VolumeOffline:
3462 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3466 * IN source - the volintXInfo structure to copy.
3468 * OUT dest - the vos_volumeEntry_t to fill
3472 * No locks are obtained or released by this function
3476 * Returns != 0 upon successful completion.
3480 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3484 afs_status_t tst = 0;
3488 * If the volume is not marked OK, all the other fields are invalid
3489 * We take the extra step of blanking out dest here to prevent the
3490 * user from seeing stale data from a previous call
3493 memset(dest, 0, sizeof(*dest));
3495 switch (source->status) {
3497 dest->status = VOS_OK;
3500 dest->status = VOS_SALVAGE;
3503 dest->status = VOS_NO_VNODE;
3506 dest->status = VOS_NO_VOL;
3509 dest->status = VOS_VOL_EXISTS;
3512 dest->status = VOS_NO_SERVICE;
3515 dest->status = VOS_OFFLINE;
3518 dest->status = VOS_ONLINE;
3521 dest->status = VOS_DISK_FULL;
3524 dest->status = VOS_OVER_QUOTA;
3527 dest->status = VOS_BUSY;
3530 dest->status = VOS_MOVED;
3535 * Check to see if the entry is marked ok before copying all the
3539 if (dest->status == VOS_OK) {
3540 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3541 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3542 dest->id = source->volid;
3543 if (source->type == 0) {
3544 dest->type = VOS_READ_WRITE_VOLUME;
3545 } else if (source->type == 1) {
3546 dest->type = VOS_READ_ONLY_VOLUME;
3547 } else if (source->type == 2) {
3548 dest->type = VOS_BACKUP_VOLUME;
3550 dest->backupId = source->backupID;
3551 dest->readWriteId = source->parentID;
3552 dest->readOnlyId = source->cloneID;
3553 dest->copyCreationDate = source->copyDate;
3554 dest->creationDate = source->creationDate;
3555 dest->lastAccessDate = source->accessDate;
3556 dest->lastUpdateDate = source->updateDate;
3557 dest->lastBackupDate = source->backupDate;
3558 dest->accessesSinceMidnight = source->dayUse;
3559 dest->fileCount = source->filecount;
3560 dest->maxQuota = source->maxquota;
3561 dest->currentSize = source->size;
3562 if (source->inUse == 1) {
3563 dest->volumeDisposition = VOS_ONLINE;
3565 dest->volumeDisposition = VOS_OFFLINE;
3568 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3569 dest->readStats[i] = source->stat_reads[i];
3570 dest->writeStats[i] = source->stat_writes[i];
3573 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3574 dest->fileAuthorWriteSameNetwork[i] =
3575 source->stat_fileSameAuthor[i];
3576 dest->fileAuthorWriteDifferentNetwork[i] =
3577 source->stat_fileDiffAuthor[i];
3578 dest->dirAuthorWriteSameNetwork[i] =
3579 source->stat_dirSameAuthor[i];
3580 dest->dirAuthorWriteDifferentNetwork[i] =
3581 source->stat_dirDiffAuthor[i];
3594 * vos_VolumeGet - get information about a particular volume.
3598 * IN cellHandle - a previously opened cellHandle that corresponds
3599 * to the cell where the volume exists.
3601 * IN serverHandle - a previously opened serverHandle that corresponds
3602 * to the server where the volume exists.
3604 * IN callBack - a call back function pointer that may be called to report
3605 * status information. Can be null.
3607 * IN partition - the partition where the volume exists.
3609 * IN volumeId - the volume id of the volume to be retrieved.
3611 * OUT volumeP - upon successful completion, contains the information about the
3616 * No locks are obtained or released by this function
3620 * Returns != 0 upon successful completion.
3624 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3625 vos_MessageCallBack_t callBack, unsigned int partition,
3626 unsigned int volumeId, vos_volumeEntry_p volumeP,
3630 afs_status_t tst = 0;
3631 file_server_p f_server = (file_server_p) serverHandle;
3632 struct volintXInfo *info = NULL;
3635 * Validate arguments
3638 if (!IsValidServerHandle(f_server, &tst)) {
3639 goto fail_vos_VolumeGet;
3642 if (partition > VOLMAXPARTS) {
3643 tst = ADMVOSPARTITIONIDTOOLARGE;
3644 goto fail_vos_VolumeGet;
3647 if (volumeP == NULL) {
3648 tst = ADMVOSVOLUMEPNULL;
3649 goto fail_vos_VolumeGet;
3653 * Retrieve the information for the volume
3656 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3657 goto fail_vos_VolumeGet;
3661 * Copy the volume info to our structure
3664 if (!copyvolintXInfo(info, volumeP, &tst)) {
3665 goto fail_vos_VolumeGet;
3682 * The iterator functions and data for the volume retrieval functions.
3685 typedef struct volume_get {
3686 struct volintXInfo *vollist;
3687 afs_int32 total; /* total number of volumes at this partition */
3688 afs_int32 index; /* index to the current volume */
3689 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3690 } volume_get_t, *volume_get_p;
3693 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3694 int *last_item_contains_data, afs_status_p st)
3697 afs_status_t tst = 0;
3698 volume_get_p entry = (volume_get_p) rpc_specific;
3701 * Copy the next entry into the cache
3704 if (!copyvolintXInfo
3705 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3706 goto fail_GetVolumeRPC;
3711 * See if we've processed all the entries
3715 if (entry->index == entry->total) {
3717 *last_item_contains_data = 1;
3730 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3733 afs_status_t tst = 0;
3734 volume_get_p entry = (volume_get_p) rpc_specific;
3736 memcpy(dest, (const void *)&entry->entry[slot],
3737 sizeof(vos_volumeEntry_t));
3748 DestroyVolume(void *rpc_specific, afs_status_p st)
3751 afs_status_t tst = 0;
3752 volume_get_p entry = (volume_get_p) rpc_specific;
3754 if (entry->vollist != NULL) {
3755 free(entry->vollist);
3767 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3771 * IN cellHandle - a previously opened cellHandle that corresponds
3772 * to the cell where the volumes exist.
3774 * IN serverHandle - a handle to the server where the volumes exist.
3776 * IN callBack - a call back function pointer that may be called to report
3777 * status information. Can be null.
3779 * IN partition - the partition whose volumes should be listed. Can be null.
3781 * OUT iterationIdP - upon successful completion, contains an iterator that
3782 * can be passed to vos_VolumeGetBegin.
3786 * No locks are obtained or released by this function
3790 * Returns != 0 upon successful completion.
3794 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3795 vos_MessageCallBack_t callBack, unsigned int partition,
3796 void **iterationIdP, afs_status_p st)
3799 afs_status_t tst = 0;
3800 file_server_p f_server = (file_server_p) serverHandle;
3801 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
3802 volume_get_p entry = calloc(1, sizeof(volume_get_t));
3805 * Validate arguments
3808 if (!IsValidServerHandle(f_server, &tst)) {
3809 goto fail_vos_VolumeGetBegin;
3812 if (partition > VOLMAXPARTS) {
3813 tst = ADMVOSPARTITIONIDTOOLARGE;
3814 goto fail_vos_VolumeGetBegin;
3817 if ((iter == NULL) || (entry == NULL)) {
3819 goto fail_vos_VolumeGetBegin;
3823 * Get a list of all the volumes contained in the partition at the
3827 if (!UV_XListVolumes
3828 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3830 goto fail_vos_VolumeGetBegin;
3833 if (entry->total == 0) {
3834 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3835 goto fail_vos_VolumeGetBegin;
3837 iter->done_iterating = 1;
3838 iter->st = ADMITERATORDONE;
3841 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3842 DestroyVolume, &tst)) {
3843 goto fail_vos_VolumeGetBegin;
3846 *iterationIdP = (void *)iter;
3849 fail_vos_VolumeGetBegin:
3855 if (entry != NULL) {
3867 * vos_VolumeGetNext - get information about the next volume.
3871 * IN iterationId - an iterator previously returned by
3872 * vos_VolumeGetBegin
3874 * OUT volumeP - a pointer to a vos_volumeEntry_t
3875 * that upon successful completion contains information about the
3880 * The iterator is locked while the next item is retrieved.
3884 * Returns != 0 upon successful completion.
3888 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3892 afs_status_t tst = 0;
3893 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3896 tst = ADMITERATORNULL;
3897 goto fail_vos_VolumeGetNext;
3900 if (volumeP == NULL) {
3901 tst = ADMVOSVOLUMEPNULL;
3902 goto fail_vos_VolumeGetNext;
3905 rc = IteratorNext(iter, (void *)volumeP, &tst);
3907 fail_vos_VolumeGetNext:
3916 * vos_VolumeGetDone - finish using a volume iterator.
3920 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3924 * The iterator is locked and then destroyed.
3928 * Returns != 0 upon successful completion.
3932 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3935 afs_status_t tst = 0;
3936 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3939 * Validate arguments
3943 tst = ADMITERATORNULL;
3944 goto fail_vos_VolumeGetDone;
3947 rc = IteratorDone(iter, &tst);
3949 fail_vos_VolumeGetDone:
3958 * vos_VolumeMove - move a volume from one server to another.
3962 * IN cellHandle - a previously opened cellHandle that corresponds
3963 * to the cell where the volume exists.
3965 * IN callBack - a call back function pointer that may be called to report
3966 * status information. Can be null.
3968 * IN volumeId - the volume id of the volume to be moved.
3970 * IN fromServer - a previously opened serverHandle that corresponds
3971 * to the server where the volume currently resides.
3973 * IN fromPartition - the partition where the volume currently resides.
3975 * IN toServer - a previously opened serverHandle that corresponds
3976 * to the server where the volume will be moved.
3978 * IN toPartition - the partition where the volume will be moved.
3982 * No locks are obtained or released by this function
3986 * Returns != 0 upon successful completion.
3990 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
3991 unsigned int volumeId, const void *fromServer,
3992 unsigned int fromPartition, const void *toServer,
3993 unsigned int toPartition, afs_status_p st)
3996 afs_status_t tst = 0;
3997 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3998 file_server_p from_server = (file_server_p) fromServer;
3999 file_server_p to_server = (file_server_p) toServer;
4000 afs_int32 from_server_addr =
4001 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4002 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4003 afs_int32 from_partition = fromPartition;
4004 afs_int32 to_partition = toPartition;
4007 * Validate arguments
4010 if (!IsValidCellHandle(c_handle, &tst)) {
4011 goto fail_vos_VolumeMove;
4014 if (!IsValidServerHandle(from_server, &tst)) {
4015 goto fail_vos_VolumeMove;
4018 if (!IsValidServerHandle(to_server, &tst)) {
4019 goto fail_vos_VolumeMove;
4022 if (fromPartition > VOLMAXPARTS) {
4023 tst = ADMVOSPARTITIONIDTOOLARGE;
4024 goto fail_vos_VolumeMove;
4027 if (toPartition > VOLMAXPARTS) {
4028 tst = ADMVOSPARTITIONIDTOOLARGE;
4029 goto fail_vos_VolumeMove;
4036 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4037 to_server_addr, to_partition, &tst);
4039 fail_vos_VolumeMove:
4048 * vos_VolumeRelease - release a volume.
4052 * IN cellHandle - a previously opened cellHandle that corresponds
4053 * to the cell where the volume exists.
4055 * IN callBack - a call back function pointer that may be called to report
4056 * status information. Can be null.
4058 * IN volumeId - the volume to be released.
4060 * IN force - force a complete release.
4064 * No locks are obtained or released by this function
4068 * Returns != 0 upon successful completion.
4072 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4073 unsigned int volumeId, vos_force_t force, afs_status_p st)
4076 afs_status_t tst = 0;
4077 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4078 afs_int32 server, part, forc = 0, voltype, volume;
4079 struct nvldbentry entry;
4082 * Validate arguments
4085 if (!IsValidCellHandle(c_handle, &tst)) {
4086 goto fail_vos_VolumeRelease;
4090 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4091 goto fail_vos_VolumeRelease;
4094 if (force == VOS_FORCE) {
4099 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4101 fail_vos_VolumeRelease:
4110 * vos_VolumeZap - forcibly delete a volume.
4114 * IN cellHandle - a previously opened cellHandle that corresponds
4115 * to the cell where the volume exists.
4117 * IN serverHandle - a previously opened serverHandle that corresponds
4118 * to the server where the volume exists.
4120 * IN callBack - a call back function pointer that may be called to report
4121 * status information. Can be null.
4123 * IN partition - the partition where the volume exists.
4125 * IN volumeId - the volume id of the vldb entry to be deleted.
4127 * IN force - force the deletion of bad volumes.
4131 * No locks are obtained or released by this function
4135 * Returns != 0 upon successful completion.
4139 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4140 vos_MessageCallBack_t callBack, unsigned int partition,
4141 unsigned int volumeId, vos_force_t force, afs_status_p st)
4144 afs_status_t tst = 0;
4145 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4146 file_server_p f_server = (file_server_p) serverHandle;
4149 * Verify that the cellHandle is capable of making vos rpc's
4152 if (!IsValidCellHandle(c_handle, &tst)) {
4153 goto fail_vos_VolumeZap;
4156 if (!IsValidServerHandle(f_server, &tst)) {
4157 goto fail_vos_VolumeZap;
4160 if (force == VOS_FORCE) {
4161 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4164 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4177 * vos_PartitionNameToId - translate a string representing a partition
4182 * IN partitionName - a string representing a partition. Must be of
4185 * OUT partitionId - a number containing the partition id upon successful
4190 * No locks are obtained or released by this function
4194 * Returns != 0 upon successful completion.
4198 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4202 afs_status_t tst = 0;
4203 size_t partition_name_len;
4207 * Validate arguments
4210 if (partitionName == NULL) {
4211 tst = ADMVOSPARTITIONNAMENULL;
4212 goto fail_vos_PartitionNameToId;
4215 if (partitionId == NULL) {
4216 tst = ADMVOSPARTITIONIDNULL;
4217 goto fail_vos_PartitionNameToId;
4221 * Check that string begins with /vicep
4224 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4225 tst = ADMVOSPARTITIONNAMEINVALID;
4226 goto fail_vos_PartitionNameToId;
4230 * Check that the string is either one or two characters
4231 * longer than VICE_PREFIX_SIZE
4234 partition_name_len = strlen(partitionName);
4236 if (partition_name_len == VICE_PREFIX_SIZE) {
4237 tst = ADMVOSPARTITIONNAMETOOSHORT;
4238 goto fail_vos_PartitionNameToId;
4241 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4242 tst = ADMVOSPARTITIONNAMETOOLONG;
4243 goto fail_vos_PartitionNameToId;
4247 * Check that all characters past the prefix are lower case
4250 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4251 if (!islower(partitionName[i])) {
4252 tst = ADMVOSPARTITIONNAMENOTLOWER;
4253 goto fail_vos_PartitionNameToId;
4258 * Convert the name to a number
4261 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4262 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4265 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4266 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4269 if (*partitionId > VOLMAXPARTS) {
4270 tst = ADMVOSPARTITIONIDTOOLARGE;
4271 goto fail_vos_PartitionNameToId;
4275 fail_vos_PartitionNameToId:
4284 * vos_PartitionIdToName - translate a number representing a partition
4285 * to a character string.
4289 * IN partitionId - an integer representing the partition.
4291 * OUT partitionName - a string containing the converted partition ID
4292 * upon successful completion.
4296 * No locks are obtained or released by this function
4300 * Returns != 0 upon successful completion.
4304 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4308 afs_status_t tst = 0;
4310 if (partitionId > VOLMAXPARTS) {
4311 tst = ADMVOSPARTITIONIDTOOLARGE;
4312 goto fail_vos_PartitionIdToName;
4315 if (partitionName == NULL) {
4316 tst = ADMVOSPARTITIONNAMENULL;
4317 goto fail_vos_PartitionIdToName;
4320 if (partitionId < 26) {
4321 strcpy(partitionName, VICE_PARTITION_PREFIX);
4322 partitionName[6] = partitionId + 'a';
4323 partitionName[7] = '\0';
4325 strcpy(partitionName, VICE_PARTITION_PREFIX);
4327 partitionName[6] = 'a' + (partitionId / 26);
4328 partitionName[7] = 'a' + (partitionId % 26);
4329 partitionName[8] = '\0';
4333 fail_vos_PartitionIdToName:
4342 * vos_VolumeQuotaChange - change the quota of a volume.
4346 * IN cellHandle - a previously opened cellHandle that corresponds
4347 * to the cell where the volume exists.
4349 * IN serverHandle - a previously opened serverHandle that corresponds
4350 * to the server where the volume exists.
4352 * IN callBack - a call back function pointer that may be called to report
4353 * status information. Can be null.
4355 * IN partition - the partition where the volume exists.
4357 * IN volumeId - the volume id of the volume to be modified.
4359 * IN volumeQuota - the new volume quota.
4363 * No locks are obtained or released by this function
4367 * Returns != 0 upon successful completion.
4371 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4372 vos_MessageCallBack_t callBack, unsigned int partition,
4373 unsigned int volumeId, unsigned int volumeQuota,
4377 afs_status_t tst = 0;
4378 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4379 file_server_p f_server = (file_server_p) serverHandle;
4382 struct volintInfo tstatus;
4383 int active_trans = 0;
4386 * Verify that the cellHandle is capable of making vos rpc's
4389 if (!IsValidCellHandle(c_handle, &tst)) {
4390 goto fail_vos_VolumeQuotaChange;
4393 if (!IsValidServerHandle(f_server, &tst)) {
4394 goto fail_vos_VolumeQuotaChange;
4397 memset((void *)&tstatus, 0, sizeof(tstatus));
4398 tstatus.dayUse = -1;
4399 tstatus.spare2 = -1;
4400 tstatus.maxquota = volumeQuota;
4404 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4406 goto fail_vos_VolumeQuotaChange;
4410 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4412 goto fail_vos_VolumeQuotaChange;
4416 fail_vos_VolumeQuotaChange:
4419 afs_status_t tst2 = 0;
4420 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4441 * vos_VolumeGet2 - get information about a particular volume.
4445 * IN cellHandle - a previously opened cellHandle that corresponds
4446 * to the cell where the volume exists.
4448 * IN serverHandle - a previously opened serverHandle that corresponds
4449 * to the server where the volume exists.
4451 * IN callBack - a call back function pointer that may be called to report
4452 * status information. Can be null.
4454 * IN partition - the partition where the volume exists.
4456 * IN volumeId - the volume id of the volume to be retrieved.
4458 * OUT pinfo - upon successful completion, contains the information about the
4463 * No locks are obtained or released by this function
4467 * Returns != 0 upon successful completion.
4471 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4472 vos_MessageCallBack_t callBack, unsigned int partition,
4473 unsigned int volumeId, volintInfo* pinfo,
4477 afs_status_t tst = 0;
4478 file_server_p f_server = (file_server_p) serverHandle;
4479 volintInfo *pinfo_=0;
4482 * Validate arguments
4485 if (!IsValidServerHandle(f_server, &tst)) {
4486 goto fail_vos_VolumeGet2;
4489 if (partition > VOLMAXPARTS) {
4490 tst = ADMVOSPARTITIONIDTOOLARGE;
4491 goto fail_vos_VolumeGet2;
4494 if (pinfo == NULL) {
4495 tst = ADMVOSVOLUMEPNULL;
4496 goto fail_vos_VolumeGet2;
4500 * Retrieve the information for the volume
4503 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4504 goto fail_vos_VolumeGet2;
4510 fail_vos_VolumeGet2:
4512 if (pinfo_ != NULL) {
4513 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4524 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4528 * IN cellHandle - a previously opened cellHandle that corresponds
4529 * to the cell where the volume exists.
4531 * IN serverHandle - a previously opened serverHandle that corresponds
4532 * to the server where the volume exists.
4534 * IN partition - the partition where the volume exists.
4536 * IN volumeId - the volume id of the volume to be retrieved.
4540 * No locks are obtained or released by this function
4544 * Returns != 0 upon successful completion.
4548 vos_ClearVolUpdateCounter(const void *cellHandle,
4549 const void *serverHandle,
4550 unsigned int partition,
4551 unsigned int volumeId,
4555 afs_status_t tst = 0;
4556 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4557 file_server_p f_server = (file_server_p) serverHandle;
4560 struct volintInfo tstatus;
4561 int active_trans = 0;
4564 * Verify that the cellHandle is capable of making vos rpc's
4567 if (!IsValidCellHandle(c_handle, &tst)) {
4568 goto fail_vos_ClearVolUpdateCounter;
4571 if (!IsValidServerHandle(f_server, &tst)) {
4572 goto fail_vos_ClearVolUpdateCounter;
4575 memset((void *)&tstatus, 0, sizeof(tstatus));
4576 tstatus.maxquota = -1;
4577 tstatus.dayUse = -1;
4578 tstatus.creationDate = -1;
4579 tstatus.updateDate = -1;
4581 tstatus.spare0 = -1;
4582 tstatus.spare1 = -1;
4584 tstatus.spare3 = -1;
4587 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4589 goto fail_vos_ClearVolUpdateCounter;
4593 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4595 goto fail_vos_ClearVolUpdateCounter;
4599 fail_vos_ClearVolUpdateCounter:
4602 afs_status_t tst2 = 0;
4603 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);