$(INCFILEDIR)\cm_conn.h \
$(INCFILEDIR)\cm_error.h \
$(INCFILEDIR)\cm_ioctl.h \
+ $(INCFILEDIR)\cm_getaddrs.h \
$(INCFILEDIR)\cm_scache.h \
$(INCFILEDIR)\cm_server.h \
$(INCFILEDIR)\cm_user.h \
$(OUT)\cm_direct.obj \
$(OUT)\cm_access.obj \
$(OUT)\cm_eacces.obj \
+ $(OUT)\cm_getaddrs.obj \
$(OUT)\cm_callback.obj \
$(OUT)\cm_vnodeops.obj \
$(OUT)\cm_dir.obj \
--- /dev/null
+/*
+ * Copyright (c) 2014 Your File System, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission from Secure Endpoints, Inc. and
+ * Your File System, Inc.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <roken.h>
+
+#include <afs/stds.h>
+#include "afsd.h"
+#include "cm_getaddrs.h"
+
+/*
+ * cm_GetAddrsU takes as input a uuid and a unique value which
+ * represent the set of addresses that are required. These values
+ * are used as input to the VL_GetAddrsU RPC which returns a list
+ * of addresses. For each returned address a bucket in the provided
+ * arrays (serverFlags, serverNumber, serverUUID, serverUnique)
+ * are populated. The serverFlags array entries are filled with the
+ * 'Flags' value provided as input. 'serverNumber' is the server's
+ * IP address.
+ */
+
+afs_uint32
+cm_GetAddrsU(cm_cell_t *cellp, cm_user_t *userp, cm_req_t *reqp,
+ afsUUID *Uuid, afs_int32 Unique, afs_int32 Flags,
+ int *index,
+ afs_int32 serverFlags[],
+ afs_int32 serverNumber[],
+ afsUUID serverUUID[],
+ afs_int32 serverUnique[])
+{
+ afs_uint32 code = 0;
+ cm_conn_t *connp;
+ struct rx_connection *rxconnp;
+ afs_uint32 * addrp, nentries;
+ afs_int32 unique;
+ bulkaddrs addrs;
+ ListAddrByAttributes attrs;
+ afsUUID uuid;
+ int i;
+
+ memset(&uuid, 0, sizeof(uuid));
+ memset(&addrs, 0, sizeof(addrs));
+ memset(&attrs, 0, sizeof(attrs));
+
+ attrs.Mask = VLADDR_UUID;
+ attrs.uuid = *Uuid;
+
+ do {
+ code = cm_ConnByMServers(cellp->vlServersp, 0, userp, reqp, &connp);
+ if (code)
+ continue;
+ rxconnp = cm_GetRxConn(connp);
+ code = VL_GetAddrsU(rxconnp, &attrs, &uuid, &unique, &nentries,
+ &addrs);
+ rx_PutConnection(rxconnp);
+ } while (cm_Analyze(connp, userp, reqp, NULL, cellp, 0, NULL, NULL,
+ &cellp->vlServersp, NULL, code));
+
+ code = cm_MapVLRPCError(code, reqp);
+
+ if (afsd_logp->enabled) {
+ char uuidstr[128];
+ afsUUID_to_string(Uuid, uuidstr, sizeof(uuidstr));
+
+ if (code)
+ osi_Log2(afsd_logp,
+ "CALL VL_GetAddrsU serverNumber %s FAILURE, code 0x%x",
+ osi_LogSaveString(afsd_logp, uuidstr),
+ code);
+ else
+ osi_Log1(afsd_logp, "CALL VL_GetAddrsU serverNumber %s SUCCESS",
+ osi_LogSaveString(afsd_logp, uuidstr));
+ }
+
+ if (code)
+ return CM_ERROR_RETRY;
+
+ if (nentries == 0) {
+ code = CM_ERROR_INVAL;
+ } else {
+ addrp = addrs.bulkaddrs_val;
+ for (i = 0; i < nentries && (*index) < NMAXNSERVERS; (*index)++, i++) {
+ serverFlags[*index] = Flags;
+ serverNumber[*index] = addrp[i];
+ serverUUID[*index] = uuid;
+ serverUnique[*index] = unique;
+ }
+ }
+ xdr_free((xdrproc_t) xdr_bulkaddrs, &addrs);
+
+ return code;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Your File System, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission from Secure Endpoints, Inc. and
+ * Your File System, Inc.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _CM_GETADDRS_H_
+#define _CM_GETADDRS_H_
+
+#include <opr/uuid.h>
+
+extern afs_uint32
+cm_GetAddrsU(cm_cell_t *cellp, cm_user_t *userp, cm_req_t *reqp,
+ afsUUID *Uuid, afs_int32 Unique, afs_int32 Flags, int *index,
+ afs_int32 serverFlags[], afs_int32 serverNumber[], afsUUID serverUUID[],
+ afs_int32 serverUnique[]);
+
+#endif /* _CM_GETADDRS_H_ */
#include <strsafe.h>
#include <malloc.h>
#include "afsd.h"
+#include "cm_getaddrs.h"
#include <osi.h>
#include <rx/rx.h>
long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *reqp,
cm_volume_t *volp)
{
- struct rx_connection *rxconnp;
- cm_conn_t *connp;
int i;
- afs_uint32 j, k;
+ afs_uint32 j;
cm_serverRef_t *tsrp;
cm_server_t *tsp;
struct sockaddr_in tsockAddr;
afs_int32 roID;
afs_int32 bkID;
afs_int32 serverNumber[NMAXNSERVERS];
+ afs_int32 serverUnique[NMAXNSERVERS];
afs_int32 serverFlags[NMAXNSERVERS];
afsUUID serverUUID[NMAXNSERVERS];
afs_int32 rwServers_alldown = 1;
}
memset(serverUUID, 0, sizeof(serverUUID));
+ memset(serverUnique, 0, sizeof(serverUnique));
switch ( method ) {
case 0:
serverNumber[j] = uvldbEntry.serverNumber[i].time_low;
j++;
} else {
- afs_uint32 * addrp, nentries, code, unique;
- bulkaddrs addrs;
- ListAddrByAttributes attrs;
- afsUUID uuid;
-
- memset(&attrs, 0, sizeof(attrs));
- attrs.Mask = VLADDR_UUID;
- attrs.uuid = uvldbEntry.serverNumber[i];
- memset(&uuid, 0, sizeof(uuid));
- memset(&addrs, 0, sizeof(addrs));
-
- do {
- code = cm_ConnByMServers(cellp->vlServersp, FALSE, userp, reqp, &connp);
- if (code)
- continue;
-
- rxconnp = cm_GetRxConn(connp);
- code = VL_GetAddrsU(rxconnp, &attrs, &uuid, &unique, &nentries, &addrs);
- rx_PutConnection(rxconnp);
- } while (cm_Analyze(connp, userp, reqp, NULL, cellp, 0, NULL, NULL, &cellp->vlServersp, NULL, code));
-
- if ( code ) {
- code = cm_MapVLRPCError(code, reqp);
- osi_Log2(afsd_logp, "CALL VL_GetAddrsU serverNumber %u FAILURE, code 0x%x",
- i, code);
- continue;
- }
- osi_Log1(afsd_logp, "CALL VL_GetAddrsU serverNumber %u SUCCESS", i);
-
- addrp = addrs.bulkaddrs_val;
- for (k = 0; k < nentries && j < NMAXNSERVERS; j++, k++) {
- serverFlags[j] = uvldbEntry.serverFlags[i];
- serverNumber[j] = addrp[k];
- serverUUID[j] = uuid;
- }
-
- xdr_free((xdrproc_t) xdr_bulkaddrs, &addrs);
-
- if (nentries == 0)
- code = CM_ERROR_INVAL;
+ code = cm_GetAddrsU(cellp, userp, reqp,
+ &uvldbEntry.serverNumber[i],
+ uvldbEntry.serverUnique[i],
+ uvldbEntry.serverFlags[i], &j,
+ serverFlags, serverNumber,
+ serverUUID, serverUnique);
+ if (code == CM_ERROR_RETRY)
+ continue;
}
}
nServers = j; /* update the server count */