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>
30 #include <sys/types.h>
31 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #include <arpa/inet.h>
37 #include "afs_vosAdmin.h"
38 #include "../adminutil/afs_AdminInternal.h"
39 #include <afs/afs_utilAdmin.h>
40 #include <afs/vlserver.h>
41 #include <afs/volser.h>
42 #include <afs/volint.h>
43 #include <afs/partition.h>
47 #include "lockprocs.h"
49 typedef struct file_server {
52 struct rx_connection *serv;
54 } file_server_t, *file_server_p;
57 * IsValidServerHandle - test a server handle for validity.
61 * IN serverHandle - the serverHandle to be validated.
65 * No locks are obtained or released by this function
69 * Returns != 0 upon successful completion.
73 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
78 if (serverHandle == NULL) {
79 tst = ADMVOSSERVERHANDLENULL;
80 goto fail_IsValidServerHandle;
83 if (serverHandle->is_valid != 1) {
84 tst = ADMVOSSERVERHANDLEINVALID;
85 goto fail_IsValidServerHandle;
88 if ((serverHandle->begin_magic != BEGIN_MAGIC)
89 || (serverHandle->end_magic != END_MAGIC)) {
90 tst = ADMVOSSERVERHANDLEBADMAGIC;
91 goto fail_IsValidServerHandle;
95 fail_IsValidServerHandle:
105 * IsValidCellHandle - verify that a cell handle can be used to make vos
110 * IN cellHandle - the cellHandle to be validated.
114 * No locks are obtained or released by this function
118 * Returns != 0 upon successful completion.
122 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
125 afs_status_t tst = 0;
127 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
128 goto fail_IsValidCellHandle;
131 if (cellHandle->vos_valid == 0) {
132 tst = ADMVOSCELLHANDLEINVALIDVOS;
133 goto fail_IsValidCellHandle;
137 fail_IsValidCellHandle:
145 /* set <server> and <part> to the correct values depending on
146 * <voltype> and <entry> */
148 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
149 afs_int32 * part, int *previdx)
151 int i, istart, vtype;
156 /* Doesn't check for non-existance of backup volume */
157 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
159 istart = 0; /* seach the entire entry */
162 /* Seach from beginning of entry or pick up where we left off */
163 istart = ((*previdx < 0) ? 0 : *previdx + 1);
166 for (i = istart; i < entry->nServers; i++) {
167 if (entry->serverFlags[i] & vtype) {
168 *server = entry->serverNumber[i];
169 *part = entry->serverPartition[i];
175 /* Didn't find any, return -1 */
181 * vos_BackupVolumeCreate - create a backup volume for a volume.
185 * IN cellHandle - a previously opened cellHandle that corresponds
186 * to the cell where volume exists.
188 * IN callBack - a call back function pointer that may be called to report
189 * status information. Can be null.
191 * IN volumeId - the volume to create the back up for.
195 * No locks are obtained or released by this function
199 * Returns != 0 upon successful completion.
203 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
204 unsigned int volumeId, afs_status_p st)
207 afs_status_t tst = 0;
208 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
209 struct nvldbentry rw_vol_entry;
211 afs_int32 rw_partition;
212 afs_int32 rw_vol_type;
213 struct nvldbentry bk_vol_entry;
215 afs_int32 bk_partition;
216 afs_int32 bk_vol_type;
223 if (!IsValidCellHandle(c_handle, &tst)) {
224 goto fail_vos_BackupVolumeCreate;
228 * Get the volume information and verify that we've been passed
229 * a read write volume id
233 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
234 &rw_vol_type, &tst)) {
235 goto fail_vos_BackupVolumeCreate;
238 if (rw_vol_type != RWVOL) {
239 tst = ADMVOSMUSTBERWVOL;
240 goto fail_vos_BackupVolumeCreate;
244 * Check to see that if a backup volume exists, it exists on the
245 * same server as volumeId
248 if (rw_vol_entry.flags & BACK_EXISTS) {
250 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
251 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
252 goto fail_vos_BackupVolumeCreate;
254 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
255 goto fail_vos_BackupVolumeCreate;
258 tst = ADMVOSBACKUPVOLWRONGSERVER;
259 goto fail_vos_BackupVolumeCreate;
264 * Create the new backup volume
267 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
269 fail_vos_BackupVolumeCreate:
278 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
282 * IN cellHandle - a previously opened cellHandle that corresponds
283 * to the cell where the volumes exist.
285 * IN serverHandle - the server where the backups are to be created. Can be
288 * IN callBack - a call back function pointer that may be called to report
289 * status information. Can be null.
291 * IN partition - the partition where the backups are to be created. Can be
294 * IN volumePrefix - all volumes with this prefix will have backup volumes
295 * created. Can be null.
297 * IN excludePrefix - exclude the volumes that match volumePrefix.
301 * No locks are obtained or released by this function
305 * Returns != 0 upon successful completion.
309 vos_BackupVolumeCreateMultiple(const void *cellHandle,
310 const void *serverHandle,
311 vos_MessageCallBack_t callBack,
312 const unsigned int *partition,
313 const char *volumePrefix,
314 vos_exclude_t excludePrefix, afs_status_p st)
317 afs_status_t tst = 0;
318 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
319 file_server_p f_server = (file_server_p) serverHandle;
320 struct VldbListByAttributes attr;
323 size_t prefix_len = 0;
324 nbulkentries arrayEntries;
325 afs_int32 nentries = 0;
326 register struct nvldbentry *entry;
328 afs_int32 rw_volid, rw_server, rw_partition;
333 memset((void *)&attr, 0, sizeof(attr));
338 * The only required argument to this function is the cellHandle.
339 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
343 if (!IsValidCellHandle(c_handle, &tst)) {
344 goto fail_vos_BackupVolumeCreateMultiple;
347 if ((excludePrefix == VOS_EXCLUDE)
348 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
349 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
350 goto fail_vos_BackupVolumeCreateMultiple;
353 if (f_server != NULL) {
354 if (!IsValidServerHandle(f_server, &tst)) {
355 goto fail_vos_BackupVolumeCreateMultiple;
357 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
358 attr.Mask |= VLLIST_SERVER;
361 if (partition != NULL) {
362 if (*partition > VOLMAXPARTS) {
363 tst = ADMVOSPARTITIONTOOLARGE;
364 goto fail_vos_BackupVolumeCreateMultiple;
366 attr.partition = *partition;
367 attr.Mask |= VLLIST_PARTITION;
370 if (excludePrefix == VOS_EXCLUDE) {
374 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
376 prefix_len = strlen(volumePrefix);
379 memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
382 * Get a list of all the volumes in the cell
385 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
386 goto fail_vos_BackupVolumeCreateMultiple;
390 * Cycle through the list of volumes and see if we should create a backup
391 * for each individual volume
394 for (i = 0; i < nentries; i++) {
395 entry = &arrayEntries.nbulkentries_val[i];
398 * Skip entries that don't have a RW volume
401 if (!(entry->flags & RW_EXISTS)) {
402 if (callBack != NULL) {
403 const char *messageText;
404 if (util_AdminErrorCodeTranslate
405 (ADMVOSVOLUMENOREADWRITE, 0, &messageText, &tst)) {
406 sprintf(backbuf, "%s %s", messageText, entry->name);
407 (**callBack) (VOS_VERBOSE_MESSAGE, backbuf);
414 * See if we should skip this entry because of the prefix/exclude
415 * combination we've been passed
420 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
424 if (strncmp(entry->name, volumePrefix, prefix_len)) {
430 rw_volid = entry->volumeId[RWVOL];
431 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
433 if ((rw_server == -1) || (rw_partition == -1)) {
434 if (callBack != NULL) {
435 const char *messageText;
436 if (util_AdminErrorCodeTranslate
437 (ADMVOSVLDBBADENTRY, 0, &messageText, &tst)) {
438 sprintf(backbuf, "%s %s", messageText, entry->name);
439 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
446 * Check that the RW volume is on the same server that we were
450 if (serverHandle != NULL) {
451 if (!VLDB_IsSameAddrs
452 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
453 rw_server, &equal, &tst)) {
454 if (callBack != NULL) {
455 const char *messageText;
456 if (util_AdminErrorCodeTranslate
457 (ADMVOSVLDBBADSERVER, 0, &messageText, &tst)) {
458 sprintf(backbuf, "%s %x %d", messageText,
459 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
461 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
467 if (callBack != NULL) {
468 const char *messageText;
469 if (util_AdminErrorCodeTranslate
470 (ADMVOSVLDBDIFFERENTADDR, 0, &messageText, &tst)) {
471 sprintf(backbuf, "%s %s", messageText, entry->name);
472 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
480 * Check that the RW volume is on the same partition we were
484 if (partition != NULL) {
485 if (*partition != rw_partition) {
494 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid,
498 fail_vos_BackupVolumeCreateMultiple:
500 if (arrayEntries.nbulkentries_val) {
501 free(arrayEntries.nbulkentries_val);
511 * vos_PartitionGet - get information about a single partition.
515 * IN cellHandle - a previously opened cellHandle that corresponds
516 * to the cell where the server lives.
518 * IN serverHandle - a previously open vos server handle that holds
519 * the partition of interest.
521 * IN callBack - a call back function pointer that may be called to report
522 * status information. Can be null.
524 * IN partition - the integer that represents the partition of interest.
526 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
527 * completion contains information regarding the partition.
531 * No locks are obtained or released by this function
535 * Returns != 0 upon successful completion.
539 vos_PartitionGet(const void *cellHandle, const void *serverHandle,
540 vos_MessageCallBack_t callBack, unsigned int partition,
541 vos_partitionEntry_p partitionP, afs_status_p st)
544 afs_status_t tst = 0;
545 struct diskPartition part_info;
546 file_server_p f_server = (file_server_p) serverHandle;
547 char partitionName[10]; /* this rpc requires a character partition name */
553 if (!IsValidServerHandle(f_server, &tst)) {
554 goto fail_vos_PartitionGet;
557 if (partitionP == NULL) {
558 tst = ADMVOSPARTITIONPNULL;
559 goto fail_vos_PartitionGet;
562 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
563 goto fail_vos_PartitionGet;
566 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
568 goto fail_vos_PartitionGet;
570 strcpy(partitionP->name, part_info.name);
571 strcpy(partitionP->deviceName, part_info.devName);
572 partitionP->lockFileDescriptor = part_info.lock_fd;
573 partitionP->totalSpace = part_info.minFree;
574 partitionP->totalFreeSpace = part_info.free;
577 fail_vos_PartitionGet:
586 * The iterator functions and data for the partition retrieval functions.
589 typedef struct partition_get {
590 afs_int32 total_received; /* the total number of valid partiions retrieved */
591 int number_processed; /* the number of valid paritions we've handed out */
592 int index; /* the current index into the part_list array */
593 struct partList part_list; /* the list of partitions */
594 vos_partitionEntry_t partition[CACHED_ITEMS]; /* the cache of partitions */
595 const void *server; /* the server where the parititions exist */
596 } partition_get_t, *partition_get_p;
599 GetPartitionInfoRPC(void *rpc_specific, int slot, int *last_item,
600 int *last_item_contains_data, afs_status_p st)
603 afs_status_t tst = 0;
604 partition_get_p part = (partition_get_p) rpc_specific;
605 vos_partitionEntry_p ptr = (vos_partitionEntry_p) & part->partition[slot];
608 * Skip partition entries that are not valid
611 while (!(part->part_list.partFlags[part->index] & PARTVALID)) {
616 * Get information for the next partition
619 if (!vos_PartitionGet
621 (unsigned int)part->part_list.partId[part->index], ptr, &tst)) {
622 goto fail_GetPartitionInfoRPC;
626 part->number_processed++;
628 if (part->number_processed == part->total_received) {
630 *last_item_contains_data = 1;
634 fail_GetPartitionInfoRPC:
643 GetPartitionInfoFromCache(void *rpc_specific, int slot, void *dest,
647 afs_status_t tst = 0;
648 partition_get_p part = (partition_get_p) rpc_specific;
650 memcpy(dest, (const void *)&part->partition[slot],
651 sizeof(vos_partitionEntry_t));
661 * vos_PartitionGetBegin - begin to iterate over the partitions at a
666 * IN cellHandle - a previously opened cellHandle that corresponds
667 * to the cell where the server exists.
669 * IN serverHandle - the server that houses the partitions of interest.
671 * IN callBack - a call back function pointer that may be called to report
672 * status information. Can be null.
674 * OUT iterationIdP - upon successful completion, contains an iterator that can
675 * be passed to vos_PartitionGetNext.
679 * No locks are obtained or released by this function
683 * Returns != 0 upon successful completion.
687 vos_PartitionGetBegin(const void *cellHandle, const void *serverHandle,
688 vos_MessageCallBack_t callBack, void **iterationIdP,
692 afs_status_t tst = 0;
693 file_server_p f_server = (file_server_p) serverHandle;
694 afs_admin_iterator_p iter =
695 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
696 partition_get_p part =
697 (partition_get_p) calloc(1, sizeof(partition_get_t));
703 if (!IsValidServerHandle(f_server, &tst)) {
704 goto fail_vos_PartitionGetBegin;
707 if (iterationIdP == NULL) {
708 goto fail_vos_PartitionGetBegin;
711 if ((iter == NULL) || (part == NULL)) {
713 goto fail_vos_PartitionGetBegin;
717 * Fill in the part structure
720 part->server = serverHandle;
721 if (!UV_ListPartitions
722 (f_server->serv, &part->part_list, &part->total_received, &tst)) {
723 goto fail_vos_PartitionGetBegin;
727 * If we didn't receive any partitions, don't spawn a background thread.
728 * Mark the iterator complete.
731 if (part->total_received == 0) {
732 if (!IteratorInit(iter, (void *)part, NULL, NULL, NULL, NULL, &tst)) {
733 goto fail_vos_PartitionGetBegin;
735 iter->done_iterating = 1;
736 iter->st = ADMITERATORDONE;
739 (iter, (void *)part, GetPartitionInfoRPC,
740 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
741 goto fail_vos_PartitionGetBegin;
744 *iterationIdP = (void *)iter;
747 fail_vos_PartitionGetBegin:
765 * vos_PartitionGetNext - get the next partition at a server.
769 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
771 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
772 * completion contains the next partition.
776 * The iterator is locked while the next parition is retrieved.
780 * Returns != 0 upon successful completion.
784 vos_PartitionGetNext(const void *iterationId, vos_partitionEntry_p partitionP,
788 afs_status_t tst = 0;
789 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
792 tst = ADMITERATORNULL;
793 goto fail_vos_PartitionGetNext;
796 if (partitionP == NULL) {
797 tst = ADMVOSPARTITIONPNULL;
798 goto fail_vos_PartitionGetNext;
801 rc = IteratorNext(iter, (void *)partitionP, &tst);
803 fail_vos_PartitionGetNext:
812 * vos_PartitionGetDone - finish using a partition iterator.
816 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
820 * The iterator is locked and then destroyed.
824 * Returns != 0 upon successful completion.
828 vos_PartitionGetDone(const void *iterationId, afs_status_p st)
831 afs_status_t tst = 0;
832 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
839 tst = ADMITERATORNULL;
840 goto fail_vos_PartitionGetDone;
843 rc = IteratorDone(iter, &tst);
845 fail_vos_PartitionGetDone:
854 * vos_ServerOpen - open a handle to an individual server for future
859 * IN cellHandle - a previously opened cellHandle that corresponds
860 * to the cell where the server lives.
862 * IN serverName - the machine name of the server
864 * OUT serverHandleP - a void pointer that upon successful completion
865 * contains a handle that is used in future operations upon the server.
869 * No locks are obtained or released by this function
873 * Returns != 0 upon successful completion.
877 vos_ServerOpen(const void *cellHandle, const char *serverName,
878 void **serverHandleP, afs_status_p st)
881 afs_status_t tst = 0;
882 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
883 file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
885 struct rx_securityClass *sc[3];
888 if (f_server == NULL) {
890 goto fail_vos_ServerOpen;
897 if (!IsValidCellHandle(c_handle, &tst)) {
898 goto fail_vos_ServerOpen;
901 if (!c_handle->tokens->afs_token_set) {
902 tst = ADMVOSCELLHANDLENOAFSTOKENS;
903 goto fail_vos_ServerOpen;
906 if (!util_AdminServerAddressGetFromName
907 (serverName, &server_address, &tst)) {
908 goto fail_vos_ServerOpen;
911 scIndex = c_handle->tokens->sc_index;
912 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
914 rx_GetCachedConnection(htonl(server_address),
915 htons(AFSCONF_VOLUMEPORT), VOLSERVICE_ID,
916 sc[scIndex], scIndex);
917 if (f_server->serv != NULL) {
918 f_server->begin_magic = BEGIN_MAGIC;
919 f_server->end_magic = END_MAGIC;
920 f_server->is_valid = 1;
921 *serverHandleP = (void *)f_server;
924 tst = ADMVOSSERVERNOCONNECTION;
925 goto fail_vos_ServerOpen;
937 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
941 * IN serverHandle - an existing server handle.
945 * No locks are obtained or released by this function
949 * Returns != 0 upon successful completion.
953 vos_ServerClose(const void *serverHandle, afs_status_p st)
956 afs_status_t tst = 0;
957 file_server_p f_server = (file_server_p) serverHandle;
959 if (!IsValidServerHandle(f_server, &tst)) {
960 goto fail_vos_ServerClose;
963 rx_ReleaseCachedConnection(f_server->serv);
964 f_server->is_valid = 0;
968 fail_vos_ServerClose:
977 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
982 * IN cellHandle - a previously opened cellHandle that corresponds
983 * to the cell where the server lives.
985 * IN serverHandle - a handle to the server machine.
987 * IN callBack - a call back function pointer that may be called to report
988 * status information. Can be null.
990 * IN partition - the partition to synchronize. Can be NULL.
992 * IN force - force deletion of bad volumes.
996 * No locks are obtained or released by this function
1000 * Returns != 0 upon successful completion.
1004 vos_ServerSync(const void *cellHandle, const void *serverHandle,
1005 vos_MessageCallBack_t callBack, const unsigned int *partition,
1009 afs_status_t tst = 0;
1010 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1011 file_server_p f_server = (file_server_p) serverHandle;
1016 * Validate arguments
1019 if (!IsValidCellHandle(c_handle, &tst)) {
1020 goto fail_vos_ServerSync;
1023 if (!IsValidServerHandle(f_server, &tst)) {
1024 goto fail_vos_ServerSync;
1027 if (partition != NULL) {
1028 if (*partition > VOLMAXPARTS) {
1029 tst = ADMVOSPARTITIONTOOLARGE;
1030 goto fail_vos_ServerSync;
1032 part = (afs_int32) * partition;
1040 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1042 fail_vos_ServerSync:
1051 * vos_FileServerAddressChange - change an existing file server address.
1055 * IN cellHandle - a previously opened cellHandle that corresponds
1056 * to the cell where the address should be changed.
1058 * IN callBack - a call back function pointer that may be called to report
1059 * status information. Can be null.
1061 * IN oldAddress - the old server address in host byte order
1063 * IN newAddress - the new server address in host byte order
1067 * No locks are obtained or released by this function
1071 * Returns != 0 upon successful completion.
1075 vos_FileServerAddressChange(const void *cellHandle,
1076 vos_MessageCallBack_t callBack, int oldAddress,
1077 int newAddress, afs_status_p st)
1080 afs_status_t tst = 0;
1081 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1084 * Validate arguments
1087 if (!IsValidCellHandle(c_handle, &tst)) {
1088 goto fail_vos_FileServerAddressChange;
1092 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, oldAddress,
1095 goto fail_vos_FileServerAddressChange;
1099 fail_vos_FileServerAddressChange:
1108 * vos_FileServerAddressRemove - remove an existing file server address.
1112 * IN cellHandle - a previously opened cellHandle that corresponds
1113 * to the cell where the address should be removed.
1115 * IN callBack - a call back function pointer that may be called to report
1116 * status information. Can be null.
1118 * IN serverAddress - the server address to remove in host byte order.
1122 * No locks are obtained or released by this function
1126 * Returns != 0 upon successful completion.
1130 vos_FileServerAddressRemove(const void *cellHandle,
1131 vos_MessageCallBack_t callBack, int serverAddress,
1135 afs_status_t tst = 0;
1136 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1137 int dummyAddress = 0xffffffff;
1140 * Validate arguments
1143 if (!IsValidCellHandle(c_handle, &tst)) {
1144 goto fail_vos_FileServerAddressRemove;
1148 ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, dummyAddress,
1151 goto fail_vos_FileServerAddressRemove;
1155 fail_vos_FileServerAddressRemove:
1164 * The iterator functions and data for the server retrieval functions.
1166 * These functions are very similar to the FileServerAddressGet
1167 * functions. The main difference being that instead of returning
1168 * a single address at a time for a server, we fill an array with
1169 * all the addresses of a server.
1172 typedef struct server_get {
1173 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1174 afs_int32 total_addresses; /* total number of addresses */
1175 bulkaddrs addresses; /* the list of addresses */
1176 int address_index; /* current index into address list */
1177 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1178 } server_get_t, *server_get_p;
1181 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1182 int *last_item_contains_data, afs_status_p st)
1185 afs_status_t tst = 0;
1186 server_get_p serv = (server_get_p) rpc_specific;
1187 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1188 afs_int32 base, index;
1191 ListAddrByAttributes m_attrs;
1192 afs_int32 total_multi;
1193 bulkaddrs addr_multi;
1197 * Check to see if this is a multihomed address server
1200 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1201 base = (*addrP >> 16) & 0xff;
1202 index = (*addrP) & 0xffff;
1204 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1205 && (index <= VL_MHSRV_PERBLK)) {
1208 * This is a multihomed server. Make an rpc to retrieve
1209 * all its addresses. Copy the addresses into the cache.
1212 m_attrs.Mask = VLADDR_INDEX;
1213 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1215 addr_multi.bulkaddrs_val = 0;
1216 addr_multi.bulkaddrs_len = 0;
1218 ubik_Call(VL_GetAddrsU, serv->vldb, 0, &m_attrs, &m_uuid,
1219 &m_unique, &total_multi, &addr_multi);
1221 goto fail_GetServerRPC;
1225 * Remove any bogus IP addresses which the user may have
1226 * been unable to remove.
1229 RemoveBadAddresses(&total_multi, &addr_multi);
1232 * Copy all the addresses into the cache
1235 for (i = 0; i < total_multi; i++) {
1236 serv->server[slot].serverAddress[i] =
1237 addr_multi.bulkaddrs_val[i];
1240 serv->server[slot].count = total_multi;
1241 serv->address_index++;
1242 free(addr_multi.bulkaddrs_val);
1246 * The next address is just a plain old address
1250 serv->server[slot].serverAddress[0] = *addrP;
1251 serv->server[slot].count = 1;
1252 serv->address_index++;
1256 * See if we've processed all the entries
1260 if (serv->address_index == serv->total_addresses) {
1262 *last_item_contains_data = 1;
1275 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1278 afs_status_t tst = 0;
1279 server_get_p serv = (server_get_p) rpc_specific;
1281 memcpy(dest, (const void *)&serv->server[slot],
1282 sizeof(vos_fileServerEntry_t));
1293 DestroyServer(void *rpc_specific, afs_status_p st)
1296 afs_status_t tst = 0;
1297 server_get_p serv = (server_get_p) rpc_specific;
1299 if (serv->addresses.bulkaddrs_val != NULL) {
1300 free(serv->addresses.bulkaddrs_val);
1311 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1315 * IN cellHandle - a previously opened cellHandle that corresponds
1316 * to the cell where the file servers exist.
1318 * IN callBack - a call back function pointer that may be called to report
1319 * status information. Can be null.
1321 * OUT iterationIdP - upon successful completion, contains an iterator that
1322 * can be passed to vos_FileServerGetNext.
1326 * No locks are obtained or released by this function
1330 * Returns != 0 upon successful completion.
1334 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1335 void **iterationIdP, afs_status_p st)
1338 afs_status_t tst = 0;
1339 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1340 afs_admin_iterator_p iter =
1341 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1342 server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
1343 struct VLCallBack unused;
1347 * Validate arguments
1350 if (!IsValidCellHandle(c_handle, &tst)) {
1351 goto fail_vos_FileServerGetBegin;
1354 if (iterationIdP == NULL) {
1355 goto fail_vos_FileServerGetBegin;
1358 if ((iter == NULL) || (serv == NULL)) {
1360 goto fail_vos_FileServerGetBegin;
1364 * Fill in the serv structure
1367 serv->vldb = c_handle->vos;
1369 ubik_Call_New(VL_GetAddrs, c_handle->vos, 0, 0, 0, &unused,
1370 &serv->total_addresses, &serv->addresses);
1373 goto fail_vos_FileServerGetBegin;
1377 * Remove any bogus IP addresses which the user may have
1378 * been unable to remove.
1381 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1383 if (serv->total_addresses == 0) {
1384 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1385 goto fail_vos_FileServerGetBegin;
1387 iter->done_iterating = 1;
1388 iter->st = ADMITERATORDONE;
1391 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1392 DestroyServer, &tst)) {
1393 goto fail_vos_FileServerGetBegin;
1396 *iterationIdP = (void *)iter;
1399 fail_vos_FileServerGetBegin:
1406 if (serv->addresses.bulkaddrs_val != NULL) {
1407 free(serv->addresses.bulkaddrs_val);
1420 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1424 * IN iterationId - an iterator previously returned by
1425 * vos_FileServerGetBegin
1427 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1428 * completion contains information about the next server in the cell.
1432 * The iterator is locked while the next server is retrieved.
1436 * Returns != 0 upon successful completion.
1440 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1444 afs_status_t tst = 0;
1445 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1448 tst = ADMITERATORNULL;
1449 goto fail_vos_FileServerGetNext;
1452 if (serverEntryP == NULL) {
1453 tst = ADMVOSSERVERENTRYPNULL;
1454 goto fail_vos_FileServerGetNext;
1457 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1459 fail_vos_FileServerGetNext:
1468 * vos_FileServerGetDone - finish using a partition iterator.
1472 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1476 * The iterator is locked and then destroyed.
1480 * Returns != 0 upon successful completion.
1484 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1487 afs_status_t tst = 0;
1488 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1491 * Validate arguments
1495 tst = ADMITERATORNULL;
1496 goto fail_vos_FileServerGetDone;
1499 rc = IteratorDone(iter, &tst);
1501 fail_vos_FileServerGetDone:
1510 * The iterator functions and data for the transation retrieval functions.
1513 typedef struct transaction_get {
1514 afs_int32 total; /* total number of transactions */
1515 afs_int32 index; /* index to the current transaction */
1516 transDebugInfo *cur; /* the current transaction */
1517 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1518 } transaction_get_t, *transaction_get_p;
1521 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1522 int *last_item_contains_data, afs_status_p st)
1525 afs_status_t tst = 0;
1526 transaction_get_p t = (transaction_get_p) rpc_specific;
1527 int index = t->index;
1530 * Copy the next transaction into the cache
1533 t->tran[slot].transactionId = t->cur[index].tid;
1534 t->tran[slot].lastActiveTime = t->cur[index].time;
1535 t->tran[slot].creationTime = t->cur[index].creationTime;
1536 t->tran[slot].errorCode = t->cur[index].returnCode;
1537 t->tran[slot].volumeId = t->cur[index].volid;
1538 t->tran[slot].partition = t->cur[index].partition;
1539 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1540 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1541 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1542 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1543 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1545 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1547 switch (t->cur[index].iflags) {
1549 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1552 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1555 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1558 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1561 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1565 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1567 switch (t->cur[index].vflags) {
1568 case VTDeleteOnSalvage:
1569 t->tran[slot].volumeActiveStatus =
1570 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1572 case VTOutOfService:
1573 t->tran[slot].volumeActiveStatus =
1574 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1577 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1581 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1583 if (t->cur[index].tflags) {
1584 t->tran[slot].volumeTransactionStatus =
1585 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1591 * See if we've processed all the entries
1595 if (t->index == t->total) {
1597 *last_item_contains_data = 1;
1608 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1612 afs_status_t tst = 0;
1613 transaction_get_p tran = (transaction_get_p) rpc_specific;
1615 memcpy(dest, (const void *)&tran->tran[slot],
1616 sizeof(vos_serverTransactionStatus_p));
1627 DestroyTransaction(void *rpc_specific, afs_status_p st)
1630 afs_status_t tst = 0;
1631 transaction_get_p tran = (transaction_get_p) rpc_specific;
1633 if (tran->cur != NULL) {
1645 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1646 * at a volume server.
1650 * IN cellHandle - a previously opened cellHandle that corresponds
1651 * to the cell where the volume server exists.
1653 * IN serverHandle - a handle to the server to query.
1655 * IN callBack - a call back function pointer that may be called to report
1656 * status information. Can be null.
1658 * OUT iterationIdP - upon successful completion, contains an iterator that
1659 * can be passed to vos_ServerTransactionStatusGetNext.
1663 * No locks are obtained or released by this function
1667 * Returns != 0 upon successful completion.
1671 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1672 const void *serverHandle,
1673 vos_MessageCallBack_t callBack,
1674 void **iterationIdP, afs_status_p st)
1677 afs_status_t tst = 0;
1678 file_server_p f_server = (file_server_p) serverHandle;
1679 afs_admin_iterator_p iter =
1680 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1681 transaction_get_p tran =
1682 (transaction_get_p) calloc(1, sizeof(transaction_get_t));
1686 * Validate arguments
1689 if (!IsValidServerHandle(f_server, &tst)) {
1690 goto fail_vos_ServerTransactionStatusGetBegin;
1693 if (iterationIdP == NULL) {
1694 goto fail_vos_ServerTransactionStatusGetBegin;
1697 if ((iter == NULL) || (tran == NULL)) {
1699 goto fail_vos_ServerTransactionStatusGetBegin;
1703 * Fill in the tran structure
1706 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1707 goto fail_vos_ServerTransactionStatusGetBegin;
1710 if (tran->total == 0) {
1711 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1712 goto fail_vos_ServerTransactionStatusGetBegin;
1714 iter->done_iterating = 1;
1715 iter->st = ADMITERATORDONE;
1718 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1719 NULL, DestroyTransaction, &tst)) {
1720 goto fail_vos_ServerTransactionStatusGetBegin;
1723 *iterationIdP = (void *)iter;
1726 fail_vos_ServerTransactionStatusGetBegin:
1733 if (tran->cur != NULL) {
1747 * vos_ServerTransactionStatusGetNext - get information about the next
1748 * active transaction.
1752 * IN iterationId - an iterator previously returned by
1753 * vos_ServerTransactionStatusGetBegin
1755 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1756 * that upon successful completion contains information about the
1761 * The iterator is locked while the next item is retrieved.
1765 * Returns != 0 upon successful completion.
1769 vos_ServerTransactionStatusGetNext(const void *iterationId,
1770 vos_serverTransactionStatus_p
1771 serverTransactionStatusP, afs_status_p st)
1774 afs_status_t tst = 0;
1775 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1778 tst = ADMITERATORNULL;
1779 goto fail_vos_ServerTransactionStatusGetNext;
1782 if (serverTransactionStatusP == NULL) {
1783 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1784 goto fail_vos_ServerTransactionStatusGetNext;
1787 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1789 fail_vos_ServerTransactionStatusGetNext:
1798 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1802 * IN iterationId - an iterator previously returned by
1803 * vos_ServerTransactionStatusGetBegin
1807 * The iterator is locked and then destroyed.
1811 * Returns != 0 upon successful completion.
1815 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1818 afs_status_t tst = 0;
1819 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1822 * Validate arguments
1826 tst = ADMITERATORNULL;
1827 goto fail_vos_ServerTransactionStatusGetDone;
1830 rc = IteratorDone(iter, &tst);
1832 fail_vos_ServerTransactionStatusGetDone:
1841 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1845 afs_status_t tst = 0;
1848 dest->numServers = source->nServers;
1849 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1850 dest->volumeId[i] = source->volumeId[i];
1852 dest->cloneId = source->cloneId;
1853 dest->status = VOS_VLDB_ENTRY_OK;
1854 if (source->flags & VLOP_ALLOPERS) {
1855 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1857 if (source->flags & VLOP_MOVE) {
1858 dest->status |= VOS_VLDB_ENTRY_MOVE;
1860 if (source->flags & VLOP_RELEASE) {
1861 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1863 if (source->flags & VLOP_BACKUP) {
1864 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1866 if (source->flags & VLOP_DELETE) {
1867 dest->status |= VOS_VLDB_ENTRY_DELETE;
1869 if (source->flags & VLOP_DUMP) {
1870 dest->status |= VOS_VLDB_ENTRY_DUMP;
1873 if (source->flags & VLF_RWEXISTS) {
1874 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1876 if (source->flags & VLF_ROEXISTS) {
1877 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1879 if (source->flags & VLF_BACKEXISTS) {
1880 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1883 strcpy(dest->name, source->name);
1884 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1885 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1886 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1887 dest->volumeSites[i].serverFlags = 0;
1889 if (source->serverFlags[i] & NEW_REPSITE) {
1890 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1892 if (source->serverFlags[i] & ITSROVOL) {
1893 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1895 if (source->serverFlags[i] & ITSRWVOL) {
1896 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1898 if (source->serverFlags[i] & ITSBACKVOL) {
1899 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1901 if (source->serverFlags[i] & RO_DONTUSE) {
1902 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1915 * vos_VLDBGet- get a volume's vldb entry.
1919 * IN cellHandle - a previously opened cellHandle that corresponds
1920 * to the cell where the volume entries exist.
1922 * IN callBack - a call back function pointer that may be called to report
1923 * status information. Can be null.
1925 * IN volumeId - the id of the volume to retrieve.
1927 * IN volumeName - the name of the volume to retrieve.
1929 * OUT vldbEntry - upon successful completion, contains the information regarding
1934 * No locks are obtained or released by this function
1938 * Returns != 0 upon successful completion.
1942 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1943 const unsigned int *volumeId, const char *volumeName,
1944 vos_vldbEntry_p vldbEntry, afs_status_p st)
1947 afs_status_t tst = 0;
1948 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1949 struct nvldbentry entry;
1953 * Validate arguments
1956 if (!IsValidCellHandle(c_handle, &tst)) {
1957 goto fail_vos_VLDBGet;
1960 if (vldbEntry == NULL) {
1961 tst = ADMVOSVLDBENTRYNULL;
1962 goto fail_vos_VLDBGet;
1965 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1966 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1967 goto fail_vos_VLDBGet;
1971 * Retrieve the entry
1974 if (!((volumeName == NULL) || (*volumeName == 0))) {
1975 if (!ValidateVolumeName(volumeName, &tst)) {
1976 goto fail_vos_VLDBGet;
1978 if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1979 goto fail_vos_VLDBGet;
1982 if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1983 goto fail_vos_VLDBGet;
1988 * Copy the entry into our structure
1991 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1992 goto fail_vos_VLDBGet;
2005 * The iterator functions and data for the vldb entry retrieval functions.
2008 typedef struct vldb_entry_get {
2009 afs_int32 total; /* total number of vldb entries */
2010 afs_int32 index; /* index to the current vldb entry */
2011 nbulkentries entries; /* the list of entries retrieved */
2012 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2013 } vldb_entry_get_t, *vldb_entry_get_p;
2016 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2017 int *last_item_contains_data, afs_status_p st)
2020 afs_status_t tst = 0;
2021 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2024 * Copy the next entry into the cache
2028 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2030 goto fail_GetVLDBEntryRPC;
2035 * See if we've processed all the entries
2039 if (entry->index == entry->total) {
2041 *last_item_contains_data = 1;
2045 fail_GetVLDBEntryRPC:
2054 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2058 afs_status_t tst = 0;
2059 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2061 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2072 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2075 afs_status_t tst = 0;
2076 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2078 if (entry->entries.nbulkentries_val != NULL) {
2079 free(entry->entries.nbulkentries_val);
2091 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2095 * IN cellHandle - a previously opened cellHandle that corresponds
2096 * to the cell where the volume entries exist.
2098 * IN serverHandle - a handle to the server whose entries should be listed.
2101 * IN callBack - a call back function pointer that may be called to report
2102 * status information. Can be null.
2104 * IN partition - the partition whose entries should be listed.
2107 * OUT iterationIdP - upon successful completion, contains an iterator that
2108 * can be passed to vos_VLDBGetNext.
2112 * No locks are obtained or released by this function
2116 * Returns != 0 upon successful completion.
2120 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2121 vos_MessageCallBack_t callBack, unsigned int *partition,
2122 void **iterationIdP, afs_status_p st)
2125 afs_status_t tst = 0;
2126 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2127 file_server_p f_server = (file_server_p) serverHandle;
2128 afs_admin_iterator_p iter =
2129 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2130 vldb_entry_get_p entry =
2131 (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2132 struct VldbListByAttributes attr;
2135 memset(&attr, 0, sizeof(attr));
2138 * Validate arguments
2141 if (!IsValidCellHandle(c_handle, &tst)) {
2142 goto fail_vos_VLDBGetBegin;
2145 if ((iter == NULL) || (entry == NULL)) {
2147 goto fail_vos_VLDBGetBegin;
2150 if (f_server != NULL) {
2151 if (!IsValidServerHandle(f_server, &tst)) {
2152 goto fail_vos_VLDBGetBegin;
2154 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2155 attr.Mask |= VLLIST_SERVER;
2158 if (partition != NULL) {
2159 if (*partition > VOLMAXPARTS) {
2160 tst = ADMVOSPARTITIONTOOLARGE;
2161 goto fail_vos_VLDBGetBegin;
2163 attr.partition = *partition;
2164 attr.Mask |= VLLIST_PARTITION;
2167 if (!VLDB_ListAttributes
2168 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2169 goto fail_vos_VLDBGetBegin;
2172 if (entry->total <= 0) {
2173 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2174 goto fail_vos_VLDBGetBegin;
2176 iter->done_iterating = 1;
2177 iter->st = ADMITERATORDONE;
2180 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2181 NULL, DestroyVLDBEntry, &tst)) {
2182 goto fail_vos_VLDBGetBegin;
2185 *iterationIdP = (void *)iter;
2188 fail_vos_VLDBGetBegin:
2194 if (entry->entries.nbulkentries_val != NULL) {
2195 free(entry->entries.nbulkentries_val);
2197 if (entry != NULL) {
2209 * vos_VLDBGetNext - get information about the next volume.
2213 * IN iterationId - an iterator previously returned by
2216 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2217 * that upon successful completion contains information about the
2222 * The iterator is locked while the next item is retrieved.
2226 * Returns != 0 upon successful completion.
2230 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2234 afs_status_t tst = 0;
2235 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2238 tst = ADMITERATORNULL;
2239 goto fail_vos_VLDBGetNext;
2242 if (vldbEntry == NULL) {
2243 tst = ADMVOSVLDBENTRYNULL;
2244 goto fail_vos_VLDBGetNext;
2247 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2249 fail_vos_VLDBGetNext:
2258 * vos_VLDBGetDone - finish using a volume iterator.
2262 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2266 * The iterator is locked and then destroyed.
2270 * Returns != 0 upon successful completion.
2274 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2277 afs_status_t tst = 0;
2278 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2281 * Validate arguments
2285 tst = ADMITERATORNULL;
2286 goto fail_vos_VLDBGetDone;
2289 rc = IteratorDone(iter, &tst);
2291 fail_vos_VLDBGetDone:
2300 * vos_VLDBEntryRemove - remove a vldb entry.
2304 * IN cellHandle - a previously opened cellHandle that corresponds
2305 * to the cell where the vldb entry exists.
2307 * IN serverHandle - a previously opened serverHandle that corresponds
2308 * to the server where the vldb entry exists. Can be null.
2310 * IN callBack - a call back function pointer that may be called to report
2311 * status information. Can be null.
2313 * IN partition - the partition where the vldb entry exists. Can be null.
2315 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2319 * No locks are obtained or released by this function
2323 * Returns != 0 upon successful completion.
2327 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2328 vos_MessageCallBack_t callBack,
2329 const unsigned int *partition, unsigned int *volumeId,
2333 afs_status_t tst = 0;
2334 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2335 file_server_p f_server = (file_server_p) serverHandle;
2336 struct VldbListByAttributes attr;
2337 nbulkentries entries;
2341 memset(&attr, 0, sizeof(attr));
2342 memset(&entries, 0, sizeof(entries));
2345 * Validate arguments
2348 if (!IsValidCellHandle(c_handle, &tst)) {
2349 goto fail_vos_VLDBEntryRemove;
2353 * If the volume is specified, just delete it
2356 if (volumeId != NULL) {
2357 tst = ubik_Call(VL_DeleteEntry, c_handle->vos, 0, *volumeId, -1);
2359 goto fail_vos_VLDBEntryRemove;
2363 if (f_server != NULL) {
2364 if (!IsValidServerHandle(f_server, &tst)) {
2365 goto fail_vos_VLDBEntryRemove;
2367 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2368 attr.Mask |= VLLIST_SERVER;
2371 if (partition != NULL) {
2372 if (*partition > VOLMAXPARTS) {
2373 tst = ADMVOSPARTITIONTOOLARGE;
2374 goto fail_vos_VLDBEntryRemove;
2376 attr.partition = *partition;
2377 attr.Mask |= VLLIST_PARTITION;
2380 if ((f_server == NULL) && (partition == NULL)) {
2381 tst = ADMVOSVLDBDELETEALLNULL;
2382 goto fail_vos_VLDBEntryRemove;
2385 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2386 goto fail_vos_VLDBEntryRemove;
2389 if (nentries <= 0) {
2390 tst = ADMVOSVLDBNOENTRIES;
2391 goto fail_vos_VLDBEntryRemove;
2394 for (i = 0; i < nentries; i++) {
2395 ubik_Call(VL_DeleteEntry, c_handle->vos, 0,
2396 entries.nbulkentries_val[i].volumeId[RWVOL]);
2400 fail_vos_VLDBEntryRemove:
2402 if (entries.nbulkentries_val) {
2403 free(entries.nbulkentries_val);
2413 * vos_VLDBUnlock - unlock vldb entries en masse.
2417 * IN cellHandle - a previously opened cellHandle that corresponds
2418 * to the cell where the vldb entries exist.
2420 * IN serverHandle - a previously opened serverHandle that corresponds
2421 * to the server where the vldb entries exist. Can be null.
2423 * IN callBack - a call back function pointer that may be called to report
2424 * status information. Can be null.
2426 * IN partition - the partition where the vldb entries exist. Can be null.
2430 * No locks are obtained or released by this function
2434 * Returns != 0 upon successful completion.
2438 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2439 vos_MessageCallBack_t callBack, const unsigned int *partition,
2443 afs_status_t tst = 0;
2444 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2445 file_server_p f_server = (file_server_p) serverHandle;
2446 struct VldbListByAttributes attr;
2447 nbulkentries entries;
2451 memset(&attr, 0, sizeof(attr));
2452 memset(&entries, 0, sizeof(entries));
2455 * Validate arguments
2458 if (!IsValidCellHandle(c_handle, &tst)) {
2459 goto fail_vos_VLDBUnlock;
2462 if (f_server != NULL) {
2463 if (!IsValidServerHandle(f_server, &tst)) {
2464 goto fail_vos_VLDBUnlock;
2466 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2467 attr.Mask |= VLLIST_SERVER;
2470 if (partition != NULL) {
2471 if (*partition > VOLMAXPARTS) {
2472 tst = ADMVOSPARTITIONTOOLARGE;
2473 goto fail_vos_VLDBUnlock;
2475 attr.partition = *partition;
2476 attr.Mask |= VLLIST_PARTITION;
2478 attr.flag = VLOP_ALLOPERS;
2479 attr.Mask |= VLLIST_FLAG;
2482 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2483 goto fail_vos_VLDBUnlock;
2486 if (nentries <= 0) {
2487 tst = ADMVOSVLDBNOENTRIES;
2488 goto fail_vos_VLDBUnlock;
2491 for (i = 0; i < nentries; i++) {
2492 vos_VLDBEntryUnlock(cellHandle, 0,
2493 entries.nbulkentries_val[i].volumeId[RWVOL],
2498 fail_vos_VLDBUnlock:
2500 if (entries.nbulkentries_val) {
2501 free(entries.nbulkentries_val);
2512 * vos_VLDBEntryLock - lock a vldb entry.
2516 * IN cellHandle - a previously opened cellHandle that corresponds
2517 * to the cell where the vldb entry exists.
2519 * IN callBack - a call back function pointer that may be called to report
2520 * status information. Can be null.
2522 * IN volumeId - the volume id of the vldb entry to be deleted.
2526 * No locks are obtained or released by this function
2530 * Returns != 0 upon successful completion.
2534 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2535 unsigned int volumeId, afs_status_p st)
2538 afs_status_t tst = 0;
2539 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2542 * Validate arguments
2545 if (!IsValidCellHandle(c_handle, &tst)) {
2546 goto fail_vos_VLDBEntryLock;
2549 tst = ubik_Call(VL_SetLock, c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2551 goto fail_vos_VLDBEntryLock;
2555 fail_vos_VLDBEntryLock:
2564 * vos_VLDBEntryUnlock - unlock a vldb entry.
2568 * IN cellHandle - a previously opened cellHandle that corresponds
2569 * to the cell where the vldb entry exists.
2571 * IN callBack - a call back function pointer that may be called to report
2572 * status information. Can be null.
2574 * IN volumeId - the volume id of the vldb entry to be unlocked.
2578 * No locks are obtained or released by this function
2582 * Returns != 0 upon successful completion.
2586 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2587 unsigned int volumeId, afs_status_p st)
2590 afs_status_t tst = 0;
2591 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2594 * Validate arguments
2597 if (!IsValidCellHandle(c_handle, &tst)) {
2598 goto fail_vos_VLDBEntryUnlock;
2603 ubik_Call(VL_ReleaseLock, c_handle->vos, 0, volumeId, -1,
2604 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2606 goto fail_vos_VLDBEntryUnlock;
2610 fail_vos_VLDBEntryUnlock:
2619 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2623 * IN cellHandle - a previously opened cellHandle that corresponds
2624 * to the cell where the volume exists.
2626 * IN serverHandle - a previously opened serverHandle that corresponds
2627 * to the server where the new volume should be created.
2629 * IN callBack - a call back function pointer that may be called to report
2630 * status information. Can be null.
2632 * IN partition - the partition where then new volume should be created.
2634 * IN volumeId - the volume id of the volume to be replicated.
2638 * No locks are obtained or released by this function
2642 * Returns != 0 upon successful completion.
2646 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2647 vos_MessageCallBack_t callBack,
2648 unsigned int partition, unsigned int volumeId,
2652 afs_status_t tst = 0;
2653 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2654 file_server_p f_server = (file_server_p) serverHandle;
2657 * Validate arguments
2660 if (!IsValidCellHandle(c_handle, &tst)) {
2661 goto fail_vos_VLDBReadOnlySiteCreate;
2664 if (!IsValidServerHandle(f_server, &tst)) {
2665 goto fail_vos_VLDBReadOnlySiteCreate;
2668 if (partition > VOLMAXPARTS) {
2669 tst = ADMVOSPARTITIONTOOLARGE;
2670 goto fail_vos_VLDBReadOnlySiteCreate;
2674 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2676 goto fail_vos_VLDBReadOnlySiteCreate;
2680 fail_vos_VLDBReadOnlySiteCreate:
2689 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2694 * IN cellHandle - a previously opened cellHandle that corresponds
2695 * to the cell where the volume exists.
2697 * IN serverHandle - a previously opened serverHandle that corresponds
2698 * to the server where the volume should be deleted.
2700 * IN callBack - a call back function pointer that may be called to report
2701 * status information. Can be null.
2703 * IN partition - the partition where then volume should be deleted.
2705 * IN volumeId - the volume id of the volume to be deleted.
2709 * No locks are obtained or released by this function
2713 * Returns != 0 upon successful completion.
2717 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2718 vos_MessageCallBack_t callBack,
2719 unsigned int partition, unsigned int volumeId,
2723 afs_status_t tst = 0;
2724 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2725 file_server_p f_server = (file_server_p) serverHandle;
2728 * Validate arguments
2731 if (!IsValidCellHandle(c_handle, &tst)) {
2732 goto fail_vos_VLDBReadOnlySiteDelete;
2735 if (!IsValidServerHandle(f_server, &tst)) {
2736 goto fail_vos_VLDBReadOnlySiteDelete;
2739 if (partition > VOLMAXPARTS) {
2740 tst = ADMVOSPARTITIONTOOLARGE;
2741 goto fail_vos_VLDBReadOnlySiteDelete;
2745 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2747 goto fail_vos_VLDBReadOnlySiteDelete;
2751 fail_vos_VLDBReadOnlySiteDelete:
2760 * vos_VLDBSync - synchronize the vldb with the fileserver.
2764 * IN cellHandle - a previously opened cellHandle that corresponds
2765 * to the cell where the sync should occur.
2767 * IN serverHandle - a previously opened serverHandle that corresponds
2768 * to the server where the sync should occur.
2770 * IN callBack - a call back function pointer that may be called to report
2771 * status information. Can be null.
2773 * IN partition - the partition where the sync should occur. Can be null.
2775 * IN force - force deletion of bad volumes.
2779 * No locks are obtained or released by this function
2783 * Returns != 0 upon successful completion.
2787 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2788 vos_MessageCallBack_t callBack, const unsigned int *partition,
2789 vos_force_t force, afs_status_p st)
2792 afs_status_t tst = 0;
2793 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2794 file_server_p f_server = (file_server_p) serverHandle;
2800 * Validate arguments
2803 if (!IsValidCellHandle(c_handle, &tst)) {
2804 goto fail_vos_VLDBSync;
2807 if (!IsValidServerHandle(f_server, &tst)) {
2808 goto fail_vos_VLDBSync;
2811 if (partition != NULL) {
2812 if (*partition > VOLMAXPARTS) {
2813 tst = ADMVOSPARTITIONTOOLARGE;
2814 goto fail_vos_VLDBSync;
2816 part = (afs_int32) * partition;
2820 if (force == VOS_FORCE) {
2828 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2839 * vos_VolumeCreate - create a new partition.
2843 * IN cellHandle - a previously opened cellHandle that corresponds
2844 * to the cell where the server lives.
2846 * IN serverHandle - a previously open vos server handle that holds
2847 * the partition where the volume should be create.
2849 * IN callBack - a call back function pointer that may be called to report
2850 * status information. Can be null.
2852 * IN partition - the integer that represents the partition that will
2853 * house the new volume.
2855 * IN volumeName - the name of the new volume.
2857 * IN quota - the quota of the new volume.
2859 * OUT volumeId - the volume id of the newly created volume.
2863 * No locks are obtained or released by this function
2867 * Returns != 0 upon successful completion.
2871 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2872 vos_MessageCallBack_t callBack, unsigned int partition,
2873 const char *volumeName, unsigned int quota,
2874 unsigned int *volumeId, afs_status_p st)
2877 afs_status_t tst = 0;
2878 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2879 file_server_p f_server = (file_server_p) serverHandle;
2880 vos_partitionEntry_t pinfo;
2881 struct nvldbentry vinfo;
2884 * Validate arguments
2887 if (!IsValidCellHandle(c_handle, &tst)) {
2888 goto fail_vos_VolumeCreate;
2891 if (!IsValidServerHandle(f_server, &tst)) {
2892 goto fail_vos_VolumeCreate;
2895 if (partition > VOLMAXPARTS) {
2896 tst = ADMVOSPARTITIONTOOLARGE;
2897 goto fail_vos_VolumeCreate;
2900 if (!ValidateVolumeName(volumeName, &tst)) {
2901 goto fail_vos_VolumeCreate;
2904 if (volumeId == NULL) {
2905 tst = ADMVOSVOLUMEID;
2906 goto fail_vos_VolumeCreate;
2910 * Check that partition is valid at the server
2913 if (!vos_PartitionGet
2914 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2915 goto fail_vos_VolumeCreate;
2919 * Check that the volume doesn't already exist
2922 if (VLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2923 tst = ADMVOSVOLUMENAMEDUP;
2924 goto fail_vos_VolumeCreate;
2928 * Create the new volume
2931 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2932 quota, volumeId, &tst);
2934 fail_vos_VolumeCreate:
2943 * vos_VolumeDelete - remove a volume.
2947 * IN cellHandle - a previously opened cellHandle that corresponds
2948 * to the cell where the volume exists.
2950 * IN serverHandle - a previously opened serverHandle that corresponds
2951 * to the server where the volume exists.
2953 * IN callBack - a call back function pointer that may be called to report
2954 * status information. Can be null.
2956 * IN partition - the partition where the volume exists.
2958 * IN volumeId - the volume id of the volume to be deleted.
2962 * No locks are obtained or released by this function
2966 * Returns != 0 upon successful completion.
2970 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2971 vos_MessageCallBack_t callBack, unsigned int partition,
2972 unsigned int volumeId, afs_status_p st)
2975 afs_status_t tst = 0;
2976 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2977 file_server_p f_server = (file_server_p) serverHandle;
2978 vos_partitionEntry_t pinfo;
2981 * Validate arguments
2984 if (!IsValidCellHandle(c_handle, &tst)) {
2985 goto fail_vos_VolumeDelete;
2988 if (!IsValidServerHandle(f_server, &tst)) {
2989 goto fail_vos_VolumeDelete;
2992 if (partition > VOLMAXPARTS) {
2993 tst = ADMVOSPARTITIONTOOLARGE;
2994 goto fail_vos_VolumeDelete;
2998 * Check that partition is valid at the server
3001 if (!vos_PartitionGet
3002 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
3003 goto fail_vos_VolumeDelete;
3006 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3008 fail_vos_VolumeDelete:
3017 * vos_VolumeRename - rename a volume.
3021 * IN cellHandle - a previously opened cellHandle that corresponds
3022 * to the cell where the volume exists.
3024 * IN serverHandle - a previously opened serverHandle that corresponds
3025 * to the server where the vldb entry exists. Can be null.
3027 * IN callBack - a call back function pointer that may be called to report
3028 * status information. Can be null.
3030 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3032 * IN newVolumeName - the new name.
3036 * No locks are obtained or released by this function
3040 * Returns != 0 upon successful completion.
3044 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3045 unsigned int readWriteVolumeId, const char *newVolumeName,
3049 afs_status_t tst = 0;
3050 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3051 struct nvldbentry entry;
3054 * Validate arguments
3057 if (!IsValidCellHandle(c_handle, &tst)) {
3058 goto fail_vos_VolumeRename;
3061 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3062 tst = ADMVOSNEWVOLUMENAMENULL;
3063 goto fail_vos_VolumeRename;
3067 * Retrieve the entry
3070 if (!VLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3071 goto fail_vos_VolumeRename;
3074 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3076 fail_vos_VolumeRename:
3085 * vos_VolumeDump - dump a volume
3089 * IN cellHandle - a previously opened cellHandle that corresponds
3090 * to the cell where the volume exists.
3092 * IN serverHandle - a previously opened serverHandle that corresponds
3093 * to the server where the volume exists. Can be null.
3095 * IN callBack - a call back function pointer that may be called to report
3096 * status information. Can be null.
3098 * IN volumeId - the volume id of the volume to be dumped.
3100 * IN startTime - files with modification times >= this time will be dumped.
3102 * IN dumpFile - the file to dump the volume to.
3106 * No locks are obtained or released by this function
3110 * Returns != 0 upon successful completion.
3114 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3115 vos_MessageCallBack_t callBack, unsigned int *partition,
3116 unsigned int volumeId, unsigned int startTime,
3117 const char *dumpFile, afs_status_p st)
3120 afs_status_t tst = 0;
3121 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3122 file_server_p f_server = (file_server_p) serverHandle;
3123 afs_int32 server, part, voltype;
3124 struct nvldbentry entry;
3127 * Validate arguments
3130 if (!IsValidCellHandle(c_handle, &tst)) {
3131 goto fail_vos_VolumeDump;
3134 if (serverHandle != NULL) {
3135 if (!IsValidServerHandle(f_server, &tst)) {
3136 goto fail_vos_VolumeDump;
3141 * You must specify both the serverHandle and the partition
3144 if (serverHandle || partition) {
3145 if (!serverHandle || !partition) {
3146 tst = ADMVOSSERVERANDPARTITION;
3147 goto fail_vos_VolumeDump;
3149 if (*partition > VOLMAXPARTS) {
3150 tst = ADMVOSPARTITIONTOOLARGE;
3151 goto fail_vos_VolumeDump;
3153 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3158 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3159 goto fail_vos_VolumeDump;
3163 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3164 tst = ADMVOSDUMPFILENULL;
3165 goto fail_vos_VolumeDump;
3168 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3171 fail_vos_VolumeDump:
3180 * vos_VolumeRestore - restore a volume from a dump
3184 * IN cellHandle - a previously opened cellHandle that corresponds
3185 * to the cell where the volume exists.
3187 * IN serverHandle - a previously opened serverHandle that corresponds
3188 * to the server where the volume exists.
3190 * IN callBack - a call back function pointer that may be called to report
3191 * status information. Can be null.
3193 * IN partition - the partition where the volume exists.
3195 * IN volumeId - the volume id of the volume to be restored.
3197 * IN volumeName - the volume name of the volume to be restored.
3199 * IN dumpFile - the file from which to restore the volume.
3201 * IN dumpType - the type of dump to perform.
3205 * No locks are obtained or released by this function
3209 * Returns != 0 upon successful completion.
3213 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3214 vos_MessageCallBack_t callBack, unsigned int partition,
3215 unsigned int *volumeId, const char *volumeName,
3216 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3220 afs_status_t tst = 0;
3221 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3222 file_server_p f_server = (file_server_p) serverHandle;
3223 struct nvldbentry entry;
3224 afs_int32 volid, server;
3227 int restoreflags = 0;
3228 afs_int32 Oserver, Opart, Otype;
3229 struct nvldbentry Oentry;
3233 * Validate arguments
3236 if (!IsValidCellHandle(c_handle, &tst)) {
3237 goto fail_vos_VolumeRestore;
3240 if (serverHandle != NULL) {
3241 if (!IsValidServerHandle(f_server, &tst)) {
3242 goto fail_vos_VolumeRestore;
3247 * Must pass volumeName
3250 if ((volumeName == NULL) || (*volumeName == 0)) {
3251 tst = ADMVOSVOLUMENAMENULL;
3252 goto fail_vos_VolumeRestore;
3255 if (!ValidateVolumeName(volumeName, &tst)) {
3256 goto fail_vos_VolumeRestore;
3260 * If volumeId is passed, it must be a valid volume id
3263 if (volumeId != NULL) {
3264 if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3265 goto fail_vos_VolumeRestore;
3272 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3274 if (partition > VOLMAXPARTS) {
3275 tst = ADMVOSPARTITIONTOOLARGE;
3276 goto fail_vos_VolumeRestore;
3280 * Check that dumpFile exists and can be accessed
3283 fd = open(dumpFile, 0);
3284 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3286 tst = ADMVOSDUMPFILEOPENFAIL;
3287 goto fail_vos_VolumeRestore;
3292 if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3293 restoreflags = RV_FULLRST;
3294 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3295 restoreflags = RV_FULLRST;
3297 volid = entry.volumeId[RWVOL];
3298 } else if ((entry.volumeId[RWVOL] != 0)
3299 && (entry.volumeId[RWVOL] != volid)) {
3300 volid = entry.volumeId[RWVOL];
3305 volid = entry.volumeId[RWVOL];
3306 } else if ((entry.volumeId[RWVOL] != 0)
3307 && (entry.volumeId[RWVOL] != volid)) {
3308 volid = entry.volumeId[RWVOL];
3312 * If the vldb says the same volume exists somewhere else
3313 * the caller must specify a full restore, not an incremental
3316 if (dumpType == VOS_RESTORE_FULL) {
3317 restoreflags = RV_FULLRST;
3321 * Check to see if the volume exists where the caller said
3324 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3325 goto fail_vos_VolumeRestore;
3327 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3328 goto fail_vos_VolumeRestore;
3332 tst = ADMVOSRESTOREVOLEXIST;
3333 goto fail_vos_VolumeRestore;
3338 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3339 restoreflags, dumpFile, &tst);
3341 fail_vos_VolumeRestore:
3350 * vos_VolumeOnline - bring a volume online.
3354 * IN serverHandle - a previously opened serverHandle that corresponds
3355 * to the server where the volume exists.
3357 * IN callBack - a call back function pointer that may be called to report
3358 * status information. Can be null.
3360 * IN partition - the partition where the volume exists.
3362 * IN volumeId - the volume id of the volume to be brought online.
3366 * No locks are obtained or released by this function
3370 * Returns != 0 upon successful completion.
3374 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3375 unsigned int partition, unsigned int volumeId,
3376 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3380 afs_status_t tst = 0;
3381 file_server_p f_server = (file_server_p) serverHandle;
3385 * Validate arguments
3388 if (!IsValidServerHandle(f_server, &tst)) {
3389 goto fail_vos_VolumeOnline;
3392 if (partition > VOLMAXPARTS) {
3393 tst = ADMVOSPARTITIONIDTOOLARGE;
3394 goto fail_vos_VolumeOnline;
3397 if (volumeStatus == VOS_ONLINE_BUSY) {
3401 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3404 fail_vos_VolumeOnline:
3413 * vos_VolumeOffline - take a volume offline.
3417 * IN serverHandle - a previously opened serverHandle that corresponds
3418 * to the server where the volume exists.
3420 * IN callBack - a call back function pointer that may be called to report
3421 * status information. Can be null.
3423 * IN partition - the partition where the volume exists.
3425 * IN volumeId - the volume id of the volume to be taken offline.
3429 * No locks are obtained or released by this function
3433 * Returns != 0 upon successful completion.
3437 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3438 unsigned int partition, unsigned int volumeId,
3442 afs_status_t tst = 0;
3443 file_server_p f_server = (file_server_p) serverHandle;
3446 * Validate arguments
3449 if (!IsValidServerHandle(f_server, &tst)) {
3450 goto fail_vos_VolumeOffline;
3453 if (partition > VOLMAXPARTS) {
3454 tst = ADMVOSPARTITIONIDTOOLARGE;
3455 goto fail_vos_VolumeOffline;
3458 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3459 VTOutOfService, 0, &tst);
3461 fail_vos_VolumeOffline:
3470 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3474 * IN source - the volintXInfo structure to copy.
3476 * OUT dest - the vos_volumeEntry_t to fill
3480 * No locks are obtained or released by this function
3484 * Returns != 0 upon successful completion.
3488 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3492 afs_status_t tst = 0;
3496 * If the volume is not marked OK, all the other fields are invalid
3497 * We take the extra step of blanking out dest here to prevent the
3498 * user from seeing stale data from a previous call
3501 memset(dest, 0, sizeof(dest));
3503 switch (source->status) {
3505 dest->status = VOS_OK;
3508 dest->status = VOS_SALVAGE;
3511 dest->status = VOS_NO_VNODE;
3514 dest->status = VOS_NO_VOL;
3517 dest->status = VOS_VOL_EXISTS;
3520 dest->status = VOS_NO_SERVICE;
3523 dest->status = VOS_OFFLINE;
3526 dest->status = VOS_ONLINE;
3529 dest->status = VOS_DISK_FULL;
3532 dest->status = VOS_OVER_QUOTA;
3535 dest->status = VOS_BUSY;
3538 dest->status = VOS_MOVED;
3543 * Check to see if the entry is marked ok before copying all the
3547 if (dest->status == VOS_OK) {
3548 strcpy(dest->name, source->name);
3549 dest->id = source->volid;
3550 if (source->type == 0) {
3551 dest->type = VOS_READ_WRITE_VOLUME;
3552 } else if (source->type == 1) {
3553 dest->type = VOS_READ_ONLY_VOLUME;
3554 } else if (source->type == 2) {
3555 dest->type = VOS_BACKUP_VOLUME;
3557 dest->backupId = source->backupID;
3558 dest->readWriteId = source->parentID;
3559 dest->readOnlyId = source->cloneID;
3560 dest->copyCreationDate = source->copyDate;
3561 dest->creationDate = source->creationDate;
3562 dest->lastAccessDate = source->accessDate;
3563 dest->lastUpdateDate = source->updateDate;
3564 dest->lastBackupDate = source->backupDate;
3565 dest->accessesSinceMidnight = source->dayUse;
3566 dest->fileCount = source->filecount;
3567 dest->maxQuota = source->maxquota;
3568 dest->currentSize = source->size;
3569 if (source->inUse == 1) {
3570 dest->volumeDisposition = VOS_ONLINE;
3572 dest->volumeDisposition = VOS_OFFLINE;
3575 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3576 dest->readStats[i] = source->stat_reads[i];
3577 dest->writeStats[i] = source->stat_writes[i];
3580 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3581 dest->fileAuthorWriteSameNetwork[i] =
3582 source->stat_fileSameAuthor[i];
3583 dest->fileAuthorWriteDifferentNetwork[i] =
3584 source->stat_fileDiffAuthor[i];
3585 dest->dirAuthorWriteSameNetwork[i] =
3586 source->stat_dirSameAuthor[i];
3587 dest->dirAuthorWriteDifferentNetwork[i] =
3588 source->stat_dirDiffAuthor[i];
3601 * vos_VolumeGet - get information about a particular volume.
3605 * IN cellHandle - a previously opened cellHandle that corresponds
3606 * to the cell where the volume exists.
3608 * IN serverHandle - a previously opened serverHandle that corresponds
3609 * to the server where the volume exists.
3611 * IN callBack - a call back function pointer that may be called to report
3612 * status information. Can be null.
3614 * IN partition - the partition where the volume exists.
3616 * IN volumeId - the volume id of the volume to be retrieved.
3618 * OUT volumeP - upon successful completion, contains the information about the
3623 * No locks are obtained or released by this function
3627 * Returns != 0 upon successful completion.
3631 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3632 vos_MessageCallBack_t callBack, unsigned int partition,
3633 unsigned int volumeId, vos_volumeEntry_p volumeP,
3637 afs_status_t tst = 0;
3638 file_server_p f_server = (file_server_p) serverHandle;
3639 struct volintXInfo *info = NULL;
3642 * Validate arguments
3645 if (!IsValidServerHandle(f_server, &tst)) {
3646 goto fail_vos_VolumeGet;
3649 if (partition > VOLMAXPARTS) {
3650 tst = ADMVOSPARTITIONIDTOOLARGE;
3651 goto fail_vos_VolumeGet;
3654 if (volumeP == NULL) {
3655 tst = ADMVOSVOLUMEPNULL;
3656 goto fail_vos_VolumeGet;
3660 * Retrieve the information for the volume
3663 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3664 goto fail_vos_VolumeGet;
3668 * Copy the volume info to our structure
3671 if (!copyvolintXInfo(info, volumeP, &tst)) {
3672 goto fail_vos_VolumeGet;
3689 * The iterator functions and data for the volume retrieval functions.
3692 typedef struct volume_get {
3693 struct volintXInfo *vollist;
3694 afs_int32 total; /* total number of volumes at this partition */
3695 afs_int32 index; /* index to the current volume */
3696 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3697 } volume_get_t, *volume_get_p;
3700 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3701 int *last_item_contains_data, afs_status_p st)
3704 afs_status_t tst = 0;
3705 volume_get_p entry = (volume_get_p) rpc_specific;
3708 * Copy the next entry into the cache
3711 if (!copyvolintXInfo
3712 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3713 goto fail_GetVolumeRPC;
3718 * See if we've processed all the entries
3722 if (entry->index == entry->total) {
3724 *last_item_contains_data = 1;
3737 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3740 afs_status_t tst = 0;
3741 volume_get_p entry = (volume_get_p) rpc_specific;
3743 memcpy(dest, (const void *)&entry->entry[slot],
3744 sizeof(vos_volumeEntry_t));
3755 DestroyVolume(void *rpc_specific, afs_status_p st)
3758 afs_status_t tst = 0;
3759 volume_get_p entry = (volume_get_p) rpc_specific;
3761 if (entry->vollist != NULL) {
3762 free(entry->vollist);
3774 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3778 * IN cellHandle - a previously opened cellHandle that corresponds
3779 * to the cell where the volumes exist.
3781 * IN serverHandle - a handle to the server where the volumes exist.
3783 * IN callBack - a call back function pointer that may be called to report
3784 * status information. Can be null.
3786 * IN partition - the partition whose volumes should be listed. Can be null.
3788 * OUT iterationIdP - upon successful completion, contains an iterator that
3789 * can be passed to vos_VolumeGetBegin.
3793 * No locks are obtained or released by this function
3797 * Returns != 0 upon successful completion.
3801 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3802 vos_MessageCallBack_t callBack, unsigned int partition,
3803 void **iterationIdP, afs_status_p st)
3806 afs_status_t tst = 0;
3807 file_server_p f_server = (file_server_p) serverHandle;
3808 afs_admin_iterator_p iter =
3809 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3810 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3813 * Validate arguments
3816 if (!IsValidServerHandle(f_server, &tst)) {
3817 goto fail_vos_VolumeGetBegin;
3820 if (partition > VOLMAXPARTS) {
3821 tst = ADMVOSPARTITIONIDTOOLARGE;
3822 goto fail_vos_VolumeGetBegin;
3825 if ((iter == NULL) || (entry == NULL)) {
3827 goto fail_vos_VolumeGetBegin;
3831 * Get a list of all the volumes contained in the partition at the
3835 if (!UV_XListVolumes
3836 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3838 goto fail_vos_VolumeGetBegin;
3841 if (entry->total == 0) {
3842 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3843 goto fail_vos_VolumeGetBegin;
3845 iter->done_iterating = 1;
3846 iter->st = ADMITERATORDONE;
3849 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3850 DestroyVolume, &tst)) {
3851 goto fail_vos_VolumeGetBegin;
3854 *iterationIdP = (void *)iter;
3857 fail_vos_VolumeGetBegin:
3863 if (entry != NULL) {
3875 * vos_VolumeGetNext - get information about the next volume.
3879 * IN iterationId - an iterator previously returned by
3880 * vos_VolumeGetBegin
3882 * OUT volumeP - a pointer to a vos_volumeEntry_t
3883 * that upon successful completion contains information about the
3888 * The iterator is locked while the next item is retrieved.
3892 * Returns != 0 upon successful completion.
3896 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3900 afs_status_t tst = 0;
3901 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3904 tst = ADMITERATORNULL;
3905 goto fail_vos_VolumeGetNext;
3908 if (volumeP == NULL) {
3909 tst = ADMVOSVOLUMEPNULL;
3910 goto fail_vos_VolumeGetNext;
3913 rc = IteratorNext(iter, (void *)volumeP, &tst);
3915 fail_vos_VolumeGetNext:
3924 * vos_VolumeGetDone - finish using a volume iterator.
3928 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3932 * The iterator is locked and then destroyed.
3936 * Returns != 0 upon successful completion.
3940 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3943 afs_status_t tst = 0;
3944 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3947 * Validate arguments
3951 tst = ADMITERATORNULL;
3952 goto fail_vos_VolumeGetDone;
3955 rc = IteratorDone(iter, &tst);
3957 fail_vos_VolumeGetDone:
3966 * vos_VolumeMove - move a volume from one server to another.
3970 * IN cellHandle - a previously opened cellHandle that corresponds
3971 * to the cell where the volume exists.
3973 * IN callBack - a call back function pointer that may be called to report
3974 * status information. Can be null.
3976 * IN volumeId - the volume id of the volume to be moved.
3978 * IN fromServer - a previously opened serverHandle that corresponds
3979 * to the server where the volume currently resides.
3981 * IN fromPartition - the partition where the volume currently resides.
3983 * IN toServer - a previously opened serverHandle that corresponds
3984 * to the server where the volume will be moved.
3986 * IN toPartition - the partition where the volume will be moved.
3990 * No locks are obtained or released by this function
3994 * Returns != 0 upon successful completion.
3998 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
3999 unsigned int volumeId, const void *fromServer,
4000 unsigned int fromPartition, const void *toServer,
4001 unsigned int toPartition, afs_status_p st)
4004 afs_status_t tst = 0;
4005 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4006 file_server_p from_server = (file_server_p) fromServer;
4007 file_server_p to_server = (file_server_p) toServer;
4008 afs_int32 from_server_addr =
4009 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4010 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4011 afs_int32 from_partition = fromPartition;
4012 afs_int32 to_partition = toPartition;
4015 * Validate arguments
4018 if (!IsValidCellHandle(c_handle, &tst)) {
4019 goto fail_vos_VolumeMove;
4022 if (!IsValidServerHandle(from_server, &tst)) {
4023 goto fail_vos_VolumeMove;
4026 if (!IsValidServerHandle(to_server, &tst)) {
4027 goto fail_vos_VolumeMove;
4030 if (fromPartition > VOLMAXPARTS) {
4031 tst = ADMVOSPARTITIONIDTOOLARGE;
4032 goto fail_vos_VolumeMove;
4035 if (toPartition > VOLMAXPARTS) {
4036 tst = ADMVOSPARTITIONIDTOOLARGE;
4037 goto fail_vos_VolumeMove;
4044 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4045 to_server_addr, to_partition, &tst);
4047 fail_vos_VolumeMove:
4056 * vos_VolumeRelease - release a volume.
4060 * IN cellHandle - a previously opened cellHandle that corresponds
4061 * to the cell where the volume exists.
4063 * IN callBack - a call back function pointer that may be called to report
4064 * status information. Can be null.
4066 * IN volumeId - the volume to be released.
4068 * IN force - force a complete release.
4072 * No locks are obtained or released by this function
4076 * Returns != 0 upon successful completion.
4080 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4081 unsigned int volumeId, vos_force_t force, afs_status_p st)
4084 afs_status_t tst = 0;
4085 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4086 afs_int32 server, part, forc = 0, voltype, volume;
4087 struct nvldbentry entry;
4090 * Validate arguments
4093 if (!IsValidCellHandle(c_handle, &tst)) {
4094 goto fail_vos_VolumeRelease;
4098 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4099 goto fail_vos_VolumeRelease;
4102 if (force == VOS_FORCE) {
4107 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4109 fail_vos_VolumeRelease:
4118 * vos_VolumeZap - forcibly delete a volume.
4122 * IN cellHandle - a previously opened cellHandle that corresponds
4123 * to the cell where the volume exists.
4125 * IN serverHandle - a previously opened serverHandle that corresponds
4126 * to the server where the volume exists.
4128 * IN callBack - a call back function pointer that may be called to report
4129 * status information. Can be null.
4131 * IN partition - the partition where the volume exists.
4133 * IN volumeId - the volume id of the vldb entry to be deleted.
4135 * IN force - force the deletion of bad volumes.
4139 * No locks are obtained or released by this function
4143 * Returns != 0 upon successful completion.
4147 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4148 vos_MessageCallBack_t callBack, unsigned int partition,
4149 unsigned int volumeId, vos_force_t force, afs_status_p st)
4152 afs_status_t tst = 0;
4153 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4154 file_server_p f_server = (file_server_p) serverHandle;
4157 * Verify that the cellHandle is capable of making vos rpc's
4160 if (!IsValidCellHandle(c_handle, &tst)) {
4161 goto fail_vos_VolumeZap;
4164 if (!IsValidServerHandle(f_server, &tst)) {
4165 goto fail_vos_VolumeZap;
4168 if (force == VOS_FORCE) {
4169 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4172 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4185 * vos_PartitionNameToId - translate a string representing a partition
4190 * IN partitionName - a string representing a partition. Must be of
4193 * OUT partitionId - a number containing the partition id upon successful
4198 * No locks are obtained or released by this function
4202 * Returns != 0 upon successful completion.
4206 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4210 afs_status_t tst = 0;
4211 size_t partition_name_len;
4215 * Validate arguments
4218 if (partitionName == NULL) {
4219 tst = ADMVOSPARTITIONNAMENULL;
4220 goto fail_vos_PartitionNameToId;
4223 if (partitionId == NULL) {
4224 tst = ADMVOSPARTITIONIDNULL;
4225 goto fail_vos_PartitionNameToId;
4229 * Check that string begins with /vicep
4232 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4233 tst = ADMVOSPARTITIONNAMEINVALID;
4234 goto fail_vos_PartitionNameToId;
4238 * Check that the string is either one or two characters
4239 * longer than VICE_PREFIX_SIZE
4242 partition_name_len = strlen(partitionName);
4244 if (partition_name_len == VICE_PREFIX_SIZE) {
4245 tst = ADMVOSPARTITIONNAMETOOSHORT;
4246 goto fail_vos_PartitionNameToId;
4249 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4250 tst = ADMVOSPARTITIONNAMETOOLONG;
4251 goto fail_vos_PartitionNameToId;
4255 * Check that all characters past the prefix are lower case
4258 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4259 if (!islower(partitionName[i])) {
4260 tst = ADMVOSPARTITIONNAMENOTLOWER;
4261 goto fail_vos_PartitionNameToId;
4266 * Convert the name to a number
4269 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4270 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4273 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4274 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4277 if (*partitionId > VOLMAXPARTS) {
4278 tst = ADMVOSPARTITIONIDTOOLARGE;
4279 goto fail_vos_PartitionNameToId;
4283 fail_vos_PartitionNameToId:
4292 * vos_PartitionIdToName - translate a number representing a partition
4293 * to a character string.
4297 * IN partitionId - an integer representing the partition.
4299 * OUT partitionName - a string containing the converted partition ID
4300 * upon successful completion.
4304 * No locks are obtained or released by this function
4308 * Returns != 0 upon successful completion.
4312 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4316 afs_status_t tst = 0;
4318 if (partitionId > VOLMAXPARTS) {
4319 tst = ADMVOSPARTITIONIDTOOLARGE;
4320 goto fail_vos_PartitionIdToName;
4323 if (partitionName == NULL) {
4324 tst = ADMVOSPARTITIONNAMENULL;
4325 goto fail_vos_PartitionIdToName;
4328 if (partitionId < 26) {
4329 strcpy(partitionName, VICE_PARTITION_PREFIX);
4330 partitionName[6] = partitionId + 'a';
4331 partitionName[7] = '\0';
4333 strcpy(partitionName, VICE_PARTITION_PREFIX);
4335 partitionName[6] = 'a' + (partitionId / 26);
4336 partitionName[7] = 'a' + (partitionId % 26);
4337 partitionName[8] = '\0';
4341 fail_vos_PartitionIdToName:
4350 * vos_VolumeQuotaChange - change the quota of a volume.
4354 * IN cellHandle - a previously opened cellHandle that corresponds
4355 * to the cell where the volume exists.
4357 * IN serverHandle - a previously opened serverHandle that corresponds
4358 * to the server where the volume exists.
4360 * IN callBack - a call back function pointer that may be called to report
4361 * status information. Can be null.
4363 * IN partition - the partition where the volume exists.
4365 * IN volumeId - the volume id of the volume to be modified.
4367 * IN volumeQuota - the new volume quota.
4371 * No locks are obtained or released by this function
4375 * Returns != 0 upon successful completion.
4379 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4380 vos_MessageCallBack_t callBack, unsigned int partition,
4381 unsigned int volumeId, unsigned int volumeQuota,
4385 afs_status_t tst = 0;
4386 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4387 file_server_p f_server = (file_server_p) serverHandle;
4390 struct volintInfo tstatus;
4391 int active_trans = 0;
4394 * Verify that the cellHandle is capable of making vos rpc's
4397 if (!IsValidCellHandle(c_handle, &tst)) {
4398 goto fail_vos_VolumeQuotaChange;
4401 if (!IsValidServerHandle(f_server, &tst)) {
4402 goto fail_vos_VolumeQuotaChange;
4405 memset((void *)&tstatus, 0, sizeof(tstatus));
4406 tstatus.dayUse = -1;
4407 tstatus.maxquota = volumeQuota;
4410 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4412 goto fail_vos_VolumeQuotaChange;
4416 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4418 goto fail_vos_VolumeQuotaChange;
4422 fail_vos_VolumeQuotaChange:
4425 afs_status_t tst2 = 0;
4426 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);