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/volser.h>
20 #include <afs/volint.h>
22 #include "afs_vosAdmin.h"
23 #include "../adminutil/afs_AdminInternal.h"
25 /* File descriptors are HANDLE's on NT. The following typedef helps catch
26 * type errors. Duplicated from vol/ihandle.h
33 #define INVALID_FD ((FD_t)-1)
35 #include <afs/partition.h>
37 #include <rx/rxstat.h>
38 #include <afs/afs_utilAdmin.h>
41 #include "lockprocs.h"
43 typedef struct file_server {
46 struct rx_connection *serv;
48 } file_server_t, *file_server_p;
51 * IsValidServerHandle - test a server handle for validity.
55 * IN serverHandle - the serverHandle to be validated.
59 * No locks are obtained or released by this function
63 * Returns != 0 upon successful completion.
67 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
72 if (serverHandle == NULL) {
73 tst = ADMVOSSERVERHANDLENULL;
74 goto fail_IsValidServerHandle;
77 if (serverHandle->is_valid != 1) {
78 tst = ADMVOSSERVERHANDLEINVALID;
79 goto fail_IsValidServerHandle;
82 if ((serverHandle->begin_magic != BEGIN_MAGIC)
83 || (serverHandle->end_magic != END_MAGIC)) {
84 tst = ADMVOSSERVERHANDLEBADMAGIC;
85 goto fail_IsValidServerHandle;
89 fail_IsValidServerHandle:
99 * IsValidCellHandle - verify that a cell handle can be used to make vos
104 * IN cellHandle - the cellHandle to be validated.
108 * No locks are obtained or released by this function
112 * Returns != 0 upon successful completion.
116 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
119 afs_status_t tst = 0;
121 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
122 goto fail_IsValidCellHandle;
125 if (cellHandle->vos_valid == 0) {
126 tst = ADMVOSCELLHANDLEINVALIDVOS;
127 goto fail_IsValidCellHandle;
131 fail_IsValidCellHandle:
139 /* set <server> and <part> to the correct values depending on
140 * <voltype> and <entry> */
142 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
143 afs_int32 * part, int *previdx)
145 int i, istart, vtype;
150 /* Doesn't check for non-existance of backup volume */
151 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
153 istart = 0; /* seach the entire entry */
156 /* Seach from beginning of entry or pick up where we left off */
157 istart = ((*previdx < 0) ? 0 : *previdx + 1);
160 for (i = istart; i < entry->nServers; i++) {
161 if (entry->serverFlags[i] & vtype) {
162 *server = entry->serverNumber[i];
163 *part = entry->serverPartition[i];
169 /* Didn't find any, return -1 */
175 * vos_BackupVolumeCreate - create a backup volume for a volume.
179 * IN cellHandle - a previously opened cellHandle that corresponds
180 * to the cell where volume exists.
182 * IN callBack - a call back function pointer that may be called to report
183 * status information. Can be null.
185 * IN volumeId - the volume to create the back up for.
189 * No locks are obtained or released by this function
193 * Returns != 0 upon successful completion.
197 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
198 unsigned int volumeId, afs_status_p st)
201 afs_status_t tst = 0;
202 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
203 struct nvldbentry rw_vol_entry;
205 afs_int32 rw_partition;
206 afs_int32 rw_vol_type;
207 struct nvldbentry bk_vol_entry;
209 afs_int32 bk_partition;
210 afs_int32 bk_vol_type;
217 if (!IsValidCellHandle(c_handle, &tst)) {
218 goto fail_vos_BackupVolumeCreate;
222 * Get the volume information and verify that we've been passed
223 * a read write volume id
227 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
228 &rw_vol_type, &tst)) {
229 goto fail_vos_BackupVolumeCreate;
232 if (rw_vol_type != RWVOL) {
233 tst = ADMVOSMUSTBERWVOL;
234 goto fail_vos_BackupVolumeCreate;
238 * Check to see that if a backup volume exists, it exists on the
239 * same server as volumeId
242 if (rw_vol_entry.flags & BACK_EXISTS) {
244 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
245 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
246 goto fail_vos_BackupVolumeCreate;
248 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
249 goto fail_vos_BackupVolumeCreate;
252 tst = ADMVOSBACKUPVOLWRONGSERVER;
253 goto fail_vos_BackupVolumeCreate;
258 * Create the new backup volume
261 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
263 fail_vos_BackupVolumeCreate:
272 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
276 * IN cellHandle - a previously opened cellHandle that corresponds
277 * to the cell where the volumes exist.
279 * IN serverHandle - the server where the backups are to be created. Can be
282 * IN callBack - a call back function pointer that may be called to report
283 * status information. Can be null.
285 * IN partition - the partition where the backups are to be created. Can be
288 * IN volumePrefix - all volumes with this prefix will have backup volumes
289 * created. Can be null.
291 * IN excludePrefix - exclude the volumes that match volumePrefix.
295 * No locks are obtained or released by this function
299 * Returns != 0 upon successful completion.
303 vos_BackupVolumeCreateMultiple(const void *cellHandle,
304 const void *serverHandle,
305 vos_MessageCallBack_t callBack,
306 const unsigned int *partition,
307 const char *volumePrefix,
308 vos_exclude_t excludePrefix, afs_status_p st)
311 afs_status_t tst = 0;
312 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
313 file_server_p f_server = (file_server_p) serverHandle;
314 struct VldbListByAttributes attr;
317 size_t prefix_len = 0;
318 nbulkentries arrayEntries;
319 afs_int32 nentries = 0;
320 struct nvldbentry *entry;
322 afs_int32 rw_volid, rw_server, rw_partition;
327 memset((void *)&attr, 0, sizeof(attr));
332 * The only required argument to this function is the cellHandle.
333 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
337 if (!IsValidCellHandle(c_handle, &tst)) {
338 goto fail_vos_BackupVolumeCreateMultiple;
341 if ((excludePrefix == VOS_EXCLUDE)
342 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
343 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
344 goto fail_vos_BackupVolumeCreateMultiple;
347 if (f_server != NULL) {
348 if (!IsValidServerHandle(f_server, &tst)) {
349 goto fail_vos_BackupVolumeCreateMultiple;
351 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
352 attr.Mask |= VLLIST_SERVER;
355 if (partition != NULL) {
356 if (*partition > VOLMAXPARTS) {
357 tst = ADMVOSPARTITIONTOOLARGE;
358 goto fail_vos_BackupVolumeCreateMultiple;
360 attr.partition = *partition;
361 attr.Mask |= VLLIST_PARTITION;
364 if (excludePrefix == VOS_EXCLUDE) {
368 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
370 prefix_len = strlen(volumePrefix);
373 memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
376 * Get a list of all the volumes in the cell
379 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
380 goto fail_vos_BackupVolumeCreateMultiple;
384 * Cycle through the list of volumes and see if we should create a backup
385 * for each individual volume
388 for (i = 0; i < nentries; i++) {
389 entry = &arrayEntries.nbulkentries_val[i];
392 * Skip entries that don't have a RW volume
395 if (!(entry->flags & RW_EXISTS)) {
396 if (callBack != NULL) {
397 const char *messageText;
398 if (util_AdminErrorCodeTranslate
399 (ADMVOSVOLUMENOREADWRITE, 0, &messageText, &tst)) {
400 sprintf(backbuf, "%s %s", messageText, entry->name);
401 (**callBack) (VOS_VERBOSE_MESSAGE, backbuf);
408 * See if we should skip this entry because of the prefix/exclude
409 * combination we've been passed
414 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
418 if (strncmp(entry->name, volumePrefix, prefix_len)) {
424 rw_volid = entry->volumeId[RWVOL];
425 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
427 if ((rw_server == -1) || (rw_partition == -1)) {
428 if (callBack != NULL) {
429 const char *messageText;
430 if (util_AdminErrorCodeTranslate
431 (ADMVOSVLDBBADENTRY, 0, &messageText, &tst)) {
432 sprintf(backbuf, "%s %s", messageText, entry->name);
433 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
440 * Check that the RW volume is on the same server that we were
444 if (serverHandle != NULL) {
445 if (!VLDB_IsSameAddrs
446 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
447 rw_server, &equal, &tst)) {
448 if (callBack != NULL) {
449 const char *messageText;
450 if (util_AdminErrorCodeTranslate
451 (ADMVOSVLDBBADSERVER, 0, &messageText, &tst)) {
452 sprintf(backbuf, "%s %x %d", messageText,
453 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
455 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
461 if (callBack != NULL) {
462 const char *messageText;
463 if (util_AdminErrorCodeTranslate
464 (ADMVOSVLDBDIFFERENTADDR, 0, &messageText, &tst)) {
465 sprintf(backbuf, "%s %s", messageText, entry->name);
466 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
474 * Check that the RW volume is on the same partition we were
478 if (partition != NULL) {
479 if (*partition != rw_partition) {
488 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid,
492 fail_vos_BackupVolumeCreateMultiple:
494 if (arrayEntries.nbulkentries_val) {
495 free(arrayEntries.nbulkentries_val);
505 * vos_PartitionGet - get information about a single partition.
509 * IN cellHandle - a previously opened cellHandle that corresponds
510 * to the cell where the server lives.
512 * IN serverHandle - a previously open vos server handle that holds
513 * the partition of interest.
515 * IN callBack - a call back function pointer that may be called to report
516 * status information. Can be null.
518 * IN partition - the integer that represents the partition of interest.
520 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
521 * completion contains information regarding the partition.
525 * No locks are obtained or released by this function
529 * Returns != 0 upon successful completion.
533 vos_PartitionGet(const void *cellHandle, const void *serverHandle,
534 vos_MessageCallBack_t callBack, unsigned int partition,
535 vos_partitionEntry_p partitionP, afs_status_p st)
538 afs_status_t tst = 0;
539 struct diskPartition part_info;
540 file_server_p f_server = (file_server_p) serverHandle;
541 char partitionName[10]; /* this rpc requires a character partition name */
547 if (!IsValidServerHandle(f_server, &tst)) {
548 goto fail_vos_PartitionGet;
551 if (partitionP == NULL) {
552 tst = ADMVOSPARTITIONPNULL;
553 goto fail_vos_PartitionGet;
556 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
557 goto fail_vos_PartitionGet;
560 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
562 goto fail_vos_PartitionGet;
564 strncpy(partitionP->name, part_info.name, VOS_MAX_PARTITION_NAME_LEN);
565 partitionP->name[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
566 strncpy(partitionP->deviceName, part_info.devName, VOS_MAX_PARTITION_NAME_LEN);
567 partitionP->deviceName[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
568 partitionP->lockFileDescriptor = part_info.lock_fd;
569 partitionP->totalSpace = part_info.minFree;
570 partitionP->totalFreeSpace = part_info.free;
573 fail_vos_PartitionGet:
582 * The iterator functions and data for the partition retrieval functions.
585 typedef struct partition_get {
586 afs_int32 total_received; /* the total number of valid partiions retrieved */
587 int number_processed; /* the number of valid paritions we've handed out */
588 int index; /* the current index into the part_list array */
589 struct partList part_list; /* the list of partitions */
590 vos_partitionEntry_t partition[CACHED_ITEMS]; /* the cache of partitions */
591 const void *server; /* the server where the parititions exist */
592 } partition_get_t, *partition_get_p;
595 GetPartitionInfoRPC(void *rpc_specific, int slot, int *last_item,
596 int *last_item_contains_data, afs_status_p st)
599 afs_status_t tst = 0;
600 partition_get_p part = (partition_get_p) rpc_specific;
601 vos_partitionEntry_p ptr = (vos_partitionEntry_p) & part->partition[slot];
604 * Skip partition entries that are not valid
607 while (!(part->part_list.partFlags[part->index] & PARTVALID)) {
612 * Get information for the next partition
615 if (!vos_PartitionGet
617 (unsigned int)part->part_list.partId[part->index], ptr, &tst)) {
618 goto fail_GetPartitionInfoRPC;
622 part->number_processed++;
624 if (part->number_processed == part->total_received) {
626 *last_item_contains_data = 1;
630 fail_GetPartitionInfoRPC:
639 GetPartitionInfoFromCache(void *rpc_specific, int slot, void *dest,
643 afs_status_t tst = 0;
644 partition_get_p part = (partition_get_p) rpc_specific;
646 memcpy(dest, (const void *)&part->partition[slot],
647 sizeof(vos_partitionEntry_t));
657 * vos_PartitionGetBegin - begin to iterate over the partitions at a
662 * IN cellHandle - a previously opened cellHandle that corresponds
663 * to the cell where the server exists.
665 * IN serverHandle - the server that houses the partitions of interest.
667 * IN callBack - a call back function pointer that may be called to report
668 * status information. Can be null.
670 * OUT iterationIdP - upon successful completion, contains an iterator that can
671 * be passed to vos_PartitionGetNext.
675 * No locks are obtained or released by this function
679 * Returns != 0 upon successful completion.
683 vos_PartitionGetBegin(const void *cellHandle, const void *serverHandle,
684 vos_MessageCallBack_t callBack, void **iterationIdP,
688 afs_status_t tst = 0;
689 file_server_p f_server = (file_server_p) serverHandle;
690 afs_admin_iterator_p iter =
691 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
692 partition_get_p part =
693 (partition_get_p) calloc(1, sizeof(partition_get_t));
699 if (!IsValidServerHandle(f_server, &tst)) {
700 goto fail_vos_PartitionGetBegin;
703 if (iterationIdP == NULL) {
704 goto fail_vos_PartitionGetBegin;
707 if ((iter == NULL) || (part == NULL)) {
709 goto fail_vos_PartitionGetBegin;
713 * Fill in the part structure
716 part->server = serverHandle;
717 if (!UV_ListPartitions
718 (f_server->serv, &part->part_list, &part->total_received, &tst)) {
719 goto fail_vos_PartitionGetBegin;
723 * If we didn't receive any partitions, don't spawn a background thread.
724 * Mark the iterator complete.
727 if (part->total_received == 0) {
728 if (!IteratorInit(iter, (void *)part, NULL, NULL, NULL, NULL, &tst)) {
729 goto fail_vos_PartitionGetBegin;
731 iter->done_iterating = 1;
732 iter->st = ADMITERATORDONE;
735 (iter, (void *)part, GetPartitionInfoRPC,
736 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
737 goto fail_vos_PartitionGetBegin;
740 *iterationIdP = (void *)iter;
743 fail_vos_PartitionGetBegin:
761 * vos_PartitionGetNext - get the next partition at a server.
765 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
767 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
768 * completion contains the next partition.
772 * The iterator is locked while the next parition is retrieved.
776 * Returns != 0 upon successful completion.
780 vos_PartitionGetNext(const void *iterationId, vos_partitionEntry_p partitionP,
784 afs_status_t tst = 0;
785 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
788 tst = ADMITERATORNULL;
789 goto fail_vos_PartitionGetNext;
792 if (partitionP == NULL) {
793 tst = ADMVOSPARTITIONPNULL;
794 goto fail_vos_PartitionGetNext;
797 rc = IteratorNext(iter, (void *)partitionP, &tst);
799 fail_vos_PartitionGetNext:
808 * vos_PartitionGetDone - finish using a partition iterator.
812 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
816 * The iterator is locked and then destroyed.
820 * Returns != 0 upon successful completion.
824 vos_PartitionGetDone(const void *iterationId, afs_status_p st)
827 afs_status_t tst = 0;
828 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
835 tst = ADMITERATORNULL;
836 goto fail_vos_PartitionGetDone;
839 rc = IteratorDone(iter, &tst);
841 fail_vos_PartitionGetDone:
850 * vos_ServerOpen - open a handle to an individual server for future
855 * IN cellHandle - a previously opened cellHandle that corresponds
856 * to the cell where the server lives.
858 * IN serverName - the machine name of the server
860 * OUT serverHandleP - a void pointer that upon successful completion
861 * contains a handle that is used in future operations upon the server.
865 * No locks are obtained or released by this function
869 * Returns != 0 upon successful completion.
873 vos_ServerOpen(const void *cellHandle, const char *serverName,
874 void **serverHandleP, afs_status_p st)
877 afs_status_t tst = 0;
878 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
879 file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
881 struct rx_securityClass *sc[3];
884 if (f_server == NULL) {
886 goto fail_vos_ServerOpen;
893 if (!IsValidCellHandle(c_handle, &tst)) {
894 goto fail_vos_ServerOpen;
897 if (!c_handle->tokens->afs_token_set) {
898 tst = ADMVOSCELLHANDLENOAFSTOKENS;
899 goto fail_vos_ServerOpen;
902 if (!util_AdminServerAddressGetFromName
903 (serverName, &server_address, &tst)) {
904 goto fail_vos_ServerOpen;
907 scIndex = c_handle->tokens->sc_index;
908 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
910 rx_GetCachedConnection(htonl(server_address),
911 htons(AFSCONF_VOLUMEPORT), VOLSERVICE_ID,
912 sc[scIndex], scIndex);
913 if (f_server->serv != NULL) {
914 f_server->begin_magic = BEGIN_MAGIC;
915 f_server->end_magic = END_MAGIC;
916 f_server->is_valid = 1;
917 *serverHandleP = (void *)f_server;
920 tst = ADMVOSSERVERNOCONNECTION;
921 goto fail_vos_ServerOpen;
933 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
937 * IN serverHandle - an existing server handle.
941 * No locks are obtained or released by this function
945 * Returns != 0 upon successful completion.
949 vos_ServerClose(const void *serverHandle, afs_status_p st)
952 afs_status_t tst = 0;
953 file_server_p f_server = (file_server_p) serverHandle;
955 if (!IsValidServerHandle(f_server, &tst)) {
956 goto fail_vos_ServerClose;
959 rx_ReleaseCachedConnection(f_server->serv);
960 f_server->is_valid = 0;
964 fail_vos_ServerClose:
973 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
978 * IN cellHandle - a previously opened cellHandle that corresponds
979 * to the cell where the server lives.
981 * IN serverHandle - a handle to the server machine.
983 * IN callBack - a call back function pointer that may be called to report
984 * status information. Can be null.
986 * IN partition - the partition to synchronize. Can be NULL.
988 * IN force - force deletion of bad volumes.
992 * No locks are obtained or released by this function
996 * Returns != 0 upon successful completion.
1000 vos_ServerSync(const void *cellHandle, const void *serverHandle,
1001 vos_MessageCallBack_t callBack, const unsigned int *partition,
1005 afs_status_t tst = 0;
1006 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1007 file_server_p f_server = (file_server_p) serverHandle;
1012 * Validate arguments
1015 if (!IsValidCellHandle(c_handle, &tst)) {
1016 goto fail_vos_ServerSync;
1019 if (!IsValidServerHandle(f_server, &tst)) {
1020 goto fail_vos_ServerSync;
1023 if (partition != NULL) {
1024 if (*partition > VOLMAXPARTS) {
1025 tst = ADMVOSPARTITIONTOOLARGE;
1026 goto fail_vos_ServerSync;
1028 part = (afs_int32) * partition;
1036 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1038 fail_vos_ServerSync:
1047 * vos_FileServerAddressChange - change an existing file server address.
1051 * IN cellHandle - a previously opened cellHandle that corresponds
1052 * to the cell where the address should be changed.
1054 * IN callBack - a call back function pointer that may be called to report
1055 * status information. Can be null.
1057 * IN oldAddress - the old server address in host byte order
1059 * IN newAddress - the new server address in host byte order
1063 * No locks are obtained or released by this function
1067 * Returns != 0 upon successful completion.
1071 vos_FileServerAddressChange(const void *cellHandle,
1072 vos_MessageCallBack_t callBack,
1073 unsigned int oldAddress,
1074 unsigned int newAddress, afs_status_p st)
1077 afs_status_t tst = 0;
1078 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1081 * Validate arguments
1084 if (!IsValidCellHandle(c_handle, &tst)) {
1085 goto fail_vos_FileServerAddressChange;
1089 ubik_VL_ChangeAddr(c_handle->vos, 0, oldAddress, newAddress);
1091 goto fail_vos_FileServerAddressChange;
1095 fail_vos_FileServerAddressChange:
1104 * vos_FileServerAddressRemove - remove an existing file server address.
1108 * IN cellHandle - a previously opened cellHandle that corresponds
1109 * to the cell where the address should be removed.
1111 * IN callBack - a call back function pointer that may be called to report
1112 * status information. Can be null.
1114 * IN serverAddress - the server address to remove in host byte order.
1118 * No locks are obtained or released by this function
1122 * Returns != 0 upon successful completion.
1126 vos_FileServerAddressRemove(const void *cellHandle,
1127 vos_MessageCallBack_t callBack,
1128 unsigned int serverAddress,
1132 afs_status_t tst = 0;
1133 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1134 unsigned int dummyAddress = 0xffffffff;
1137 * Validate arguments
1140 if (!IsValidCellHandle(c_handle, &tst)) {
1141 goto fail_vos_FileServerAddressRemove;
1145 ubik_VL_ChangeAddr(c_handle->vos, 0, dummyAddress,
1148 goto fail_vos_FileServerAddressRemove;
1152 fail_vos_FileServerAddressRemove:
1161 * The iterator functions and data for the server retrieval functions.
1163 * These functions are very similar to the FileServerAddressGet
1164 * functions. The main difference being that instead of returning
1165 * a single address at a time for a server, we fill an array with
1166 * all the addresses of a server.
1169 typedef struct server_get {
1170 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1171 afs_int32 total_addresses; /* total number of addresses */
1172 bulkaddrs addresses; /* the list of addresses */
1173 int address_index; /* current index into address list */
1174 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1175 } server_get_t, *server_get_p;
1178 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1179 int *last_item_contains_data, afs_status_p st)
1182 afs_status_t tst = 0;
1183 server_get_p serv = (server_get_p) rpc_specific;
1184 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1185 afs_int32 base, index;
1188 ListAddrByAttributes m_attrs;
1189 afs_int32 total_multi;
1190 bulkaddrs addr_multi;
1194 * Check to see if this is a multihomed address server
1197 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1198 base = (*addrP >> 16) & 0xff;
1199 index = (*addrP) & 0xffff;
1201 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1202 && (index <= VL_MHSRV_PERBLK)) {
1205 * This is a multihomed server. Make an rpc to retrieve
1206 * all its addresses. Copy the addresses into the cache.
1209 m_attrs.Mask = VLADDR_INDEX;
1210 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1212 addr_multi.bulkaddrs_val = 0;
1213 addr_multi.bulkaddrs_len = 0;
1215 ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
1216 &m_unique, &total_multi, &addr_multi);
1218 goto fail_GetServerRPC;
1222 * Remove any bogus IP addresses which the user may have
1223 * been unable to remove.
1226 RemoveBadAddresses(&total_multi, &addr_multi);
1229 * Copy all the addresses into the cache
1232 for (i = 0; i < total_multi; i++) {
1233 serv->server[slot].serverAddress[i] =
1234 addr_multi.bulkaddrs_val[i];
1237 serv->server[slot].count = total_multi;
1238 serv->address_index++;
1239 free(addr_multi.bulkaddrs_val);
1243 * The next address is just a plain old address
1247 serv->server[slot].serverAddress[0] = *addrP;
1248 serv->server[slot].count = 1;
1249 serv->address_index++;
1253 * See if we've processed all the entries
1257 if (serv->address_index == serv->total_addresses) {
1259 *last_item_contains_data = 1;
1272 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1275 afs_status_t tst = 0;
1276 server_get_p serv = (server_get_p) rpc_specific;
1278 memcpy(dest, (const void *)&serv->server[slot],
1279 sizeof(vos_fileServerEntry_t));
1290 DestroyServer(void *rpc_specific, afs_status_p st)
1293 afs_status_t tst = 0;
1294 server_get_p serv = (server_get_p) rpc_specific;
1296 if (serv->addresses.bulkaddrs_val != NULL) {
1297 free(serv->addresses.bulkaddrs_val);
1308 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1312 * IN cellHandle - a previously opened cellHandle that corresponds
1313 * to the cell where the file servers exist.
1315 * IN callBack - a call back function pointer that may be called to report
1316 * status information. Can be null.
1318 * OUT iterationIdP - upon successful completion, contains an iterator that
1319 * can be passed to vos_FileServerGetNext.
1323 * No locks are obtained or released by this function
1327 * Returns != 0 upon successful completion.
1331 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1332 void **iterationIdP, afs_status_p st)
1335 afs_status_t tst = 0;
1336 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1337 afs_admin_iterator_p iter =
1338 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1339 server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
1340 struct VLCallBack unused;
1344 * Validate arguments
1347 if (!IsValidCellHandle(c_handle, &tst)) {
1348 goto fail_vos_FileServerGetBegin;
1351 if (iterationIdP == NULL) {
1352 goto fail_vos_FileServerGetBegin;
1355 if ((iter == NULL) || (serv == NULL)) {
1357 goto fail_vos_FileServerGetBegin;
1361 * Fill in the serv structure
1364 serv->vldb = c_handle->vos;
1366 ubik_VL_GetAddrs(c_handle->vos, 0, 0, 0, &unused,
1367 &serv->total_addresses, &serv->addresses);
1370 goto fail_vos_FileServerGetBegin;
1374 * Remove any bogus IP addresses which the user may have
1375 * been unable to remove.
1378 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1380 if (serv->total_addresses == 0) {
1381 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1382 goto fail_vos_FileServerGetBegin;
1384 iter->done_iterating = 1;
1385 iter->st = ADMITERATORDONE;
1388 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1389 DestroyServer, &tst)) {
1390 goto fail_vos_FileServerGetBegin;
1393 *iterationIdP = (void *)iter;
1396 fail_vos_FileServerGetBegin:
1403 if (serv->addresses.bulkaddrs_val != NULL) {
1404 free(serv->addresses.bulkaddrs_val);
1417 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1421 * IN iterationId - an iterator previously returned by
1422 * vos_FileServerGetBegin
1424 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1425 * completion contains information about the next server in the cell.
1429 * The iterator is locked while the next server is retrieved.
1433 * Returns != 0 upon successful completion.
1437 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1441 afs_status_t tst = 0;
1442 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1445 tst = ADMITERATORNULL;
1446 goto fail_vos_FileServerGetNext;
1449 if (serverEntryP == NULL) {
1450 tst = ADMVOSSERVERENTRYPNULL;
1451 goto fail_vos_FileServerGetNext;
1454 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1456 fail_vos_FileServerGetNext:
1465 * vos_FileServerGetDone - finish using a partition iterator.
1469 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1473 * The iterator is locked and then destroyed.
1477 * Returns != 0 upon successful completion.
1481 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1484 afs_status_t tst = 0;
1485 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1488 * Validate arguments
1492 tst = ADMITERATORNULL;
1493 goto fail_vos_FileServerGetDone;
1496 rc = IteratorDone(iter, &tst);
1498 fail_vos_FileServerGetDone:
1507 * The iterator functions and data for the transation retrieval functions.
1510 typedef struct transaction_get {
1511 afs_int32 total; /* total number of transactions */
1512 afs_int32 index; /* index to the current transaction */
1513 transDebugInfo *cur; /* the current transaction */
1514 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1515 } transaction_get_t, *transaction_get_p;
1518 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1519 int *last_item_contains_data, afs_status_p st)
1522 afs_status_t tst = 0;
1523 transaction_get_p t = (transaction_get_p) rpc_specific;
1524 int index = t->index;
1527 * Copy the next transaction into the cache
1530 t->tran[slot].transactionId = t->cur[index].tid;
1531 t->tran[slot].lastActiveTime = t->cur[index].time;
1532 t->tran[slot].creationTime = t->cur[index].creationTime;
1533 t->tran[slot].errorCode = t->cur[index].returnCode;
1534 t->tran[slot].volumeId = t->cur[index].volid;
1535 t->tran[slot].partition = t->cur[index].partition;
1536 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1537 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1538 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1539 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1540 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1542 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1544 switch (t->cur[index].iflags) {
1546 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1549 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1552 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1555 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1558 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1562 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1564 switch (t->cur[index].vflags) {
1565 case VTDeleteOnSalvage:
1566 t->tran[slot].volumeActiveStatus =
1567 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1569 case VTOutOfService:
1570 t->tran[slot].volumeActiveStatus =
1571 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1574 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1578 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1580 if (t->cur[index].tflags) {
1581 t->tran[slot].volumeTransactionStatus =
1582 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1588 * See if we've processed all the entries
1592 if (t->index == t->total) {
1594 *last_item_contains_data = 1;
1605 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1609 afs_status_t tst = 0;
1610 transaction_get_p tran = (transaction_get_p) rpc_specific;
1612 memcpy(dest, (const void *)&tran->tran[slot],
1613 sizeof(vos_serverTransactionStatus_p));
1624 DestroyTransaction(void *rpc_specific, afs_status_p st)
1627 afs_status_t tst = 0;
1628 transaction_get_p tran = (transaction_get_p) rpc_specific;
1630 if (tran->cur != NULL) {
1642 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1643 * at a volume server.
1647 * IN cellHandle - a previously opened cellHandle that corresponds
1648 * to the cell where the volume server exists.
1650 * IN serverHandle - a handle to the server to query.
1652 * IN callBack - a call back function pointer that may be called to report
1653 * status information. Can be null.
1655 * OUT iterationIdP - upon successful completion, contains an iterator that
1656 * can be passed to vos_ServerTransactionStatusGetNext.
1660 * No locks are obtained or released by this function
1664 * Returns != 0 upon successful completion.
1668 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1669 const void *serverHandle,
1670 vos_MessageCallBack_t callBack,
1671 void **iterationIdP, afs_status_p st)
1674 afs_status_t tst = 0;
1675 file_server_p f_server = (file_server_p) serverHandle;
1676 afs_admin_iterator_p iter =
1677 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1678 transaction_get_p tran =
1679 (transaction_get_p) calloc(1, sizeof(transaction_get_t));
1683 * Validate arguments
1686 if (!IsValidServerHandle(f_server, &tst)) {
1687 goto fail_vos_ServerTransactionStatusGetBegin;
1690 if (iterationIdP == NULL) {
1691 goto fail_vos_ServerTransactionStatusGetBegin;
1694 if ((iter == NULL) || (tran == NULL)) {
1696 goto fail_vos_ServerTransactionStatusGetBegin;
1700 * Fill in the tran structure
1703 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1704 goto fail_vos_ServerTransactionStatusGetBegin;
1707 if (tran->total == 0) {
1708 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1709 goto fail_vos_ServerTransactionStatusGetBegin;
1711 iter->done_iterating = 1;
1712 iter->st = ADMITERATORDONE;
1715 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1716 NULL, DestroyTransaction, &tst)) {
1717 goto fail_vos_ServerTransactionStatusGetBegin;
1720 *iterationIdP = (void *)iter;
1723 fail_vos_ServerTransactionStatusGetBegin:
1730 if (tran->cur != NULL) {
1744 * vos_ServerTransactionStatusGetNext - get information about the next
1745 * active transaction.
1749 * IN iterationId - an iterator previously returned by
1750 * vos_ServerTransactionStatusGetBegin
1752 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1753 * that upon successful completion contains information about the
1758 * The iterator is locked while the next item is retrieved.
1762 * Returns != 0 upon successful completion.
1766 vos_ServerTransactionStatusGetNext(const void *iterationId,
1767 vos_serverTransactionStatus_p
1768 serverTransactionStatusP, afs_status_p st)
1771 afs_status_t tst = 0;
1772 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1775 tst = ADMITERATORNULL;
1776 goto fail_vos_ServerTransactionStatusGetNext;
1779 if (serverTransactionStatusP == NULL) {
1780 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1781 goto fail_vos_ServerTransactionStatusGetNext;
1784 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1786 fail_vos_ServerTransactionStatusGetNext:
1795 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1799 * IN iterationId - an iterator previously returned by
1800 * vos_ServerTransactionStatusGetBegin
1804 * The iterator is locked and then destroyed.
1808 * Returns != 0 upon successful completion.
1812 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1815 afs_status_t tst = 0;
1816 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1819 * Validate arguments
1823 tst = ADMITERATORNULL;
1824 goto fail_vos_ServerTransactionStatusGetDone;
1827 rc = IteratorDone(iter, &tst);
1829 fail_vos_ServerTransactionStatusGetDone:
1838 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1842 afs_status_t tst = 0;
1845 dest->numServers = source->nServers;
1846 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1847 dest->volumeId[i] = source->volumeId[i];
1849 dest->cloneId = source->cloneId;
1850 dest->status = VOS_VLDB_ENTRY_OK;
1851 if (source->flags & VLOP_ALLOPERS) {
1852 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1854 if (source->flags & VLOP_MOVE) {
1855 dest->status |= VOS_VLDB_ENTRY_MOVE;
1857 if (source->flags & VLOP_RELEASE) {
1858 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1860 if (source->flags & VLOP_BACKUP) {
1861 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1863 if (source->flags & VLOP_DELETE) {
1864 dest->status |= VOS_VLDB_ENTRY_DELETE;
1866 if (source->flags & VLOP_DUMP) {
1867 dest->status |= VOS_VLDB_ENTRY_DUMP;
1870 if (source->flags & VLF_RWEXISTS) {
1871 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1873 if (source->flags & VLF_ROEXISTS) {
1874 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1876 if (source->flags & VLF_BACKEXISTS) {
1877 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1880 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1881 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1882 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1883 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1884 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1885 dest->volumeSites[i].serverFlags = 0;
1887 if (source->serverFlags[i] & NEW_REPSITE) {
1888 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1890 if (source->serverFlags[i] & ITSROVOL) {
1891 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1893 if (source->serverFlags[i] & ITSRWVOL) {
1894 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1896 if (source->serverFlags[i] & ITSBACKVOL) {
1897 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1899 if (source->serverFlags[i] & RO_DONTUSE) {
1900 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1913 * vos_VLDBGet- get a volume's vldb entry.
1917 * IN cellHandle - a previously opened cellHandle that corresponds
1918 * to the cell where the volume entries exist.
1920 * IN callBack - a call back function pointer that may be called to report
1921 * status information. Can be null.
1923 * IN volumeId - the id of the volume to retrieve.
1925 * IN volumeName - the name of the volume to retrieve.
1927 * OUT vldbEntry - upon successful completion, contains the information regarding
1932 * No locks are obtained or released by this function
1936 * Returns != 0 upon successful completion.
1940 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1941 const unsigned int *volumeId, char *volumeName,
1942 vos_vldbEntry_p vldbEntry, afs_status_p st)
1945 afs_status_t tst = 0;
1946 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1947 struct nvldbentry entry;
1951 * Validate arguments
1954 if (!IsValidCellHandle(c_handle, &tst)) {
1955 goto fail_vos_VLDBGet;
1958 if (vldbEntry == NULL) {
1959 tst = ADMVOSVLDBENTRYNULL;
1960 goto fail_vos_VLDBGet;
1963 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1964 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1965 goto fail_vos_VLDBGet;
1969 * Retrieve the entry
1972 if (!((volumeName == NULL) || (*volumeName == 0))) {
1973 if (!ValidateVolumeName(volumeName, &tst)) {
1974 goto fail_vos_VLDBGet;
1976 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1977 goto fail_vos_VLDBGet;
1980 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1981 goto fail_vos_VLDBGet;
1986 * Copy the entry into our structure
1989 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1990 goto fail_vos_VLDBGet;
2003 * The iterator functions and data for the vldb entry retrieval functions.
2006 typedef struct vldb_entry_get {
2007 afs_int32 total; /* total number of vldb entries */
2008 afs_int32 index; /* index to the current vldb entry */
2009 nbulkentries entries; /* the list of entries retrieved */
2010 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2011 } vldb_entry_get_t, *vldb_entry_get_p;
2014 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2015 int *last_item_contains_data, afs_status_p st)
2018 afs_status_t tst = 0;
2019 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2022 * Copy the next entry into the cache
2026 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2028 goto fail_GetVLDBEntryRPC;
2033 * See if we've processed all the entries
2037 if (entry->index == entry->total) {
2039 *last_item_contains_data = 1;
2043 fail_GetVLDBEntryRPC:
2052 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2056 afs_status_t tst = 0;
2057 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2059 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2070 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2073 afs_status_t tst = 0;
2074 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2076 if (entry->entries.nbulkentries_val != NULL) {
2077 free(entry->entries.nbulkentries_val);
2089 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2093 * IN cellHandle - a previously opened cellHandle that corresponds
2094 * to the cell where the volume entries exist.
2096 * IN serverHandle - a handle to the server whose entries should be listed.
2099 * IN callBack - a call back function pointer that may be called to report
2100 * status information. Can be null.
2102 * IN partition - the partition whose entries should be listed.
2105 * OUT iterationIdP - upon successful completion, contains an iterator that
2106 * can be passed to vos_VLDBGetNext.
2110 * No locks are obtained or released by this function
2114 * Returns != 0 upon successful completion.
2118 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2119 vos_MessageCallBack_t callBack, unsigned int *partition,
2120 void **iterationIdP, afs_status_p st)
2123 afs_status_t tst = 0;
2124 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2125 file_server_p f_server = (file_server_p) serverHandle;
2126 afs_admin_iterator_p iter =
2127 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2128 vldb_entry_get_p entry =
2129 (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2130 struct VldbListByAttributes attr;
2133 memset(&attr, 0, sizeof(attr));
2136 * Validate arguments
2139 if (!IsValidCellHandle(c_handle, &tst)) {
2140 goto fail_vos_VLDBGetBegin;
2143 if ((iter == NULL) || (entry == NULL)) {
2145 goto fail_vos_VLDBGetBegin;
2148 if (f_server != NULL) {
2149 if (!IsValidServerHandle(f_server, &tst)) {
2150 goto fail_vos_VLDBGetBegin;
2152 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2153 attr.Mask |= VLLIST_SERVER;
2156 if (partition != NULL) {
2157 if (*partition > VOLMAXPARTS) {
2158 tst = ADMVOSPARTITIONTOOLARGE;
2159 goto fail_vos_VLDBGetBegin;
2161 attr.partition = *partition;
2162 attr.Mask |= VLLIST_PARTITION;
2165 if (!VLDB_ListAttributes
2166 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2167 goto fail_vos_VLDBGetBegin;
2170 if (entry->total <= 0) {
2171 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2172 goto fail_vos_VLDBGetBegin;
2174 iter->done_iterating = 1;
2175 iter->st = ADMITERATORDONE;
2178 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2179 NULL, DestroyVLDBEntry, &tst)) {
2180 goto fail_vos_VLDBGetBegin;
2183 *iterationIdP = (void *)iter;
2186 fail_vos_VLDBGetBegin:
2192 if (entry->entries.nbulkentries_val != NULL) {
2193 free(entry->entries.nbulkentries_val);
2195 if (entry != NULL) {
2207 * vos_VLDBGetNext - get information about the next volume.
2211 * IN iterationId - an iterator previously returned by
2214 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2215 * that upon successful completion contains information about the
2220 * The iterator is locked while the next item is retrieved.
2224 * Returns != 0 upon successful completion.
2228 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2232 afs_status_t tst = 0;
2233 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2236 tst = ADMITERATORNULL;
2237 goto fail_vos_VLDBGetNext;
2240 if (vldbEntry == NULL) {
2241 tst = ADMVOSVLDBENTRYNULL;
2242 goto fail_vos_VLDBGetNext;
2245 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2247 fail_vos_VLDBGetNext:
2256 * vos_VLDBGetDone - finish using a volume iterator.
2260 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2264 * The iterator is locked and then destroyed.
2268 * Returns != 0 upon successful completion.
2272 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2275 afs_status_t tst = 0;
2276 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2279 * Validate arguments
2283 tst = ADMITERATORNULL;
2284 goto fail_vos_VLDBGetDone;
2287 rc = IteratorDone(iter, &tst);
2289 fail_vos_VLDBGetDone:
2298 * vos_VLDBEntryRemove - remove a vldb entry.
2302 * IN cellHandle - a previously opened cellHandle that corresponds
2303 * to the cell where the vldb entry exists.
2305 * IN serverHandle - a previously opened serverHandle that corresponds
2306 * to the server where the vldb entry exists. Can be null.
2308 * IN callBack - a call back function pointer that may be called to report
2309 * status information. Can be null.
2311 * IN partition - the partition where the vldb entry exists. Can be null.
2313 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2317 * No locks are obtained or released by this function
2321 * Returns != 0 upon successful completion.
2325 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2326 vos_MessageCallBack_t callBack,
2327 const unsigned int *partition, unsigned int *volumeId,
2331 afs_status_t tst = 0;
2332 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2333 file_server_p f_server = (file_server_p) serverHandle;
2334 struct VldbListByAttributes attr;
2335 nbulkentries entries;
2339 memset(&attr, 0, sizeof(attr));
2340 memset(&entries, 0, sizeof(entries));
2343 * Validate arguments
2346 if (!IsValidCellHandle(c_handle, &tst)) {
2347 goto fail_vos_VLDBEntryRemove;
2351 * If the volume is specified, just delete it
2354 if (volumeId != NULL) {
2355 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2357 goto fail_vos_VLDBEntryRemove;
2361 if (f_server != NULL) {
2362 if (!IsValidServerHandle(f_server, &tst)) {
2363 goto fail_vos_VLDBEntryRemove;
2365 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2366 attr.Mask |= VLLIST_SERVER;
2369 if (partition != NULL) {
2370 if (*partition > VOLMAXPARTS) {
2371 tst = ADMVOSPARTITIONTOOLARGE;
2372 goto fail_vos_VLDBEntryRemove;
2374 attr.partition = *partition;
2375 attr.Mask |= VLLIST_PARTITION;
2378 if ((f_server == NULL) && (partition == NULL)) {
2379 tst = ADMVOSVLDBDELETEALLNULL;
2380 goto fail_vos_VLDBEntryRemove;
2383 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2384 goto fail_vos_VLDBEntryRemove;
2387 if (nentries <= 0) {
2388 tst = ADMVOSVLDBNOENTRIES;
2389 goto fail_vos_VLDBEntryRemove;
2392 for (i = 0; i < nentries; i++) {
2393 ubik_VL_DeleteEntry(c_handle->vos, 0,
2394 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2398 fail_vos_VLDBEntryRemove:
2400 if (entries.nbulkentries_val) {
2401 free(entries.nbulkentries_val);
2411 * vos_VLDBUnlock - unlock vldb entries en masse.
2415 * IN cellHandle - a previously opened cellHandle that corresponds
2416 * to the cell where the vldb entries exist.
2418 * IN serverHandle - a previously opened serverHandle that corresponds
2419 * to the server where the vldb entries exist. Can be null.
2421 * IN callBack - a call back function pointer that may be called to report
2422 * status information. Can be null.
2424 * IN partition - the partition where the vldb entries exist. Can be null.
2428 * No locks are obtained or released by this function
2432 * Returns != 0 upon successful completion.
2436 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2437 vos_MessageCallBack_t callBack, const unsigned int *partition,
2441 afs_status_t tst = 0;
2442 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2443 file_server_p f_server = (file_server_p) serverHandle;
2444 struct VldbListByAttributes attr;
2445 nbulkentries entries;
2449 memset(&attr, 0, sizeof(attr));
2450 memset(&entries, 0, sizeof(entries));
2453 * Validate arguments
2456 if (!IsValidCellHandle(c_handle, &tst)) {
2457 goto fail_vos_VLDBUnlock;
2460 if (f_server != NULL) {
2461 if (!IsValidServerHandle(f_server, &tst)) {
2462 goto fail_vos_VLDBUnlock;
2464 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2465 attr.Mask |= VLLIST_SERVER;
2468 if (partition != NULL) {
2469 if (*partition > VOLMAXPARTS) {
2470 tst = ADMVOSPARTITIONTOOLARGE;
2471 goto fail_vos_VLDBUnlock;
2473 attr.partition = *partition;
2474 attr.Mask |= VLLIST_PARTITION;
2476 attr.flag = VLOP_ALLOPERS;
2477 attr.Mask |= VLLIST_FLAG;
2480 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2481 goto fail_vos_VLDBUnlock;
2484 if (nentries <= 0) {
2485 tst = ADMVOSVLDBNOENTRIES;
2486 goto fail_vos_VLDBUnlock;
2489 for (i = 0; i < nentries; i++) {
2490 vos_VLDBEntryUnlock(cellHandle, 0,
2491 entries.nbulkentries_val[i].volumeId[RWVOL],
2496 fail_vos_VLDBUnlock:
2498 if (entries.nbulkentries_val) {
2499 free(entries.nbulkentries_val);
2510 * vos_VLDBEntryLock - lock a vldb entry.
2514 * IN cellHandle - a previously opened cellHandle that corresponds
2515 * to the cell where the vldb entry exists.
2517 * IN callBack - a call back function pointer that may be called to report
2518 * status information. Can be null.
2520 * IN volumeId - the volume id of the vldb entry to be deleted.
2524 * No locks are obtained or released by this function
2528 * Returns != 0 upon successful completion.
2532 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2533 unsigned int volumeId, afs_status_p st)
2536 afs_status_t tst = 0;
2537 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2540 * Validate arguments
2543 if (!IsValidCellHandle(c_handle, &tst)) {
2544 goto fail_vos_VLDBEntryLock;
2547 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2549 goto fail_vos_VLDBEntryLock;
2553 fail_vos_VLDBEntryLock:
2562 * vos_VLDBEntryUnlock - unlock a vldb entry.
2566 * IN cellHandle - a previously opened cellHandle that corresponds
2567 * to the cell where the vldb entry exists.
2569 * IN callBack - a call back function pointer that may be called to report
2570 * status information. Can be null.
2572 * IN volumeId - the volume id of the vldb entry to be unlocked.
2576 * No locks are obtained or released by this function
2580 * Returns != 0 upon successful completion.
2584 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2585 unsigned int volumeId, afs_status_p st)
2588 afs_status_t tst = 0;
2589 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2592 * Validate arguments
2595 if (!IsValidCellHandle(c_handle, &tst)) {
2596 goto fail_vos_VLDBEntryUnlock;
2601 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2602 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2604 goto fail_vos_VLDBEntryUnlock;
2608 fail_vos_VLDBEntryUnlock:
2617 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2621 * IN cellHandle - a previously opened cellHandle that corresponds
2622 * to the cell where the volume exists.
2624 * IN serverHandle - a previously opened serverHandle that corresponds
2625 * to the server where the new volume should be created.
2627 * IN callBack - a call back function pointer that may be called to report
2628 * status information. Can be null.
2630 * IN partition - the partition where then new volume should be created.
2632 * IN volumeId - the volume id of the volume to be replicated.
2636 * No locks are obtained or released by this function
2640 * Returns != 0 upon successful completion.
2644 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2645 vos_MessageCallBack_t callBack,
2646 unsigned int partition, unsigned int volumeId,
2650 afs_status_t tst = 0;
2651 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2652 file_server_p f_server = (file_server_p) serverHandle;
2655 * Validate arguments
2658 if (!IsValidCellHandle(c_handle, &tst)) {
2659 goto fail_vos_VLDBReadOnlySiteCreate;
2662 if (!IsValidServerHandle(f_server, &tst)) {
2663 goto fail_vos_VLDBReadOnlySiteCreate;
2666 if (partition > VOLMAXPARTS) {
2667 tst = ADMVOSPARTITIONTOOLARGE;
2668 goto fail_vos_VLDBReadOnlySiteCreate;
2672 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2674 goto fail_vos_VLDBReadOnlySiteCreate;
2678 fail_vos_VLDBReadOnlySiteCreate:
2687 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2692 * IN cellHandle - a previously opened cellHandle that corresponds
2693 * to the cell where the volume exists.
2695 * IN serverHandle - a previously opened serverHandle that corresponds
2696 * to the server where the volume should be deleted.
2698 * IN callBack - a call back function pointer that may be called to report
2699 * status information. Can be null.
2701 * IN partition - the partition where then volume should be deleted.
2703 * IN volumeId - the volume id of the volume to be deleted.
2707 * No locks are obtained or released by this function
2711 * Returns != 0 upon successful completion.
2715 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2716 vos_MessageCallBack_t callBack,
2717 unsigned int partition, unsigned int volumeId,
2721 afs_status_t tst = 0;
2722 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2723 file_server_p f_server = (file_server_p) serverHandle;
2726 * Validate arguments
2729 if (!IsValidCellHandle(c_handle, &tst)) {
2730 goto fail_vos_VLDBReadOnlySiteDelete;
2733 if (!IsValidServerHandle(f_server, &tst)) {
2734 goto fail_vos_VLDBReadOnlySiteDelete;
2737 if (partition > VOLMAXPARTS) {
2738 tst = ADMVOSPARTITIONTOOLARGE;
2739 goto fail_vos_VLDBReadOnlySiteDelete;
2743 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2745 goto fail_vos_VLDBReadOnlySiteDelete;
2749 fail_vos_VLDBReadOnlySiteDelete:
2758 * vos_VLDBSync - synchronize the vldb with the fileserver.
2762 * IN cellHandle - a previously opened cellHandle that corresponds
2763 * to the cell where the sync should occur.
2765 * IN serverHandle - a previously opened serverHandle that corresponds
2766 * to the server where the sync should occur.
2768 * IN callBack - a call back function pointer that may be called to report
2769 * status information. Can be null.
2771 * IN partition - the partition where the sync should occur. Can be null.
2773 * IN force - force deletion of bad volumes.
2777 * No locks are obtained or released by this function
2781 * Returns != 0 upon successful completion.
2785 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2786 vos_MessageCallBack_t callBack, const unsigned int *partition,
2787 vos_force_t force, afs_status_p st)
2790 afs_status_t tst = 0;
2791 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2792 file_server_p f_server = (file_server_p) serverHandle;
2798 * Validate arguments
2801 if (!IsValidCellHandle(c_handle, &tst)) {
2802 goto fail_vos_VLDBSync;
2805 if (!IsValidServerHandle(f_server, &tst)) {
2806 goto fail_vos_VLDBSync;
2809 if (partition != NULL) {
2810 if (*partition > VOLMAXPARTS) {
2811 tst = ADMVOSPARTITIONTOOLARGE;
2812 goto fail_vos_VLDBSync;
2814 part = (afs_int32) * partition;
2818 if (force == VOS_FORCE) {
2826 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2837 * vos_VolumeCreate - create a new partition.
2841 * IN cellHandle - a previously opened cellHandle that corresponds
2842 * to the cell where the server lives.
2844 * IN serverHandle - a previously open vos server handle that holds
2845 * the partition where the volume should be create.
2847 * IN callBack - a call back function pointer that may be called to report
2848 * status information. Can be null.
2850 * IN partition - the integer that represents the partition that will
2851 * house the new volume.
2853 * IN volumeName - the name of the new volume.
2855 * IN quota - the quota of the new volume.
2857 * OUT volumeId - the volume id of the newly created volume.
2861 * No locks are obtained or released by this function
2865 * Returns != 0 upon successful completion.
2869 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2870 vos_MessageCallBack_t callBack, unsigned int partition,
2871 char *volumeName, unsigned int quota,
2872 unsigned int *volumeId, afs_status_p st)
2875 afs_status_t tst = 0;
2876 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2877 file_server_p f_server = (file_server_p) serverHandle;
2878 vos_partitionEntry_t pinfo;
2879 struct nvldbentry vinfo;
2882 * Validate arguments
2885 if (!IsValidCellHandle(c_handle, &tst)) {
2886 goto fail_vos_VolumeCreate;
2889 if (!IsValidServerHandle(f_server, &tst)) {
2890 goto fail_vos_VolumeCreate;
2893 if (partition > VOLMAXPARTS) {
2894 tst = ADMVOSPARTITIONTOOLARGE;
2895 goto fail_vos_VolumeCreate;
2898 if (!ValidateVolumeName(volumeName, &tst)) {
2899 goto fail_vos_VolumeCreate;
2902 if (volumeId == NULL) {
2903 tst = ADMVOSVOLUMEID;
2904 goto fail_vos_VolumeCreate;
2908 * Check that partition is valid at the server
2911 if (!vos_PartitionGet
2912 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2913 goto fail_vos_VolumeCreate;
2917 * Check that the volume doesn't already exist
2920 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2921 tst = ADMVOSVOLUMENAMEDUP;
2922 goto fail_vos_VolumeCreate;
2926 * Create the new volume
2929 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2930 quota, volumeId, &tst);
2932 fail_vos_VolumeCreate:
2941 * vos_VolumeDelete - remove a volume.
2945 * IN cellHandle - a previously opened cellHandle that corresponds
2946 * to the cell where the volume exists.
2948 * IN serverHandle - a previously opened serverHandle that corresponds
2949 * to the server where the volume exists.
2951 * IN callBack - a call back function pointer that may be called to report
2952 * status information. Can be null.
2954 * IN partition - the partition where the volume exists.
2956 * IN volumeId - the volume id of the volume to be deleted.
2960 * No locks are obtained or released by this function
2964 * Returns != 0 upon successful completion.
2968 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2969 vos_MessageCallBack_t callBack, unsigned int partition,
2970 unsigned int volumeId, afs_status_p st)
2973 afs_status_t tst = 0;
2974 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2975 file_server_p f_server = (file_server_p) serverHandle;
2976 vos_partitionEntry_t pinfo;
2979 * Validate arguments
2982 if (!IsValidCellHandle(c_handle, &tst)) {
2983 goto fail_vos_VolumeDelete;
2986 if (!IsValidServerHandle(f_server, &tst)) {
2987 goto fail_vos_VolumeDelete;
2990 if (partition > VOLMAXPARTS) {
2991 tst = ADMVOSPARTITIONTOOLARGE;
2992 goto fail_vos_VolumeDelete;
2996 * Check that partition is valid at the server
2999 if (!vos_PartitionGet
3000 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
3001 goto fail_vos_VolumeDelete;
3004 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3006 fail_vos_VolumeDelete:
3015 * vos_VolumeRename - rename a volume.
3019 * IN cellHandle - a previously opened cellHandle that corresponds
3020 * to the cell where the volume exists.
3022 * IN serverHandle - a previously opened serverHandle that corresponds
3023 * to the server where the vldb entry exists. Can be null.
3025 * IN callBack - a call back function pointer that may be called to report
3026 * status information. Can be null.
3028 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3030 * IN newVolumeName - the new name.
3034 * No locks are obtained or released by this function
3038 * Returns != 0 upon successful completion.
3042 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3043 unsigned int readWriteVolumeId, char *newVolumeName,
3047 afs_status_t tst = 0;
3048 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3049 struct nvldbentry entry;
3052 * Validate arguments
3055 if (!IsValidCellHandle(c_handle, &tst)) {
3056 goto fail_vos_VolumeRename;
3059 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3060 tst = ADMVOSNEWVOLUMENAMENULL;
3061 goto fail_vos_VolumeRename;
3065 * Retrieve the entry
3068 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3069 goto fail_vos_VolumeRename;
3072 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3074 fail_vos_VolumeRename:
3083 * vos_VolumeDump - dump a volume
3087 * IN cellHandle - a previously opened cellHandle that corresponds
3088 * to the cell where the volume exists.
3090 * IN serverHandle - a previously opened serverHandle that corresponds
3091 * to the server where the volume exists. Can be null.
3093 * IN callBack - a call back function pointer that may be called to report
3094 * status information. Can be null.
3096 * IN volumeId - the volume id of the volume to be dumped.
3098 * IN startTime - files with modification times >= this time will be dumped.
3100 * IN dumpFile - the file to dump the volume to.
3104 * No locks are obtained or released by this function
3108 * Returns != 0 upon successful completion.
3112 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3113 vos_MessageCallBack_t callBack, unsigned int *partition,
3114 unsigned int volumeId, unsigned int startTime,
3115 const char *dumpFile, afs_status_p st)
3118 afs_status_t tst = 0;
3119 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3120 file_server_p f_server = (file_server_p) serverHandle;
3121 afs_int32 server, part, voltype;
3122 struct nvldbentry entry;
3125 * Validate arguments
3128 if (!IsValidCellHandle(c_handle, &tst)) {
3129 goto fail_vos_VolumeDump;
3132 if (serverHandle != NULL) {
3133 if (!IsValidServerHandle(f_server, &tst)) {
3134 goto fail_vos_VolumeDump;
3139 * You must specify both the serverHandle and the partition
3142 if (serverHandle || partition) {
3143 if (!serverHandle || !partition) {
3144 tst = ADMVOSSERVERANDPARTITION;
3145 goto fail_vos_VolumeDump;
3147 if (*partition > VOLMAXPARTS) {
3148 tst = ADMVOSPARTITIONTOOLARGE;
3149 goto fail_vos_VolumeDump;
3151 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3156 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3157 goto fail_vos_VolumeDump;
3161 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3162 tst = ADMVOSDUMPFILENULL;
3163 goto fail_vos_VolumeDump;
3166 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3169 fail_vos_VolumeDump:
3178 * vos_VolumeRestore - restore a volume from a dump
3182 * IN cellHandle - a previously opened cellHandle that corresponds
3183 * to the cell where the volume exists.
3185 * IN serverHandle - a previously opened serverHandle that corresponds
3186 * to the server where the volume exists.
3188 * IN callBack - a call back function pointer that may be called to report
3189 * status information. Can be null.
3191 * IN partition - the partition where the volume exists.
3193 * IN volumeId - the volume id of the volume to be restored.
3195 * IN volumeName - the volume name of the volume to be restored.
3197 * IN dumpFile - the file from which to restore the volume.
3199 * IN dumpType - the type of dump to perform.
3203 * No locks are obtained or released by this function
3207 * Returns != 0 upon successful completion.
3211 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3212 vos_MessageCallBack_t callBack, unsigned int partition,
3213 unsigned int *volumeId, char *volumeName,
3214 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3218 afs_status_t tst = 0;
3219 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3220 file_server_p f_server = (file_server_p) serverHandle;
3221 struct nvldbentry entry;
3222 afs_int32 volid, server;
3225 int restoreflags = 0;
3226 afs_int32 Oserver, Opart, Otype;
3227 struct nvldbentry Oentry;
3231 * Validate arguments
3234 if (!IsValidCellHandle(c_handle, &tst)) {
3235 goto fail_vos_VolumeRestore;
3238 if (serverHandle != NULL) {
3239 if (!IsValidServerHandle(f_server, &tst)) {
3240 goto fail_vos_VolumeRestore;
3245 * Must pass volumeName
3248 if ((volumeName == NULL) || (*volumeName == 0)) {
3249 tst = ADMVOSVOLUMENAMENULL;
3250 goto fail_vos_VolumeRestore;
3253 if (!ValidateVolumeName(volumeName, &tst)) {
3254 goto fail_vos_VolumeRestore;
3258 * If volumeId is passed, it must be a valid volume id
3261 if (volumeId != NULL) {
3262 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3263 goto fail_vos_VolumeRestore;
3270 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3272 if (partition > VOLMAXPARTS) {
3273 tst = ADMVOSPARTITIONTOOLARGE;
3274 goto fail_vos_VolumeRestore;
3278 * Check that dumpFile exists and can be accessed
3281 fd = open(dumpFile, 0);
3282 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3284 tst = ADMVOSDUMPFILEOPENFAIL;
3285 goto fail_vos_VolumeRestore;
3290 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3291 restoreflags = RV_FULLRST;
3292 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3293 restoreflags = RV_FULLRST;
3295 volid = entry.volumeId[RWVOL];
3296 } else if ((entry.volumeId[RWVOL] != 0)
3297 && (entry.volumeId[RWVOL] != volid)) {
3298 volid = entry.volumeId[RWVOL];
3303 volid = entry.volumeId[RWVOL];
3304 } else if ((entry.volumeId[RWVOL] != 0)
3305 && (entry.volumeId[RWVOL] != volid)) {
3306 volid = entry.volumeId[RWVOL];
3310 * If the vldb says the same volume exists somewhere else
3311 * the caller must specify a full restore, not an incremental
3314 if (dumpType == VOS_RESTORE_FULL) {
3315 restoreflags = RV_FULLRST;
3319 * Check to see if the volume exists where the caller said
3322 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3323 goto fail_vos_VolumeRestore;
3325 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3326 goto fail_vos_VolumeRestore;
3330 tst = ADMVOSRESTOREVOLEXIST;
3331 goto fail_vos_VolumeRestore;
3336 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3337 restoreflags, dumpFile, &tst);
3339 fail_vos_VolumeRestore:
3348 * vos_VolumeOnline - bring a volume online.
3352 * IN serverHandle - a previously opened serverHandle that corresponds
3353 * to the server where the volume exists.
3355 * IN callBack - a call back function pointer that may be called to report
3356 * status information. Can be null.
3358 * IN partition - the partition where the volume exists.
3360 * IN volumeId - the volume id of the volume to be brought online.
3364 * No locks are obtained or released by this function
3368 * Returns != 0 upon successful completion.
3372 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3373 unsigned int partition, unsigned int volumeId,
3374 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3378 afs_status_t tst = 0;
3379 file_server_p f_server = (file_server_p) serverHandle;
3383 * Validate arguments
3386 if (!IsValidServerHandle(f_server, &tst)) {
3387 goto fail_vos_VolumeOnline;
3390 if (partition > VOLMAXPARTS) {
3391 tst = ADMVOSPARTITIONIDTOOLARGE;
3392 goto fail_vos_VolumeOnline;
3395 if (volumeStatus == VOS_ONLINE_BUSY) {
3399 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3402 fail_vos_VolumeOnline:
3411 * vos_VolumeOffline - take a volume offline.
3415 * IN serverHandle - a previously opened serverHandle that corresponds
3416 * to the server where the volume exists.
3418 * IN callBack - a call back function pointer that may be called to report
3419 * status information. Can be null.
3421 * IN partition - the partition where the volume exists.
3423 * IN volumeId - the volume id of the volume to be taken offline.
3427 * No locks are obtained or released by this function
3431 * Returns != 0 upon successful completion.
3435 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3436 unsigned int partition, unsigned int volumeId,
3440 afs_status_t tst = 0;
3441 file_server_p f_server = (file_server_p) serverHandle;
3444 * Validate arguments
3447 if (!IsValidServerHandle(f_server, &tst)) {
3448 goto fail_vos_VolumeOffline;
3451 if (partition > VOLMAXPARTS) {
3452 tst = ADMVOSPARTITIONIDTOOLARGE;
3453 goto fail_vos_VolumeOffline;
3456 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3457 VTOutOfService, 0, &tst);
3459 fail_vos_VolumeOffline:
3468 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3472 * IN source - the volintXInfo structure to copy.
3474 * OUT dest - the vos_volumeEntry_t to fill
3478 * No locks are obtained or released by this function
3482 * Returns != 0 upon successful completion.
3486 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3490 afs_status_t tst = 0;
3494 * If the volume is not marked OK, all the other fields are invalid
3495 * We take the extra step of blanking out dest here to prevent the
3496 * user from seeing stale data from a previous call
3499 memset(dest, 0, sizeof(*dest));
3501 switch (source->status) {
3503 dest->status = VOS_OK;
3506 dest->status = VOS_SALVAGE;
3509 dest->status = VOS_NO_VNODE;
3512 dest->status = VOS_NO_VOL;
3515 dest->status = VOS_VOL_EXISTS;
3518 dest->status = VOS_NO_SERVICE;
3521 dest->status = VOS_OFFLINE;
3524 dest->status = VOS_ONLINE;
3527 dest->status = VOS_DISK_FULL;
3530 dest->status = VOS_OVER_QUOTA;
3533 dest->status = VOS_BUSY;
3536 dest->status = VOS_MOVED;
3541 * Check to see if the entry is marked ok before copying all the
3545 if (dest->status == VOS_OK) {
3546 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3547 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3548 dest->id = source->volid;
3549 if (source->type == 0) {
3550 dest->type = VOS_READ_WRITE_VOLUME;
3551 } else if (source->type == 1) {
3552 dest->type = VOS_READ_ONLY_VOLUME;
3553 } else if (source->type == 2) {
3554 dest->type = VOS_BACKUP_VOLUME;
3556 dest->backupId = source->backupID;
3557 dest->readWriteId = source->parentID;
3558 dest->readOnlyId = source->cloneID;
3559 dest->copyCreationDate = source->copyDate;
3560 dest->creationDate = source->creationDate;
3561 dest->lastAccessDate = source->accessDate;
3562 dest->lastUpdateDate = source->updateDate;
3563 dest->lastBackupDate = source->backupDate;
3564 dest->accessesSinceMidnight = source->dayUse;
3565 dest->fileCount = source->filecount;
3566 dest->maxQuota = source->maxquota;
3567 dest->currentSize = source->size;
3568 if (source->inUse == 1) {
3569 dest->volumeDisposition = VOS_ONLINE;
3571 dest->volumeDisposition = VOS_OFFLINE;
3574 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3575 dest->readStats[i] = source->stat_reads[i];
3576 dest->writeStats[i] = source->stat_writes[i];
3579 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3580 dest->fileAuthorWriteSameNetwork[i] =
3581 source->stat_fileSameAuthor[i];
3582 dest->fileAuthorWriteDifferentNetwork[i] =
3583 source->stat_fileDiffAuthor[i];
3584 dest->dirAuthorWriteSameNetwork[i] =
3585 source->stat_dirSameAuthor[i];
3586 dest->dirAuthorWriteDifferentNetwork[i] =
3587 source->stat_dirDiffAuthor[i];
3600 * vos_VolumeGet - get information about a particular volume.
3604 * IN cellHandle - a previously opened cellHandle that corresponds
3605 * to the cell where the volume exists.
3607 * IN serverHandle - a previously opened serverHandle that corresponds
3608 * to the server where the volume exists.
3610 * IN callBack - a call back function pointer that may be called to report
3611 * status information. Can be null.
3613 * IN partition - the partition where the volume exists.
3615 * IN volumeId - the volume id of the volume to be retrieved.
3617 * OUT volumeP - upon successful completion, contains the information about the
3622 * No locks are obtained or released by this function
3626 * Returns != 0 upon successful completion.
3630 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3631 vos_MessageCallBack_t callBack, unsigned int partition,
3632 unsigned int volumeId, vos_volumeEntry_p volumeP,
3636 afs_status_t tst = 0;
3637 file_server_p f_server = (file_server_p) serverHandle;
3638 struct volintXInfo *info = NULL;
3641 * Validate arguments
3644 if (!IsValidServerHandle(f_server, &tst)) {
3645 goto fail_vos_VolumeGet;
3648 if (partition > VOLMAXPARTS) {
3649 tst = ADMVOSPARTITIONIDTOOLARGE;
3650 goto fail_vos_VolumeGet;
3653 if (volumeP == NULL) {
3654 tst = ADMVOSVOLUMEPNULL;
3655 goto fail_vos_VolumeGet;
3659 * Retrieve the information for the volume
3662 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3663 goto fail_vos_VolumeGet;
3667 * Copy the volume info to our structure
3670 if (!copyvolintXInfo(info, volumeP, &tst)) {
3671 goto fail_vos_VolumeGet;
3688 * The iterator functions and data for the volume retrieval functions.
3691 typedef struct volume_get {
3692 struct volintXInfo *vollist;
3693 afs_int32 total; /* total number of volumes at this partition */
3694 afs_int32 index; /* index to the current volume */
3695 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3696 } volume_get_t, *volume_get_p;
3699 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3700 int *last_item_contains_data, afs_status_p st)
3703 afs_status_t tst = 0;
3704 volume_get_p entry = (volume_get_p) rpc_specific;
3707 * Copy the next entry into the cache
3710 if (!copyvolintXInfo
3711 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3712 goto fail_GetVolumeRPC;
3717 * See if we've processed all the entries
3721 if (entry->index == entry->total) {
3723 *last_item_contains_data = 1;
3736 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3739 afs_status_t tst = 0;
3740 volume_get_p entry = (volume_get_p) rpc_specific;
3742 memcpy(dest, (const void *)&entry->entry[slot],
3743 sizeof(vos_volumeEntry_t));
3754 DestroyVolume(void *rpc_specific, afs_status_p st)
3757 afs_status_t tst = 0;
3758 volume_get_p entry = (volume_get_p) rpc_specific;
3760 if (entry->vollist != NULL) {
3761 free(entry->vollist);
3773 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3777 * IN cellHandle - a previously opened cellHandle that corresponds
3778 * to the cell where the volumes exist.
3780 * IN serverHandle - a handle to the server where the volumes exist.
3782 * IN callBack - a call back function pointer that may be called to report
3783 * status information. Can be null.
3785 * IN partition - the partition whose volumes should be listed. Can be null.
3787 * OUT iterationIdP - upon successful completion, contains an iterator that
3788 * can be passed to vos_VolumeGetBegin.
3792 * No locks are obtained or released by this function
3796 * Returns != 0 upon successful completion.
3800 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3801 vos_MessageCallBack_t callBack, unsigned int partition,
3802 void **iterationIdP, afs_status_p st)
3805 afs_status_t tst = 0;
3806 file_server_p f_server = (file_server_p) serverHandle;
3807 afs_admin_iterator_p iter =
3808 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3809 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3812 * Validate arguments
3815 if (!IsValidServerHandle(f_server, &tst)) {
3816 goto fail_vos_VolumeGetBegin;
3819 if (partition > VOLMAXPARTS) {
3820 tst = ADMVOSPARTITIONIDTOOLARGE;
3821 goto fail_vos_VolumeGetBegin;
3824 if ((iter == NULL) || (entry == NULL)) {
3826 goto fail_vos_VolumeGetBegin;
3830 * Get a list of all the volumes contained in the partition at the
3834 if (!UV_XListVolumes
3835 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3837 goto fail_vos_VolumeGetBegin;
3840 if (entry->total == 0) {
3841 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3842 goto fail_vos_VolumeGetBegin;
3844 iter->done_iterating = 1;
3845 iter->st = ADMITERATORDONE;
3848 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3849 DestroyVolume, &tst)) {
3850 goto fail_vos_VolumeGetBegin;
3853 *iterationIdP = (void *)iter;
3856 fail_vos_VolumeGetBegin:
3862 if (entry != NULL) {
3874 * vos_VolumeGetNext - get information about the next volume.
3878 * IN iterationId - an iterator previously returned by
3879 * vos_VolumeGetBegin
3881 * OUT volumeP - a pointer to a vos_volumeEntry_t
3882 * that upon successful completion contains information about the
3887 * The iterator is locked while the next item is retrieved.
3891 * Returns != 0 upon successful completion.
3895 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3899 afs_status_t tst = 0;
3900 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3903 tst = ADMITERATORNULL;
3904 goto fail_vos_VolumeGetNext;
3907 if (volumeP == NULL) {
3908 tst = ADMVOSVOLUMEPNULL;
3909 goto fail_vos_VolumeGetNext;
3912 rc = IteratorNext(iter, (void *)volumeP, &tst);
3914 fail_vos_VolumeGetNext:
3923 * vos_VolumeGetDone - finish using a volume iterator.
3927 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3931 * The iterator is locked and then destroyed.
3935 * Returns != 0 upon successful completion.
3939 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3942 afs_status_t tst = 0;
3943 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3946 * Validate arguments
3950 tst = ADMITERATORNULL;
3951 goto fail_vos_VolumeGetDone;
3954 rc = IteratorDone(iter, &tst);
3956 fail_vos_VolumeGetDone:
3965 * vos_VolumeMove - move a volume from one server to another.
3969 * IN cellHandle - a previously opened cellHandle that corresponds
3970 * to the cell where the volume exists.
3972 * IN callBack - a call back function pointer that may be called to report
3973 * status information. Can be null.
3975 * IN volumeId - the volume id of the volume to be moved.
3977 * IN fromServer - a previously opened serverHandle that corresponds
3978 * to the server where the volume currently resides.
3980 * IN fromPartition - the partition where the volume currently resides.
3982 * IN toServer - a previously opened serverHandle that corresponds
3983 * to the server where the volume will be moved.
3985 * IN toPartition - the partition where the volume will be moved.
3989 * No locks are obtained or released by this function
3993 * Returns != 0 upon successful completion.
3997 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
3998 unsigned int volumeId, const void *fromServer,
3999 unsigned int fromPartition, const void *toServer,
4000 unsigned int toPartition, afs_status_p st)
4003 afs_status_t tst = 0;
4004 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4005 file_server_p from_server = (file_server_p) fromServer;
4006 file_server_p to_server = (file_server_p) toServer;
4007 afs_int32 from_server_addr =
4008 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4009 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4010 afs_int32 from_partition = fromPartition;
4011 afs_int32 to_partition = toPartition;
4014 * Validate arguments
4017 if (!IsValidCellHandle(c_handle, &tst)) {
4018 goto fail_vos_VolumeMove;
4021 if (!IsValidServerHandle(from_server, &tst)) {
4022 goto fail_vos_VolumeMove;
4025 if (!IsValidServerHandle(to_server, &tst)) {
4026 goto fail_vos_VolumeMove;
4029 if (fromPartition > VOLMAXPARTS) {
4030 tst = ADMVOSPARTITIONIDTOOLARGE;
4031 goto fail_vos_VolumeMove;
4034 if (toPartition > VOLMAXPARTS) {
4035 tst = ADMVOSPARTITIONIDTOOLARGE;
4036 goto fail_vos_VolumeMove;
4043 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4044 to_server_addr, to_partition, &tst);
4046 fail_vos_VolumeMove:
4055 * vos_VolumeRelease - release a volume.
4059 * IN cellHandle - a previously opened cellHandle that corresponds
4060 * to the cell where the volume exists.
4062 * IN callBack - a call back function pointer that may be called to report
4063 * status information. Can be null.
4065 * IN volumeId - the volume to be released.
4067 * IN force - force a complete release.
4071 * No locks are obtained or released by this function
4075 * Returns != 0 upon successful completion.
4079 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4080 unsigned int volumeId, vos_force_t force, afs_status_p st)
4083 afs_status_t tst = 0;
4084 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4085 afs_int32 server, part, forc = 0, voltype, volume;
4086 struct nvldbentry entry;
4089 * Validate arguments
4092 if (!IsValidCellHandle(c_handle, &tst)) {
4093 goto fail_vos_VolumeRelease;
4097 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4098 goto fail_vos_VolumeRelease;
4101 if (force == VOS_FORCE) {
4106 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4108 fail_vos_VolumeRelease:
4117 * vos_VolumeZap - forcibly delete a volume.
4121 * IN cellHandle - a previously opened cellHandle that corresponds
4122 * to the cell where the volume exists.
4124 * IN serverHandle - a previously opened serverHandle that corresponds
4125 * to the server where the volume exists.
4127 * IN callBack - a call back function pointer that may be called to report
4128 * status information. Can be null.
4130 * IN partition - the partition where the volume exists.
4132 * IN volumeId - the volume id of the vldb entry to be deleted.
4134 * IN force - force the deletion of bad volumes.
4138 * No locks are obtained or released by this function
4142 * Returns != 0 upon successful completion.
4146 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4147 vos_MessageCallBack_t callBack, unsigned int partition,
4148 unsigned int volumeId, vos_force_t force, afs_status_p st)
4151 afs_status_t tst = 0;
4152 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4153 file_server_p f_server = (file_server_p) serverHandle;
4156 * Verify that the cellHandle is capable of making vos rpc's
4159 if (!IsValidCellHandle(c_handle, &tst)) {
4160 goto fail_vos_VolumeZap;
4163 if (!IsValidServerHandle(f_server, &tst)) {
4164 goto fail_vos_VolumeZap;
4167 if (force == VOS_FORCE) {
4168 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4171 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4184 * vos_PartitionNameToId - translate a string representing a partition
4189 * IN partitionName - a string representing a partition. Must be of
4192 * OUT partitionId - a number containing the partition id upon successful
4197 * No locks are obtained or released by this function
4201 * Returns != 0 upon successful completion.
4205 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4209 afs_status_t tst = 0;
4210 size_t partition_name_len;
4214 * Validate arguments
4217 if (partitionName == NULL) {
4218 tst = ADMVOSPARTITIONNAMENULL;
4219 goto fail_vos_PartitionNameToId;
4222 if (partitionId == NULL) {
4223 tst = ADMVOSPARTITIONIDNULL;
4224 goto fail_vos_PartitionNameToId;
4228 * Check that string begins with /vicep
4231 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4232 tst = ADMVOSPARTITIONNAMEINVALID;
4233 goto fail_vos_PartitionNameToId;
4237 * Check that the string is either one or two characters
4238 * longer than VICE_PREFIX_SIZE
4241 partition_name_len = strlen(partitionName);
4243 if (partition_name_len == VICE_PREFIX_SIZE) {
4244 tst = ADMVOSPARTITIONNAMETOOSHORT;
4245 goto fail_vos_PartitionNameToId;
4248 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4249 tst = ADMVOSPARTITIONNAMETOOLONG;
4250 goto fail_vos_PartitionNameToId;
4254 * Check that all characters past the prefix are lower case
4257 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4258 if (!islower(partitionName[i])) {
4259 tst = ADMVOSPARTITIONNAMENOTLOWER;
4260 goto fail_vos_PartitionNameToId;
4265 * Convert the name to a number
4268 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4269 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4272 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4273 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4276 if (*partitionId > VOLMAXPARTS) {
4277 tst = ADMVOSPARTITIONIDTOOLARGE;
4278 goto fail_vos_PartitionNameToId;
4282 fail_vos_PartitionNameToId:
4291 * vos_PartitionIdToName - translate a number representing a partition
4292 * to a character string.
4296 * IN partitionId - an integer representing the partition.
4298 * OUT partitionName - a string containing the converted partition ID
4299 * upon successful completion.
4303 * No locks are obtained or released by this function
4307 * Returns != 0 upon successful completion.
4311 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4315 afs_status_t tst = 0;
4317 if (partitionId > VOLMAXPARTS) {
4318 tst = ADMVOSPARTITIONIDTOOLARGE;
4319 goto fail_vos_PartitionIdToName;
4322 if (partitionName == NULL) {
4323 tst = ADMVOSPARTITIONNAMENULL;
4324 goto fail_vos_PartitionIdToName;
4327 if (partitionId < 26) {
4328 strcpy(partitionName, VICE_PARTITION_PREFIX);
4329 partitionName[6] = partitionId + 'a';
4330 partitionName[7] = '\0';
4332 strcpy(partitionName, VICE_PARTITION_PREFIX);
4334 partitionName[6] = 'a' + (partitionId / 26);
4335 partitionName[7] = 'a' + (partitionId % 26);
4336 partitionName[8] = '\0';
4340 fail_vos_PartitionIdToName:
4349 * vos_VolumeQuotaChange - change the quota of a volume.
4353 * IN cellHandle - a previously opened cellHandle that corresponds
4354 * to the cell where the volume exists.
4356 * IN serverHandle - a previously opened serverHandle that corresponds
4357 * to the server where the volume exists.
4359 * IN callBack - a call back function pointer that may be called to report
4360 * status information. Can be null.
4362 * IN partition - the partition where the volume exists.
4364 * IN volumeId - the volume id of the volume to be modified.
4366 * IN volumeQuota - the new volume quota.
4370 * No locks are obtained or released by this function
4374 * Returns != 0 upon successful completion.
4378 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4379 vos_MessageCallBack_t callBack, unsigned int partition,
4380 unsigned int volumeId, unsigned int volumeQuota,
4384 afs_status_t tst = 0;
4385 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4386 file_server_p f_server = (file_server_p) serverHandle;
4389 struct volintInfo tstatus;
4390 int active_trans = 0;
4393 * Verify that the cellHandle is capable of making vos rpc's
4396 if (!IsValidCellHandle(c_handle, &tst)) {
4397 goto fail_vos_VolumeQuotaChange;
4400 if (!IsValidServerHandle(f_server, &tst)) {
4401 goto fail_vos_VolumeQuotaChange;
4404 memset((void *)&tstatus, 0, sizeof(tstatus));
4405 tstatus.dayUse = -1;
4406 tstatus.spare2 = -1;
4407 tstatus.maxquota = volumeQuota;
4411 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4413 goto fail_vos_VolumeQuotaChange;
4417 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4419 goto fail_vos_VolumeQuotaChange;
4423 fail_vos_VolumeQuotaChange:
4426 afs_status_t tst2 = 0;
4427 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4448 * vos_VolumeGet2 - get information about a particular volume.
4452 * IN cellHandle - a previously opened cellHandle that corresponds
4453 * to the cell where the volume exists.
4455 * IN serverHandle - a previously opened serverHandle that corresponds
4456 * to the server where the volume exists.
4458 * IN callBack - a call back function pointer that may be called to report
4459 * status information. Can be null.
4461 * IN partition - the partition where the volume exists.
4463 * IN volumeId - the volume id of the volume to be retrieved.
4465 * OUT pinfo - upon successful completion, contains the information about the
4470 * No locks are obtained or released by this function
4474 * Returns != 0 upon successful completion.
4478 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4479 vos_MessageCallBack_t callBack, unsigned int partition,
4480 unsigned int volumeId, volintInfo* pinfo,
4484 afs_status_t tst = 0;
4485 file_server_p f_server = (file_server_p) serverHandle;
4486 volintInfo *pinfo_=0;
4489 * Validate arguments
4492 if (!IsValidServerHandle(f_server, &tst)) {
4493 goto fail_vos_VolumeGet2;
4496 if (partition > VOLMAXPARTS) {
4497 tst = ADMVOSPARTITIONIDTOOLARGE;
4498 goto fail_vos_VolumeGet2;
4501 if (pinfo == NULL) {
4502 tst = ADMVOSVOLUMEPNULL;
4503 goto fail_vos_VolumeGet2;
4507 * Retrieve the information for the volume
4510 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4511 goto fail_vos_VolumeGet2;
4517 fail_vos_VolumeGet2:
4519 if (pinfo_ != NULL) {
4520 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4531 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4535 * IN cellHandle - a previously opened cellHandle that corresponds
4536 * to the cell where the volume exists.
4538 * IN serverHandle - a previously opened serverHandle that corresponds
4539 * to the server where the volume exists.
4541 * IN partition - the partition where the volume exists.
4543 * IN volumeId - the volume id of the volume to be retrieved.
4547 * No locks are obtained or released by this function
4551 * Returns != 0 upon successful completion.
4555 vos_ClearVolUpdateCounter(const void *cellHandle,
4556 const void *serverHandle,
4557 unsigned int partition,
4558 unsigned int volumeId,
4562 afs_status_t tst = 0;
4563 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4564 file_server_p f_server = (file_server_p) serverHandle;
4567 struct volintInfo tstatus;
4568 int active_trans = 0;
4571 * Verify that the cellHandle is capable of making vos rpc's
4574 if (!IsValidCellHandle(c_handle, &tst)) {
4575 goto fail_vos_ClearVolUpdateCounter;
4578 if (!IsValidServerHandle(f_server, &tst)) {
4579 goto fail_vos_ClearVolUpdateCounter;
4582 memset((void *)&tstatus, 0, sizeof(tstatus));
4583 tstatus.maxquota = -1;
4584 tstatus.dayUse = -1;
4585 tstatus.creationDate = -1;
4586 tstatus.updateDate = -1;
4588 tstatus.spare0 = -1;
4589 tstatus.spare1 = -1;
4591 tstatus.spare3 = -1;
4594 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4596 goto fail_vos_ClearVolUpdateCounter;
4600 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4602 goto fail_vos_ClearVolUpdateCounter;
4606 fail_vos_ClearVolUpdateCounter:
4609 afs_status_t tst2 = 0;
4610 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);