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 & BACK_EXISTS) {
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 & 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 = 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;
1192 * Check to see if this is a multihomed address server
1195 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1196 base = (*addrP >> 16) & 0xff;
1197 index = (*addrP) & 0xffff;
1199 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1200 && (index <= VL_MHSRV_PERBLK)) {
1203 * This is a multihomed server. Make an rpc to retrieve
1204 * all its addresses. Copy the addresses into the cache.
1207 m_attrs.Mask = VLADDR_INDEX;
1208 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1210 addr_multi.bulkaddrs_val = 0;
1211 addr_multi.bulkaddrs_len = 0;
1213 ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
1214 &m_unique, &total_multi, &addr_multi);
1216 goto fail_GetServerRPC;
1220 * Remove any bogus IP addresses which the user may have
1221 * been unable to remove.
1224 RemoveBadAddresses(&total_multi, &addr_multi);
1227 * Copy all the addresses into the cache
1230 for (i = 0; i < total_multi; i++) {
1231 serv->server[slot].serverAddress[i] =
1232 addr_multi.bulkaddrs_val[i];
1235 serv->server[slot].count = total_multi;
1236 serv->address_index++;
1237 free(addr_multi.bulkaddrs_val);
1241 * The next address is just a plain old address
1245 serv->server[slot].serverAddress[0] = *addrP;
1246 serv->server[slot].count = 1;
1247 serv->address_index++;
1251 * See if we've processed all the entries
1255 if (serv->address_index == serv->total_addresses) {
1257 *last_item_contains_data = 1;
1270 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1273 afs_status_t tst = 0;
1274 server_get_p serv = (server_get_p) rpc_specific;
1276 memcpy(dest, (const void *)&serv->server[slot],
1277 sizeof(vos_fileServerEntry_t));
1288 DestroyServer(void *rpc_specific, afs_status_p st)
1291 afs_status_t tst = 0;
1292 server_get_p serv = (server_get_p) rpc_specific;
1294 if (serv->addresses.bulkaddrs_val != NULL) {
1295 free(serv->addresses.bulkaddrs_val);
1306 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1310 * IN cellHandle - a previously opened cellHandle that corresponds
1311 * to the cell where the file servers exist.
1313 * IN callBack - a call back function pointer that may be called to report
1314 * status information. Can be null.
1316 * OUT iterationIdP - upon successful completion, contains an iterator that
1317 * can be passed to vos_FileServerGetNext.
1321 * No locks are obtained or released by this function
1325 * Returns != 0 upon successful completion.
1329 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1330 void **iterationIdP, afs_status_p st)
1333 afs_status_t tst = 0;
1334 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1335 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
1336 server_get_p serv = calloc(1, sizeof(server_get_t));
1337 struct VLCallBack unused;
1341 * Validate arguments
1344 if (!IsValidCellHandle(c_handle, &tst)) {
1345 goto fail_vos_FileServerGetBegin;
1348 if (iterationIdP == NULL) {
1349 goto fail_vos_FileServerGetBegin;
1352 if ((iter == NULL) || (serv == NULL)) {
1354 goto fail_vos_FileServerGetBegin;
1358 * Fill in the serv structure
1361 serv->vldb = c_handle->vos;
1363 ubik_VL_GetAddrs(c_handle->vos, 0, 0, 0, &unused,
1364 &serv->total_addresses, &serv->addresses);
1367 goto fail_vos_FileServerGetBegin;
1371 * Remove any bogus IP addresses which the user may have
1372 * been unable to remove.
1375 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1377 if (serv->total_addresses == 0) {
1378 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1379 goto fail_vos_FileServerGetBegin;
1381 iter->done_iterating = 1;
1382 iter->st = ADMITERATORDONE;
1385 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1386 DestroyServer, &tst)) {
1387 goto fail_vos_FileServerGetBegin;
1390 *iterationIdP = (void *)iter;
1393 fail_vos_FileServerGetBegin:
1400 if (serv->addresses.bulkaddrs_val != NULL) {
1401 free(serv->addresses.bulkaddrs_val);
1414 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1418 * IN iterationId - an iterator previously returned by
1419 * vos_FileServerGetBegin
1421 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1422 * completion contains information about the next server in the cell.
1426 * The iterator is locked while the next server is retrieved.
1430 * Returns != 0 upon successful completion.
1434 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1438 afs_status_t tst = 0;
1439 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1442 tst = ADMITERATORNULL;
1443 goto fail_vos_FileServerGetNext;
1446 if (serverEntryP == NULL) {
1447 tst = ADMVOSSERVERENTRYPNULL;
1448 goto fail_vos_FileServerGetNext;
1451 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1453 fail_vos_FileServerGetNext:
1462 * vos_FileServerGetDone - finish using a partition iterator.
1466 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1470 * The iterator is locked and then destroyed.
1474 * Returns != 0 upon successful completion.
1478 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1481 afs_status_t tst = 0;
1482 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1485 * Validate arguments
1489 tst = ADMITERATORNULL;
1490 goto fail_vos_FileServerGetDone;
1493 rc = IteratorDone(iter, &tst);
1495 fail_vos_FileServerGetDone:
1504 * The iterator functions and data for the transation retrieval functions.
1507 typedef struct transaction_get {
1508 afs_int32 total; /* total number of transactions */
1509 afs_int32 index; /* index to the current transaction */
1510 transDebugInfo *cur; /* the current transaction */
1511 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1512 } transaction_get_t, *transaction_get_p;
1515 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1516 int *last_item_contains_data, afs_status_p st)
1519 afs_status_t tst = 0;
1520 transaction_get_p t = (transaction_get_p) rpc_specific;
1521 int index = t->index;
1524 * Copy the next transaction into the cache
1527 t->tran[slot].transactionId = t->cur[index].tid;
1528 t->tran[slot].lastActiveTime = t->cur[index].time;
1529 t->tran[slot].creationTime = t->cur[index].creationTime;
1530 t->tran[slot].errorCode = t->cur[index].returnCode;
1531 t->tran[slot].volumeId = t->cur[index].volid;
1532 t->tran[slot].partition = t->cur[index].partition;
1533 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1534 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1535 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1536 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1537 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1539 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1541 switch (t->cur[index].iflags) {
1543 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1546 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1549 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1552 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1555 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1559 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1561 switch (t->cur[index].vflags) {
1562 case VTDeleteOnSalvage:
1563 t->tran[slot].volumeActiveStatus =
1564 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1566 case VTOutOfService:
1567 t->tran[slot].volumeActiveStatus =
1568 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1571 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1575 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1577 if (t->cur[index].tflags) {
1578 t->tran[slot].volumeTransactionStatus =
1579 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1585 * See if we've processed all the entries
1589 if (t->index == t->total) {
1591 *last_item_contains_data = 1;
1602 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1606 afs_status_t tst = 0;
1607 transaction_get_p tran = (transaction_get_p) rpc_specific;
1609 memcpy(dest, (const void *)&tran->tran[slot],
1610 sizeof(vos_serverTransactionStatus_p));
1621 DestroyTransaction(void *rpc_specific, afs_status_p st)
1624 afs_status_t tst = 0;
1625 transaction_get_p tran = (transaction_get_p) rpc_specific;
1627 if (tran->cur != NULL) {
1639 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1640 * at a volume server.
1644 * IN cellHandle - a previously opened cellHandle that corresponds
1645 * to the cell where the volume server exists.
1647 * IN serverHandle - a handle to the server to query.
1649 * IN callBack - a call back function pointer that may be called to report
1650 * status information. Can be null.
1652 * OUT iterationIdP - upon successful completion, contains an iterator that
1653 * can be passed to vos_ServerTransactionStatusGetNext.
1657 * No locks are obtained or released by this function
1661 * Returns != 0 upon successful completion.
1665 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1666 const void *serverHandle,
1667 vos_MessageCallBack_t callBack,
1668 void **iterationIdP, afs_status_p st)
1671 afs_status_t tst = 0;
1672 file_server_p f_server = (file_server_p) serverHandle;
1673 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
1674 transaction_get_p tran = calloc(1, sizeof(transaction_get_t));
1678 * Validate arguments
1681 if (!IsValidServerHandle(f_server, &tst)) {
1682 goto fail_vos_ServerTransactionStatusGetBegin;
1685 if (iterationIdP == NULL) {
1686 goto fail_vos_ServerTransactionStatusGetBegin;
1689 if ((iter == NULL) || (tran == NULL)) {
1691 goto fail_vos_ServerTransactionStatusGetBegin;
1695 * Fill in the tran structure
1698 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1699 goto fail_vos_ServerTransactionStatusGetBegin;
1702 if (tran->total == 0) {
1703 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1704 goto fail_vos_ServerTransactionStatusGetBegin;
1706 iter->done_iterating = 1;
1707 iter->st = ADMITERATORDONE;
1710 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1711 NULL, DestroyTransaction, &tst)) {
1712 goto fail_vos_ServerTransactionStatusGetBegin;
1715 *iterationIdP = (void *)iter;
1718 fail_vos_ServerTransactionStatusGetBegin:
1725 if (tran->cur != NULL) {
1739 * vos_ServerTransactionStatusGetNext - get information about the next
1740 * active transaction.
1744 * IN iterationId - an iterator previously returned by
1745 * vos_ServerTransactionStatusGetBegin
1747 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1748 * that upon successful completion contains information about the
1753 * The iterator is locked while the next item is retrieved.
1757 * Returns != 0 upon successful completion.
1761 vos_ServerTransactionStatusGetNext(const void *iterationId,
1762 vos_serverTransactionStatus_p
1763 serverTransactionStatusP, afs_status_p st)
1766 afs_status_t tst = 0;
1767 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1770 tst = ADMITERATORNULL;
1771 goto fail_vos_ServerTransactionStatusGetNext;
1774 if (serverTransactionStatusP == NULL) {
1775 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1776 goto fail_vos_ServerTransactionStatusGetNext;
1779 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1781 fail_vos_ServerTransactionStatusGetNext:
1790 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1794 * IN iterationId - an iterator previously returned by
1795 * vos_ServerTransactionStatusGetBegin
1799 * The iterator is locked and then destroyed.
1803 * Returns != 0 upon successful completion.
1807 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1810 afs_status_t tst = 0;
1811 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1814 * Validate arguments
1818 tst = ADMITERATORNULL;
1819 goto fail_vos_ServerTransactionStatusGetDone;
1822 rc = IteratorDone(iter, &tst);
1824 fail_vos_ServerTransactionStatusGetDone:
1833 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1837 afs_status_t tst = 0;
1840 dest->numServers = source->nServers;
1841 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1842 dest->volumeId[i] = source->volumeId[i];
1844 dest->cloneId = source->cloneId;
1845 dest->status = VOS_VLDB_ENTRY_OK;
1846 if (source->flags & VLOP_ALLOPERS) {
1847 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1849 if (source->flags & VLOP_MOVE) {
1850 dest->status |= VOS_VLDB_ENTRY_MOVE;
1852 if (source->flags & VLOP_RELEASE) {
1853 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1855 if (source->flags & VLOP_BACKUP) {
1856 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1858 if (source->flags & VLOP_DELETE) {
1859 dest->status |= VOS_VLDB_ENTRY_DELETE;
1861 if (source->flags & VLOP_DUMP) {
1862 dest->status |= VOS_VLDB_ENTRY_DUMP;
1865 if (source->flags & VLF_RWEXISTS) {
1866 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1868 if (source->flags & VLF_ROEXISTS) {
1869 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1871 if (source->flags & VLF_BACKEXISTS) {
1872 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1875 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1876 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1877 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1878 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1879 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1880 dest->volumeSites[i].serverFlags = 0;
1882 if (source->serverFlags[i] & NEW_REPSITE) {
1883 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1885 if (source->serverFlags[i] & ITSROVOL) {
1886 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1888 if (source->serverFlags[i] & ITSRWVOL) {
1889 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1891 if (source->serverFlags[i] & ITSBACKVOL) {
1892 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1894 if (source->serverFlags[i] & RO_DONTUSE) {
1895 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1908 * vos_VLDBGet- get a volume's vldb entry.
1912 * IN cellHandle - a previously opened cellHandle that corresponds
1913 * to the cell where the volume entries exist.
1915 * IN callBack - a call back function pointer that may be called to report
1916 * status information. Can be null.
1918 * IN volumeId - the id of the volume to retrieve.
1920 * IN volumeName - the name of the volume to retrieve.
1922 * OUT vldbEntry - upon successful completion, contains the information regarding
1927 * No locks are obtained or released by this function
1931 * Returns != 0 upon successful completion.
1935 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1936 const unsigned int *volumeId, char *volumeName,
1937 vos_vldbEntry_p vldbEntry, afs_status_p st)
1940 afs_status_t tst = 0;
1941 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1942 struct nvldbentry entry;
1946 * Validate arguments
1949 if (!IsValidCellHandle(c_handle, &tst)) {
1950 goto fail_vos_VLDBGet;
1953 if (vldbEntry == NULL) {
1954 tst = ADMVOSVLDBENTRYNULL;
1955 goto fail_vos_VLDBGet;
1958 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1959 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1960 goto fail_vos_VLDBGet;
1964 * Retrieve the entry
1967 if (!((volumeName == NULL) || (*volumeName == 0))) {
1968 if (!ValidateVolumeName(volumeName, &tst)) {
1969 goto fail_vos_VLDBGet;
1971 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1972 goto fail_vos_VLDBGet;
1975 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1976 goto fail_vos_VLDBGet;
1981 * Copy the entry into our structure
1984 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1985 goto fail_vos_VLDBGet;
1998 * The iterator functions and data for the vldb entry retrieval functions.
2001 typedef struct vldb_entry_get {
2002 afs_int32 total; /* total number of vldb entries */
2003 afs_int32 index; /* index to the current vldb entry */
2004 nbulkentries entries; /* the list of entries retrieved */
2005 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2006 } vldb_entry_get_t, *vldb_entry_get_p;
2009 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2010 int *last_item_contains_data, afs_status_p st)
2013 afs_status_t tst = 0;
2014 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2017 * Copy the next entry into the cache
2021 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2023 goto fail_GetVLDBEntryRPC;
2028 * See if we've processed all the entries
2032 if (entry->index == entry->total) {
2034 *last_item_contains_data = 1;
2038 fail_GetVLDBEntryRPC:
2047 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2051 afs_status_t tst = 0;
2052 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2054 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2065 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2068 afs_status_t tst = 0;
2069 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2071 if (entry->entries.nbulkentries_val != NULL) {
2072 free(entry->entries.nbulkentries_val);
2084 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2088 * IN cellHandle - a previously opened cellHandle that corresponds
2089 * to the cell where the volume entries exist.
2091 * IN serverHandle - a handle to the server whose entries should be listed.
2094 * IN callBack - a call back function pointer that may be called to report
2095 * status information. Can be null.
2097 * IN partition - the partition whose entries should be listed.
2100 * OUT iterationIdP - upon successful completion, contains an iterator that
2101 * can be passed to vos_VLDBGetNext.
2105 * No locks are obtained or released by this function
2109 * Returns != 0 upon successful completion.
2113 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2114 vos_MessageCallBack_t callBack, unsigned int *partition,
2115 void **iterationIdP, afs_status_p st)
2118 afs_status_t tst = 0;
2119 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2120 file_server_p f_server = (file_server_p) serverHandle;
2121 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
2122 vldb_entry_get_p entry = calloc(1, sizeof(vldb_entry_get_t));
2123 struct VldbListByAttributes attr;
2126 memset(&attr, 0, sizeof(attr));
2129 * Validate arguments
2132 if (!IsValidCellHandle(c_handle, &tst)) {
2133 goto fail_vos_VLDBGetBegin;
2136 if ((iter == NULL) || (entry == NULL)) {
2138 goto fail_vos_VLDBGetBegin;
2141 if (f_server != NULL) {
2142 if (!IsValidServerHandle(f_server, &tst)) {
2143 goto fail_vos_VLDBGetBegin;
2145 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2146 attr.Mask |= VLLIST_SERVER;
2149 if (partition != NULL) {
2150 if (*partition > VOLMAXPARTS) {
2151 tst = ADMVOSPARTITIONTOOLARGE;
2152 goto fail_vos_VLDBGetBegin;
2154 attr.partition = *partition;
2155 attr.Mask |= VLLIST_PARTITION;
2158 if (!VLDB_ListAttributes
2159 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2160 goto fail_vos_VLDBGetBegin;
2163 if (entry->total <= 0) {
2164 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2165 goto fail_vos_VLDBGetBegin;
2167 iter->done_iterating = 1;
2168 iter->st = ADMITERATORDONE;
2171 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2172 NULL, DestroyVLDBEntry, &tst)) {
2173 goto fail_vos_VLDBGetBegin;
2176 *iterationIdP = (void *)iter;
2179 fail_vos_VLDBGetBegin:
2185 if (entry->entries.nbulkentries_val != NULL) {
2186 free(entry->entries.nbulkentries_val);
2188 if (entry != NULL) {
2200 * vos_VLDBGetNext - get information about the next volume.
2204 * IN iterationId - an iterator previously returned by
2207 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2208 * that upon successful completion contains information about the
2213 * The iterator is locked while the next item is retrieved.
2217 * Returns != 0 upon successful completion.
2221 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2225 afs_status_t tst = 0;
2226 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2229 tst = ADMITERATORNULL;
2230 goto fail_vos_VLDBGetNext;
2233 if (vldbEntry == NULL) {
2234 tst = ADMVOSVLDBENTRYNULL;
2235 goto fail_vos_VLDBGetNext;
2238 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2240 fail_vos_VLDBGetNext:
2249 * vos_VLDBGetDone - finish using a volume iterator.
2253 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2257 * The iterator is locked and then destroyed.
2261 * Returns != 0 upon successful completion.
2265 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2268 afs_status_t tst = 0;
2269 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2272 * Validate arguments
2276 tst = ADMITERATORNULL;
2277 goto fail_vos_VLDBGetDone;
2280 rc = IteratorDone(iter, &tst);
2282 fail_vos_VLDBGetDone:
2291 * vos_VLDBEntryRemove - remove a vldb entry.
2295 * IN cellHandle - a previously opened cellHandle that corresponds
2296 * to the cell where the vldb entry exists.
2298 * IN serverHandle - a previously opened serverHandle that corresponds
2299 * to the server where the vldb entry exists. Can be null.
2301 * IN callBack - a call back function pointer that may be called to report
2302 * status information. Can be null.
2304 * IN partition - the partition where the vldb entry exists. Can be null.
2306 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2310 * No locks are obtained or released by this function
2314 * Returns != 0 upon successful completion.
2318 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2319 vos_MessageCallBack_t callBack,
2320 const unsigned int *partition, unsigned int *volumeId,
2324 afs_status_t tst = 0;
2325 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2326 file_server_p f_server = (file_server_p) serverHandle;
2327 struct VldbListByAttributes attr;
2328 nbulkentries entries;
2332 memset(&attr, 0, sizeof(attr));
2333 memset(&entries, 0, sizeof(entries));
2336 * Validate arguments
2339 if (!IsValidCellHandle(c_handle, &tst)) {
2340 goto fail_vos_VLDBEntryRemove;
2344 * If the volume is specified, just delete it
2347 if (volumeId != NULL) {
2348 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2350 goto fail_vos_VLDBEntryRemove;
2354 if (f_server != NULL) {
2355 if (!IsValidServerHandle(f_server, &tst)) {
2356 goto fail_vos_VLDBEntryRemove;
2358 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2359 attr.Mask |= VLLIST_SERVER;
2362 if (partition != NULL) {
2363 if (*partition > VOLMAXPARTS) {
2364 tst = ADMVOSPARTITIONTOOLARGE;
2365 goto fail_vos_VLDBEntryRemove;
2367 attr.partition = *partition;
2368 attr.Mask |= VLLIST_PARTITION;
2371 if ((f_server == NULL) && (partition == NULL)) {
2372 tst = ADMVOSVLDBDELETEALLNULL;
2373 goto fail_vos_VLDBEntryRemove;
2376 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2377 goto fail_vos_VLDBEntryRemove;
2380 if (nentries <= 0) {
2381 tst = ADMVOSVLDBNOENTRIES;
2382 goto fail_vos_VLDBEntryRemove;
2385 for (i = 0; i < nentries; i++) {
2386 ubik_VL_DeleteEntry(c_handle->vos, 0,
2387 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2391 fail_vos_VLDBEntryRemove:
2393 if (entries.nbulkentries_val) {
2394 free(entries.nbulkentries_val);
2404 * vos_VLDBUnlock - unlock vldb entries en masse.
2408 * IN cellHandle - a previously opened cellHandle that corresponds
2409 * to the cell where the vldb entries exist.
2411 * IN serverHandle - a previously opened serverHandle that corresponds
2412 * to the server where the vldb entries exist. Can be null.
2414 * IN callBack - a call back function pointer that may be called to report
2415 * status information. Can be null.
2417 * IN partition - the partition where the vldb entries exist. Can be null.
2421 * No locks are obtained or released by this function
2425 * Returns != 0 upon successful completion.
2429 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2430 vos_MessageCallBack_t callBack, const unsigned int *partition,
2434 afs_status_t tst = 0;
2435 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2436 file_server_p f_server = (file_server_p) serverHandle;
2437 struct VldbListByAttributes attr;
2438 nbulkentries entries;
2442 memset(&attr, 0, sizeof(attr));
2443 memset(&entries, 0, sizeof(entries));
2446 * Validate arguments
2449 if (!IsValidCellHandle(c_handle, &tst)) {
2450 goto fail_vos_VLDBUnlock;
2453 if (f_server != NULL) {
2454 if (!IsValidServerHandle(f_server, &tst)) {
2455 goto fail_vos_VLDBUnlock;
2457 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2458 attr.Mask |= VLLIST_SERVER;
2461 if (partition != NULL) {
2462 if (*partition > VOLMAXPARTS) {
2463 tst = ADMVOSPARTITIONTOOLARGE;
2464 goto fail_vos_VLDBUnlock;
2466 attr.partition = *partition;
2467 attr.Mask |= VLLIST_PARTITION;
2469 attr.flag = VLOP_ALLOPERS;
2470 attr.Mask |= VLLIST_FLAG;
2473 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2474 goto fail_vos_VLDBUnlock;
2477 if (nentries <= 0) {
2478 tst = ADMVOSVLDBNOENTRIES;
2479 goto fail_vos_VLDBUnlock;
2482 for (i = 0; i < nentries; i++) {
2483 vos_VLDBEntryUnlock(cellHandle, 0,
2484 entries.nbulkentries_val[i].volumeId[RWVOL],
2489 fail_vos_VLDBUnlock:
2491 if (entries.nbulkentries_val) {
2492 free(entries.nbulkentries_val);
2503 * vos_VLDBEntryLock - lock a vldb entry.
2507 * IN cellHandle - a previously opened cellHandle that corresponds
2508 * to the cell where the vldb entry exists.
2510 * IN callBack - a call back function pointer that may be called to report
2511 * status information. Can be null.
2513 * IN volumeId - the volume id of the vldb entry to be deleted.
2517 * No locks are obtained or released by this function
2521 * Returns != 0 upon successful completion.
2525 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2526 unsigned int volumeId, afs_status_p st)
2529 afs_status_t tst = 0;
2530 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2533 * Validate arguments
2536 if (!IsValidCellHandle(c_handle, &tst)) {
2537 goto fail_vos_VLDBEntryLock;
2540 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2542 goto fail_vos_VLDBEntryLock;
2546 fail_vos_VLDBEntryLock:
2555 * vos_VLDBEntryUnlock - unlock a vldb entry.
2559 * IN cellHandle - a previously opened cellHandle that corresponds
2560 * to the cell where the vldb entry exists.
2562 * IN callBack - a call back function pointer that may be called to report
2563 * status information. Can be null.
2565 * IN volumeId - the volume id of the vldb entry to be unlocked.
2569 * No locks are obtained or released by this function
2573 * Returns != 0 upon successful completion.
2577 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2578 unsigned int volumeId, afs_status_p st)
2581 afs_status_t tst = 0;
2582 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2585 * Validate arguments
2588 if (!IsValidCellHandle(c_handle, &tst)) {
2589 goto fail_vos_VLDBEntryUnlock;
2594 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2595 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2597 goto fail_vos_VLDBEntryUnlock;
2601 fail_vos_VLDBEntryUnlock:
2610 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2614 * IN cellHandle - a previously opened cellHandle that corresponds
2615 * to the cell where the volume exists.
2617 * IN serverHandle - a previously opened serverHandle that corresponds
2618 * to the server where the new volume should be created.
2620 * IN callBack - a call back function pointer that may be called to report
2621 * status information. Can be null.
2623 * IN partition - the partition where then new volume should be created.
2625 * IN volumeId - the volume id of the volume to be replicated.
2629 * No locks are obtained or released by this function
2633 * Returns != 0 upon successful completion.
2637 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2638 vos_MessageCallBack_t callBack,
2639 unsigned int partition, unsigned int volumeId,
2643 afs_status_t tst = 0;
2644 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2645 file_server_p f_server = (file_server_p) serverHandle;
2648 * Validate arguments
2651 if (!IsValidCellHandle(c_handle, &tst)) {
2652 goto fail_vos_VLDBReadOnlySiteCreate;
2655 if (!IsValidServerHandle(f_server, &tst)) {
2656 goto fail_vos_VLDBReadOnlySiteCreate;
2659 if (partition > VOLMAXPARTS) {
2660 tst = ADMVOSPARTITIONTOOLARGE;
2661 goto fail_vos_VLDBReadOnlySiteCreate;
2665 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2667 goto fail_vos_VLDBReadOnlySiteCreate;
2671 fail_vos_VLDBReadOnlySiteCreate:
2680 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2685 * IN cellHandle - a previously opened cellHandle that corresponds
2686 * to the cell where the volume exists.
2688 * IN serverHandle - a previously opened serverHandle that corresponds
2689 * to the server where the volume should be deleted.
2691 * IN callBack - a call back function pointer that may be called to report
2692 * status information. Can be null.
2694 * IN partition - the partition where then volume should be deleted.
2696 * IN volumeId - the volume id of the volume to be deleted.
2700 * No locks are obtained or released by this function
2704 * Returns != 0 upon successful completion.
2708 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2709 vos_MessageCallBack_t callBack,
2710 unsigned int partition, unsigned int volumeId,
2714 afs_status_t tst = 0;
2715 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2716 file_server_p f_server = (file_server_p) serverHandle;
2719 * Validate arguments
2722 if (!IsValidCellHandle(c_handle, &tst)) {
2723 goto fail_vos_VLDBReadOnlySiteDelete;
2726 if (!IsValidServerHandle(f_server, &tst)) {
2727 goto fail_vos_VLDBReadOnlySiteDelete;
2730 if (partition > VOLMAXPARTS) {
2731 tst = ADMVOSPARTITIONTOOLARGE;
2732 goto fail_vos_VLDBReadOnlySiteDelete;
2736 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2738 goto fail_vos_VLDBReadOnlySiteDelete;
2742 fail_vos_VLDBReadOnlySiteDelete:
2751 * vos_VLDBSync - synchronize the vldb with the fileserver.
2755 * IN cellHandle - a previously opened cellHandle that corresponds
2756 * to the cell where the sync should occur.
2758 * IN serverHandle - a previously opened serverHandle that corresponds
2759 * to the server where the sync should occur.
2761 * IN callBack - a call back function pointer that may be called to report
2762 * status information. Can be null.
2764 * IN partition - the partition where the sync should occur. Can be null.
2766 * IN force - force deletion of bad volumes.
2770 * No locks are obtained or released by this function
2774 * Returns != 0 upon successful completion.
2778 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2779 vos_MessageCallBack_t callBack, const unsigned int *partition,
2780 vos_force_t force, afs_status_p st)
2783 afs_status_t tst = 0;
2784 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2785 file_server_p f_server = (file_server_p) serverHandle;
2791 * Validate arguments
2794 if (!IsValidCellHandle(c_handle, &tst)) {
2795 goto fail_vos_VLDBSync;
2798 if (!IsValidServerHandle(f_server, &tst)) {
2799 goto fail_vos_VLDBSync;
2802 if (partition != NULL) {
2803 if (*partition > VOLMAXPARTS) {
2804 tst = ADMVOSPARTITIONTOOLARGE;
2805 goto fail_vos_VLDBSync;
2807 part = (afs_int32) * partition;
2811 if (force == VOS_FORCE) {
2819 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2830 * vos_VolumeCreate - create a new partition.
2834 * IN cellHandle - a previously opened cellHandle that corresponds
2835 * to the cell where the server lives.
2837 * IN serverHandle - a previously open vos server handle that holds
2838 * the partition where the volume should be create.
2840 * IN callBack - a call back function pointer that may be called to report
2841 * status information. Can be null.
2843 * IN partition - the integer that represents the partition that will
2844 * house the new volume.
2846 * IN volumeName - the name of the new volume.
2848 * IN quota - the quota of the new volume.
2850 * OUT volumeId - the volume id of the newly created volume.
2854 * No locks are obtained or released by this function
2858 * Returns != 0 upon successful completion.
2862 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2863 vos_MessageCallBack_t callBack, unsigned int partition,
2864 char *volumeName, unsigned int quota,
2865 unsigned int *volumeId, afs_status_p st)
2868 afs_status_t tst = 0;
2869 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2870 file_server_p f_server = (file_server_p) serverHandle;
2871 vos_partitionEntry_t pinfo;
2872 struct nvldbentry vinfo;
2875 * Validate arguments
2878 if (!IsValidCellHandle(c_handle, &tst)) {
2879 goto fail_vos_VolumeCreate;
2882 if (!IsValidServerHandle(f_server, &tst)) {
2883 goto fail_vos_VolumeCreate;
2886 if (partition > VOLMAXPARTS) {
2887 tst = ADMVOSPARTITIONTOOLARGE;
2888 goto fail_vos_VolumeCreate;
2891 if (!ValidateVolumeName(volumeName, &tst)) {
2892 goto fail_vos_VolumeCreate;
2895 if (volumeId == NULL) {
2896 tst = ADMVOSVOLUMEID;
2897 goto fail_vos_VolumeCreate;
2901 * Check that partition is valid at the server
2904 if (!vos_PartitionGet
2905 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2906 goto fail_vos_VolumeCreate;
2910 * Check that the volume doesn't already exist
2913 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2914 tst = ADMVOSVOLUMENAMEDUP;
2915 goto fail_vos_VolumeCreate;
2919 * Create the new volume
2922 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2923 quota, volumeId, &tst);
2925 fail_vos_VolumeCreate:
2934 * vos_VolumeDelete - remove a volume.
2938 * IN cellHandle - a previously opened cellHandle that corresponds
2939 * to the cell where the volume exists.
2941 * IN serverHandle - a previously opened serverHandle that corresponds
2942 * to the server where the volume exists.
2944 * IN callBack - a call back function pointer that may be called to report
2945 * status information. Can be null.
2947 * IN partition - the partition where the volume exists.
2949 * IN volumeId - the volume id of the volume to be deleted.
2953 * No locks are obtained or released by this function
2957 * Returns != 0 upon successful completion.
2961 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2962 vos_MessageCallBack_t callBack, unsigned int partition,
2963 unsigned int volumeId, afs_status_p st)
2966 afs_status_t tst = 0;
2967 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2968 file_server_p f_server = (file_server_p) serverHandle;
2969 vos_partitionEntry_t pinfo;
2972 * Validate arguments
2975 if (!IsValidCellHandle(c_handle, &tst)) {
2976 goto fail_vos_VolumeDelete;
2979 if (!IsValidServerHandle(f_server, &tst)) {
2980 goto fail_vos_VolumeDelete;
2983 if (partition > VOLMAXPARTS) {
2984 tst = ADMVOSPARTITIONTOOLARGE;
2985 goto fail_vos_VolumeDelete;
2989 * Check that partition is valid at the server
2992 if (!vos_PartitionGet
2993 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2994 goto fail_vos_VolumeDelete;
2997 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
2999 fail_vos_VolumeDelete:
3008 * vos_VolumeRename - rename a volume.
3012 * IN cellHandle - a previously opened cellHandle that corresponds
3013 * to the cell where the volume exists.
3015 * IN serverHandle - a previously opened serverHandle that corresponds
3016 * to the server where the vldb entry exists. Can be null.
3018 * IN callBack - a call back function pointer that may be called to report
3019 * status information. Can be null.
3021 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3023 * IN newVolumeName - the new name.
3027 * No locks are obtained or released by this function
3031 * Returns != 0 upon successful completion.
3035 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3036 unsigned int readWriteVolumeId, char *newVolumeName,
3040 afs_status_t tst = 0;
3041 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3042 struct nvldbentry entry;
3045 * Validate arguments
3048 if (!IsValidCellHandle(c_handle, &tst)) {
3049 goto fail_vos_VolumeRename;
3052 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3053 tst = ADMVOSNEWVOLUMENAMENULL;
3054 goto fail_vos_VolumeRename;
3058 * Retrieve the entry
3061 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3062 goto fail_vos_VolumeRename;
3065 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3067 fail_vos_VolumeRename:
3076 * vos_VolumeDump - dump a volume
3080 * IN cellHandle - a previously opened cellHandle that corresponds
3081 * to the cell where the volume exists.
3083 * IN serverHandle - a previously opened serverHandle that corresponds
3084 * to the server where the volume exists. Can be null.
3086 * IN callBack - a call back function pointer that may be called to report
3087 * status information. Can be null.
3089 * IN volumeId - the volume id of the volume to be dumped.
3091 * IN startTime - files with modification times >= this time will be dumped.
3093 * IN dumpFile - the file to dump the volume to.
3097 * No locks are obtained or released by this function
3101 * Returns != 0 upon successful completion.
3105 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3106 vos_MessageCallBack_t callBack, unsigned int *partition,
3107 unsigned int volumeId, unsigned int startTime,
3108 const char *dumpFile, afs_status_p st)
3111 afs_status_t tst = 0;
3112 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3113 file_server_p f_server = (file_server_p) serverHandle;
3114 afs_int32 server, part, voltype;
3115 struct nvldbentry entry;
3118 * Validate arguments
3121 if (!IsValidCellHandle(c_handle, &tst)) {
3122 goto fail_vos_VolumeDump;
3125 if (serverHandle != NULL) {
3126 if (!IsValidServerHandle(f_server, &tst)) {
3127 goto fail_vos_VolumeDump;
3132 * You must specify both the serverHandle and the partition
3135 if (serverHandle || partition) {
3136 if (!serverHandle || !partition) {
3137 tst = ADMVOSSERVERANDPARTITION;
3138 goto fail_vos_VolumeDump;
3140 if (*partition > VOLMAXPARTS) {
3141 tst = ADMVOSPARTITIONTOOLARGE;
3142 goto fail_vos_VolumeDump;
3144 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3149 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3150 goto fail_vos_VolumeDump;
3154 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3155 tst = ADMVOSDUMPFILENULL;
3156 goto fail_vos_VolumeDump;
3159 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3162 fail_vos_VolumeDump:
3171 * vos_VolumeRestore - restore a volume from a dump
3175 * IN cellHandle - a previously opened cellHandle that corresponds
3176 * to the cell where the volume exists.
3178 * IN serverHandle - a previously opened serverHandle that corresponds
3179 * to the server where the volume exists.
3181 * IN callBack - a call back function pointer that may be called to report
3182 * status information. Can be null.
3184 * IN partition - the partition where the volume exists.
3186 * IN volumeId - the volume id of the volume to be restored.
3188 * IN volumeName - the volume name of the volume to be restored.
3190 * IN dumpFile - the file from which to restore the volume.
3192 * IN dumpType - the type of dump to perform.
3196 * No locks are obtained or released by this function
3200 * Returns != 0 upon successful completion.
3204 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3205 vos_MessageCallBack_t callBack, unsigned int partition,
3206 unsigned int *volumeId, char *volumeName,
3207 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3211 afs_status_t tst = 0;
3212 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3213 file_server_p f_server = (file_server_p) serverHandle;
3214 struct nvldbentry entry;
3215 afs_int32 volid, server;
3218 int restoreflags = 0;
3219 afs_int32 Oserver, Opart, Otype;
3220 struct nvldbentry Oentry;
3224 * Validate arguments
3227 if (!IsValidCellHandle(c_handle, &tst)) {
3228 goto fail_vos_VolumeRestore;
3231 if (serverHandle != NULL) {
3232 if (!IsValidServerHandle(f_server, &tst)) {
3233 goto fail_vos_VolumeRestore;
3238 * Must pass volumeName
3241 if ((volumeName == NULL) || (*volumeName == 0)) {
3242 tst = ADMVOSVOLUMENAMENULL;
3243 goto fail_vos_VolumeRestore;
3246 if (!ValidateVolumeName(volumeName, &tst)) {
3247 goto fail_vos_VolumeRestore;
3251 * If volumeId is passed, it must be a valid volume id
3254 if (volumeId != NULL) {
3255 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3256 goto fail_vos_VolumeRestore;
3263 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3265 if (partition > VOLMAXPARTS) {
3266 tst = ADMVOSPARTITIONTOOLARGE;
3267 goto fail_vos_VolumeRestore;
3271 * Check that dumpFile exists and can be accessed
3274 fd = open(dumpFile, 0);
3275 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3277 tst = ADMVOSDUMPFILEOPENFAIL;
3278 goto fail_vos_VolumeRestore;
3283 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3284 restoreflags = RV_FULLRST;
3285 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3286 restoreflags = RV_FULLRST;
3288 volid = entry.volumeId[RWVOL];
3289 } else if ((entry.volumeId[RWVOL] != 0)
3290 && (entry.volumeId[RWVOL] != volid)) {
3291 volid = entry.volumeId[RWVOL];
3296 volid = entry.volumeId[RWVOL];
3297 } else if ((entry.volumeId[RWVOL] != 0)
3298 && (entry.volumeId[RWVOL] != volid)) {
3299 volid = entry.volumeId[RWVOL];
3303 * If the vldb says the same volume exists somewhere else
3304 * the caller must specify a full restore, not an incremental
3307 if (dumpType == VOS_RESTORE_FULL) {
3308 restoreflags = RV_FULLRST;
3312 * Check to see if the volume exists where the caller said
3315 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3316 goto fail_vos_VolumeRestore;
3318 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3319 goto fail_vos_VolumeRestore;
3323 tst = ADMVOSRESTOREVOLEXIST;
3324 goto fail_vos_VolumeRestore;
3329 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3330 restoreflags, dumpFile, &tst);
3332 fail_vos_VolumeRestore:
3341 * vos_VolumeOnline - bring a volume online.
3345 * IN serverHandle - a previously opened serverHandle that corresponds
3346 * to the server where the volume exists.
3348 * IN callBack - a call back function pointer that may be called to report
3349 * status information. Can be null.
3351 * IN partition - the partition where the volume exists.
3353 * IN volumeId - the volume id of the volume to be brought online.
3357 * No locks are obtained or released by this function
3361 * Returns != 0 upon successful completion.
3365 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3366 unsigned int partition, unsigned int volumeId,
3367 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3371 afs_status_t tst = 0;
3372 file_server_p f_server = (file_server_p) serverHandle;
3376 * Validate arguments
3379 if (!IsValidServerHandle(f_server, &tst)) {
3380 goto fail_vos_VolumeOnline;
3383 if (partition > VOLMAXPARTS) {
3384 tst = ADMVOSPARTITIONIDTOOLARGE;
3385 goto fail_vos_VolumeOnline;
3388 if (volumeStatus == VOS_ONLINE_BUSY) {
3392 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3395 fail_vos_VolumeOnline:
3404 * vos_VolumeOffline - take a volume offline.
3408 * IN serverHandle - a previously opened serverHandle that corresponds
3409 * to the server where the volume exists.
3411 * IN callBack - a call back function pointer that may be called to report
3412 * status information. Can be null.
3414 * IN partition - the partition where the volume exists.
3416 * IN volumeId - the volume id of the volume to be taken offline.
3420 * No locks are obtained or released by this function
3424 * Returns != 0 upon successful completion.
3428 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3429 unsigned int partition, unsigned int volumeId,
3433 afs_status_t tst = 0;
3434 file_server_p f_server = (file_server_p) serverHandle;
3437 * Validate arguments
3440 if (!IsValidServerHandle(f_server, &tst)) {
3441 goto fail_vos_VolumeOffline;
3444 if (partition > VOLMAXPARTS) {
3445 tst = ADMVOSPARTITIONIDTOOLARGE;
3446 goto fail_vos_VolumeOffline;
3449 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3450 VTOutOfService, 0, &tst);
3452 fail_vos_VolumeOffline:
3461 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3465 * IN source - the volintXInfo structure to copy.
3467 * OUT dest - the vos_volumeEntry_t to fill
3471 * No locks are obtained or released by this function
3475 * Returns != 0 upon successful completion.
3479 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3483 afs_status_t tst = 0;
3487 * If the volume is not marked OK, all the other fields are invalid
3488 * We take the extra step of blanking out dest here to prevent the
3489 * user from seeing stale data from a previous call
3492 memset(dest, 0, sizeof(*dest));
3494 switch (source->status) {
3496 dest->status = VOS_OK;
3499 dest->status = VOS_SALVAGE;
3502 dest->status = VOS_NO_VNODE;
3505 dest->status = VOS_NO_VOL;
3508 dest->status = VOS_VOL_EXISTS;
3511 dest->status = VOS_NO_SERVICE;
3514 dest->status = VOS_OFFLINE;
3517 dest->status = VOS_ONLINE;
3520 dest->status = VOS_DISK_FULL;
3523 dest->status = VOS_OVER_QUOTA;
3526 dest->status = VOS_BUSY;
3529 dest->status = VOS_MOVED;
3534 * Check to see if the entry is marked ok before copying all the
3538 if (dest->status == VOS_OK) {
3539 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3540 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3541 dest->id = source->volid;
3542 if (source->type == 0) {
3543 dest->type = VOS_READ_WRITE_VOLUME;
3544 } else if (source->type == 1) {
3545 dest->type = VOS_READ_ONLY_VOLUME;
3546 } else if (source->type == 2) {
3547 dest->type = VOS_BACKUP_VOLUME;
3549 dest->backupId = source->backupID;
3550 dest->readWriteId = source->parentID;
3551 dest->readOnlyId = source->cloneID;
3552 dest->copyCreationDate = source->copyDate;
3553 dest->creationDate = source->creationDate;
3554 dest->lastAccessDate = source->accessDate;
3555 dest->lastUpdateDate = source->updateDate;
3556 dest->lastBackupDate = source->backupDate;
3557 dest->accessesSinceMidnight = source->dayUse;
3558 dest->fileCount = source->filecount;
3559 dest->maxQuota = source->maxquota;
3560 dest->currentSize = source->size;
3561 if (source->inUse == 1) {
3562 dest->volumeDisposition = VOS_ONLINE;
3564 dest->volumeDisposition = VOS_OFFLINE;
3567 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3568 dest->readStats[i] = source->stat_reads[i];
3569 dest->writeStats[i] = source->stat_writes[i];
3572 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3573 dest->fileAuthorWriteSameNetwork[i] =
3574 source->stat_fileSameAuthor[i];
3575 dest->fileAuthorWriteDifferentNetwork[i] =
3576 source->stat_fileDiffAuthor[i];
3577 dest->dirAuthorWriteSameNetwork[i] =
3578 source->stat_dirSameAuthor[i];
3579 dest->dirAuthorWriteDifferentNetwork[i] =
3580 source->stat_dirDiffAuthor[i];
3593 * vos_VolumeGet - get information about a particular volume.
3597 * IN cellHandle - a previously opened cellHandle that corresponds
3598 * to the cell where the volume exists.
3600 * IN serverHandle - a previously opened serverHandle that corresponds
3601 * to the server where the volume exists.
3603 * IN callBack - a call back function pointer that may be called to report
3604 * status information. Can be null.
3606 * IN partition - the partition where the volume exists.
3608 * IN volumeId - the volume id of the volume to be retrieved.
3610 * OUT volumeP - upon successful completion, contains the information about the
3615 * No locks are obtained or released by this function
3619 * Returns != 0 upon successful completion.
3623 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3624 vos_MessageCallBack_t callBack, unsigned int partition,
3625 unsigned int volumeId, vos_volumeEntry_p volumeP,
3629 afs_status_t tst = 0;
3630 file_server_p f_server = (file_server_p) serverHandle;
3631 struct volintXInfo *info = NULL;
3634 * Validate arguments
3637 if (!IsValidServerHandle(f_server, &tst)) {
3638 goto fail_vos_VolumeGet;
3641 if (partition > VOLMAXPARTS) {
3642 tst = ADMVOSPARTITIONIDTOOLARGE;
3643 goto fail_vos_VolumeGet;
3646 if (volumeP == NULL) {
3647 tst = ADMVOSVOLUMEPNULL;
3648 goto fail_vos_VolumeGet;
3652 * Retrieve the information for the volume
3655 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3656 goto fail_vos_VolumeGet;
3660 * Copy the volume info to our structure
3663 if (!copyvolintXInfo(info, volumeP, &tst)) {
3664 goto fail_vos_VolumeGet;
3681 * The iterator functions and data for the volume retrieval functions.
3684 typedef struct volume_get {
3685 struct volintXInfo *vollist;
3686 afs_int32 total; /* total number of volumes at this partition */
3687 afs_int32 index; /* index to the current volume */
3688 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3689 } volume_get_t, *volume_get_p;
3692 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3693 int *last_item_contains_data, afs_status_p st)
3696 afs_status_t tst = 0;
3697 volume_get_p entry = (volume_get_p) rpc_specific;
3700 * Copy the next entry into the cache
3703 if (!copyvolintXInfo
3704 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3705 goto fail_GetVolumeRPC;
3710 * See if we've processed all the entries
3714 if (entry->index == entry->total) {
3716 *last_item_contains_data = 1;
3729 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3732 afs_status_t tst = 0;
3733 volume_get_p entry = (volume_get_p) rpc_specific;
3735 memcpy(dest, (const void *)&entry->entry[slot],
3736 sizeof(vos_volumeEntry_t));
3747 DestroyVolume(void *rpc_specific, afs_status_p st)
3750 afs_status_t tst = 0;
3751 volume_get_p entry = (volume_get_p) rpc_specific;
3753 if (entry->vollist != NULL) {
3754 free(entry->vollist);
3766 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3770 * IN cellHandle - a previously opened cellHandle that corresponds
3771 * to the cell where the volumes exist.
3773 * IN serverHandle - a handle to the server where the volumes exist.
3775 * IN callBack - a call back function pointer that may be called to report
3776 * status information. Can be null.
3778 * IN partition - the partition whose volumes should be listed. Can be null.
3780 * OUT iterationIdP - upon successful completion, contains an iterator that
3781 * can be passed to vos_VolumeGetBegin.
3785 * No locks are obtained or released by this function
3789 * Returns != 0 upon successful completion.
3793 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3794 vos_MessageCallBack_t callBack, unsigned int partition,
3795 void **iterationIdP, afs_status_p st)
3798 afs_status_t tst = 0;
3799 file_server_p f_server = (file_server_p) serverHandle;
3800 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
3801 volume_get_p entry = calloc(1, sizeof(volume_get_t));
3804 * Validate arguments
3807 if (!IsValidServerHandle(f_server, &tst)) {
3808 goto fail_vos_VolumeGetBegin;
3811 if (partition > VOLMAXPARTS) {
3812 tst = ADMVOSPARTITIONIDTOOLARGE;
3813 goto fail_vos_VolumeGetBegin;
3816 if ((iter == NULL) || (entry == NULL)) {
3818 goto fail_vos_VolumeGetBegin;
3822 * Get a list of all the volumes contained in the partition at the
3826 if (!UV_XListVolumes
3827 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3829 goto fail_vos_VolumeGetBegin;
3832 if (entry->total == 0) {
3833 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3834 goto fail_vos_VolumeGetBegin;
3836 iter->done_iterating = 1;
3837 iter->st = ADMITERATORDONE;
3840 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3841 DestroyVolume, &tst)) {
3842 goto fail_vos_VolumeGetBegin;
3845 *iterationIdP = (void *)iter;
3848 fail_vos_VolumeGetBegin:
3854 if (entry != NULL) {
3866 * vos_VolumeGetNext - get information about the next volume.
3870 * IN iterationId - an iterator previously returned by
3871 * vos_VolumeGetBegin
3873 * OUT volumeP - a pointer to a vos_volumeEntry_t
3874 * that upon successful completion contains information about the
3879 * The iterator is locked while the next item is retrieved.
3883 * Returns != 0 upon successful completion.
3887 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3891 afs_status_t tst = 0;
3892 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3895 tst = ADMITERATORNULL;
3896 goto fail_vos_VolumeGetNext;
3899 if (volumeP == NULL) {
3900 tst = ADMVOSVOLUMEPNULL;
3901 goto fail_vos_VolumeGetNext;
3904 rc = IteratorNext(iter, (void *)volumeP, &tst);
3906 fail_vos_VolumeGetNext:
3915 * vos_VolumeGetDone - finish using a volume iterator.
3919 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3923 * The iterator is locked and then destroyed.
3927 * Returns != 0 upon successful completion.
3931 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3934 afs_status_t tst = 0;
3935 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3938 * Validate arguments
3942 tst = ADMITERATORNULL;
3943 goto fail_vos_VolumeGetDone;
3946 rc = IteratorDone(iter, &tst);
3948 fail_vos_VolumeGetDone:
3957 * vos_VolumeMove - move a volume from one server to another.
3961 * IN cellHandle - a previously opened cellHandle that corresponds
3962 * to the cell where the volume exists.
3964 * IN callBack - a call back function pointer that may be called to report
3965 * status information. Can be null.
3967 * IN volumeId - the volume id of the volume to be moved.
3969 * IN fromServer - a previously opened serverHandle that corresponds
3970 * to the server where the volume currently resides.
3972 * IN fromPartition - the partition where the volume currently resides.
3974 * IN toServer - a previously opened serverHandle that corresponds
3975 * to the server where the volume will be moved.
3977 * IN toPartition - the partition where the volume will be moved.
3981 * No locks are obtained or released by this function
3985 * Returns != 0 upon successful completion.
3989 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
3990 unsigned int volumeId, const void *fromServer,
3991 unsigned int fromPartition, const void *toServer,
3992 unsigned int toPartition, afs_status_p st)
3995 afs_status_t tst = 0;
3996 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3997 file_server_p from_server = (file_server_p) fromServer;
3998 file_server_p to_server = (file_server_p) toServer;
3999 afs_int32 from_server_addr =
4000 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4001 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4002 afs_int32 from_partition = fromPartition;
4003 afs_int32 to_partition = toPartition;
4006 * Validate arguments
4009 if (!IsValidCellHandle(c_handle, &tst)) {
4010 goto fail_vos_VolumeMove;
4013 if (!IsValidServerHandle(from_server, &tst)) {
4014 goto fail_vos_VolumeMove;
4017 if (!IsValidServerHandle(to_server, &tst)) {
4018 goto fail_vos_VolumeMove;
4021 if (fromPartition > VOLMAXPARTS) {
4022 tst = ADMVOSPARTITIONIDTOOLARGE;
4023 goto fail_vos_VolumeMove;
4026 if (toPartition > VOLMAXPARTS) {
4027 tst = ADMVOSPARTITIONIDTOOLARGE;
4028 goto fail_vos_VolumeMove;
4035 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4036 to_server_addr, to_partition, &tst);
4038 fail_vos_VolumeMove:
4047 * vos_VolumeRelease - release a volume.
4051 * IN cellHandle - a previously opened cellHandle that corresponds
4052 * to the cell where the volume exists.
4054 * IN callBack - a call back function pointer that may be called to report
4055 * status information. Can be null.
4057 * IN volumeId - the volume to be released.
4059 * IN force - force a complete release.
4063 * No locks are obtained or released by this function
4067 * Returns != 0 upon successful completion.
4071 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4072 unsigned int volumeId, vos_force_t force, afs_status_p st)
4075 afs_status_t tst = 0;
4076 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4077 afs_int32 server, part, forc = 0, voltype, volume;
4078 struct nvldbentry entry;
4081 * Validate arguments
4084 if (!IsValidCellHandle(c_handle, &tst)) {
4085 goto fail_vos_VolumeRelease;
4089 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4090 goto fail_vos_VolumeRelease;
4093 if (force == VOS_FORCE) {
4098 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4100 fail_vos_VolumeRelease:
4109 * vos_VolumeZap - forcibly delete a volume.
4113 * IN cellHandle - a previously opened cellHandle that corresponds
4114 * to the cell where the volume exists.
4116 * IN serverHandle - a previously opened serverHandle that corresponds
4117 * to the server where the volume exists.
4119 * IN callBack - a call back function pointer that may be called to report
4120 * status information. Can be null.
4122 * IN partition - the partition where the volume exists.
4124 * IN volumeId - the volume id of the vldb entry to be deleted.
4126 * IN force - force the deletion of bad volumes.
4130 * No locks are obtained or released by this function
4134 * Returns != 0 upon successful completion.
4138 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4139 vos_MessageCallBack_t callBack, unsigned int partition,
4140 unsigned int volumeId, vos_force_t force, afs_status_p st)
4143 afs_status_t tst = 0;
4144 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4145 file_server_p f_server = (file_server_p) serverHandle;
4148 * Verify that the cellHandle is capable of making vos rpc's
4151 if (!IsValidCellHandle(c_handle, &tst)) {
4152 goto fail_vos_VolumeZap;
4155 if (!IsValidServerHandle(f_server, &tst)) {
4156 goto fail_vos_VolumeZap;
4159 if (force == VOS_FORCE) {
4160 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4163 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4176 * vos_PartitionNameToId - translate a string representing a partition
4181 * IN partitionName - a string representing a partition. Must be of
4184 * OUT partitionId - a number containing the partition id upon successful
4189 * No locks are obtained or released by this function
4193 * Returns != 0 upon successful completion.
4197 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4201 afs_status_t tst = 0;
4202 size_t partition_name_len;
4206 * Validate arguments
4209 if (partitionName == NULL) {
4210 tst = ADMVOSPARTITIONNAMENULL;
4211 goto fail_vos_PartitionNameToId;
4214 if (partitionId == NULL) {
4215 tst = ADMVOSPARTITIONIDNULL;
4216 goto fail_vos_PartitionNameToId;
4220 * Check that string begins with /vicep
4223 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4224 tst = ADMVOSPARTITIONNAMEINVALID;
4225 goto fail_vos_PartitionNameToId;
4229 * Check that the string is either one or two characters
4230 * longer than VICE_PREFIX_SIZE
4233 partition_name_len = strlen(partitionName);
4235 if (partition_name_len == VICE_PREFIX_SIZE) {
4236 tst = ADMVOSPARTITIONNAMETOOSHORT;
4237 goto fail_vos_PartitionNameToId;
4240 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4241 tst = ADMVOSPARTITIONNAMETOOLONG;
4242 goto fail_vos_PartitionNameToId;
4246 * Check that all characters past the prefix are lower case
4249 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4250 if (!islower(partitionName[i])) {
4251 tst = ADMVOSPARTITIONNAMENOTLOWER;
4252 goto fail_vos_PartitionNameToId;
4257 * Convert the name to a number
4260 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4261 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4264 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4265 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4268 if (*partitionId > VOLMAXPARTS) {
4269 tst = ADMVOSPARTITIONIDTOOLARGE;
4270 goto fail_vos_PartitionNameToId;
4274 fail_vos_PartitionNameToId:
4283 * vos_PartitionIdToName - translate a number representing a partition
4284 * to a character string.
4288 * IN partitionId - an integer representing the partition.
4290 * OUT partitionName - a string containing the converted partition ID
4291 * upon successful completion.
4295 * No locks are obtained or released by this function
4299 * Returns != 0 upon successful completion.
4303 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4307 afs_status_t tst = 0;
4309 if (partitionId > VOLMAXPARTS) {
4310 tst = ADMVOSPARTITIONIDTOOLARGE;
4311 goto fail_vos_PartitionIdToName;
4314 if (partitionName == NULL) {
4315 tst = ADMVOSPARTITIONNAMENULL;
4316 goto fail_vos_PartitionIdToName;
4319 if (partitionId < 26) {
4320 strcpy(partitionName, VICE_PARTITION_PREFIX);
4321 partitionName[6] = partitionId + 'a';
4322 partitionName[7] = '\0';
4324 strcpy(partitionName, VICE_PARTITION_PREFIX);
4326 partitionName[6] = 'a' + (partitionId / 26);
4327 partitionName[7] = 'a' + (partitionId % 26);
4328 partitionName[8] = '\0';
4332 fail_vos_PartitionIdToName:
4341 * vos_VolumeQuotaChange - change the quota of a volume.
4345 * IN cellHandle - a previously opened cellHandle that corresponds
4346 * to the cell where the volume exists.
4348 * IN serverHandle - a previously opened serverHandle that corresponds
4349 * to the server where the volume exists.
4351 * IN callBack - a call back function pointer that may be called to report
4352 * status information. Can be null.
4354 * IN partition - the partition where the volume exists.
4356 * IN volumeId - the volume id of the volume to be modified.
4358 * IN volumeQuota - the new volume quota.
4362 * No locks are obtained or released by this function
4366 * Returns != 0 upon successful completion.
4370 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4371 vos_MessageCallBack_t callBack, unsigned int partition,
4372 unsigned int volumeId, unsigned int volumeQuota,
4376 afs_status_t tst = 0;
4377 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4378 file_server_p f_server = (file_server_p) serverHandle;
4381 struct volintInfo tstatus;
4382 int active_trans = 0;
4385 * Verify that the cellHandle is capable of making vos rpc's
4388 if (!IsValidCellHandle(c_handle, &tst)) {
4389 goto fail_vos_VolumeQuotaChange;
4392 if (!IsValidServerHandle(f_server, &tst)) {
4393 goto fail_vos_VolumeQuotaChange;
4396 memset((void *)&tstatus, 0, sizeof(tstatus));
4397 tstatus.dayUse = -1;
4398 tstatus.spare2 = -1;
4399 tstatus.maxquota = volumeQuota;
4403 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4405 goto fail_vos_VolumeQuotaChange;
4409 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4411 goto fail_vos_VolumeQuotaChange;
4415 fail_vos_VolumeQuotaChange:
4418 afs_status_t tst2 = 0;
4419 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4440 * vos_VolumeGet2 - get information about a particular volume.
4444 * IN cellHandle - a previously opened cellHandle that corresponds
4445 * to the cell where the volume exists.
4447 * IN serverHandle - a previously opened serverHandle that corresponds
4448 * to the server where the volume exists.
4450 * IN callBack - a call back function pointer that may be called to report
4451 * status information. Can be null.
4453 * IN partition - the partition where the volume exists.
4455 * IN volumeId - the volume id of the volume to be retrieved.
4457 * OUT pinfo - upon successful completion, contains the information about the
4462 * No locks are obtained or released by this function
4466 * Returns != 0 upon successful completion.
4470 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4471 vos_MessageCallBack_t callBack, unsigned int partition,
4472 unsigned int volumeId, volintInfo* pinfo,
4476 afs_status_t tst = 0;
4477 file_server_p f_server = (file_server_p) serverHandle;
4478 volintInfo *pinfo_=0;
4481 * Validate arguments
4484 if (!IsValidServerHandle(f_server, &tst)) {
4485 goto fail_vos_VolumeGet2;
4488 if (partition > VOLMAXPARTS) {
4489 tst = ADMVOSPARTITIONIDTOOLARGE;
4490 goto fail_vos_VolumeGet2;
4493 if (pinfo == NULL) {
4494 tst = ADMVOSVOLUMEPNULL;
4495 goto fail_vos_VolumeGet2;
4499 * Retrieve the information for the volume
4502 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4503 goto fail_vos_VolumeGet2;
4509 fail_vos_VolumeGet2:
4511 if (pinfo_ != NULL) {
4512 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4523 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4527 * IN cellHandle - a previously opened cellHandle that corresponds
4528 * to the cell where the volume exists.
4530 * IN serverHandle - a previously opened serverHandle that corresponds
4531 * to the server where the volume exists.
4533 * IN partition - the partition where the volume exists.
4535 * IN volumeId - the volume id of the volume to be retrieved.
4539 * No locks are obtained or released by this function
4543 * Returns != 0 upon successful completion.
4547 vos_ClearVolUpdateCounter(const void *cellHandle,
4548 const void *serverHandle,
4549 unsigned int partition,
4550 unsigned int volumeId,
4554 afs_status_t tst = 0;
4555 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4556 file_server_p f_server = (file_server_p) serverHandle;
4559 struct volintInfo tstatus;
4560 int active_trans = 0;
4563 * Verify that the cellHandle is capable of making vos rpc's
4566 if (!IsValidCellHandle(c_handle, &tst)) {
4567 goto fail_vos_ClearVolUpdateCounter;
4570 if (!IsValidServerHandle(f_server, &tst)) {
4571 goto fail_vos_ClearVolUpdateCounter;
4574 memset((void *)&tstatus, 0, sizeof(tstatus));
4575 tstatus.maxquota = -1;
4576 tstatus.dayUse = -1;
4577 tstatus.creationDate = -1;
4578 tstatus.updateDate = -1;
4580 tstatus.spare0 = -1;
4581 tstatus.spare1 = -1;
4583 tstatus.spare3 = -1;
4586 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4588 goto fail_vos_ClearVolUpdateCounter;
4592 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4594 goto fail_vos_ClearVolUpdateCounter;
4598 fail_vos_ClearVolUpdateCounter:
4601 afs_status_t tst2 = 0;
4602 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);