2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
24 #include <sys/types.h>
25 #include <sys/socket.h>
27 #include <netinet/in.h>
28 #include <arpa/inet.h>
31 #include "afs_vosAdmin.h"
32 #include "../adminutil/afs_AdminInternal.h"
33 #include <afs/vlserver.h>
34 #include <afs/volser.h>
35 #include <afs/volint.h>
36 #include <afs/partition.h>
38 #include <rx/rxstat.h>
39 #include <afs/afs_utilAdmin.h>
42 #include "lockprocs.h"
44 /* File descriptors are HANDLE's on NT. The following typedef helps catch
45 * type errors. Duplicated from vol/ihandle.h
52 #define INVALID_FD ((FD_t)-1)
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 register 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, int oldAddress,
1084 int newAddress, afs_status_p st)
1087 afs_status_t tst = 0;
1088 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1091 * Validate arguments
1094 if (!IsValidCellHandle(c_handle, &tst)) {
1095 goto fail_vos_FileServerAddressChange;
1099 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, oldAddress,
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, int serverAddress,
1142 afs_status_t tst = 0;
1143 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1144 int dummyAddress = 0xffffffff;
1147 * Validate arguments
1150 if (!IsValidCellHandle(c_handle, &tst)) {
1151 goto fail_vos_FileServerAddressRemove;
1155 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, dummyAddress,
1158 goto fail_vos_FileServerAddressRemove;
1162 fail_vos_FileServerAddressRemove:
1171 * The iterator functions and data for the server retrieval functions.
1173 * These functions are very similar to the FileServerAddressGet
1174 * functions. The main difference being that instead of returning
1175 * a single address at a time for a server, we fill an array with
1176 * all the addresses of a server.
1179 typedef struct server_get {
1180 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1181 afs_int32 total_addresses; /* total number of addresses */
1182 bulkaddrs addresses; /* the list of addresses */
1183 int address_index; /* current index into address list */
1184 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1185 } server_get_t, *server_get_p;
1188 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1189 int *last_item_contains_data, afs_status_p st)
1192 afs_status_t tst = 0;
1193 server_get_p serv = (server_get_p) rpc_specific;
1194 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1195 afs_int32 base, index;
1198 ListAddrByAttributes m_attrs;
1199 afs_int32 total_multi;
1200 bulkaddrs addr_multi;
1204 * Check to see if this is a multihomed address server
1207 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1208 base = (*addrP >> 16) & 0xff;
1209 index = (*addrP) & 0xffff;
1211 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1212 && (index <= VL_MHSRV_PERBLK)) {
1215 * This is a multihomed server. Make an rpc to retrieve
1216 * all its addresses. Copy the addresses into the cache.
1219 m_attrs.Mask = VLADDR_INDEX;
1220 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1222 addr_multi.bulkaddrs_val = 0;
1223 addr_multi.bulkaddrs_len = 0;
1225 ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
1226 &m_unique, &total_multi, &addr_multi);
1228 goto fail_GetServerRPC;
1232 * Remove any bogus IP addresses which the user may have
1233 * been unable to remove.
1236 RemoveBadAddresses(&total_multi, &addr_multi);
1239 * Copy all the addresses into the cache
1242 for (i = 0; i < total_multi; i++) {
1243 serv->server[slot].serverAddress[i] =
1244 addr_multi.bulkaddrs_val[i];
1247 serv->server[slot].count = total_multi;
1248 serv->address_index++;
1249 free(addr_multi.bulkaddrs_val);
1253 * The next address is just a plain old address
1257 serv->server[slot].serverAddress[0] = *addrP;
1258 serv->server[slot].count = 1;
1259 serv->address_index++;
1263 * See if we've processed all the entries
1267 if (serv->address_index == serv->total_addresses) {
1269 *last_item_contains_data = 1;
1282 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1285 afs_status_t tst = 0;
1286 server_get_p serv = (server_get_p) rpc_specific;
1288 memcpy(dest, (const void *)&serv->server[slot],
1289 sizeof(vos_fileServerEntry_t));
1300 DestroyServer(void *rpc_specific, afs_status_p st)
1303 afs_status_t tst = 0;
1304 server_get_p serv = (server_get_p) rpc_specific;
1306 if (serv->addresses.bulkaddrs_val != NULL) {
1307 free(serv->addresses.bulkaddrs_val);
1318 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1322 * IN cellHandle - a previously opened cellHandle that corresponds
1323 * to the cell where the file servers exist.
1325 * IN callBack - a call back function pointer that may be called to report
1326 * status information. Can be null.
1328 * OUT iterationIdP - upon successful completion, contains an iterator that
1329 * can be passed to vos_FileServerGetNext.
1333 * No locks are obtained or released by this function
1337 * Returns != 0 upon successful completion.
1341 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1342 void **iterationIdP, afs_status_p st)
1345 afs_status_t tst = 0;
1346 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1347 afs_admin_iterator_p iter =
1348 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1349 server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
1350 struct VLCallBack unused;
1354 * Validate arguments
1357 if (!IsValidCellHandle(c_handle, &tst)) {
1358 goto fail_vos_FileServerGetBegin;
1361 if (iterationIdP == NULL) {
1362 goto fail_vos_FileServerGetBegin;
1365 if ((iter == NULL) || (serv == NULL)) {
1367 goto fail_vos_FileServerGetBegin;
1371 * Fill in the serv structure
1374 serv->vldb = c_handle->vos;
1376 ubik_Call_New(VL_GetAddrs, c_handle->vos, 0, 0, 0, &unused,
1377 &serv->total_addresses, &serv->addresses);
1380 goto fail_vos_FileServerGetBegin;
1384 * Remove any bogus IP addresses which the user may have
1385 * been unable to remove.
1388 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1390 if (serv->total_addresses == 0) {
1391 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1392 goto fail_vos_FileServerGetBegin;
1394 iter->done_iterating = 1;
1395 iter->st = ADMITERATORDONE;
1398 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1399 DestroyServer, &tst)) {
1400 goto fail_vos_FileServerGetBegin;
1403 *iterationIdP = (void *)iter;
1406 fail_vos_FileServerGetBegin:
1413 if (serv->addresses.bulkaddrs_val != NULL) {
1414 free(serv->addresses.bulkaddrs_val);
1427 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1431 * IN iterationId - an iterator previously returned by
1432 * vos_FileServerGetBegin
1434 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1435 * completion contains information about the next server in the cell.
1439 * The iterator is locked while the next server is retrieved.
1443 * Returns != 0 upon successful completion.
1447 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1451 afs_status_t tst = 0;
1452 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1455 tst = ADMITERATORNULL;
1456 goto fail_vos_FileServerGetNext;
1459 if (serverEntryP == NULL) {
1460 tst = ADMVOSSERVERENTRYPNULL;
1461 goto fail_vos_FileServerGetNext;
1464 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1466 fail_vos_FileServerGetNext:
1475 * vos_FileServerGetDone - finish using a partition iterator.
1479 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1483 * The iterator is locked and then destroyed.
1487 * Returns != 0 upon successful completion.
1491 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1494 afs_status_t tst = 0;
1495 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1498 * Validate arguments
1502 tst = ADMITERATORNULL;
1503 goto fail_vos_FileServerGetDone;
1506 rc = IteratorDone(iter, &tst);
1508 fail_vos_FileServerGetDone:
1517 * The iterator functions and data for the transation retrieval functions.
1520 typedef struct transaction_get {
1521 afs_int32 total; /* total number of transactions */
1522 afs_int32 index; /* index to the current transaction */
1523 transDebugInfo *cur; /* the current transaction */
1524 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1525 } transaction_get_t, *transaction_get_p;
1528 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1529 int *last_item_contains_data, afs_status_p st)
1532 afs_status_t tst = 0;
1533 transaction_get_p t = (transaction_get_p) rpc_specific;
1534 int index = t->index;
1537 * Copy the next transaction into the cache
1540 t->tran[slot].transactionId = t->cur[index].tid;
1541 t->tran[slot].lastActiveTime = t->cur[index].time;
1542 t->tran[slot].creationTime = t->cur[index].creationTime;
1543 t->tran[slot].errorCode = t->cur[index].returnCode;
1544 t->tran[slot].volumeId = t->cur[index].volid;
1545 t->tran[slot].partition = t->cur[index].partition;
1546 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1547 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1548 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1549 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1550 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1552 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1554 switch (t->cur[index].iflags) {
1556 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1559 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1562 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1565 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1568 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1572 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1574 switch (t->cur[index].vflags) {
1575 case VTDeleteOnSalvage:
1576 t->tran[slot].volumeActiveStatus =
1577 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1579 case VTOutOfService:
1580 t->tran[slot].volumeActiveStatus =
1581 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1584 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1588 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1590 if (t->cur[index].tflags) {
1591 t->tran[slot].volumeTransactionStatus =
1592 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1598 * See if we've processed all the entries
1602 if (t->index == t->total) {
1604 *last_item_contains_data = 1;
1615 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1619 afs_status_t tst = 0;
1620 transaction_get_p tran = (transaction_get_p) rpc_specific;
1622 memcpy(dest, (const void *)&tran->tran[slot],
1623 sizeof(vos_serverTransactionStatus_p));
1634 DestroyTransaction(void *rpc_specific, afs_status_p st)
1637 afs_status_t tst = 0;
1638 transaction_get_p tran = (transaction_get_p) rpc_specific;
1640 if (tran->cur != NULL) {
1652 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1653 * at a volume server.
1657 * IN cellHandle - a previously opened cellHandle that corresponds
1658 * to the cell where the volume server exists.
1660 * IN serverHandle - a handle to the server to query.
1662 * IN callBack - a call back function pointer that may be called to report
1663 * status information. Can be null.
1665 * OUT iterationIdP - upon successful completion, contains an iterator that
1666 * can be passed to vos_ServerTransactionStatusGetNext.
1670 * No locks are obtained or released by this function
1674 * Returns != 0 upon successful completion.
1678 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1679 const void *serverHandle,
1680 vos_MessageCallBack_t callBack,
1681 void **iterationIdP, afs_status_p st)
1684 afs_status_t tst = 0;
1685 file_server_p f_server = (file_server_p) serverHandle;
1686 afs_admin_iterator_p iter =
1687 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1688 transaction_get_p tran =
1689 (transaction_get_p) calloc(1, sizeof(transaction_get_t));
1693 * Validate arguments
1696 if (!IsValidServerHandle(f_server, &tst)) {
1697 goto fail_vos_ServerTransactionStatusGetBegin;
1700 if (iterationIdP == NULL) {
1701 goto fail_vos_ServerTransactionStatusGetBegin;
1704 if ((iter == NULL) || (tran == NULL)) {
1706 goto fail_vos_ServerTransactionStatusGetBegin;
1710 * Fill in the tran structure
1713 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1714 goto fail_vos_ServerTransactionStatusGetBegin;
1717 if (tran->total == 0) {
1718 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1719 goto fail_vos_ServerTransactionStatusGetBegin;
1721 iter->done_iterating = 1;
1722 iter->st = ADMITERATORDONE;
1725 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1726 NULL, DestroyTransaction, &tst)) {
1727 goto fail_vos_ServerTransactionStatusGetBegin;
1730 *iterationIdP = (void *)iter;
1733 fail_vos_ServerTransactionStatusGetBegin:
1740 if (tran->cur != NULL) {
1754 * vos_ServerTransactionStatusGetNext - get information about the next
1755 * active transaction.
1759 * IN iterationId - an iterator previously returned by
1760 * vos_ServerTransactionStatusGetBegin
1762 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1763 * that upon successful completion contains information about the
1768 * The iterator is locked while the next item is retrieved.
1772 * Returns != 0 upon successful completion.
1776 vos_ServerTransactionStatusGetNext(const void *iterationId,
1777 vos_serverTransactionStatus_p
1778 serverTransactionStatusP, afs_status_p st)
1781 afs_status_t tst = 0;
1782 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1785 tst = ADMITERATORNULL;
1786 goto fail_vos_ServerTransactionStatusGetNext;
1789 if (serverTransactionStatusP == NULL) {
1790 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1791 goto fail_vos_ServerTransactionStatusGetNext;
1794 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1796 fail_vos_ServerTransactionStatusGetNext:
1805 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1809 * IN iterationId - an iterator previously returned by
1810 * vos_ServerTransactionStatusGetBegin
1814 * The iterator is locked and then destroyed.
1818 * Returns != 0 upon successful completion.
1822 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1825 afs_status_t tst = 0;
1826 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1829 * Validate arguments
1833 tst = ADMITERATORNULL;
1834 goto fail_vos_ServerTransactionStatusGetDone;
1837 rc = IteratorDone(iter, &tst);
1839 fail_vos_ServerTransactionStatusGetDone:
1848 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1852 afs_status_t tst = 0;
1855 dest->numServers = source->nServers;
1856 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1857 dest->volumeId[i] = source->volumeId[i];
1859 dest->cloneId = source->cloneId;
1860 dest->status = VOS_VLDB_ENTRY_OK;
1861 if (source->flags & VLOP_ALLOPERS) {
1862 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1864 if (source->flags & VLOP_MOVE) {
1865 dest->status |= VOS_VLDB_ENTRY_MOVE;
1867 if (source->flags & VLOP_RELEASE) {
1868 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1870 if (source->flags & VLOP_BACKUP) {
1871 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1873 if (source->flags & VLOP_DELETE) {
1874 dest->status |= VOS_VLDB_ENTRY_DELETE;
1876 if (source->flags & VLOP_DUMP) {
1877 dest->status |= VOS_VLDB_ENTRY_DUMP;
1880 if (source->flags & VLF_RWEXISTS) {
1881 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1883 if (source->flags & VLF_ROEXISTS) {
1884 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1886 if (source->flags & VLF_BACKEXISTS) {
1887 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1890 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1891 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1892 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1893 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1894 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1895 dest->volumeSites[i].serverFlags = 0;
1897 if (source->serverFlags[i] & NEW_REPSITE) {
1898 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1900 if (source->serverFlags[i] & ITSROVOL) {
1901 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1903 if (source->serverFlags[i] & ITSRWVOL) {
1904 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1906 if (source->serverFlags[i] & ITSBACKVOL) {
1907 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1909 if (source->serverFlags[i] & RO_DONTUSE) {
1910 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1923 * vos_VLDBGet- get a volume's vldb entry.
1927 * IN cellHandle - a previously opened cellHandle that corresponds
1928 * to the cell where the volume entries exist.
1930 * IN callBack - a call back function pointer that may be called to report
1931 * status information. Can be null.
1933 * IN volumeId - the id of the volume to retrieve.
1935 * IN volumeName - the name of the volume to retrieve.
1937 * OUT vldbEntry - upon successful completion, contains the information regarding
1942 * No locks are obtained or released by this function
1946 * Returns != 0 upon successful completion.
1950 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1951 const unsigned int *volumeId, const char *volumeName,
1952 vos_vldbEntry_p vldbEntry, afs_status_p st)
1955 afs_status_t tst = 0;
1956 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1957 struct nvldbentry entry;
1961 * Validate arguments
1964 if (!IsValidCellHandle(c_handle, &tst)) {
1965 goto fail_vos_VLDBGet;
1968 if (vldbEntry == NULL) {
1969 tst = ADMVOSVLDBENTRYNULL;
1970 goto fail_vos_VLDBGet;
1973 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1974 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1975 goto fail_vos_VLDBGet;
1979 * Retrieve the entry
1982 if (!((volumeName == NULL) || (*volumeName == 0))) {
1983 if (!ValidateVolumeName(volumeName, &tst)) {
1984 goto fail_vos_VLDBGet;
1986 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1987 goto fail_vos_VLDBGet;
1990 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1991 goto fail_vos_VLDBGet;
1996 * Copy the entry into our structure
1999 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
2000 goto fail_vos_VLDBGet;
2013 * The iterator functions and data for the vldb entry retrieval functions.
2016 typedef struct vldb_entry_get {
2017 afs_int32 total; /* total number of vldb entries */
2018 afs_int32 index; /* index to the current vldb entry */
2019 nbulkentries entries; /* the list of entries retrieved */
2020 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2021 } vldb_entry_get_t, *vldb_entry_get_p;
2024 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2025 int *last_item_contains_data, afs_status_p st)
2028 afs_status_t tst = 0;
2029 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2032 * Copy the next entry into the cache
2036 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2038 goto fail_GetVLDBEntryRPC;
2043 * See if we've processed all the entries
2047 if (entry->index == entry->total) {
2049 *last_item_contains_data = 1;
2053 fail_GetVLDBEntryRPC:
2062 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2066 afs_status_t tst = 0;
2067 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2069 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2080 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2083 afs_status_t tst = 0;
2084 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2086 if (entry->entries.nbulkentries_val != NULL) {
2087 free(entry->entries.nbulkentries_val);
2099 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2103 * IN cellHandle - a previously opened cellHandle that corresponds
2104 * to the cell where the volume entries exist.
2106 * IN serverHandle - a handle to the server whose entries should be listed.
2109 * IN callBack - a call back function pointer that may be called to report
2110 * status information. Can be null.
2112 * IN partition - the partition whose entries should be listed.
2115 * OUT iterationIdP - upon successful completion, contains an iterator that
2116 * can be passed to vos_VLDBGetNext.
2120 * No locks are obtained or released by this function
2124 * Returns != 0 upon successful completion.
2128 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2129 vos_MessageCallBack_t callBack, unsigned int *partition,
2130 void **iterationIdP, afs_status_p st)
2133 afs_status_t tst = 0;
2134 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2135 file_server_p f_server = (file_server_p) serverHandle;
2136 afs_admin_iterator_p iter =
2137 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2138 vldb_entry_get_p entry =
2139 (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2140 struct VldbListByAttributes attr;
2143 memset(&attr, 0, sizeof(attr));
2146 * Validate arguments
2149 if (!IsValidCellHandle(c_handle, &tst)) {
2150 goto fail_vos_VLDBGetBegin;
2153 if ((iter == NULL) || (entry == NULL)) {
2155 goto fail_vos_VLDBGetBegin;
2158 if (f_server != NULL) {
2159 if (!IsValidServerHandle(f_server, &tst)) {
2160 goto fail_vos_VLDBGetBegin;
2162 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2163 attr.Mask |= VLLIST_SERVER;
2166 if (partition != NULL) {
2167 if (*partition > VOLMAXPARTS) {
2168 tst = ADMVOSPARTITIONTOOLARGE;
2169 goto fail_vos_VLDBGetBegin;
2171 attr.partition = *partition;
2172 attr.Mask |= VLLIST_PARTITION;
2175 if (!VLDB_ListAttributes
2176 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2177 goto fail_vos_VLDBGetBegin;
2180 if (entry->total <= 0) {
2181 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2182 goto fail_vos_VLDBGetBegin;
2184 iter->done_iterating = 1;
2185 iter->st = ADMITERATORDONE;
2188 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2189 NULL, DestroyVLDBEntry, &tst)) {
2190 goto fail_vos_VLDBGetBegin;
2193 *iterationIdP = (void *)iter;
2196 fail_vos_VLDBGetBegin:
2202 if (entry->entries.nbulkentries_val != NULL) {
2203 free(entry->entries.nbulkentries_val);
2205 if (entry != NULL) {
2217 * vos_VLDBGetNext - get information about the next volume.
2221 * IN iterationId - an iterator previously returned by
2224 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2225 * that upon successful completion contains information about the
2230 * The iterator is locked while the next item is retrieved.
2234 * Returns != 0 upon successful completion.
2238 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2242 afs_status_t tst = 0;
2243 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2246 tst = ADMITERATORNULL;
2247 goto fail_vos_VLDBGetNext;
2250 if (vldbEntry == NULL) {
2251 tst = ADMVOSVLDBENTRYNULL;
2252 goto fail_vos_VLDBGetNext;
2255 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2257 fail_vos_VLDBGetNext:
2266 * vos_VLDBGetDone - finish using a volume iterator.
2270 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2274 * The iterator is locked and then destroyed.
2278 * Returns != 0 upon successful completion.
2282 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2285 afs_status_t tst = 0;
2286 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2289 * Validate arguments
2293 tst = ADMITERATORNULL;
2294 goto fail_vos_VLDBGetDone;
2297 rc = IteratorDone(iter, &tst);
2299 fail_vos_VLDBGetDone:
2308 * vos_VLDBEntryRemove - remove a vldb entry.
2312 * IN cellHandle - a previously opened cellHandle that corresponds
2313 * to the cell where the vldb entry exists.
2315 * IN serverHandle - a previously opened serverHandle that corresponds
2316 * to the server where the vldb entry exists. Can be null.
2318 * IN callBack - a call back function pointer that may be called to report
2319 * status information. Can be null.
2321 * IN partition - the partition where the vldb entry exists. Can be null.
2323 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2327 * No locks are obtained or released by this function
2331 * Returns != 0 upon successful completion.
2335 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2336 vos_MessageCallBack_t callBack,
2337 const unsigned int *partition, unsigned int *volumeId,
2341 afs_status_t tst = 0;
2342 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2343 file_server_p f_server = (file_server_p) serverHandle;
2344 struct VldbListByAttributes attr;
2345 nbulkentries entries;
2349 memset(&attr, 0, sizeof(attr));
2350 memset(&entries, 0, sizeof(entries));
2353 * Validate arguments
2356 if (!IsValidCellHandle(c_handle, &tst)) {
2357 goto fail_vos_VLDBEntryRemove;
2361 * If the volume is specified, just delete it
2364 if (volumeId != NULL) {
2365 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2367 goto fail_vos_VLDBEntryRemove;
2371 if (f_server != NULL) {
2372 if (!IsValidServerHandle(f_server, &tst)) {
2373 goto fail_vos_VLDBEntryRemove;
2375 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2376 attr.Mask |= VLLIST_SERVER;
2379 if (partition != NULL) {
2380 if (*partition > VOLMAXPARTS) {
2381 tst = ADMVOSPARTITIONTOOLARGE;
2382 goto fail_vos_VLDBEntryRemove;
2384 attr.partition = *partition;
2385 attr.Mask |= VLLIST_PARTITION;
2388 if ((f_server == NULL) && (partition == NULL)) {
2389 tst = ADMVOSVLDBDELETEALLNULL;
2390 goto fail_vos_VLDBEntryRemove;
2393 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2394 goto fail_vos_VLDBEntryRemove;
2397 if (nentries <= 0) {
2398 tst = ADMVOSVLDBNOENTRIES;
2399 goto fail_vos_VLDBEntryRemove;
2402 for (i = 0; i < nentries; i++) {
2403 ubik_VL_DeleteEntry(c_handle->vos, 0,
2404 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2408 fail_vos_VLDBEntryRemove:
2410 if (entries.nbulkentries_val) {
2411 free(entries.nbulkentries_val);
2421 * vos_VLDBUnlock - unlock vldb entries en masse.
2425 * IN cellHandle - a previously opened cellHandle that corresponds
2426 * to the cell where the vldb entries exist.
2428 * IN serverHandle - a previously opened serverHandle that corresponds
2429 * to the server where the vldb entries exist. Can be null.
2431 * IN callBack - a call back function pointer that may be called to report
2432 * status information. Can be null.
2434 * IN partition - the partition where the vldb entries exist. Can be null.
2438 * No locks are obtained or released by this function
2442 * Returns != 0 upon successful completion.
2446 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2447 vos_MessageCallBack_t callBack, const unsigned int *partition,
2451 afs_status_t tst = 0;
2452 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2453 file_server_p f_server = (file_server_p) serverHandle;
2454 struct VldbListByAttributes attr;
2455 nbulkentries entries;
2459 memset(&attr, 0, sizeof(attr));
2460 memset(&entries, 0, sizeof(entries));
2463 * Validate arguments
2466 if (!IsValidCellHandle(c_handle, &tst)) {
2467 goto fail_vos_VLDBUnlock;
2470 if (f_server != NULL) {
2471 if (!IsValidServerHandle(f_server, &tst)) {
2472 goto fail_vos_VLDBUnlock;
2474 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2475 attr.Mask |= VLLIST_SERVER;
2478 if (partition != NULL) {
2479 if (*partition > VOLMAXPARTS) {
2480 tst = ADMVOSPARTITIONTOOLARGE;
2481 goto fail_vos_VLDBUnlock;
2483 attr.partition = *partition;
2484 attr.Mask |= VLLIST_PARTITION;
2486 attr.flag = VLOP_ALLOPERS;
2487 attr.Mask |= VLLIST_FLAG;
2490 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2491 goto fail_vos_VLDBUnlock;
2494 if (nentries <= 0) {
2495 tst = ADMVOSVLDBNOENTRIES;
2496 goto fail_vos_VLDBUnlock;
2499 for (i = 0; i < nentries; i++) {
2500 vos_VLDBEntryUnlock(cellHandle, 0,
2501 entries.nbulkentries_val[i].volumeId[RWVOL],
2506 fail_vos_VLDBUnlock:
2508 if (entries.nbulkentries_val) {
2509 free(entries.nbulkentries_val);
2520 * vos_VLDBEntryLock - lock a vldb entry.
2524 * IN cellHandle - a previously opened cellHandle that corresponds
2525 * to the cell where the vldb entry exists.
2527 * IN callBack - a call back function pointer that may be called to report
2528 * status information. Can be null.
2530 * IN volumeId - the volume id of the vldb entry to be deleted.
2534 * No locks are obtained or released by this function
2538 * Returns != 0 upon successful completion.
2542 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2543 unsigned int volumeId, afs_status_p st)
2546 afs_status_t tst = 0;
2547 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2550 * Validate arguments
2553 if (!IsValidCellHandle(c_handle, &tst)) {
2554 goto fail_vos_VLDBEntryLock;
2557 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2559 goto fail_vos_VLDBEntryLock;
2563 fail_vos_VLDBEntryLock:
2572 * vos_VLDBEntryUnlock - unlock a vldb entry.
2576 * IN cellHandle - a previously opened cellHandle that corresponds
2577 * to the cell where the vldb entry exists.
2579 * IN callBack - a call back function pointer that may be called to report
2580 * status information. Can be null.
2582 * IN volumeId - the volume id of the vldb entry to be unlocked.
2586 * No locks are obtained or released by this function
2590 * Returns != 0 upon successful completion.
2594 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2595 unsigned int volumeId, afs_status_p st)
2598 afs_status_t tst = 0;
2599 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2602 * Validate arguments
2605 if (!IsValidCellHandle(c_handle, &tst)) {
2606 goto fail_vos_VLDBEntryUnlock;
2611 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2612 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2614 goto fail_vos_VLDBEntryUnlock;
2618 fail_vos_VLDBEntryUnlock:
2627 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2631 * IN cellHandle - a previously opened cellHandle that corresponds
2632 * to the cell where the volume exists.
2634 * IN serverHandle - a previously opened serverHandle that corresponds
2635 * to the server where the new volume should be created.
2637 * IN callBack - a call back function pointer that may be called to report
2638 * status information. Can be null.
2640 * IN partition - the partition where then new volume should be created.
2642 * IN volumeId - the volume id of the volume to be replicated.
2646 * No locks are obtained or released by this function
2650 * Returns != 0 upon successful completion.
2654 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2655 vos_MessageCallBack_t callBack,
2656 unsigned int partition, unsigned int volumeId,
2660 afs_status_t tst = 0;
2661 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2662 file_server_p f_server = (file_server_p) serverHandle;
2665 * Validate arguments
2668 if (!IsValidCellHandle(c_handle, &tst)) {
2669 goto fail_vos_VLDBReadOnlySiteCreate;
2672 if (!IsValidServerHandle(f_server, &tst)) {
2673 goto fail_vos_VLDBReadOnlySiteCreate;
2676 if (partition > VOLMAXPARTS) {
2677 tst = ADMVOSPARTITIONTOOLARGE;
2678 goto fail_vos_VLDBReadOnlySiteCreate;
2682 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2684 goto fail_vos_VLDBReadOnlySiteCreate;
2688 fail_vos_VLDBReadOnlySiteCreate:
2697 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2702 * IN cellHandle - a previously opened cellHandle that corresponds
2703 * to the cell where the volume exists.
2705 * IN serverHandle - a previously opened serverHandle that corresponds
2706 * to the server where the volume should be deleted.
2708 * IN callBack - a call back function pointer that may be called to report
2709 * status information. Can be null.
2711 * IN partition - the partition where then volume should be deleted.
2713 * IN volumeId - the volume id of the volume to be deleted.
2717 * No locks are obtained or released by this function
2721 * Returns != 0 upon successful completion.
2725 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2726 vos_MessageCallBack_t callBack,
2727 unsigned int partition, unsigned int volumeId,
2731 afs_status_t tst = 0;
2732 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2733 file_server_p f_server = (file_server_p) serverHandle;
2736 * Validate arguments
2739 if (!IsValidCellHandle(c_handle, &tst)) {
2740 goto fail_vos_VLDBReadOnlySiteDelete;
2743 if (!IsValidServerHandle(f_server, &tst)) {
2744 goto fail_vos_VLDBReadOnlySiteDelete;
2747 if (partition > VOLMAXPARTS) {
2748 tst = ADMVOSPARTITIONTOOLARGE;
2749 goto fail_vos_VLDBReadOnlySiteDelete;
2753 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2755 goto fail_vos_VLDBReadOnlySiteDelete;
2759 fail_vos_VLDBReadOnlySiteDelete:
2768 * vos_VLDBSync - synchronize the vldb with the fileserver.
2772 * IN cellHandle - a previously opened cellHandle that corresponds
2773 * to the cell where the sync should occur.
2775 * IN serverHandle - a previously opened serverHandle that corresponds
2776 * to the server where the sync should occur.
2778 * IN callBack - a call back function pointer that may be called to report
2779 * status information. Can be null.
2781 * IN partition - the partition where the sync should occur. Can be null.
2783 * IN force - force deletion of bad volumes.
2787 * No locks are obtained or released by this function
2791 * Returns != 0 upon successful completion.
2795 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2796 vos_MessageCallBack_t callBack, const unsigned int *partition,
2797 vos_force_t force, afs_status_p st)
2800 afs_status_t tst = 0;
2801 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2802 file_server_p f_server = (file_server_p) serverHandle;
2808 * Validate arguments
2811 if (!IsValidCellHandle(c_handle, &tst)) {
2812 goto fail_vos_VLDBSync;
2815 if (!IsValidServerHandle(f_server, &tst)) {
2816 goto fail_vos_VLDBSync;
2819 if (partition != NULL) {
2820 if (*partition > VOLMAXPARTS) {
2821 tst = ADMVOSPARTITIONTOOLARGE;
2822 goto fail_vos_VLDBSync;
2824 part = (afs_int32) * partition;
2828 if (force == VOS_FORCE) {
2836 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2847 * vos_VolumeCreate - create a new partition.
2851 * IN cellHandle - a previously opened cellHandle that corresponds
2852 * to the cell where the server lives.
2854 * IN serverHandle - a previously open vos server handle that holds
2855 * the partition where the volume should be create.
2857 * IN callBack - a call back function pointer that may be called to report
2858 * status information. Can be null.
2860 * IN partition - the integer that represents the partition that will
2861 * house the new volume.
2863 * IN volumeName - the name of the new volume.
2865 * IN quota - the quota of the new volume.
2867 * OUT volumeId - the volume id of the newly created volume.
2871 * No locks are obtained or released by this function
2875 * Returns != 0 upon successful completion.
2879 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2880 vos_MessageCallBack_t callBack, unsigned int partition,
2881 const char *volumeName, unsigned int quota,
2882 unsigned int *volumeId, afs_status_p st)
2885 afs_status_t tst = 0;
2886 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2887 file_server_p f_server = (file_server_p) serverHandle;
2888 vos_partitionEntry_t pinfo;
2889 struct nvldbentry vinfo;
2892 * Validate arguments
2895 if (!IsValidCellHandle(c_handle, &tst)) {
2896 goto fail_vos_VolumeCreate;
2899 if (!IsValidServerHandle(f_server, &tst)) {
2900 goto fail_vos_VolumeCreate;
2903 if (partition > VOLMAXPARTS) {
2904 tst = ADMVOSPARTITIONTOOLARGE;
2905 goto fail_vos_VolumeCreate;
2908 if (!ValidateVolumeName(volumeName, &tst)) {
2909 goto fail_vos_VolumeCreate;
2912 if (volumeId == NULL) {
2913 tst = ADMVOSVOLUMEID;
2914 goto fail_vos_VolumeCreate;
2918 * Check that partition is valid at the server
2921 if (!vos_PartitionGet
2922 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2923 goto fail_vos_VolumeCreate;
2927 * Check that the volume doesn't already exist
2930 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2931 tst = ADMVOSVOLUMENAMEDUP;
2932 goto fail_vos_VolumeCreate;
2936 * Create the new volume
2939 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2940 quota, volumeId, &tst);
2942 fail_vos_VolumeCreate:
2951 * vos_VolumeDelete - remove a volume.
2955 * IN cellHandle - a previously opened cellHandle that corresponds
2956 * to the cell where the volume exists.
2958 * IN serverHandle - a previously opened serverHandle that corresponds
2959 * to the server where the volume exists.
2961 * IN callBack - a call back function pointer that may be called to report
2962 * status information. Can be null.
2964 * IN partition - the partition where the volume exists.
2966 * IN volumeId - the volume id of the volume to be deleted.
2970 * No locks are obtained or released by this function
2974 * Returns != 0 upon successful completion.
2978 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2979 vos_MessageCallBack_t callBack, unsigned int partition,
2980 unsigned int volumeId, afs_status_p st)
2983 afs_status_t tst = 0;
2984 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2985 file_server_p f_server = (file_server_p) serverHandle;
2986 vos_partitionEntry_t pinfo;
2989 * Validate arguments
2992 if (!IsValidCellHandle(c_handle, &tst)) {
2993 goto fail_vos_VolumeDelete;
2996 if (!IsValidServerHandle(f_server, &tst)) {
2997 goto fail_vos_VolumeDelete;
3000 if (partition > VOLMAXPARTS) {
3001 tst = ADMVOSPARTITIONTOOLARGE;
3002 goto fail_vos_VolumeDelete;
3006 * Check that partition is valid at the server
3009 if (!vos_PartitionGet
3010 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
3011 goto fail_vos_VolumeDelete;
3014 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3016 fail_vos_VolumeDelete:
3025 * vos_VolumeRename - rename a volume.
3029 * IN cellHandle - a previously opened cellHandle that corresponds
3030 * to the cell where the volume exists.
3032 * IN serverHandle - a previously opened serverHandle that corresponds
3033 * to the server where the vldb entry exists. Can be null.
3035 * IN callBack - a call back function pointer that may be called to report
3036 * status information. Can be null.
3038 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3040 * IN newVolumeName - the new name.
3044 * No locks are obtained or released by this function
3048 * Returns != 0 upon successful completion.
3052 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3053 unsigned int readWriteVolumeId, const char *newVolumeName,
3057 afs_status_t tst = 0;
3058 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3059 struct nvldbentry entry;
3062 * Validate arguments
3065 if (!IsValidCellHandle(c_handle, &tst)) {
3066 goto fail_vos_VolumeRename;
3069 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3070 tst = ADMVOSNEWVOLUMENAMENULL;
3071 goto fail_vos_VolumeRename;
3075 * Retrieve the entry
3078 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3079 goto fail_vos_VolumeRename;
3082 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3084 fail_vos_VolumeRename:
3093 * vos_VolumeDump - dump a volume
3097 * IN cellHandle - a previously opened cellHandle that corresponds
3098 * to the cell where the volume exists.
3100 * IN serverHandle - a previously opened serverHandle that corresponds
3101 * to the server where the volume exists. Can be null.
3103 * IN callBack - a call back function pointer that may be called to report
3104 * status information. Can be null.
3106 * IN volumeId - the volume id of the volume to be dumped.
3108 * IN startTime - files with modification times >= this time will be dumped.
3110 * IN dumpFile - the file to dump the volume to.
3114 * No locks are obtained or released by this function
3118 * Returns != 0 upon successful completion.
3122 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3123 vos_MessageCallBack_t callBack, unsigned int *partition,
3124 unsigned int volumeId, unsigned int startTime,
3125 const char *dumpFile, afs_status_p st)
3128 afs_status_t tst = 0;
3129 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3130 file_server_p f_server = (file_server_p) serverHandle;
3131 afs_int32 server, part, voltype;
3132 struct nvldbentry entry;
3135 * Validate arguments
3138 if (!IsValidCellHandle(c_handle, &tst)) {
3139 goto fail_vos_VolumeDump;
3142 if (serverHandle != NULL) {
3143 if (!IsValidServerHandle(f_server, &tst)) {
3144 goto fail_vos_VolumeDump;
3149 * You must specify both the serverHandle and the partition
3152 if (serverHandle || partition) {
3153 if (!serverHandle || !partition) {
3154 tst = ADMVOSSERVERANDPARTITION;
3155 goto fail_vos_VolumeDump;
3157 if (*partition > VOLMAXPARTS) {
3158 tst = ADMVOSPARTITIONTOOLARGE;
3159 goto fail_vos_VolumeDump;
3161 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3166 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3167 goto fail_vos_VolumeDump;
3171 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3172 tst = ADMVOSDUMPFILENULL;
3173 goto fail_vos_VolumeDump;
3176 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3179 fail_vos_VolumeDump:
3188 * vos_VolumeRestore - restore a volume from a dump
3192 * IN cellHandle - a previously opened cellHandle that corresponds
3193 * to the cell where the volume exists.
3195 * IN serverHandle - a previously opened serverHandle that corresponds
3196 * to the server where the volume exists.
3198 * IN callBack - a call back function pointer that may be called to report
3199 * status information. Can be null.
3201 * IN partition - the partition where the volume exists.
3203 * IN volumeId - the volume id of the volume to be restored.
3205 * IN volumeName - the volume name of the volume to be restored.
3207 * IN dumpFile - the file from which to restore the volume.
3209 * IN dumpType - the type of dump to perform.
3213 * No locks are obtained or released by this function
3217 * Returns != 0 upon successful completion.
3221 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3222 vos_MessageCallBack_t callBack, unsigned int partition,
3223 unsigned int *volumeId, const char *volumeName,
3224 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3228 afs_status_t tst = 0;
3229 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3230 file_server_p f_server = (file_server_p) serverHandle;
3231 struct nvldbentry entry;
3232 afs_int32 volid, server;
3235 int restoreflags = 0;
3236 afs_int32 Oserver, Opart, Otype;
3237 struct nvldbentry Oentry;
3241 * Validate arguments
3244 if (!IsValidCellHandle(c_handle, &tst)) {
3245 goto fail_vos_VolumeRestore;
3248 if (serverHandle != NULL) {
3249 if (!IsValidServerHandle(f_server, &tst)) {
3250 goto fail_vos_VolumeRestore;
3255 * Must pass volumeName
3258 if ((volumeName == NULL) || (*volumeName == 0)) {
3259 tst = ADMVOSVOLUMENAMENULL;
3260 goto fail_vos_VolumeRestore;
3263 if (!ValidateVolumeName(volumeName, &tst)) {
3264 goto fail_vos_VolumeRestore;
3268 * If volumeId is passed, it must be a valid volume id
3271 if (volumeId != NULL) {
3272 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3273 goto fail_vos_VolumeRestore;
3280 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3282 if (partition > VOLMAXPARTS) {
3283 tst = ADMVOSPARTITIONTOOLARGE;
3284 goto fail_vos_VolumeRestore;
3288 * Check that dumpFile exists and can be accessed
3291 fd = open(dumpFile, 0);
3292 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3294 tst = ADMVOSDUMPFILEOPENFAIL;
3295 goto fail_vos_VolumeRestore;
3300 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3301 restoreflags = RV_FULLRST;
3302 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3303 restoreflags = RV_FULLRST;
3305 volid = entry.volumeId[RWVOL];
3306 } else if ((entry.volumeId[RWVOL] != 0)
3307 && (entry.volumeId[RWVOL] != volid)) {
3308 volid = entry.volumeId[RWVOL];
3313 volid = entry.volumeId[RWVOL];
3314 } else if ((entry.volumeId[RWVOL] != 0)
3315 && (entry.volumeId[RWVOL] != volid)) {
3316 volid = entry.volumeId[RWVOL];
3320 * If the vldb says the same volume exists somewhere else
3321 * the caller must specify a full restore, not an incremental
3324 if (dumpType == VOS_RESTORE_FULL) {
3325 restoreflags = RV_FULLRST;
3329 * Check to see if the volume exists where the caller said
3332 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3333 goto fail_vos_VolumeRestore;
3335 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3336 goto fail_vos_VolumeRestore;
3340 tst = ADMVOSRESTOREVOLEXIST;
3341 goto fail_vos_VolumeRestore;
3346 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3347 restoreflags, dumpFile, &tst);
3349 fail_vos_VolumeRestore:
3358 * vos_VolumeOnline - bring a volume online.
3362 * IN serverHandle - a previously opened serverHandle that corresponds
3363 * to the server where the volume exists.
3365 * IN callBack - a call back function pointer that may be called to report
3366 * status information. Can be null.
3368 * IN partition - the partition where the volume exists.
3370 * IN volumeId - the volume id of the volume to be brought online.
3374 * No locks are obtained or released by this function
3378 * Returns != 0 upon successful completion.
3382 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3383 unsigned int partition, unsigned int volumeId,
3384 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3388 afs_status_t tst = 0;
3389 file_server_p f_server = (file_server_p) serverHandle;
3393 * Validate arguments
3396 if (!IsValidServerHandle(f_server, &tst)) {
3397 goto fail_vos_VolumeOnline;
3400 if (partition > VOLMAXPARTS) {
3401 tst = ADMVOSPARTITIONIDTOOLARGE;
3402 goto fail_vos_VolumeOnline;
3405 if (volumeStatus == VOS_ONLINE_BUSY) {
3409 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3412 fail_vos_VolumeOnline:
3421 * vos_VolumeOffline - take a volume offline.
3425 * IN serverHandle - a previously opened serverHandle that corresponds
3426 * to the server where the volume exists.
3428 * IN callBack - a call back function pointer that may be called to report
3429 * status information. Can be null.
3431 * IN partition - the partition where the volume exists.
3433 * IN volumeId - the volume id of the volume to be taken offline.
3437 * No locks are obtained or released by this function
3441 * Returns != 0 upon successful completion.
3445 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3446 unsigned int partition, unsigned int volumeId,
3450 afs_status_t tst = 0;
3451 file_server_p f_server = (file_server_p) serverHandle;
3454 * Validate arguments
3457 if (!IsValidServerHandle(f_server, &tst)) {
3458 goto fail_vos_VolumeOffline;
3461 if (partition > VOLMAXPARTS) {
3462 tst = ADMVOSPARTITIONIDTOOLARGE;
3463 goto fail_vos_VolumeOffline;
3466 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3467 VTOutOfService, 0, &tst);
3469 fail_vos_VolumeOffline:
3478 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3482 * IN source - the volintXInfo structure to copy.
3484 * OUT dest - the vos_volumeEntry_t to fill
3488 * No locks are obtained or released by this function
3492 * Returns != 0 upon successful completion.
3496 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3500 afs_status_t tst = 0;
3504 * If the volume is not marked OK, all the other fields are invalid
3505 * We take the extra step of blanking out dest here to prevent the
3506 * user from seeing stale data from a previous call
3509 memset(dest, 0, sizeof(dest));
3511 switch (source->status) {
3513 dest->status = VOS_OK;
3516 dest->status = VOS_SALVAGE;
3519 dest->status = VOS_NO_VNODE;
3522 dest->status = VOS_NO_VOL;
3525 dest->status = VOS_VOL_EXISTS;
3528 dest->status = VOS_NO_SERVICE;
3531 dest->status = VOS_OFFLINE;
3534 dest->status = VOS_ONLINE;
3537 dest->status = VOS_DISK_FULL;
3540 dest->status = VOS_OVER_QUOTA;
3543 dest->status = VOS_BUSY;
3546 dest->status = VOS_MOVED;
3551 * Check to see if the entry is marked ok before copying all the
3555 if (dest->status == VOS_OK) {
3556 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3557 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3558 dest->id = source->volid;
3559 if (source->type == 0) {
3560 dest->type = VOS_READ_WRITE_VOLUME;
3561 } else if (source->type == 1) {
3562 dest->type = VOS_READ_ONLY_VOLUME;
3563 } else if (source->type == 2) {
3564 dest->type = VOS_BACKUP_VOLUME;
3566 dest->backupId = source->backupID;
3567 dest->readWriteId = source->parentID;
3568 dest->readOnlyId = source->cloneID;
3569 dest->copyCreationDate = source->copyDate;
3570 dest->creationDate = source->creationDate;
3571 dest->lastAccessDate = source->accessDate;
3572 dest->lastUpdateDate = source->updateDate;
3573 dest->lastBackupDate = source->backupDate;
3574 dest->accessesSinceMidnight = source->dayUse;
3575 dest->fileCount = source->filecount;
3576 dest->maxQuota = source->maxquota;
3577 dest->currentSize = source->size;
3578 if (source->inUse == 1) {
3579 dest->volumeDisposition = VOS_ONLINE;
3581 dest->volumeDisposition = VOS_OFFLINE;
3584 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3585 dest->readStats[i] = source->stat_reads[i];
3586 dest->writeStats[i] = source->stat_writes[i];
3589 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3590 dest->fileAuthorWriteSameNetwork[i] =
3591 source->stat_fileSameAuthor[i];
3592 dest->fileAuthorWriteDifferentNetwork[i] =
3593 source->stat_fileDiffAuthor[i];
3594 dest->dirAuthorWriteSameNetwork[i] =
3595 source->stat_dirSameAuthor[i];
3596 dest->dirAuthorWriteDifferentNetwork[i] =
3597 source->stat_dirDiffAuthor[i];
3610 * vos_VolumeGet - get information about a particular volume.
3614 * IN cellHandle - a previously opened cellHandle that corresponds
3615 * to the cell where the volume exists.
3617 * IN serverHandle - a previously opened serverHandle that corresponds
3618 * to the server where the volume exists.
3620 * IN callBack - a call back function pointer that may be called to report
3621 * status information. Can be null.
3623 * IN partition - the partition where the volume exists.
3625 * IN volumeId - the volume id of the volume to be retrieved.
3627 * OUT volumeP - upon successful completion, contains the information about the
3632 * No locks are obtained or released by this function
3636 * Returns != 0 upon successful completion.
3640 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3641 vos_MessageCallBack_t callBack, unsigned int partition,
3642 unsigned int volumeId, vos_volumeEntry_p volumeP,
3646 afs_status_t tst = 0;
3647 file_server_p f_server = (file_server_p) serverHandle;
3648 struct volintXInfo *info = NULL;
3651 * Validate arguments
3654 if (!IsValidServerHandle(f_server, &tst)) {
3655 goto fail_vos_VolumeGet;
3658 if (partition > VOLMAXPARTS) {
3659 tst = ADMVOSPARTITIONIDTOOLARGE;
3660 goto fail_vos_VolumeGet;
3663 if (volumeP == NULL) {
3664 tst = ADMVOSVOLUMEPNULL;
3665 goto fail_vos_VolumeGet;
3669 * Retrieve the information for the volume
3672 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3673 goto fail_vos_VolumeGet;
3677 * Copy the volume info to our structure
3680 if (!copyvolintXInfo(info, volumeP, &tst)) {
3681 goto fail_vos_VolumeGet;
3698 * The iterator functions and data for the volume retrieval functions.
3701 typedef struct volume_get {
3702 struct volintXInfo *vollist;
3703 afs_int32 total; /* total number of volumes at this partition */
3704 afs_int32 index; /* index to the current volume */
3705 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3706 } volume_get_t, *volume_get_p;
3709 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3710 int *last_item_contains_data, afs_status_p st)
3713 afs_status_t tst = 0;
3714 volume_get_p entry = (volume_get_p) rpc_specific;
3717 * Copy the next entry into the cache
3720 if (!copyvolintXInfo
3721 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3722 goto fail_GetVolumeRPC;
3727 * See if we've processed all the entries
3731 if (entry->index == entry->total) {
3733 *last_item_contains_data = 1;
3746 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3749 afs_status_t tst = 0;
3750 volume_get_p entry = (volume_get_p) rpc_specific;
3752 memcpy(dest, (const void *)&entry->entry[slot],
3753 sizeof(vos_volumeEntry_t));
3764 DestroyVolume(void *rpc_specific, afs_status_p st)
3767 afs_status_t tst = 0;
3768 volume_get_p entry = (volume_get_p) rpc_specific;
3770 if (entry->vollist != NULL) {
3771 free(entry->vollist);
3783 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3787 * IN cellHandle - a previously opened cellHandle that corresponds
3788 * to the cell where the volumes exist.
3790 * IN serverHandle - a handle to the server where the volumes exist.
3792 * IN callBack - a call back function pointer that may be called to report
3793 * status information. Can be null.
3795 * IN partition - the partition whose volumes should be listed. Can be null.
3797 * OUT iterationIdP - upon successful completion, contains an iterator that
3798 * can be passed to vos_VolumeGetBegin.
3802 * No locks are obtained or released by this function
3806 * Returns != 0 upon successful completion.
3810 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3811 vos_MessageCallBack_t callBack, unsigned int partition,
3812 void **iterationIdP, afs_status_p st)
3815 afs_status_t tst = 0;
3816 file_server_p f_server = (file_server_p) serverHandle;
3817 afs_admin_iterator_p iter =
3818 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3819 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3822 * Validate arguments
3825 if (!IsValidServerHandle(f_server, &tst)) {
3826 goto fail_vos_VolumeGetBegin;
3829 if (partition > VOLMAXPARTS) {
3830 tst = ADMVOSPARTITIONIDTOOLARGE;
3831 goto fail_vos_VolumeGetBegin;
3834 if ((iter == NULL) || (entry == NULL)) {
3836 goto fail_vos_VolumeGetBegin;
3840 * Get a list of all the volumes contained in the partition at the
3844 if (!UV_XListVolumes
3845 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3847 goto fail_vos_VolumeGetBegin;
3850 if (entry->total == 0) {
3851 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3852 goto fail_vos_VolumeGetBegin;
3854 iter->done_iterating = 1;
3855 iter->st = ADMITERATORDONE;
3858 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3859 DestroyVolume, &tst)) {
3860 goto fail_vos_VolumeGetBegin;
3863 *iterationIdP = (void *)iter;
3866 fail_vos_VolumeGetBegin:
3872 if (entry != NULL) {
3884 * vos_VolumeGetNext - get information about the next volume.
3888 * IN iterationId - an iterator previously returned by
3889 * vos_VolumeGetBegin
3891 * OUT volumeP - a pointer to a vos_volumeEntry_t
3892 * that upon successful completion contains information about the
3897 * The iterator is locked while the next item is retrieved.
3901 * Returns != 0 upon successful completion.
3905 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3909 afs_status_t tst = 0;
3910 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3913 tst = ADMITERATORNULL;
3914 goto fail_vos_VolumeGetNext;
3917 if (volumeP == NULL) {
3918 tst = ADMVOSVOLUMEPNULL;
3919 goto fail_vos_VolumeGetNext;
3922 rc = IteratorNext(iter, (void *)volumeP, &tst);
3924 fail_vos_VolumeGetNext:
3933 * vos_VolumeGetDone - finish using a volume iterator.
3937 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3941 * The iterator is locked and then destroyed.
3945 * Returns != 0 upon successful completion.
3949 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3952 afs_status_t tst = 0;
3953 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3956 * Validate arguments
3960 tst = ADMITERATORNULL;
3961 goto fail_vos_VolumeGetDone;
3964 rc = IteratorDone(iter, &tst);
3966 fail_vos_VolumeGetDone:
3975 * vos_VolumeMove - move a volume from one server to another.
3979 * IN cellHandle - a previously opened cellHandle that corresponds
3980 * to the cell where the volume exists.
3982 * IN callBack - a call back function pointer that may be called to report
3983 * status information. Can be null.
3985 * IN volumeId - the volume id of the volume to be moved.
3987 * IN fromServer - a previously opened serverHandle that corresponds
3988 * to the server where the volume currently resides.
3990 * IN fromPartition - the partition where the volume currently resides.
3992 * IN toServer - a previously opened serverHandle that corresponds
3993 * to the server where the volume will be moved.
3995 * IN toPartition - the partition where the volume will be moved.
3999 * No locks are obtained or released by this function
4003 * Returns != 0 upon successful completion.
4007 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
4008 unsigned int volumeId, const void *fromServer,
4009 unsigned int fromPartition, const void *toServer,
4010 unsigned int toPartition, afs_status_p st)
4013 afs_status_t tst = 0;
4014 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4015 file_server_p from_server = (file_server_p) fromServer;
4016 file_server_p to_server = (file_server_p) toServer;
4017 afs_int32 from_server_addr =
4018 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4019 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4020 afs_int32 from_partition = fromPartition;
4021 afs_int32 to_partition = toPartition;
4024 * Validate arguments
4027 if (!IsValidCellHandle(c_handle, &tst)) {
4028 goto fail_vos_VolumeMove;
4031 if (!IsValidServerHandle(from_server, &tst)) {
4032 goto fail_vos_VolumeMove;
4035 if (!IsValidServerHandle(to_server, &tst)) {
4036 goto fail_vos_VolumeMove;
4039 if (fromPartition > VOLMAXPARTS) {
4040 tst = ADMVOSPARTITIONIDTOOLARGE;
4041 goto fail_vos_VolumeMove;
4044 if (toPartition > VOLMAXPARTS) {
4045 tst = ADMVOSPARTITIONIDTOOLARGE;
4046 goto fail_vos_VolumeMove;
4053 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4054 to_server_addr, to_partition, &tst);
4056 fail_vos_VolumeMove:
4065 * vos_VolumeRelease - release a volume.
4069 * IN cellHandle - a previously opened cellHandle that corresponds
4070 * to the cell where the volume exists.
4072 * IN callBack - a call back function pointer that may be called to report
4073 * status information. Can be null.
4075 * IN volumeId - the volume to be released.
4077 * IN force - force a complete release.
4081 * No locks are obtained or released by this function
4085 * Returns != 0 upon successful completion.
4089 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4090 unsigned int volumeId, vos_force_t force, afs_status_p st)
4093 afs_status_t tst = 0;
4094 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4095 afs_int32 server, part, forc = 0, voltype, volume;
4096 struct nvldbentry entry;
4099 * Validate arguments
4102 if (!IsValidCellHandle(c_handle, &tst)) {
4103 goto fail_vos_VolumeRelease;
4107 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4108 goto fail_vos_VolumeRelease;
4111 if (force == VOS_FORCE) {
4116 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4118 fail_vos_VolumeRelease:
4127 * vos_VolumeZap - forcibly delete a volume.
4131 * IN cellHandle - a previously opened cellHandle that corresponds
4132 * to the cell where the volume exists.
4134 * IN serverHandle - a previously opened serverHandle that corresponds
4135 * to the server where the volume exists.
4137 * IN callBack - a call back function pointer that may be called to report
4138 * status information. Can be null.
4140 * IN partition - the partition where the volume exists.
4142 * IN volumeId - the volume id of the vldb entry to be deleted.
4144 * IN force - force the deletion of bad volumes.
4148 * No locks are obtained or released by this function
4152 * Returns != 0 upon successful completion.
4156 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4157 vos_MessageCallBack_t callBack, unsigned int partition,
4158 unsigned int volumeId, vos_force_t force, afs_status_p st)
4161 afs_status_t tst = 0;
4162 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4163 file_server_p f_server = (file_server_p) serverHandle;
4166 * Verify that the cellHandle is capable of making vos rpc's
4169 if (!IsValidCellHandle(c_handle, &tst)) {
4170 goto fail_vos_VolumeZap;
4173 if (!IsValidServerHandle(f_server, &tst)) {
4174 goto fail_vos_VolumeZap;
4177 if (force == VOS_FORCE) {
4178 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4181 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4194 * vos_PartitionNameToId - translate a string representing a partition
4199 * IN partitionName - a string representing a partition. Must be of
4202 * OUT partitionId - a number containing the partition id upon successful
4207 * No locks are obtained or released by this function
4211 * Returns != 0 upon successful completion.
4215 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4219 afs_status_t tst = 0;
4220 size_t partition_name_len;
4224 * Validate arguments
4227 if (partitionName == NULL) {
4228 tst = ADMVOSPARTITIONNAMENULL;
4229 goto fail_vos_PartitionNameToId;
4232 if (partitionId == NULL) {
4233 tst = ADMVOSPARTITIONIDNULL;
4234 goto fail_vos_PartitionNameToId;
4238 * Check that string begins with /vicep
4241 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4242 tst = ADMVOSPARTITIONNAMEINVALID;
4243 goto fail_vos_PartitionNameToId;
4247 * Check that the string is either one or two characters
4248 * longer than VICE_PREFIX_SIZE
4251 partition_name_len = strlen(partitionName);
4253 if (partition_name_len == VICE_PREFIX_SIZE) {
4254 tst = ADMVOSPARTITIONNAMETOOSHORT;
4255 goto fail_vos_PartitionNameToId;
4258 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4259 tst = ADMVOSPARTITIONNAMETOOLONG;
4260 goto fail_vos_PartitionNameToId;
4264 * Check that all characters past the prefix are lower case
4267 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4268 if (!islower(partitionName[i])) {
4269 tst = ADMVOSPARTITIONNAMENOTLOWER;
4270 goto fail_vos_PartitionNameToId;
4275 * Convert the name to a number
4278 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4279 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4282 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4283 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4286 if (*partitionId > VOLMAXPARTS) {
4287 tst = ADMVOSPARTITIONIDTOOLARGE;
4288 goto fail_vos_PartitionNameToId;
4292 fail_vos_PartitionNameToId:
4301 * vos_PartitionIdToName - translate a number representing a partition
4302 * to a character string.
4306 * IN partitionId - an integer representing the partition.
4308 * OUT partitionName - a string containing the converted partition ID
4309 * upon successful completion.
4313 * No locks are obtained or released by this function
4317 * Returns != 0 upon successful completion.
4321 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4325 afs_status_t tst = 0;
4327 if (partitionId > VOLMAXPARTS) {
4328 tst = ADMVOSPARTITIONIDTOOLARGE;
4329 goto fail_vos_PartitionIdToName;
4332 if (partitionName == NULL) {
4333 tst = ADMVOSPARTITIONNAMENULL;
4334 goto fail_vos_PartitionIdToName;
4337 if (partitionId < 26) {
4338 strcpy(partitionName, VICE_PARTITION_PREFIX);
4339 partitionName[6] = partitionId + 'a';
4340 partitionName[7] = '\0';
4342 strcpy(partitionName, VICE_PARTITION_PREFIX);
4344 partitionName[6] = 'a' + (partitionId / 26);
4345 partitionName[7] = 'a' + (partitionId % 26);
4346 partitionName[8] = '\0';
4350 fail_vos_PartitionIdToName:
4359 * vos_VolumeQuotaChange - change the quota of a volume.
4363 * IN cellHandle - a previously opened cellHandle that corresponds
4364 * to the cell where the volume exists.
4366 * IN serverHandle - a previously opened serverHandle that corresponds
4367 * to the server where the volume exists.
4369 * IN callBack - a call back function pointer that may be called to report
4370 * status information. Can be null.
4372 * IN partition - the partition where the volume exists.
4374 * IN volumeId - the volume id of the volume to be modified.
4376 * IN volumeQuota - the new volume quota.
4380 * No locks are obtained or released by this function
4384 * Returns != 0 upon successful completion.
4388 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4389 vos_MessageCallBack_t callBack, unsigned int partition,
4390 unsigned int volumeId, unsigned int volumeQuota,
4394 afs_status_t tst = 0;
4395 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4396 file_server_p f_server = (file_server_p) serverHandle;
4399 struct volintInfo tstatus;
4400 int active_trans = 0;
4403 * Verify that the cellHandle is capable of making vos rpc's
4406 if (!IsValidCellHandle(c_handle, &tst)) {
4407 goto fail_vos_VolumeQuotaChange;
4410 if (!IsValidServerHandle(f_server, &tst)) {
4411 goto fail_vos_VolumeQuotaChange;
4414 memset((void *)&tstatus, 0, sizeof(tstatus));
4415 tstatus.dayUse = -1;
4416 tstatus.spare2 = -1;
4417 tstatus.maxquota = volumeQuota;
4421 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4423 goto fail_vos_VolumeQuotaChange;
4427 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4429 goto fail_vos_VolumeQuotaChange;
4433 fail_vos_VolumeQuotaChange:
4436 afs_status_t tst2 = 0;
4437 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4458 * vos_VolumeGet2 - get information about a particular volume.
4462 * IN cellHandle - a previously opened cellHandle that corresponds
4463 * to the cell where the volume exists.
4465 * IN serverHandle - a previously opened serverHandle that corresponds
4466 * to the server where the volume exists.
4468 * IN callBack - a call back function pointer that may be called to report
4469 * status information. Can be null.
4471 * IN partition - the partition where the volume exists.
4473 * IN volumeId - the volume id of the volume to be retrieved.
4475 * OUT pinfo - upon successful completion, contains the information about the
4480 * No locks are obtained or released by this function
4484 * Returns != 0 upon successful completion.
4488 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4489 vos_MessageCallBack_t callBack, unsigned int partition,
4490 unsigned int volumeId, volintInfo* pinfo,
4494 afs_status_t tst = 0;
4495 file_server_p f_server = (file_server_p) serverHandle;
4496 volintInfo *pinfo_=0;
4499 * Validate arguments
4502 if (!IsValidServerHandle(f_server, &tst)) {
4503 goto fail_vos_VolumeGet2;
4506 if (partition > VOLMAXPARTS) {
4507 tst = ADMVOSPARTITIONIDTOOLARGE;
4508 goto fail_vos_VolumeGet2;
4511 if (pinfo == NULL) {
4512 tst = ADMVOSVOLUMEPNULL;
4513 goto fail_vos_VolumeGet2;
4517 * Retrieve the information for the volume
4520 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4521 goto fail_vos_VolumeGet2;
4527 fail_vos_VolumeGet2:
4529 if (pinfo_ != NULL) {
4530 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4541 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4545 * IN cellHandle - a previously opened cellHandle that corresponds
4546 * to the cell where the volume exists.
4548 * IN serverHandle - a previously opened serverHandle that corresponds
4549 * to the server where the volume exists.
4551 * IN partition - the partition where the volume exists.
4553 * IN volumeId - the volume id of the volume to be retrieved.
4557 * No locks are obtained or released by this function
4561 * Returns != 0 upon successful completion.
4565 vos_ClearVolUpdateCounter(const void *cellHandle,
4566 const void *serverHandle,
4567 unsigned int partition,
4568 unsigned int volumeId,
4572 afs_status_t tst = 0;
4573 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4574 file_server_p f_server = (file_server_p) serverHandle;
4577 struct volintInfo tstatus;
4578 int active_trans = 0;
4581 * Verify that the cellHandle is capable of making vos rpc's
4584 if (!IsValidCellHandle(c_handle, &tst)) {
4585 goto fail_vos_ClearVolUpdateCounter;
4588 if (!IsValidServerHandle(f_server, &tst)) {
4589 goto fail_vos_ClearVolUpdateCounter;
4592 memset((void *)&tstatus, 0, sizeof(tstatus));
4593 tstatus.maxquota = -1;
4594 tstatus.dayUse = -1;
4595 tstatus.creationDate = -1;
4596 tstatus.updateDate = -1;
4598 tstatus.spare0 = -1;
4599 tstatus.spare1 = -1;
4601 tstatus.spare3 = -1;
4604 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4606 goto fail_vos_ClearVolUpdateCounter;
4610 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4612 goto fail_vos_ClearVolUpdateCounter;
4616 fail_vos_ClearVolUpdateCounter:
4619 afs_status_t tst2 = 0;
4620 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);