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>
23 #include <sys/types.h>
24 #include <sys/socket.h>
26 #include <netinet/in.h>
27 #include <arpa/inet.h>
30 #include "afs_vosAdmin.h"
31 #include "../adminutil/afs_AdminInternal.h"
32 #include <afs/vlserver.h>
33 #include <afs/volser.h>
34 #include <afs/volint.h>
36 /* File descriptors are HANDLE's on NT. The following typedef helps catch
37 * type errors. Duplicated from vol/ihandle.h
44 #define INVALID_FD ((FD_t)-1)
46 #include <afs/partition.h>
48 #include <rx/rxstat.h>
49 #include <afs/afs_utilAdmin.h>
52 #include "lockprocs.h"
54 typedef struct file_server {
57 struct rx_connection *serv;
59 } file_server_t, *file_server_p;
62 * IsValidServerHandle - test a server handle for validity.
66 * IN serverHandle - the serverHandle to be validated.
70 * No locks are obtained or released by this function
74 * Returns != 0 upon successful completion.
78 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
83 if (serverHandle == NULL) {
84 tst = ADMVOSSERVERHANDLENULL;
85 goto fail_IsValidServerHandle;
88 if (serverHandle->is_valid != 1) {
89 tst = ADMVOSSERVERHANDLEINVALID;
90 goto fail_IsValidServerHandle;
93 if ((serverHandle->begin_magic != BEGIN_MAGIC)
94 || (serverHandle->end_magic != END_MAGIC)) {
95 tst = ADMVOSSERVERHANDLEBADMAGIC;
96 goto fail_IsValidServerHandle;
100 fail_IsValidServerHandle:
110 * IsValidCellHandle - verify that a cell handle can be used to make vos
115 * IN cellHandle - the cellHandle to be validated.
119 * No locks are obtained or released by this function
123 * Returns != 0 upon successful completion.
127 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
130 afs_status_t tst = 0;
132 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
133 goto fail_IsValidCellHandle;
136 if (cellHandle->vos_valid == 0) {
137 tst = ADMVOSCELLHANDLEINVALIDVOS;
138 goto fail_IsValidCellHandle;
142 fail_IsValidCellHandle:
150 /* set <server> and <part> to the correct values depending on
151 * <voltype> and <entry> */
153 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
154 afs_int32 * part, int *previdx)
156 int i, istart, vtype;
161 /* Doesn't check for non-existance of backup volume */
162 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
164 istart = 0; /* seach the entire entry */
167 /* Seach from beginning of entry or pick up where we left off */
168 istart = ((*previdx < 0) ? 0 : *previdx + 1);
171 for (i = istart; i < entry->nServers; i++) {
172 if (entry->serverFlags[i] & vtype) {
173 *server = entry->serverNumber[i];
174 *part = entry->serverPartition[i];
180 /* Didn't find any, return -1 */
186 * vos_BackupVolumeCreate - create a backup volume for a volume.
190 * IN cellHandle - a previously opened cellHandle that corresponds
191 * to the cell where volume exists.
193 * IN callBack - a call back function pointer that may be called to report
194 * status information. Can be null.
196 * IN volumeId - the volume to create the back up for.
200 * No locks are obtained or released by this function
204 * Returns != 0 upon successful completion.
208 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
209 unsigned int volumeId, afs_status_p st)
212 afs_status_t tst = 0;
213 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
214 struct nvldbentry rw_vol_entry;
216 afs_int32 rw_partition;
217 afs_int32 rw_vol_type;
218 struct nvldbentry bk_vol_entry;
220 afs_int32 bk_partition;
221 afs_int32 bk_vol_type;
228 if (!IsValidCellHandle(c_handle, &tst)) {
229 goto fail_vos_BackupVolumeCreate;
233 * Get the volume information and verify that we've been passed
234 * a read write volume id
238 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
239 &rw_vol_type, &tst)) {
240 goto fail_vos_BackupVolumeCreate;
243 if (rw_vol_type != RWVOL) {
244 tst = ADMVOSMUSTBERWVOL;
245 goto fail_vos_BackupVolumeCreate;
249 * Check to see that if a backup volume exists, it exists on the
250 * same server as volumeId
253 if (rw_vol_entry.flags & BACK_EXISTS) {
255 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
256 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
257 goto fail_vos_BackupVolumeCreate;
259 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
260 goto fail_vos_BackupVolumeCreate;
263 tst = ADMVOSBACKUPVOLWRONGSERVER;
264 goto fail_vos_BackupVolumeCreate;
269 * Create the new backup volume
272 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
274 fail_vos_BackupVolumeCreate:
283 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
287 * IN cellHandle - a previously opened cellHandle that corresponds
288 * to the cell where the volumes exist.
290 * IN serverHandle - the server where the backups are to be created. Can be
293 * IN callBack - a call back function pointer that may be called to report
294 * status information. Can be null.
296 * IN partition - the partition where the backups are to be created. Can be
299 * IN volumePrefix - all volumes with this prefix will have backup volumes
300 * created. Can be null.
302 * IN excludePrefix - exclude the volumes that match volumePrefix.
306 * No locks are obtained or released by this function
310 * Returns != 0 upon successful completion.
314 vos_BackupVolumeCreateMultiple(const void *cellHandle,
315 const void *serverHandle,
316 vos_MessageCallBack_t callBack,
317 const unsigned int *partition,
318 const char *volumePrefix,
319 vos_exclude_t excludePrefix, afs_status_p st)
322 afs_status_t tst = 0;
323 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
324 file_server_p f_server = (file_server_p) serverHandle;
325 struct VldbListByAttributes attr;
328 size_t prefix_len = 0;
329 nbulkentries arrayEntries;
330 afs_int32 nentries = 0;
331 struct nvldbentry *entry;
333 afs_int32 rw_volid, rw_server, rw_partition;
338 memset((void *)&attr, 0, sizeof(attr));
343 * The only required argument to this function is the cellHandle.
344 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
348 if (!IsValidCellHandle(c_handle, &tst)) {
349 goto fail_vos_BackupVolumeCreateMultiple;
352 if ((excludePrefix == VOS_EXCLUDE)
353 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
354 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
355 goto fail_vos_BackupVolumeCreateMultiple;
358 if (f_server != NULL) {
359 if (!IsValidServerHandle(f_server, &tst)) {
360 goto fail_vos_BackupVolumeCreateMultiple;
362 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
363 attr.Mask |= VLLIST_SERVER;
366 if (partition != NULL) {
367 if (*partition > VOLMAXPARTS) {
368 tst = ADMVOSPARTITIONTOOLARGE;
369 goto fail_vos_BackupVolumeCreateMultiple;
371 attr.partition = *partition;
372 attr.Mask |= VLLIST_PARTITION;
375 if (excludePrefix == VOS_EXCLUDE) {
379 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
381 prefix_len = strlen(volumePrefix);
384 memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
387 * Get a list of all the volumes in the cell
390 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
391 goto fail_vos_BackupVolumeCreateMultiple;
395 * Cycle through the list of volumes and see if we should create a backup
396 * for each individual volume
399 for (i = 0; i < nentries; i++) {
400 entry = &arrayEntries.nbulkentries_val[i];
403 * Skip entries that don't have a RW volume
406 if (!(entry->flags & RW_EXISTS)) {
407 if (callBack != NULL) {
408 const char *messageText;
409 if (util_AdminErrorCodeTranslate
410 (ADMVOSVOLUMENOREADWRITE, 0, &messageText, &tst)) {
411 sprintf(backbuf, "%s %s", messageText, entry->name);
412 (**callBack) (VOS_VERBOSE_MESSAGE, backbuf);
419 * See if we should skip this entry because of the prefix/exclude
420 * combination we've been passed
425 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
429 if (strncmp(entry->name, volumePrefix, prefix_len)) {
435 rw_volid = entry->volumeId[RWVOL];
436 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
438 if ((rw_server == -1) || (rw_partition == -1)) {
439 if (callBack != NULL) {
440 const char *messageText;
441 if (util_AdminErrorCodeTranslate
442 (ADMVOSVLDBBADENTRY, 0, &messageText, &tst)) {
443 sprintf(backbuf, "%s %s", messageText, entry->name);
444 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
451 * Check that the RW volume is on the same server that we were
455 if (serverHandle != NULL) {
456 if (!VLDB_IsSameAddrs
457 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
458 rw_server, &equal, &tst)) {
459 if (callBack != NULL) {
460 const char *messageText;
461 if (util_AdminErrorCodeTranslate
462 (ADMVOSVLDBBADSERVER, 0, &messageText, &tst)) {
463 sprintf(backbuf, "%s %x %d", messageText,
464 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
466 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
472 if (callBack != NULL) {
473 const char *messageText;
474 if (util_AdminErrorCodeTranslate
475 (ADMVOSVLDBDIFFERENTADDR, 0, &messageText, &tst)) {
476 sprintf(backbuf, "%s %s", messageText, entry->name);
477 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
485 * Check that the RW volume is on the same partition we were
489 if (partition != NULL) {
490 if (*partition != rw_partition) {
499 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid,
503 fail_vos_BackupVolumeCreateMultiple:
505 if (arrayEntries.nbulkentries_val) {
506 free(arrayEntries.nbulkentries_val);
516 * vos_PartitionGet - get information about a single partition.
520 * IN cellHandle - a previously opened cellHandle that corresponds
521 * to the cell where the server lives.
523 * IN serverHandle - a previously open vos server handle that holds
524 * the partition of interest.
526 * IN callBack - a call back function pointer that may be called to report
527 * status information. Can be null.
529 * IN partition - the integer that represents the partition of interest.
531 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
532 * completion contains information regarding the partition.
536 * No locks are obtained or released by this function
540 * Returns != 0 upon successful completion.
544 vos_PartitionGet(const void *cellHandle, const void *serverHandle,
545 vos_MessageCallBack_t callBack, unsigned int partition,
546 vos_partitionEntry_p partitionP, afs_status_p st)
549 afs_status_t tst = 0;
550 struct diskPartition part_info;
551 file_server_p f_server = (file_server_p) serverHandle;
552 char partitionName[10]; /* this rpc requires a character partition name */
558 if (!IsValidServerHandle(f_server, &tst)) {
559 goto fail_vos_PartitionGet;
562 if (partitionP == NULL) {
563 tst = ADMVOSPARTITIONPNULL;
564 goto fail_vos_PartitionGet;
567 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
568 goto fail_vos_PartitionGet;
571 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
573 goto fail_vos_PartitionGet;
575 strncpy(partitionP->name, part_info.name, VOS_MAX_PARTITION_NAME_LEN);
576 partitionP->name[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
577 strncpy(partitionP->deviceName, part_info.devName, VOS_MAX_PARTITION_NAME_LEN);
578 partitionP->deviceName[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
579 partitionP->lockFileDescriptor = part_info.lock_fd;
580 partitionP->totalSpace = part_info.minFree;
581 partitionP->totalFreeSpace = part_info.free;
584 fail_vos_PartitionGet:
593 * The iterator functions and data for the partition retrieval functions.
596 typedef struct partition_get {
597 afs_int32 total_received; /* the total number of valid partiions retrieved */
598 int number_processed; /* the number of valid paritions we've handed out */
599 int index; /* the current index into the part_list array */
600 struct partList part_list; /* the list of partitions */
601 vos_partitionEntry_t partition[CACHED_ITEMS]; /* the cache of partitions */
602 const void *server; /* the server where the parititions exist */
603 } partition_get_t, *partition_get_p;
606 GetPartitionInfoRPC(void *rpc_specific, int slot, int *last_item,
607 int *last_item_contains_data, afs_status_p st)
610 afs_status_t tst = 0;
611 partition_get_p part = (partition_get_p) rpc_specific;
612 vos_partitionEntry_p ptr = (vos_partitionEntry_p) & part->partition[slot];
615 * Skip partition entries that are not valid
618 while (!(part->part_list.partFlags[part->index] & PARTVALID)) {
623 * Get information for the next partition
626 if (!vos_PartitionGet
628 (unsigned int)part->part_list.partId[part->index], ptr, &tst)) {
629 goto fail_GetPartitionInfoRPC;
633 part->number_processed++;
635 if (part->number_processed == part->total_received) {
637 *last_item_contains_data = 1;
641 fail_GetPartitionInfoRPC:
650 GetPartitionInfoFromCache(void *rpc_specific, int slot, void *dest,
654 afs_status_t tst = 0;
655 partition_get_p part = (partition_get_p) rpc_specific;
657 memcpy(dest, (const void *)&part->partition[slot],
658 sizeof(vos_partitionEntry_t));
668 * vos_PartitionGetBegin - begin to iterate over the partitions at a
673 * IN cellHandle - a previously opened cellHandle that corresponds
674 * to the cell where the server exists.
676 * IN serverHandle - the server that houses the partitions of interest.
678 * IN callBack - a call back function pointer that may be called to report
679 * status information. Can be null.
681 * OUT iterationIdP - upon successful completion, contains an iterator that can
682 * be passed to vos_PartitionGetNext.
686 * No locks are obtained or released by this function
690 * Returns != 0 upon successful completion.
694 vos_PartitionGetBegin(const void *cellHandle, const void *serverHandle,
695 vos_MessageCallBack_t callBack, void **iterationIdP,
699 afs_status_t tst = 0;
700 file_server_p f_server = (file_server_p) serverHandle;
701 afs_admin_iterator_p iter =
702 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
703 partition_get_p part =
704 (partition_get_p) calloc(1, sizeof(partition_get_t));
710 if (!IsValidServerHandle(f_server, &tst)) {
711 goto fail_vos_PartitionGetBegin;
714 if (iterationIdP == NULL) {
715 goto fail_vos_PartitionGetBegin;
718 if ((iter == NULL) || (part == NULL)) {
720 goto fail_vos_PartitionGetBegin;
724 * Fill in the part structure
727 part->server = serverHandle;
728 if (!UV_ListPartitions
729 (f_server->serv, &part->part_list, &part->total_received, &tst)) {
730 goto fail_vos_PartitionGetBegin;
734 * If we didn't receive any partitions, don't spawn a background thread.
735 * Mark the iterator complete.
738 if (part->total_received == 0) {
739 if (!IteratorInit(iter, (void *)part, NULL, NULL, NULL, NULL, &tst)) {
740 goto fail_vos_PartitionGetBegin;
742 iter->done_iterating = 1;
743 iter->st = ADMITERATORDONE;
746 (iter, (void *)part, GetPartitionInfoRPC,
747 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
748 goto fail_vos_PartitionGetBegin;
751 *iterationIdP = (void *)iter;
754 fail_vos_PartitionGetBegin:
772 * vos_PartitionGetNext - get the next partition at a server.
776 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
778 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
779 * completion contains the next partition.
783 * The iterator is locked while the next parition is retrieved.
787 * Returns != 0 upon successful completion.
791 vos_PartitionGetNext(const void *iterationId, vos_partitionEntry_p partitionP,
795 afs_status_t tst = 0;
796 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
799 tst = ADMITERATORNULL;
800 goto fail_vos_PartitionGetNext;
803 if (partitionP == NULL) {
804 tst = ADMVOSPARTITIONPNULL;
805 goto fail_vos_PartitionGetNext;
808 rc = IteratorNext(iter, (void *)partitionP, &tst);
810 fail_vos_PartitionGetNext:
819 * vos_PartitionGetDone - finish using a partition iterator.
823 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
827 * The iterator is locked and then destroyed.
831 * Returns != 0 upon successful completion.
835 vos_PartitionGetDone(const void *iterationId, afs_status_p st)
838 afs_status_t tst = 0;
839 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
846 tst = ADMITERATORNULL;
847 goto fail_vos_PartitionGetDone;
850 rc = IteratorDone(iter, &tst);
852 fail_vos_PartitionGetDone:
861 * vos_ServerOpen - open a handle to an individual server for future
866 * IN cellHandle - a previously opened cellHandle that corresponds
867 * to the cell where the server lives.
869 * IN serverName - the machine name of the server
871 * OUT serverHandleP - a void pointer that upon successful completion
872 * contains a handle that is used in future operations upon the server.
876 * No locks are obtained or released by this function
880 * Returns != 0 upon successful completion.
884 vos_ServerOpen(const void *cellHandle, const char *serverName,
885 void **serverHandleP, afs_status_p st)
888 afs_status_t tst = 0;
889 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
890 file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
892 struct rx_securityClass *sc[3];
895 if (f_server == NULL) {
897 goto fail_vos_ServerOpen;
904 if (!IsValidCellHandle(c_handle, &tst)) {
905 goto fail_vos_ServerOpen;
908 if (!c_handle->tokens->afs_token_set) {
909 tst = ADMVOSCELLHANDLENOAFSTOKENS;
910 goto fail_vos_ServerOpen;
913 if (!util_AdminServerAddressGetFromName
914 (serverName, &server_address, &tst)) {
915 goto fail_vos_ServerOpen;
918 scIndex = c_handle->tokens->sc_index;
919 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
921 rx_GetCachedConnection(htonl(server_address),
922 htons(AFSCONF_VOLUMEPORT), VOLSERVICE_ID,
923 sc[scIndex], scIndex);
924 if (f_server->serv != NULL) {
925 f_server->begin_magic = BEGIN_MAGIC;
926 f_server->end_magic = END_MAGIC;
927 f_server->is_valid = 1;
928 *serverHandleP = (void *)f_server;
931 tst = ADMVOSSERVERNOCONNECTION;
932 goto fail_vos_ServerOpen;
944 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
948 * IN serverHandle - an existing server handle.
952 * No locks are obtained or released by this function
956 * Returns != 0 upon successful completion.
960 vos_ServerClose(const void *serverHandle, afs_status_p st)
963 afs_status_t tst = 0;
964 file_server_p f_server = (file_server_p) serverHandle;
966 if (!IsValidServerHandle(f_server, &tst)) {
967 goto fail_vos_ServerClose;
970 rx_ReleaseCachedConnection(f_server->serv);
971 f_server->is_valid = 0;
975 fail_vos_ServerClose:
984 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
989 * IN cellHandle - a previously opened cellHandle that corresponds
990 * to the cell where the server lives.
992 * IN serverHandle - a handle to the server machine.
994 * IN callBack - a call back function pointer that may be called to report
995 * status information. Can be null.
997 * IN partition - the partition to synchronize. Can be NULL.
999 * IN force - force deletion of bad volumes.
1003 * No locks are obtained or released by this function
1007 * Returns != 0 upon successful completion.
1011 vos_ServerSync(const void *cellHandle, const void *serverHandle,
1012 vos_MessageCallBack_t callBack, const unsigned int *partition,
1016 afs_status_t tst = 0;
1017 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1018 file_server_p f_server = (file_server_p) serverHandle;
1023 * Validate arguments
1026 if (!IsValidCellHandle(c_handle, &tst)) {
1027 goto fail_vos_ServerSync;
1030 if (!IsValidServerHandle(f_server, &tst)) {
1031 goto fail_vos_ServerSync;
1034 if (partition != NULL) {
1035 if (*partition > VOLMAXPARTS) {
1036 tst = ADMVOSPARTITIONTOOLARGE;
1037 goto fail_vos_ServerSync;
1039 part = (afs_int32) * partition;
1047 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1049 fail_vos_ServerSync:
1058 * vos_FileServerAddressChange - change an existing file server address.
1062 * IN cellHandle - a previously opened cellHandle that corresponds
1063 * to the cell where the address should be changed.
1065 * IN callBack - a call back function pointer that may be called to report
1066 * status information. Can be null.
1068 * IN oldAddress - the old server address in host byte order
1070 * IN newAddress - the new server address in host byte order
1074 * No locks are obtained or released by this function
1078 * Returns != 0 upon successful completion.
1082 vos_FileServerAddressChange(const void *cellHandle,
1083 vos_MessageCallBack_t callBack,
1084 unsigned int oldAddress,
1085 unsigned int newAddress, afs_status_p st)
1088 afs_status_t tst = 0;
1089 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1092 * Validate arguments
1095 if (!IsValidCellHandle(c_handle, &tst)) {
1096 goto fail_vos_FileServerAddressChange;
1100 ubik_VL_ChangeAddr(c_handle->vos, 0, oldAddress, newAddress);
1102 goto fail_vos_FileServerAddressChange;
1106 fail_vos_FileServerAddressChange:
1115 * vos_FileServerAddressRemove - remove an existing file server address.
1119 * IN cellHandle - a previously opened cellHandle that corresponds
1120 * to the cell where the address should be removed.
1122 * IN callBack - a call back function pointer that may be called to report
1123 * status information. Can be null.
1125 * IN serverAddress - the server address to remove in host byte order.
1129 * No locks are obtained or released by this function
1133 * Returns != 0 upon successful completion.
1137 vos_FileServerAddressRemove(const void *cellHandle,
1138 vos_MessageCallBack_t callBack,
1139 unsigned int serverAddress,
1143 afs_status_t tst = 0;
1144 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1145 unsigned int dummyAddress = 0xffffffff;
1148 * Validate arguments
1151 if (!IsValidCellHandle(c_handle, &tst)) {
1152 goto fail_vos_FileServerAddressRemove;
1156 ubik_VL_ChangeAddr(c_handle->vos, 0, dummyAddress,
1159 goto fail_vos_FileServerAddressRemove;
1163 fail_vos_FileServerAddressRemove:
1172 * The iterator functions and data for the server retrieval functions.
1174 * These functions are very similar to the FileServerAddressGet
1175 * functions. The main difference being that instead of returning
1176 * a single address at a time for a server, we fill an array with
1177 * all the addresses of a server.
1180 typedef struct server_get {
1181 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1182 afs_int32 total_addresses; /* total number of addresses */
1183 bulkaddrs addresses; /* the list of addresses */
1184 int address_index; /* current index into address list */
1185 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1186 } server_get_t, *server_get_p;
1189 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1190 int *last_item_contains_data, afs_status_p st)
1193 afs_status_t tst = 0;
1194 server_get_p serv = (server_get_p) rpc_specific;
1195 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1196 afs_int32 base, index;
1199 ListAddrByAttributes m_attrs;
1200 afs_int32 total_multi;
1201 bulkaddrs addr_multi;
1205 * Check to see if this is a multihomed address server
1208 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1209 base = (*addrP >> 16) & 0xff;
1210 index = (*addrP) & 0xffff;
1212 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1213 && (index <= VL_MHSRV_PERBLK)) {
1216 * This is a multihomed server. Make an rpc to retrieve
1217 * all its addresses. Copy the addresses into the cache.
1220 m_attrs.Mask = VLADDR_INDEX;
1221 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1223 addr_multi.bulkaddrs_val = 0;
1224 addr_multi.bulkaddrs_len = 0;
1226 ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
1227 &m_unique, &total_multi, &addr_multi);
1229 goto fail_GetServerRPC;
1233 * Remove any bogus IP addresses which the user may have
1234 * been unable to remove.
1237 RemoveBadAddresses(&total_multi, &addr_multi);
1240 * Copy all the addresses into the cache
1243 for (i = 0; i < total_multi; i++) {
1244 serv->server[slot].serverAddress[i] =
1245 addr_multi.bulkaddrs_val[i];
1248 serv->server[slot].count = total_multi;
1249 serv->address_index++;
1250 free(addr_multi.bulkaddrs_val);
1254 * The next address is just a plain old address
1258 serv->server[slot].serverAddress[0] = *addrP;
1259 serv->server[slot].count = 1;
1260 serv->address_index++;
1264 * See if we've processed all the entries
1268 if (serv->address_index == serv->total_addresses) {
1270 *last_item_contains_data = 1;
1283 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1286 afs_status_t tst = 0;
1287 server_get_p serv = (server_get_p) rpc_specific;
1289 memcpy(dest, (const void *)&serv->server[slot],
1290 sizeof(vos_fileServerEntry_t));
1301 DestroyServer(void *rpc_specific, afs_status_p st)
1304 afs_status_t tst = 0;
1305 server_get_p serv = (server_get_p) rpc_specific;
1307 if (serv->addresses.bulkaddrs_val != NULL) {
1308 free(serv->addresses.bulkaddrs_val);
1319 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1323 * IN cellHandle - a previously opened cellHandle that corresponds
1324 * to the cell where the file servers exist.
1326 * IN callBack - a call back function pointer that may be called to report
1327 * status information. Can be null.
1329 * OUT iterationIdP - upon successful completion, contains an iterator that
1330 * can be passed to vos_FileServerGetNext.
1334 * No locks are obtained or released by this function
1338 * Returns != 0 upon successful completion.
1342 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1343 void **iterationIdP, afs_status_p st)
1346 afs_status_t tst = 0;
1347 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1348 afs_admin_iterator_p iter =
1349 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1350 server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
1351 struct VLCallBack unused;
1355 * Validate arguments
1358 if (!IsValidCellHandle(c_handle, &tst)) {
1359 goto fail_vos_FileServerGetBegin;
1362 if (iterationIdP == NULL) {
1363 goto fail_vos_FileServerGetBegin;
1366 if ((iter == NULL) || (serv == NULL)) {
1368 goto fail_vos_FileServerGetBegin;
1372 * Fill in the serv structure
1375 serv->vldb = c_handle->vos;
1377 ubik_VL_GetAddrs(c_handle->vos, 0, 0, 0, &unused,
1378 &serv->total_addresses, &serv->addresses);
1381 goto fail_vos_FileServerGetBegin;
1385 * Remove any bogus IP addresses which the user may have
1386 * been unable to remove.
1389 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1391 if (serv->total_addresses == 0) {
1392 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1393 goto fail_vos_FileServerGetBegin;
1395 iter->done_iterating = 1;
1396 iter->st = ADMITERATORDONE;
1399 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1400 DestroyServer, &tst)) {
1401 goto fail_vos_FileServerGetBegin;
1404 *iterationIdP = (void *)iter;
1407 fail_vos_FileServerGetBegin:
1414 if (serv->addresses.bulkaddrs_val != NULL) {
1415 free(serv->addresses.bulkaddrs_val);
1428 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1432 * IN iterationId - an iterator previously returned by
1433 * vos_FileServerGetBegin
1435 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1436 * completion contains information about the next server in the cell.
1440 * The iterator is locked while the next server is retrieved.
1444 * Returns != 0 upon successful completion.
1448 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1452 afs_status_t tst = 0;
1453 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1456 tst = ADMITERATORNULL;
1457 goto fail_vos_FileServerGetNext;
1460 if (serverEntryP == NULL) {
1461 tst = ADMVOSSERVERENTRYPNULL;
1462 goto fail_vos_FileServerGetNext;
1465 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1467 fail_vos_FileServerGetNext:
1476 * vos_FileServerGetDone - finish using a partition iterator.
1480 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1484 * The iterator is locked and then destroyed.
1488 * Returns != 0 upon successful completion.
1492 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1495 afs_status_t tst = 0;
1496 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1499 * Validate arguments
1503 tst = ADMITERATORNULL;
1504 goto fail_vos_FileServerGetDone;
1507 rc = IteratorDone(iter, &tst);
1509 fail_vos_FileServerGetDone:
1518 * The iterator functions and data for the transation retrieval functions.
1521 typedef struct transaction_get {
1522 afs_int32 total; /* total number of transactions */
1523 afs_int32 index; /* index to the current transaction */
1524 transDebugInfo *cur; /* the current transaction */
1525 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1526 } transaction_get_t, *transaction_get_p;
1529 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1530 int *last_item_contains_data, afs_status_p st)
1533 afs_status_t tst = 0;
1534 transaction_get_p t = (transaction_get_p) rpc_specific;
1535 int index = t->index;
1538 * Copy the next transaction into the cache
1541 t->tran[slot].transactionId = t->cur[index].tid;
1542 t->tran[slot].lastActiveTime = t->cur[index].time;
1543 t->tran[slot].creationTime = t->cur[index].creationTime;
1544 t->tran[slot].errorCode = t->cur[index].returnCode;
1545 t->tran[slot].volumeId = t->cur[index].volid;
1546 t->tran[slot].partition = t->cur[index].partition;
1547 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1548 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1549 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1550 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1551 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1553 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1555 switch (t->cur[index].iflags) {
1557 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1560 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1563 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1566 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1569 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1573 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1575 switch (t->cur[index].vflags) {
1576 case VTDeleteOnSalvage:
1577 t->tran[slot].volumeActiveStatus =
1578 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1580 case VTOutOfService:
1581 t->tran[slot].volumeActiveStatus =
1582 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1585 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1589 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1591 if (t->cur[index].tflags) {
1592 t->tran[slot].volumeTransactionStatus =
1593 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1599 * See if we've processed all the entries
1603 if (t->index == t->total) {
1605 *last_item_contains_data = 1;
1616 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1620 afs_status_t tst = 0;
1621 transaction_get_p tran = (transaction_get_p) rpc_specific;
1623 memcpy(dest, (const void *)&tran->tran[slot],
1624 sizeof(vos_serverTransactionStatus_p));
1635 DestroyTransaction(void *rpc_specific, afs_status_p st)
1638 afs_status_t tst = 0;
1639 transaction_get_p tran = (transaction_get_p) rpc_specific;
1641 if (tran->cur != NULL) {
1653 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1654 * at a volume server.
1658 * IN cellHandle - a previously opened cellHandle that corresponds
1659 * to the cell where the volume server exists.
1661 * IN serverHandle - a handle to the server to query.
1663 * IN callBack - a call back function pointer that may be called to report
1664 * status information. Can be null.
1666 * OUT iterationIdP - upon successful completion, contains an iterator that
1667 * can be passed to vos_ServerTransactionStatusGetNext.
1671 * No locks are obtained or released by this function
1675 * Returns != 0 upon successful completion.
1679 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1680 const void *serverHandle,
1681 vos_MessageCallBack_t callBack,
1682 void **iterationIdP, afs_status_p st)
1685 afs_status_t tst = 0;
1686 file_server_p f_server = (file_server_p) serverHandle;
1687 afs_admin_iterator_p iter =
1688 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1689 transaction_get_p tran =
1690 (transaction_get_p) calloc(1, sizeof(transaction_get_t));
1694 * Validate arguments
1697 if (!IsValidServerHandle(f_server, &tst)) {
1698 goto fail_vos_ServerTransactionStatusGetBegin;
1701 if (iterationIdP == NULL) {
1702 goto fail_vos_ServerTransactionStatusGetBegin;
1705 if ((iter == NULL) || (tran == NULL)) {
1707 goto fail_vos_ServerTransactionStatusGetBegin;
1711 * Fill in the tran structure
1714 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1715 goto fail_vos_ServerTransactionStatusGetBegin;
1718 if (tran->total == 0) {
1719 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1720 goto fail_vos_ServerTransactionStatusGetBegin;
1722 iter->done_iterating = 1;
1723 iter->st = ADMITERATORDONE;
1726 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1727 NULL, DestroyTransaction, &tst)) {
1728 goto fail_vos_ServerTransactionStatusGetBegin;
1731 *iterationIdP = (void *)iter;
1734 fail_vos_ServerTransactionStatusGetBegin:
1741 if (tran->cur != NULL) {
1755 * vos_ServerTransactionStatusGetNext - get information about the next
1756 * active transaction.
1760 * IN iterationId - an iterator previously returned by
1761 * vos_ServerTransactionStatusGetBegin
1763 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1764 * that upon successful completion contains information about the
1769 * The iterator is locked while the next item is retrieved.
1773 * Returns != 0 upon successful completion.
1777 vos_ServerTransactionStatusGetNext(const void *iterationId,
1778 vos_serverTransactionStatus_p
1779 serverTransactionStatusP, afs_status_p st)
1782 afs_status_t tst = 0;
1783 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1786 tst = ADMITERATORNULL;
1787 goto fail_vos_ServerTransactionStatusGetNext;
1790 if (serverTransactionStatusP == NULL) {
1791 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1792 goto fail_vos_ServerTransactionStatusGetNext;
1795 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1797 fail_vos_ServerTransactionStatusGetNext:
1806 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1810 * IN iterationId - an iterator previously returned by
1811 * vos_ServerTransactionStatusGetBegin
1815 * The iterator is locked and then destroyed.
1819 * Returns != 0 upon successful completion.
1823 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1826 afs_status_t tst = 0;
1827 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1830 * Validate arguments
1834 tst = ADMITERATORNULL;
1835 goto fail_vos_ServerTransactionStatusGetDone;
1838 rc = IteratorDone(iter, &tst);
1840 fail_vos_ServerTransactionStatusGetDone:
1849 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1853 afs_status_t tst = 0;
1856 dest->numServers = source->nServers;
1857 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1858 dest->volumeId[i] = source->volumeId[i];
1860 dest->cloneId = source->cloneId;
1861 dest->status = VOS_VLDB_ENTRY_OK;
1862 if (source->flags & VLOP_ALLOPERS) {
1863 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1865 if (source->flags & VLOP_MOVE) {
1866 dest->status |= VOS_VLDB_ENTRY_MOVE;
1868 if (source->flags & VLOP_RELEASE) {
1869 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1871 if (source->flags & VLOP_BACKUP) {
1872 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1874 if (source->flags & VLOP_DELETE) {
1875 dest->status |= VOS_VLDB_ENTRY_DELETE;
1877 if (source->flags & VLOP_DUMP) {
1878 dest->status |= VOS_VLDB_ENTRY_DUMP;
1881 if (source->flags & VLF_RWEXISTS) {
1882 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1884 if (source->flags & VLF_ROEXISTS) {
1885 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1887 if (source->flags & VLF_BACKEXISTS) {
1888 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1891 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1892 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1893 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1894 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1895 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1896 dest->volumeSites[i].serverFlags = 0;
1898 if (source->serverFlags[i] & NEW_REPSITE) {
1899 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1901 if (source->serverFlags[i] & ITSROVOL) {
1902 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1904 if (source->serverFlags[i] & ITSRWVOL) {
1905 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1907 if (source->serverFlags[i] & ITSBACKVOL) {
1908 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1910 if (source->serverFlags[i] & RO_DONTUSE) {
1911 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1924 * vos_VLDBGet- get a volume's vldb entry.
1928 * IN cellHandle - a previously opened cellHandle that corresponds
1929 * to the cell where the volume entries exist.
1931 * IN callBack - a call back function pointer that may be called to report
1932 * status information. Can be null.
1934 * IN volumeId - the id of the volume to retrieve.
1936 * IN volumeName - the name of the volume to retrieve.
1938 * OUT vldbEntry - upon successful completion, contains the information regarding
1943 * No locks are obtained or released by this function
1947 * Returns != 0 upon successful completion.
1951 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1952 const unsigned int *volumeId, char *volumeName,
1953 vos_vldbEntry_p vldbEntry, afs_status_p st)
1956 afs_status_t tst = 0;
1957 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1958 struct nvldbentry entry;
1962 * Validate arguments
1965 if (!IsValidCellHandle(c_handle, &tst)) {
1966 goto fail_vos_VLDBGet;
1969 if (vldbEntry == NULL) {
1970 tst = ADMVOSVLDBENTRYNULL;
1971 goto fail_vos_VLDBGet;
1974 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1975 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1976 goto fail_vos_VLDBGet;
1980 * Retrieve the entry
1983 if (!((volumeName == NULL) || (*volumeName == 0))) {
1984 if (!ValidateVolumeName(volumeName, &tst)) {
1985 goto fail_vos_VLDBGet;
1987 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1988 goto fail_vos_VLDBGet;
1991 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1992 goto fail_vos_VLDBGet;
1997 * Copy the entry into our structure
2000 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
2001 goto fail_vos_VLDBGet;
2014 * The iterator functions and data for the vldb entry retrieval functions.
2017 typedef struct vldb_entry_get {
2018 afs_int32 total; /* total number of vldb entries */
2019 afs_int32 index; /* index to the current vldb entry */
2020 nbulkentries entries; /* the list of entries retrieved */
2021 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2022 } vldb_entry_get_t, *vldb_entry_get_p;
2025 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2026 int *last_item_contains_data, afs_status_p st)
2029 afs_status_t tst = 0;
2030 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2033 * Copy the next entry into the cache
2037 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2039 goto fail_GetVLDBEntryRPC;
2044 * See if we've processed all the entries
2048 if (entry->index == entry->total) {
2050 *last_item_contains_data = 1;
2054 fail_GetVLDBEntryRPC:
2063 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2067 afs_status_t tst = 0;
2068 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2070 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2081 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2084 afs_status_t tst = 0;
2085 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2087 if (entry->entries.nbulkentries_val != NULL) {
2088 free(entry->entries.nbulkentries_val);
2100 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2104 * IN cellHandle - a previously opened cellHandle that corresponds
2105 * to the cell where the volume entries exist.
2107 * IN serverHandle - a handle to the server whose entries should be listed.
2110 * IN callBack - a call back function pointer that may be called to report
2111 * status information. Can be null.
2113 * IN partition - the partition whose entries should be listed.
2116 * OUT iterationIdP - upon successful completion, contains an iterator that
2117 * can be passed to vos_VLDBGetNext.
2121 * No locks are obtained or released by this function
2125 * Returns != 0 upon successful completion.
2129 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2130 vos_MessageCallBack_t callBack, unsigned int *partition,
2131 void **iterationIdP, afs_status_p st)
2134 afs_status_t tst = 0;
2135 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2136 file_server_p f_server = (file_server_p) serverHandle;
2137 afs_admin_iterator_p iter =
2138 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2139 vldb_entry_get_p entry =
2140 (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2141 struct VldbListByAttributes attr;
2144 memset(&attr, 0, sizeof(attr));
2147 * Validate arguments
2150 if (!IsValidCellHandle(c_handle, &tst)) {
2151 goto fail_vos_VLDBGetBegin;
2154 if ((iter == NULL) || (entry == NULL)) {
2156 goto fail_vos_VLDBGetBegin;
2159 if (f_server != NULL) {
2160 if (!IsValidServerHandle(f_server, &tst)) {
2161 goto fail_vos_VLDBGetBegin;
2163 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2164 attr.Mask |= VLLIST_SERVER;
2167 if (partition != NULL) {
2168 if (*partition > VOLMAXPARTS) {
2169 tst = ADMVOSPARTITIONTOOLARGE;
2170 goto fail_vos_VLDBGetBegin;
2172 attr.partition = *partition;
2173 attr.Mask |= VLLIST_PARTITION;
2176 if (!VLDB_ListAttributes
2177 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2178 goto fail_vos_VLDBGetBegin;
2181 if (entry->total <= 0) {
2182 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2183 goto fail_vos_VLDBGetBegin;
2185 iter->done_iterating = 1;
2186 iter->st = ADMITERATORDONE;
2189 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2190 NULL, DestroyVLDBEntry, &tst)) {
2191 goto fail_vos_VLDBGetBegin;
2194 *iterationIdP = (void *)iter;
2197 fail_vos_VLDBGetBegin:
2203 if (entry->entries.nbulkentries_val != NULL) {
2204 free(entry->entries.nbulkentries_val);
2206 if (entry != NULL) {
2218 * vos_VLDBGetNext - get information about the next volume.
2222 * IN iterationId - an iterator previously returned by
2225 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2226 * that upon successful completion contains information about the
2231 * The iterator is locked while the next item is retrieved.
2235 * Returns != 0 upon successful completion.
2239 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2243 afs_status_t tst = 0;
2244 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2247 tst = ADMITERATORNULL;
2248 goto fail_vos_VLDBGetNext;
2251 if (vldbEntry == NULL) {
2252 tst = ADMVOSVLDBENTRYNULL;
2253 goto fail_vos_VLDBGetNext;
2256 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2258 fail_vos_VLDBGetNext:
2267 * vos_VLDBGetDone - finish using a volume iterator.
2271 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2275 * The iterator is locked and then destroyed.
2279 * Returns != 0 upon successful completion.
2283 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2286 afs_status_t tst = 0;
2287 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2290 * Validate arguments
2294 tst = ADMITERATORNULL;
2295 goto fail_vos_VLDBGetDone;
2298 rc = IteratorDone(iter, &tst);
2300 fail_vos_VLDBGetDone:
2309 * vos_VLDBEntryRemove - remove a vldb entry.
2313 * IN cellHandle - a previously opened cellHandle that corresponds
2314 * to the cell where the vldb entry exists.
2316 * IN serverHandle - a previously opened serverHandle that corresponds
2317 * to the server where the vldb entry exists. Can be null.
2319 * IN callBack - a call back function pointer that may be called to report
2320 * status information. Can be null.
2322 * IN partition - the partition where the vldb entry exists. Can be null.
2324 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2328 * No locks are obtained or released by this function
2332 * Returns != 0 upon successful completion.
2336 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2337 vos_MessageCallBack_t callBack,
2338 const unsigned int *partition, unsigned int *volumeId,
2342 afs_status_t tst = 0;
2343 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2344 file_server_p f_server = (file_server_p) serverHandle;
2345 struct VldbListByAttributes attr;
2346 nbulkentries entries;
2350 memset(&attr, 0, sizeof(attr));
2351 memset(&entries, 0, sizeof(entries));
2354 * Validate arguments
2357 if (!IsValidCellHandle(c_handle, &tst)) {
2358 goto fail_vos_VLDBEntryRemove;
2362 * If the volume is specified, just delete it
2365 if (volumeId != NULL) {
2366 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2368 goto fail_vos_VLDBEntryRemove;
2372 if (f_server != NULL) {
2373 if (!IsValidServerHandle(f_server, &tst)) {
2374 goto fail_vos_VLDBEntryRemove;
2376 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2377 attr.Mask |= VLLIST_SERVER;
2380 if (partition != NULL) {
2381 if (*partition > VOLMAXPARTS) {
2382 tst = ADMVOSPARTITIONTOOLARGE;
2383 goto fail_vos_VLDBEntryRemove;
2385 attr.partition = *partition;
2386 attr.Mask |= VLLIST_PARTITION;
2389 if ((f_server == NULL) && (partition == NULL)) {
2390 tst = ADMVOSVLDBDELETEALLNULL;
2391 goto fail_vos_VLDBEntryRemove;
2394 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2395 goto fail_vos_VLDBEntryRemove;
2398 if (nentries <= 0) {
2399 tst = ADMVOSVLDBNOENTRIES;
2400 goto fail_vos_VLDBEntryRemove;
2403 for (i = 0; i < nentries; i++) {
2404 ubik_VL_DeleteEntry(c_handle->vos, 0,
2405 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2409 fail_vos_VLDBEntryRemove:
2411 if (entries.nbulkentries_val) {
2412 free(entries.nbulkentries_val);
2422 * vos_VLDBUnlock - unlock vldb entries en masse.
2426 * IN cellHandle - a previously opened cellHandle that corresponds
2427 * to the cell where the vldb entries exist.
2429 * IN serverHandle - a previously opened serverHandle that corresponds
2430 * to the server where the vldb entries exist. Can be null.
2432 * IN callBack - a call back function pointer that may be called to report
2433 * status information. Can be null.
2435 * IN partition - the partition where the vldb entries exist. Can be null.
2439 * No locks are obtained or released by this function
2443 * Returns != 0 upon successful completion.
2447 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2448 vos_MessageCallBack_t callBack, const unsigned int *partition,
2452 afs_status_t tst = 0;
2453 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2454 file_server_p f_server = (file_server_p) serverHandle;
2455 struct VldbListByAttributes attr;
2456 nbulkentries entries;
2460 memset(&attr, 0, sizeof(attr));
2461 memset(&entries, 0, sizeof(entries));
2464 * Validate arguments
2467 if (!IsValidCellHandle(c_handle, &tst)) {
2468 goto fail_vos_VLDBUnlock;
2471 if (f_server != NULL) {
2472 if (!IsValidServerHandle(f_server, &tst)) {
2473 goto fail_vos_VLDBUnlock;
2475 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2476 attr.Mask |= VLLIST_SERVER;
2479 if (partition != NULL) {
2480 if (*partition > VOLMAXPARTS) {
2481 tst = ADMVOSPARTITIONTOOLARGE;
2482 goto fail_vos_VLDBUnlock;
2484 attr.partition = *partition;
2485 attr.Mask |= VLLIST_PARTITION;
2487 attr.flag = VLOP_ALLOPERS;
2488 attr.Mask |= VLLIST_FLAG;
2491 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2492 goto fail_vos_VLDBUnlock;
2495 if (nentries <= 0) {
2496 tst = ADMVOSVLDBNOENTRIES;
2497 goto fail_vos_VLDBUnlock;
2500 for (i = 0; i < nentries; i++) {
2501 vos_VLDBEntryUnlock(cellHandle, 0,
2502 entries.nbulkentries_val[i].volumeId[RWVOL],
2507 fail_vos_VLDBUnlock:
2509 if (entries.nbulkentries_val) {
2510 free(entries.nbulkentries_val);
2521 * vos_VLDBEntryLock - lock a vldb entry.
2525 * IN cellHandle - a previously opened cellHandle that corresponds
2526 * to the cell where the vldb entry exists.
2528 * IN callBack - a call back function pointer that may be called to report
2529 * status information. Can be null.
2531 * IN volumeId - the volume id of the vldb entry to be deleted.
2535 * No locks are obtained or released by this function
2539 * Returns != 0 upon successful completion.
2543 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2544 unsigned int volumeId, afs_status_p st)
2547 afs_status_t tst = 0;
2548 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2551 * Validate arguments
2554 if (!IsValidCellHandle(c_handle, &tst)) {
2555 goto fail_vos_VLDBEntryLock;
2558 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2560 goto fail_vos_VLDBEntryLock;
2564 fail_vos_VLDBEntryLock:
2573 * vos_VLDBEntryUnlock - unlock a vldb entry.
2577 * IN cellHandle - a previously opened cellHandle that corresponds
2578 * to the cell where the vldb entry exists.
2580 * IN callBack - a call back function pointer that may be called to report
2581 * status information. Can be null.
2583 * IN volumeId - the volume id of the vldb entry to be unlocked.
2587 * No locks are obtained or released by this function
2591 * Returns != 0 upon successful completion.
2595 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2596 unsigned int volumeId, afs_status_p st)
2599 afs_status_t tst = 0;
2600 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2603 * Validate arguments
2606 if (!IsValidCellHandle(c_handle, &tst)) {
2607 goto fail_vos_VLDBEntryUnlock;
2612 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2613 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2615 goto fail_vos_VLDBEntryUnlock;
2619 fail_vos_VLDBEntryUnlock:
2628 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2632 * IN cellHandle - a previously opened cellHandle that corresponds
2633 * to the cell where the volume exists.
2635 * IN serverHandle - a previously opened serverHandle that corresponds
2636 * to the server where the new volume should be created.
2638 * IN callBack - a call back function pointer that may be called to report
2639 * status information. Can be null.
2641 * IN partition - the partition where then new volume should be created.
2643 * IN volumeId - the volume id of the volume to be replicated.
2647 * No locks are obtained or released by this function
2651 * Returns != 0 upon successful completion.
2655 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2656 vos_MessageCallBack_t callBack,
2657 unsigned int partition, unsigned int volumeId,
2661 afs_status_t tst = 0;
2662 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2663 file_server_p f_server = (file_server_p) serverHandle;
2666 * Validate arguments
2669 if (!IsValidCellHandle(c_handle, &tst)) {
2670 goto fail_vos_VLDBReadOnlySiteCreate;
2673 if (!IsValidServerHandle(f_server, &tst)) {
2674 goto fail_vos_VLDBReadOnlySiteCreate;
2677 if (partition > VOLMAXPARTS) {
2678 tst = ADMVOSPARTITIONTOOLARGE;
2679 goto fail_vos_VLDBReadOnlySiteCreate;
2683 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2685 goto fail_vos_VLDBReadOnlySiteCreate;
2689 fail_vos_VLDBReadOnlySiteCreate:
2698 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2703 * IN cellHandle - a previously opened cellHandle that corresponds
2704 * to the cell where the volume exists.
2706 * IN serverHandle - a previously opened serverHandle that corresponds
2707 * to the server where the volume should be deleted.
2709 * IN callBack - a call back function pointer that may be called to report
2710 * status information. Can be null.
2712 * IN partition - the partition where then volume should be deleted.
2714 * IN volumeId - the volume id of the volume to be deleted.
2718 * No locks are obtained or released by this function
2722 * Returns != 0 upon successful completion.
2726 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2727 vos_MessageCallBack_t callBack,
2728 unsigned int partition, unsigned int volumeId,
2732 afs_status_t tst = 0;
2733 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2734 file_server_p f_server = (file_server_p) serverHandle;
2737 * Validate arguments
2740 if (!IsValidCellHandle(c_handle, &tst)) {
2741 goto fail_vos_VLDBReadOnlySiteDelete;
2744 if (!IsValidServerHandle(f_server, &tst)) {
2745 goto fail_vos_VLDBReadOnlySiteDelete;
2748 if (partition > VOLMAXPARTS) {
2749 tst = ADMVOSPARTITIONTOOLARGE;
2750 goto fail_vos_VLDBReadOnlySiteDelete;
2754 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2756 goto fail_vos_VLDBReadOnlySiteDelete;
2760 fail_vos_VLDBReadOnlySiteDelete:
2769 * vos_VLDBSync - synchronize the vldb with the fileserver.
2773 * IN cellHandle - a previously opened cellHandle that corresponds
2774 * to the cell where the sync should occur.
2776 * IN serverHandle - a previously opened serverHandle that corresponds
2777 * to the server where the sync should occur.
2779 * IN callBack - a call back function pointer that may be called to report
2780 * status information. Can be null.
2782 * IN partition - the partition where the sync should occur. Can be null.
2784 * IN force - force deletion of bad volumes.
2788 * No locks are obtained or released by this function
2792 * Returns != 0 upon successful completion.
2796 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2797 vos_MessageCallBack_t callBack, const unsigned int *partition,
2798 vos_force_t force, afs_status_p st)
2801 afs_status_t tst = 0;
2802 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2803 file_server_p f_server = (file_server_p) serverHandle;
2809 * Validate arguments
2812 if (!IsValidCellHandle(c_handle, &tst)) {
2813 goto fail_vos_VLDBSync;
2816 if (!IsValidServerHandle(f_server, &tst)) {
2817 goto fail_vos_VLDBSync;
2820 if (partition != NULL) {
2821 if (*partition > VOLMAXPARTS) {
2822 tst = ADMVOSPARTITIONTOOLARGE;
2823 goto fail_vos_VLDBSync;
2825 part = (afs_int32) * partition;
2829 if (force == VOS_FORCE) {
2837 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2848 * vos_VolumeCreate - create a new partition.
2852 * IN cellHandle - a previously opened cellHandle that corresponds
2853 * to the cell where the server lives.
2855 * IN serverHandle - a previously open vos server handle that holds
2856 * the partition where the volume should be create.
2858 * IN callBack - a call back function pointer that may be called to report
2859 * status information. Can be null.
2861 * IN partition - the integer that represents the partition that will
2862 * house the new volume.
2864 * IN volumeName - the name of the new volume.
2866 * IN quota - the quota of the new volume.
2868 * OUT volumeId - the volume id of the newly created volume.
2872 * No locks are obtained or released by this function
2876 * Returns != 0 upon successful completion.
2880 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2881 vos_MessageCallBack_t callBack, unsigned int partition,
2882 char *volumeName, unsigned int quota,
2883 unsigned int *volumeId, afs_status_p st)
2886 afs_status_t tst = 0;
2887 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2888 file_server_p f_server = (file_server_p) serverHandle;
2889 vos_partitionEntry_t pinfo;
2890 struct nvldbentry vinfo;
2893 * Validate arguments
2896 if (!IsValidCellHandle(c_handle, &tst)) {
2897 goto fail_vos_VolumeCreate;
2900 if (!IsValidServerHandle(f_server, &tst)) {
2901 goto fail_vos_VolumeCreate;
2904 if (partition > VOLMAXPARTS) {
2905 tst = ADMVOSPARTITIONTOOLARGE;
2906 goto fail_vos_VolumeCreate;
2909 if (!ValidateVolumeName(volumeName, &tst)) {
2910 goto fail_vos_VolumeCreate;
2913 if (volumeId == NULL) {
2914 tst = ADMVOSVOLUMEID;
2915 goto fail_vos_VolumeCreate;
2919 * Check that partition is valid at the server
2922 if (!vos_PartitionGet
2923 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2924 goto fail_vos_VolumeCreate;
2928 * Check that the volume doesn't already exist
2931 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2932 tst = ADMVOSVOLUMENAMEDUP;
2933 goto fail_vos_VolumeCreate;
2937 * Create the new volume
2940 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2941 quota, volumeId, &tst);
2943 fail_vos_VolumeCreate:
2952 * vos_VolumeDelete - remove a volume.
2956 * IN cellHandle - a previously opened cellHandle that corresponds
2957 * to the cell where the volume exists.
2959 * IN serverHandle - a previously opened serverHandle that corresponds
2960 * to the server where the volume exists.
2962 * IN callBack - a call back function pointer that may be called to report
2963 * status information. Can be null.
2965 * IN partition - the partition where the volume exists.
2967 * IN volumeId - the volume id of the volume to be deleted.
2971 * No locks are obtained or released by this function
2975 * Returns != 0 upon successful completion.
2979 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2980 vos_MessageCallBack_t callBack, unsigned int partition,
2981 unsigned int volumeId, afs_status_p st)
2984 afs_status_t tst = 0;
2985 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2986 file_server_p f_server = (file_server_p) serverHandle;
2987 vos_partitionEntry_t pinfo;
2990 * Validate arguments
2993 if (!IsValidCellHandle(c_handle, &tst)) {
2994 goto fail_vos_VolumeDelete;
2997 if (!IsValidServerHandle(f_server, &tst)) {
2998 goto fail_vos_VolumeDelete;
3001 if (partition > VOLMAXPARTS) {
3002 tst = ADMVOSPARTITIONTOOLARGE;
3003 goto fail_vos_VolumeDelete;
3007 * Check that partition is valid at the server
3010 if (!vos_PartitionGet
3011 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
3012 goto fail_vos_VolumeDelete;
3015 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3017 fail_vos_VolumeDelete:
3026 * vos_VolumeRename - rename a volume.
3030 * IN cellHandle - a previously opened cellHandle that corresponds
3031 * to the cell where the volume exists.
3033 * IN serverHandle - a previously opened serverHandle that corresponds
3034 * to the server where the vldb entry exists. Can be null.
3036 * IN callBack - a call back function pointer that may be called to report
3037 * status information. Can be null.
3039 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3041 * IN newVolumeName - the new name.
3045 * No locks are obtained or released by this function
3049 * Returns != 0 upon successful completion.
3053 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3054 unsigned int readWriteVolumeId, char *newVolumeName,
3058 afs_status_t tst = 0;
3059 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3060 struct nvldbentry entry;
3063 * Validate arguments
3066 if (!IsValidCellHandle(c_handle, &tst)) {
3067 goto fail_vos_VolumeRename;
3070 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3071 tst = ADMVOSNEWVOLUMENAMENULL;
3072 goto fail_vos_VolumeRename;
3076 * Retrieve the entry
3079 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3080 goto fail_vos_VolumeRename;
3083 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3085 fail_vos_VolumeRename:
3094 * vos_VolumeDump - dump a volume
3098 * IN cellHandle - a previously opened cellHandle that corresponds
3099 * to the cell where the volume exists.
3101 * IN serverHandle - a previously opened serverHandle that corresponds
3102 * to the server where the volume exists. Can be null.
3104 * IN callBack - a call back function pointer that may be called to report
3105 * status information. Can be null.
3107 * IN volumeId - the volume id of the volume to be dumped.
3109 * IN startTime - files with modification times >= this time will be dumped.
3111 * IN dumpFile - the file to dump the volume to.
3115 * No locks are obtained or released by this function
3119 * Returns != 0 upon successful completion.
3123 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3124 vos_MessageCallBack_t callBack, unsigned int *partition,
3125 unsigned int volumeId, unsigned int startTime,
3126 const char *dumpFile, afs_status_p st)
3129 afs_status_t tst = 0;
3130 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3131 file_server_p f_server = (file_server_p) serverHandle;
3132 afs_int32 server, part, voltype;
3133 struct nvldbentry entry;
3136 * Validate arguments
3139 if (!IsValidCellHandle(c_handle, &tst)) {
3140 goto fail_vos_VolumeDump;
3143 if (serverHandle != NULL) {
3144 if (!IsValidServerHandle(f_server, &tst)) {
3145 goto fail_vos_VolumeDump;
3150 * You must specify both the serverHandle and the partition
3153 if (serverHandle || partition) {
3154 if (!serverHandle || !partition) {
3155 tst = ADMVOSSERVERANDPARTITION;
3156 goto fail_vos_VolumeDump;
3158 if (*partition > VOLMAXPARTS) {
3159 tst = ADMVOSPARTITIONTOOLARGE;
3160 goto fail_vos_VolumeDump;
3162 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3167 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3168 goto fail_vos_VolumeDump;
3172 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3173 tst = ADMVOSDUMPFILENULL;
3174 goto fail_vos_VolumeDump;
3177 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3180 fail_vos_VolumeDump:
3189 * vos_VolumeRestore - restore a volume from a dump
3193 * IN cellHandle - a previously opened cellHandle that corresponds
3194 * to the cell where the volume exists.
3196 * IN serverHandle - a previously opened serverHandle that corresponds
3197 * to the server where the volume exists.
3199 * IN callBack - a call back function pointer that may be called to report
3200 * status information. Can be null.
3202 * IN partition - the partition where the volume exists.
3204 * IN volumeId - the volume id of the volume to be restored.
3206 * IN volumeName - the volume name of the volume to be restored.
3208 * IN dumpFile - the file from which to restore the volume.
3210 * IN dumpType - the type of dump to perform.
3214 * No locks are obtained or released by this function
3218 * Returns != 0 upon successful completion.
3222 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3223 vos_MessageCallBack_t callBack, unsigned int partition,
3224 unsigned int *volumeId, char *volumeName,
3225 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3229 afs_status_t tst = 0;
3230 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3231 file_server_p f_server = (file_server_p) serverHandle;
3232 struct nvldbentry entry;
3233 afs_int32 volid, server;
3236 int restoreflags = 0;
3237 afs_int32 Oserver, Opart, Otype;
3238 struct nvldbentry Oentry;
3242 * Validate arguments
3245 if (!IsValidCellHandle(c_handle, &tst)) {
3246 goto fail_vos_VolumeRestore;
3249 if (serverHandle != NULL) {
3250 if (!IsValidServerHandle(f_server, &tst)) {
3251 goto fail_vos_VolumeRestore;
3256 * Must pass volumeName
3259 if ((volumeName == NULL) || (*volumeName == 0)) {
3260 tst = ADMVOSVOLUMENAMENULL;
3261 goto fail_vos_VolumeRestore;
3264 if (!ValidateVolumeName(volumeName, &tst)) {
3265 goto fail_vos_VolumeRestore;
3269 * If volumeId is passed, it must be a valid volume id
3272 if (volumeId != NULL) {
3273 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3274 goto fail_vos_VolumeRestore;
3281 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3283 if (partition > VOLMAXPARTS) {
3284 tst = ADMVOSPARTITIONTOOLARGE;
3285 goto fail_vos_VolumeRestore;
3289 * Check that dumpFile exists and can be accessed
3292 fd = open(dumpFile, 0);
3293 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3295 tst = ADMVOSDUMPFILEOPENFAIL;
3296 goto fail_vos_VolumeRestore;
3301 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3302 restoreflags = RV_FULLRST;
3303 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3304 restoreflags = RV_FULLRST;
3306 volid = entry.volumeId[RWVOL];
3307 } else if ((entry.volumeId[RWVOL] != 0)
3308 && (entry.volumeId[RWVOL] != volid)) {
3309 volid = entry.volumeId[RWVOL];
3314 volid = entry.volumeId[RWVOL];
3315 } else if ((entry.volumeId[RWVOL] != 0)
3316 && (entry.volumeId[RWVOL] != volid)) {
3317 volid = entry.volumeId[RWVOL];
3321 * If the vldb says the same volume exists somewhere else
3322 * the caller must specify a full restore, not an incremental
3325 if (dumpType == VOS_RESTORE_FULL) {
3326 restoreflags = RV_FULLRST;
3330 * Check to see if the volume exists where the caller said
3333 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3334 goto fail_vos_VolumeRestore;
3336 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3337 goto fail_vos_VolumeRestore;
3341 tst = ADMVOSRESTOREVOLEXIST;
3342 goto fail_vos_VolumeRestore;
3347 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3348 restoreflags, dumpFile, &tst);
3350 fail_vos_VolumeRestore:
3359 * vos_VolumeOnline - bring a volume online.
3363 * IN serverHandle - a previously opened serverHandle that corresponds
3364 * to the server where the volume exists.
3366 * IN callBack - a call back function pointer that may be called to report
3367 * status information. Can be null.
3369 * IN partition - the partition where the volume exists.
3371 * IN volumeId - the volume id of the volume to be brought online.
3375 * No locks are obtained or released by this function
3379 * Returns != 0 upon successful completion.
3383 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3384 unsigned int partition, unsigned int volumeId,
3385 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3389 afs_status_t tst = 0;
3390 file_server_p f_server = (file_server_p) serverHandle;
3394 * Validate arguments
3397 if (!IsValidServerHandle(f_server, &tst)) {
3398 goto fail_vos_VolumeOnline;
3401 if (partition > VOLMAXPARTS) {
3402 tst = ADMVOSPARTITIONIDTOOLARGE;
3403 goto fail_vos_VolumeOnline;
3406 if (volumeStatus == VOS_ONLINE_BUSY) {
3410 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3413 fail_vos_VolumeOnline:
3422 * vos_VolumeOffline - take a volume offline.
3426 * IN serverHandle - a previously opened serverHandle that corresponds
3427 * to the server where the volume exists.
3429 * IN callBack - a call back function pointer that may be called to report
3430 * status information. Can be null.
3432 * IN partition - the partition where the volume exists.
3434 * IN volumeId - the volume id of the volume to be taken offline.
3438 * No locks are obtained or released by this function
3442 * Returns != 0 upon successful completion.
3446 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3447 unsigned int partition, unsigned int volumeId,
3451 afs_status_t tst = 0;
3452 file_server_p f_server = (file_server_p) serverHandle;
3455 * Validate arguments
3458 if (!IsValidServerHandle(f_server, &tst)) {
3459 goto fail_vos_VolumeOffline;
3462 if (partition > VOLMAXPARTS) {
3463 tst = ADMVOSPARTITIONIDTOOLARGE;
3464 goto fail_vos_VolumeOffline;
3467 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3468 VTOutOfService, 0, &tst);
3470 fail_vos_VolumeOffline:
3479 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3483 * IN source - the volintXInfo structure to copy.
3485 * OUT dest - the vos_volumeEntry_t to fill
3489 * No locks are obtained or released by this function
3493 * Returns != 0 upon successful completion.
3497 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3501 afs_status_t tst = 0;
3505 * If the volume is not marked OK, all the other fields are invalid
3506 * We take the extra step of blanking out dest here to prevent the
3507 * user from seeing stale data from a previous call
3510 memset(dest, 0, sizeof(dest));
3512 switch (source->status) {
3514 dest->status = VOS_OK;
3517 dest->status = VOS_SALVAGE;
3520 dest->status = VOS_NO_VNODE;
3523 dest->status = VOS_NO_VOL;
3526 dest->status = VOS_VOL_EXISTS;
3529 dest->status = VOS_NO_SERVICE;
3532 dest->status = VOS_OFFLINE;
3535 dest->status = VOS_ONLINE;
3538 dest->status = VOS_DISK_FULL;
3541 dest->status = VOS_OVER_QUOTA;
3544 dest->status = VOS_BUSY;
3547 dest->status = VOS_MOVED;
3552 * Check to see if the entry is marked ok before copying all the
3556 if (dest->status == VOS_OK) {
3557 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3558 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3559 dest->id = source->volid;
3560 if (source->type == 0) {
3561 dest->type = VOS_READ_WRITE_VOLUME;
3562 } else if (source->type == 1) {
3563 dest->type = VOS_READ_ONLY_VOLUME;
3564 } else if (source->type == 2) {
3565 dest->type = VOS_BACKUP_VOLUME;
3567 dest->backupId = source->backupID;
3568 dest->readWriteId = source->parentID;
3569 dest->readOnlyId = source->cloneID;
3570 dest->copyCreationDate = source->copyDate;
3571 dest->creationDate = source->creationDate;
3572 dest->lastAccessDate = source->accessDate;
3573 dest->lastUpdateDate = source->updateDate;
3574 dest->lastBackupDate = source->backupDate;
3575 dest->accessesSinceMidnight = source->dayUse;
3576 dest->fileCount = source->filecount;
3577 dest->maxQuota = source->maxquota;
3578 dest->currentSize = source->size;
3579 if (source->inUse == 1) {
3580 dest->volumeDisposition = VOS_ONLINE;
3582 dest->volumeDisposition = VOS_OFFLINE;
3585 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3586 dest->readStats[i] = source->stat_reads[i];
3587 dest->writeStats[i] = source->stat_writes[i];
3590 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3591 dest->fileAuthorWriteSameNetwork[i] =
3592 source->stat_fileSameAuthor[i];
3593 dest->fileAuthorWriteDifferentNetwork[i] =
3594 source->stat_fileDiffAuthor[i];
3595 dest->dirAuthorWriteSameNetwork[i] =
3596 source->stat_dirSameAuthor[i];
3597 dest->dirAuthorWriteDifferentNetwork[i] =
3598 source->stat_dirDiffAuthor[i];
3611 * vos_VolumeGet - get information about a particular volume.
3615 * IN cellHandle - a previously opened cellHandle that corresponds
3616 * to the cell where the volume exists.
3618 * IN serverHandle - a previously opened serverHandle that corresponds
3619 * to the server where the volume exists.
3621 * IN callBack - a call back function pointer that may be called to report
3622 * status information. Can be null.
3624 * IN partition - the partition where the volume exists.
3626 * IN volumeId - the volume id of the volume to be retrieved.
3628 * OUT volumeP - upon successful completion, contains the information about the
3633 * No locks are obtained or released by this function
3637 * Returns != 0 upon successful completion.
3641 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3642 vos_MessageCallBack_t callBack, unsigned int partition,
3643 unsigned int volumeId, vos_volumeEntry_p volumeP,
3647 afs_status_t tst = 0;
3648 file_server_p f_server = (file_server_p) serverHandle;
3649 struct volintXInfo *info = NULL;
3652 * Validate arguments
3655 if (!IsValidServerHandle(f_server, &tst)) {
3656 goto fail_vos_VolumeGet;
3659 if (partition > VOLMAXPARTS) {
3660 tst = ADMVOSPARTITIONIDTOOLARGE;
3661 goto fail_vos_VolumeGet;
3664 if (volumeP == NULL) {
3665 tst = ADMVOSVOLUMEPNULL;
3666 goto fail_vos_VolumeGet;
3670 * Retrieve the information for the volume
3673 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3674 goto fail_vos_VolumeGet;
3678 * Copy the volume info to our structure
3681 if (!copyvolintXInfo(info, volumeP, &tst)) {
3682 goto fail_vos_VolumeGet;
3699 * The iterator functions and data for the volume retrieval functions.
3702 typedef struct volume_get {
3703 struct volintXInfo *vollist;
3704 afs_int32 total; /* total number of volumes at this partition */
3705 afs_int32 index; /* index to the current volume */
3706 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3707 } volume_get_t, *volume_get_p;
3710 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3711 int *last_item_contains_data, afs_status_p st)
3714 afs_status_t tst = 0;
3715 volume_get_p entry = (volume_get_p) rpc_specific;
3718 * Copy the next entry into the cache
3721 if (!copyvolintXInfo
3722 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3723 goto fail_GetVolumeRPC;
3728 * See if we've processed all the entries
3732 if (entry->index == entry->total) {
3734 *last_item_contains_data = 1;
3747 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3750 afs_status_t tst = 0;
3751 volume_get_p entry = (volume_get_p) rpc_specific;
3753 memcpy(dest, (const void *)&entry->entry[slot],
3754 sizeof(vos_volumeEntry_t));
3765 DestroyVolume(void *rpc_specific, afs_status_p st)
3768 afs_status_t tst = 0;
3769 volume_get_p entry = (volume_get_p) rpc_specific;
3771 if (entry->vollist != NULL) {
3772 free(entry->vollist);
3784 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3788 * IN cellHandle - a previously opened cellHandle that corresponds
3789 * to the cell where the volumes exist.
3791 * IN serverHandle - a handle to the server where the volumes exist.
3793 * IN callBack - a call back function pointer that may be called to report
3794 * status information. Can be null.
3796 * IN partition - the partition whose volumes should be listed. Can be null.
3798 * OUT iterationIdP - upon successful completion, contains an iterator that
3799 * can be passed to vos_VolumeGetBegin.
3803 * No locks are obtained or released by this function
3807 * Returns != 0 upon successful completion.
3811 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3812 vos_MessageCallBack_t callBack, unsigned int partition,
3813 void **iterationIdP, afs_status_p st)
3816 afs_status_t tst = 0;
3817 file_server_p f_server = (file_server_p) serverHandle;
3818 afs_admin_iterator_p iter =
3819 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3820 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3823 * Validate arguments
3826 if (!IsValidServerHandle(f_server, &tst)) {
3827 goto fail_vos_VolumeGetBegin;
3830 if (partition > VOLMAXPARTS) {
3831 tst = ADMVOSPARTITIONIDTOOLARGE;
3832 goto fail_vos_VolumeGetBegin;
3835 if ((iter == NULL) || (entry == NULL)) {
3837 goto fail_vos_VolumeGetBegin;
3841 * Get a list of all the volumes contained in the partition at the
3845 if (!UV_XListVolumes
3846 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3848 goto fail_vos_VolumeGetBegin;
3851 if (entry->total == 0) {
3852 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3853 goto fail_vos_VolumeGetBegin;
3855 iter->done_iterating = 1;
3856 iter->st = ADMITERATORDONE;
3859 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3860 DestroyVolume, &tst)) {
3861 goto fail_vos_VolumeGetBegin;
3864 *iterationIdP = (void *)iter;
3867 fail_vos_VolumeGetBegin:
3873 if (entry != NULL) {
3885 * vos_VolumeGetNext - get information about the next volume.
3889 * IN iterationId - an iterator previously returned by
3890 * vos_VolumeGetBegin
3892 * OUT volumeP - a pointer to a vos_volumeEntry_t
3893 * that upon successful completion contains information about the
3898 * The iterator is locked while the next item is retrieved.
3902 * Returns != 0 upon successful completion.
3906 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3910 afs_status_t tst = 0;
3911 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3914 tst = ADMITERATORNULL;
3915 goto fail_vos_VolumeGetNext;
3918 if (volumeP == NULL) {
3919 tst = ADMVOSVOLUMEPNULL;
3920 goto fail_vos_VolumeGetNext;
3923 rc = IteratorNext(iter, (void *)volumeP, &tst);
3925 fail_vos_VolumeGetNext:
3934 * vos_VolumeGetDone - finish using a volume iterator.
3938 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3942 * The iterator is locked and then destroyed.
3946 * Returns != 0 upon successful completion.
3950 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3953 afs_status_t tst = 0;
3954 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3957 * Validate arguments
3961 tst = ADMITERATORNULL;
3962 goto fail_vos_VolumeGetDone;
3965 rc = IteratorDone(iter, &tst);
3967 fail_vos_VolumeGetDone:
3976 * vos_VolumeMove - move a volume from one server to another.
3980 * IN cellHandle - a previously opened cellHandle that corresponds
3981 * to the cell where the volume exists.
3983 * IN callBack - a call back function pointer that may be called to report
3984 * status information. Can be null.
3986 * IN volumeId - the volume id of the volume to be moved.
3988 * IN fromServer - a previously opened serverHandle that corresponds
3989 * to the server where the volume currently resides.
3991 * IN fromPartition - the partition where the volume currently resides.
3993 * IN toServer - a previously opened serverHandle that corresponds
3994 * to the server where the volume will be moved.
3996 * IN toPartition - the partition where the volume will be moved.
4000 * No locks are obtained or released by this function
4004 * Returns != 0 upon successful completion.
4008 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
4009 unsigned int volumeId, const void *fromServer,
4010 unsigned int fromPartition, const void *toServer,
4011 unsigned int toPartition, afs_status_p st)
4014 afs_status_t tst = 0;
4015 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4016 file_server_p from_server = (file_server_p) fromServer;
4017 file_server_p to_server = (file_server_p) toServer;
4018 afs_int32 from_server_addr =
4019 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4020 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4021 afs_int32 from_partition = fromPartition;
4022 afs_int32 to_partition = toPartition;
4025 * Validate arguments
4028 if (!IsValidCellHandle(c_handle, &tst)) {
4029 goto fail_vos_VolumeMove;
4032 if (!IsValidServerHandle(from_server, &tst)) {
4033 goto fail_vos_VolumeMove;
4036 if (!IsValidServerHandle(to_server, &tst)) {
4037 goto fail_vos_VolumeMove;
4040 if (fromPartition > VOLMAXPARTS) {
4041 tst = ADMVOSPARTITIONIDTOOLARGE;
4042 goto fail_vos_VolumeMove;
4045 if (toPartition > VOLMAXPARTS) {
4046 tst = ADMVOSPARTITIONIDTOOLARGE;
4047 goto fail_vos_VolumeMove;
4054 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4055 to_server_addr, to_partition, &tst);
4057 fail_vos_VolumeMove:
4066 * vos_VolumeRelease - release a volume.
4070 * IN cellHandle - a previously opened cellHandle that corresponds
4071 * to the cell where the volume exists.
4073 * IN callBack - a call back function pointer that may be called to report
4074 * status information. Can be null.
4076 * IN volumeId - the volume to be released.
4078 * IN force - force a complete release.
4082 * No locks are obtained or released by this function
4086 * Returns != 0 upon successful completion.
4090 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4091 unsigned int volumeId, vos_force_t force, afs_status_p st)
4094 afs_status_t tst = 0;
4095 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4096 afs_int32 server, part, forc = 0, voltype, volume;
4097 struct nvldbentry entry;
4100 * Validate arguments
4103 if (!IsValidCellHandle(c_handle, &tst)) {
4104 goto fail_vos_VolumeRelease;
4108 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4109 goto fail_vos_VolumeRelease;
4112 if (force == VOS_FORCE) {
4117 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4119 fail_vos_VolumeRelease:
4128 * vos_VolumeZap - forcibly delete a volume.
4132 * IN cellHandle - a previously opened cellHandle that corresponds
4133 * to the cell where the volume exists.
4135 * IN serverHandle - a previously opened serverHandle that corresponds
4136 * to the server where the volume exists.
4138 * IN callBack - a call back function pointer that may be called to report
4139 * status information. Can be null.
4141 * IN partition - the partition where the volume exists.
4143 * IN volumeId - the volume id of the vldb entry to be deleted.
4145 * IN force - force the deletion of bad volumes.
4149 * No locks are obtained or released by this function
4153 * Returns != 0 upon successful completion.
4157 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4158 vos_MessageCallBack_t callBack, unsigned int partition,
4159 unsigned int volumeId, vos_force_t force, afs_status_p st)
4162 afs_status_t tst = 0;
4163 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4164 file_server_p f_server = (file_server_p) serverHandle;
4167 * Verify that the cellHandle is capable of making vos rpc's
4170 if (!IsValidCellHandle(c_handle, &tst)) {
4171 goto fail_vos_VolumeZap;
4174 if (!IsValidServerHandle(f_server, &tst)) {
4175 goto fail_vos_VolumeZap;
4178 if (force == VOS_FORCE) {
4179 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4182 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4195 * vos_PartitionNameToId - translate a string representing a partition
4200 * IN partitionName - a string representing a partition. Must be of
4203 * OUT partitionId - a number containing the partition id upon successful
4208 * No locks are obtained or released by this function
4212 * Returns != 0 upon successful completion.
4216 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4220 afs_status_t tst = 0;
4221 size_t partition_name_len;
4225 * Validate arguments
4228 if (partitionName == NULL) {
4229 tst = ADMVOSPARTITIONNAMENULL;
4230 goto fail_vos_PartitionNameToId;
4233 if (partitionId == NULL) {
4234 tst = ADMVOSPARTITIONIDNULL;
4235 goto fail_vos_PartitionNameToId;
4239 * Check that string begins with /vicep
4242 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4243 tst = ADMVOSPARTITIONNAMEINVALID;
4244 goto fail_vos_PartitionNameToId;
4248 * Check that the string is either one or two characters
4249 * longer than VICE_PREFIX_SIZE
4252 partition_name_len = strlen(partitionName);
4254 if (partition_name_len == VICE_PREFIX_SIZE) {
4255 tst = ADMVOSPARTITIONNAMETOOSHORT;
4256 goto fail_vos_PartitionNameToId;
4259 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4260 tst = ADMVOSPARTITIONNAMETOOLONG;
4261 goto fail_vos_PartitionNameToId;
4265 * Check that all characters past the prefix are lower case
4268 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4269 if (!islower(partitionName[i])) {
4270 tst = ADMVOSPARTITIONNAMENOTLOWER;
4271 goto fail_vos_PartitionNameToId;
4276 * Convert the name to a number
4279 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4280 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4283 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4284 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4287 if (*partitionId > VOLMAXPARTS) {
4288 tst = ADMVOSPARTITIONIDTOOLARGE;
4289 goto fail_vos_PartitionNameToId;
4293 fail_vos_PartitionNameToId:
4302 * vos_PartitionIdToName - translate a number representing a partition
4303 * to a character string.
4307 * IN partitionId - an integer representing the partition.
4309 * OUT partitionName - a string containing the converted partition ID
4310 * upon successful completion.
4314 * No locks are obtained or released by this function
4318 * Returns != 0 upon successful completion.
4322 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4326 afs_status_t tst = 0;
4328 if (partitionId > VOLMAXPARTS) {
4329 tst = ADMVOSPARTITIONIDTOOLARGE;
4330 goto fail_vos_PartitionIdToName;
4333 if (partitionName == NULL) {
4334 tst = ADMVOSPARTITIONNAMENULL;
4335 goto fail_vos_PartitionIdToName;
4338 if (partitionId < 26) {
4339 strcpy(partitionName, VICE_PARTITION_PREFIX);
4340 partitionName[6] = partitionId + 'a';
4341 partitionName[7] = '\0';
4343 strcpy(partitionName, VICE_PARTITION_PREFIX);
4345 partitionName[6] = 'a' + (partitionId / 26);
4346 partitionName[7] = 'a' + (partitionId % 26);
4347 partitionName[8] = '\0';
4351 fail_vos_PartitionIdToName:
4360 * vos_VolumeQuotaChange - change the quota of a volume.
4364 * IN cellHandle - a previously opened cellHandle that corresponds
4365 * to the cell where the volume exists.
4367 * IN serverHandle - a previously opened serverHandle that corresponds
4368 * to the server where the volume exists.
4370 * IN callBack - a call back function pointer that may be called to report
4371 * status information. Can be null.
4373 * IN partition - the partition where the volume exists.
4375 * IN volumeId - the volume id of the volume to be modified.
4377 * IN volumeQuota - the new volume quota.
4381 * No locks are obtained or released by this function
4385 * Returns != 0 upon successful completion.
4389 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4390 vos_MessageCallBack_t callBack, unsigned int partition,
4391 unsigned int volumeId, unsigned int volumeQuota,
4395 afs_status_t tst = 0;
4396 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4397 file_server_p f_server = (file_server_p) serverHandle;
4400 struct volintInfo tstatus;
4401 int active_trans = 0;
4404 * Verify that the cellHandle is capable of making vos rpc's
4407 if (!IsValidCellHandle(c_handle, &tst)) {
4408 goto fail_vos_VolumeQuotaChange;
4411 if (!IsValidServerHandle(f_server, &tst)) {
4412 goto fail_vos_VolumeQuotaChange;
4415 memset((void *)&tstatus, 0, sizeof(tstatus));
4416 tstatus.dayUse = -1;
4417 tstatus.spare2 = -1;
4418 tstatus.maxquota = volumeQuota;
4422 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4424 goto fail_vos_VolumeQuotaChange;
4428 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4430 goto fail_vos_VolumeQuotaChange;
4434 fail_vos_VolumeQuotaChange:
4437 afs_status_t tst2 = 0;
4438 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4459 * vos_VolumeGet2 - get information about a particular volume.
4463 * IN cellHandle - a previously opened cellHandle that corresponds
4464 * to the cell where the volume exists.
4466 * IN serverHandle - a previously opened serverHandle that corresponds
4467 * to the server where the volume exists.
4469 * IN callBack - a call back function pointer that may be called to report
4470 * status information. Can be null.
4472 * IN partition - the partition where the volume exists.
4474 * IN volumeId - the volume id of the volume to be retrieved.
4476 * OUT pinfo - upon successful completion, contains the information about the
4481 * No locks are obtained or released by this function
4485 * Returns != 0 upon successful completion.
4489 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4490 vos_MessageCallBack_t callBack, unsigned int partition,
4491 unsigned int volumeId, volintInfo* pinfo,
4495 afs_status_t tst = 0;
4496 file_server_p f_server = (file_server_p) serverHandle;
4497 volintInfo *pinfo_=0;
4500 * Validate arguments
4503 if (!IsValidServerHandle(f_server, &tst)) {
4504 goto fail_vos_VolumeGet2;
4507 if (partition > VOLMAXPARTS) {
4508 tst = ADMVOSPARTITIONIDTOOLARGE;
4509 goto fail_vos_VolumeGet2;
4512 if (pinfo == NULL) {
4513 tst = ADMVOSVOLUMEPNULL;
4514 goto fail_vos_VolumeGet2;
4518 * Retrieve the information for the volume
4521 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4522 goto fail_vos_VolumeGet2;
4528 fail_vos_VolumeGet2:
4530 if (pinfo_ != NULL) {
4531 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4542 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4546 * IN cellHandle - a previously opened cellHandle that corresponds
4547 * to the cell where the volume exists.
4549 * IN serverHandle - a previously opened serverHandle that corresponds
4550 * to the server where the volume exists.
4552 * IN partition - the partition where the volume exists.
4554 * IN volumeId - the volume id of the volume to be retrieved.
4558 * No locks are obtained or released by this function
4562 * Returns != 0 upon successful completion.
4566 vos_ClearVolUpdateCounter(const void *cellHandle,
4567 const void *serverHandle,
4568 unsigned int partition,
4569 unsigned int volumeId,
4573 afs_status_t tst = 0;
4574 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4575 file_server_p f_server = (file_server_p) serverHandle;
4578 struct volintInfo tstatus;
4579 int active_trans = 0;
4582 * Verify that the cellHandle is capable of making vos rpc's
4585 if (!IsValidCellHandle(c_handle, &tst)) {
4586 goto fail_vos_ClearVolUpdateCounter;
4589 if (!IsValidServerHandle(f_server, &tst)) {
4590 goto fail_vos_ClearVolUpdateCounter;
4593 memset((void *)&tstatus, 0, sizeof(tstatus));
4594 tstatus.maxquota = -1;
4595 tstatus.dayUse = -1;
4596 tstatus.creationDate = -1;
4597 tstatus.updateDate = -1;
4599 tstatus.spare0 = -1;
4600 tstatus.spare1 = -1;
4602 tstatus.spare3 = -1;
4605 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4607 goto fail_vos_ClearVolUpdateCounter;
4611 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4613 goto fail_vos_ClearVolUpdateCounter;
4617 fail_vos_ClearVolUpdateCounter:
4620 afs_status_t tst2 = 0;
4621 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);