[Ocfs2-commits] jlbec commits r1107 - branches/format-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Jun 15 19:56:13 CDT 2004
Author: jlbec
Date: 2004-06-15 18:56:11 -0500 (Tue, 15 Jun 2004)
New Revision: 1107
Modified:
branches/format-changes/src/ocfs.h
branches/format-changes/src/ocfs2_fs.h
branches/format-changes/src/proc.c
branches/format-changes/src/super.c
branches/format-changes/src/volcfg.c
branches/format-changes/src/vote.c
Log:
o Make ocfs_ipc_config_info sane. All of its network fields are valid
networky things in network byte order.
Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h 2004-06-15 22:55:33 UTC (rev 1106)
+++ branches/format-changes/src/ocfs.h 2004-06-15 23:56:11 UTC (rev 1107)
@@ -865,12 +865,13 @@
typedef struct _ocfs_comm_info
{
- __u32 type;
- char *ip_addr;
- __u32 ip_port;
- char *ip_mask;
-}
-ocfs_comm_info;
+ u16 ip_version; /* IP version in NBO */
+ u16 ip_port; /* IP port in NBO */
+ union {
+ __u32 ip_addr4; /* IPv4 address in NBO */
+ __u32 ip_addr6[4]; /* IPv6 address in NBO */
+ } addr_u;
+} ocfs_comm_info;
typedef struct _ocfs_global_ctxt
{
Modified: branches/format-changes/src/ocfs2_fs.h
===================================================================
--- branches/format-changes/src/ocfs2_fs.h 2004-06-15 22:55:33 UTC (rev 1106)
+++ branches/format-changes/src/ocfs2_fs.h 2004-06-15 23:56:11 UTC (rev 1107)
@@ -183,7 +183,6 @@
#define OCFS2_NODE_CONFIG_VER 2
#define OCFS2_NODE_MIN_SUPPORTED_VER 2
-#define MAX_IP_ADDR_LEN 32
#define MAX_NODE_NAME_LENGTH 32
#define OCFS2_GUID_HOSTID_LEN 20
@@ -371,46 +370,74 @@
/* Actual on-disk length specified by rec_len */
};
-typedef struct _ocfs_ipc_config_info // CLASS
+/*
+ * On-disk IPC configuration for an OCFS2 node.
+ */
+typedef struct _ocfs_ipc_config_info
{
- __u8 type; // NUMBER RANGE(0, 255)
- __u8 ip_addr[MAX_IP_ADDR_LEN+1]; // CHAR[MAX_IP_ADDR_LEN+1]
- __u32 ip_port; // NUMBER RANGE(0,ULONG_MAX)
- __u8 ip_mask[MAX_IP_ADDR_LEN+1]; // CHAR[MAX_IP_ADDR_LEN+1]
-}
-ocfs_ipc_config_info; // END CLASS
+/*00*/ __u16 ip_version; /* IP version in NBO */
+ __u16 ip_port; /* IP port in NBO */
+ __u32 ip_reserved1;
+ __u64 ip_reserved2;
+/*10*/ union {
+ __u32 ip_addr4; /* IPv4 address in NBO */
+ __u32 ip_addr6[4]; /* IPv6 address in NBO */
+ } addr_u;
+/*20*/
+} ocfs_ipc_config_info;
-/* TODO this structure will break in 64-bit.... need to pack */
+/*
+ * On-disk structure representing a Global Unique ID for an OCFS2 node.
+ *
+ * The GUID has two parts. The host_id is a generally-randomly-unique
+ * hex-as-ascii string of 20 characters (10 bytes). The mad_id field
+ * is, unsurprisingly, the MAC address of the network card that the
+ * IPC mechanism will be using (the address in
+ * ocfs_ipc_config_info.addr_u). This should (ha-ha) provide a unique
+ * identifier for a node in the OCFS2 cluster. It has the added
+ * benefit of detecting when a node has changed network cards
+ * (host_id is the same, mac_id has changed) or when an identical
+ * mac address is on a different mode (the converse).
+ */
typedef union _ocfs_guid
{
- struct
+/*00*/ struct
{
char host_id[OCFS2_GUID_HOSTID_LEN];
char mac_id[OCFS2_GUID_MACID_LEN];
} id;
__u8 guid[OCFS2_GUID_LEN];
+/*20*/
} ocfs_guid;
-typedef struct _ocfs_node_config_info // CLASS
+/*
+ * On-disk configuration information for an OCFS2 node. A node
+ * populates its own info for other nodes to read and use.
+ */
+typedef struct _ocfs_node_config_info
{
- ocfs2_disk_lock disk_lock; // DISKLOCK
- __u8 node_name[MAX_NODE_NAME_LENGTH+1]; // CHAR[MAX_NODE_NAME_LENGTH+1]
- ocfs_guid guid; // GUID
- ocfs_ipc_config_info ipc_config; // IPCONFIG
-}
-ocfs_node_config_info; // END CLASS
+/*00*/ ocfs2_disk_lock disk_lock; /* Lock on the info */
+/*30*/ ocfs_guid guid; /* GUID */
+/*50*/ ocfs_ipc_config_info ipc_config; /* IPC info */
+/*70*/ __u8 node_name[MAX_NODE_NAME_LENGTH+1]; /* Name */
+/*91*/ __u8 name_pad[7]; /* Pad to align (UGH) */
+/*98*/
+} ocfs_node_config_info;
-typedef struct _ocfs_node_config_hdr // CLASS
+/*
+ * On-disk ... for OCFS2. FIXME this description.
+ */
+typedef struct _ocfs_node_config_hdr
{
- ocfs2_disk_lock disk_lock; // DISKLOCK
- __u8 signature[OCFS2_NODE_CONFIG_SIGN_LEN]; // CHAR[NODE_CONFIG_SIGN_LEN]
- __u32 version; // NUMBER RANGE(0,ULONG_MAX)
- __u32 num_nodes; // NUMBER RANGE(0,32)
- __u32 last_node; // NUMBER RANGE(0,32)
- __u32 onch_pad; // UNUSED
- __u64 cfg_seq_num; // NUMBER RANGE(0,ULONG_LONG_MAX)
-}
-ocfs_node_config_hdr; // END CLASS
+/*00*/ ocfs2_disk_lock disk_lock;
+/*30*/ __u8 signature[OCFS2_NODE_CONFIG_SIGN_LEN];
+ __u32 version;
+ __u32 num_nodes;
+/*40*/ __u32 last_node;
+ __u32 onch_pad;
+ __u64 cfg_seq_num;
+/*50*/
+} ocfs_node_config_hdr;
#ifdef __KERNEL__
Modified: branches/format-changes/src/proc.c
===================================================================
--- branches/format-changes/src/proc.c 2004-06-15 22:55:33 UTC (rev 1106)
+++ branches/format-changes/src/proc.c 2004-06-15 23:56:11 UTC (rev 1107)
@@ -34,6 +34,7 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
+#include <linux/socket.h>
#include "ocfs_log.h"
#include "ocfs.h"
@@ -151,17 +152,17 @@
LOG_ENTRY ();
- len += sprintf (page + len, "comm voting : %d\n", comm_voting);
- len += sprintf (page + len, "ip addr/port : %s/%d\n",
- OcfsGlobalCtxt.comm_info.ip_addr,
- OcfsGlobalCtxt.comm_info.ip_port);
- len += sprintf (page + len, "guid : ");
- strncat (page + len, OcfsGlobalCtxt.guid.guid, OCFS2_GUID_LEN);
+ len += sprintf(page + len, "comm voting : %d\n", comm_voting);
+ len += sprintf(page + len, "ip addr/port : 0x%08u/%u\n",
+ ntohl(OcfsGlobalCtxt.comm_info.addr_u.ip_addr4),
+ ntohs(OcfsGlobalCtxt.comm_info.ip_port));
+ len += sprintf(page + len, "guid : ");
+ strncat(page + len, OcfsGlobalCtxt.guid.guid, OCFS2_GUID_LEN);
len += OCFS2_GUID_LEN;
- strncat (page + len, "\n", 1);
+ strncat(page + len, "\n", 1);
len++;
- ret = ocfs_proc_calc_metrics (page, start, off, count, eof, len);
+ ret = ocfs_proc_calc_metrics(page, start, off, count, eof, len);
LOG_EXIT_INT (ret);
return ret;
@@ -576,10 +577,10 @@
continue;
mount = ocfs_node_map_test_bit(&osb->publ_map, i) ? 'M' : ' ';
len += sprintf (page + len,
- "%2d %c %-32s %-15s %-6d ",
+ "%2d %c %-32s 0x%08u %-6u ",
i, mount, node->node_name,
- node->ipc_config.ip_addr,
- node->ipc_config.ip_port);
+ ntohl(node->ipc_config.addr_u.ip_addr4),
+ ntohs(node->ipc_config.ip_port));
strncat(page + len, node->guid.guid,
OCFS2_GUID_LEN);
len += OCFS2_GUID_LEN;
Modified: branches/format-changes/src/super.c
===================================================================
--- branches/format-changes/src/super.c 2004-06-15 22:55:33 UTC (rev 1106)
+++ branches/format-changes/src/super.c 2004-06-15 23:56:11 UTC (rev 1107)
@@ -41,6 +41,8 @@
#include <linux/moduleparam.h>
#endif
#include <linux/blkdev.h>
+#include <linux/socket.h>
+#include <linux/inet.h>
#include "ocfs_log.h"
#include "ocfs.h"
@@ -624,12 +626,19 @@
}
if (ip_port_v2 == 0)
- OcfsGlobalCtxt.comm_info.ip_port = OCFS_IPC_DEFAULT_PORT;
+ OcfsGlobalCtxt.comm_info.ip_port =
+ htons(OCFS_IPC_DEFAULT_PORT);
+ else if (ip_port_v2 & 0xFFFF0000) {
+ status = -EINVAL;
+ LOG_ERROR_STR("'ip_port_v2' is too large'");
+ }
else
- OcfsGlobalCtxt.comm_info.ip_port = ip_port_v2;
- LOG_TRACE_ARGS("IP port: %d\n", OcfsGlobalCtxt.comm_info.ip_port);
+ OcfsGlobalCtxt.comm_info.ip_port =
+ htons((u16)ip_port_v2);
+ LOG_TRACE_ARGS("IP port: %d\n",
+ ntohs(OcfsGlobalCtxt.comm_info.ip_port));
- if (node_name && strlen (node_name) < MAX_NODE_NAME_LENGTH) {
+ if (node_name && strlen(node_name) < MAX_NODE_NAME_LENGTH) {
OcfsGlobalCtxt.node_name = node_name;
LOG_TRACE_ARGS ("Node name: %s\n", OcfsGlobalCtxt.node_name);
} else {
@@ -637,8 +646,10 @@
LOG_ERROR_STR ("'node_name' not set or too long");
}
- if (ip_address && strlen (ip_address) < MAX_IP_ADDR_LEN) {
- OcfsGlobalCtxt.comm_info.ip_addr = ip_address;
+#define MAX_IPv4_ADDR_STR_LEN 15 /* 3x '255' + 3x '.' */
+ if (ip_address && strlen (ip_address) < MAX_IPv4_ADDR_STR_LEN) {
+ OcfsGlobalCtxt.comm_info.addr_u.ip_addr4 =
+ in_aton(ip_address);
LOG_TRACE_ARGS ("IP address: %s\n", ip_address);
} else {
status = -EINVAL;
@@ -663,8 +674,7 @@
}
/* hardcoding... not used yet */
- OcfsGlobalCtxt.comm_info.type = OCFS_UDP;
- OcfsGlobalCtxt.comm_info.ip_mask = NULL;
+ OcfsGlobalCtxt.comm_info.ip_version = htons(4);
return status;
} /* ocfs_read_params */
@@ -1022,7 +1032,8 @@
OcfsIpcCtxt.dlm_msg_size = OCFS_DLM_MAX_MSG_SIZE;
OcfsIpcCtxt.version = OCFS_IPC_DLM_VERSION;
/* start the listener thread */
- status = ocfs_init_udp_sock (&OcfsIpcCtxt.send_sock, &OcfsIpcCtxt.recv_sock);
+ status = ocfs_init_udp_sock(&OcfsIpcCtxt.send_sock,
+ &OcfsIpcCtxt.recv_sock);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
Modified: branches/format-changes/src/volcfg.c
===================================================================
--- branches/format-changes/src/volcfg.c 2004-06-15 22:55:33 UTC (rev 1106)
+++ branches/format-changes/src/volcfg.c 2004-06-15 23:56:11 UTC (rev 1107)
@@ -606,12 +606,9 @@
memcpy((*node)->guid.guid, disk->guid.guid, OCFS2_GUID_LEN);
- (*node)->ipc_config.type = disk->ipc_config.type;
(*node)->ipc_config.ip_port = disk->ipc_config.ip_port;
- strncpy((*node)->ipc_config.ip_addr, disk->ipc_config.ip_addr,
- MAX_IP_ADDR_LEN);
- strncpy((*node)->ipc_config.ip_mask, disk->ipc_config.ip_mask,
- MAX_IP_ADDR_LEN);
+ (*node)->ipc_config.addr_u.ip_addr4 =
+ disk->ipc_config.addr_u.ip_addr4;
bail:
LOG_EXIT_STATUS (status);
@@ -688,12 +685,9 @@
memcpy(disk->guid.guid, OcfsGlobalCtxt.guid.guid,
OCFS2_GUID_LEN);
- ipc->type = g_ipc->type;
ipc->ip_port = g_ipc->ip_port;
- if (g_ipc->ip_addr)
- strncpy (ipc->ip_addr, g_ipc->ip_addr, MAX_IP_ADDR_LEN);
- if (g_ipc->ip_mask)
- strncpy (ipc->ip_mask, g_ipc->ip_mask, MAX_IP_ADDR_LEN);
+ ipc->ip_version = g_ipc->ip_version;
+ ipc->addr_u.ip_addr4 = g_ipc->addr_u.ip_addr4;
LOG_EXIT ();
return ;
@@ -720,12 +714,9 @@
memcpy(node->guid.guid, OcfsGlobalCtxt.guid.guid,
OCFS2_GUID_LEN);
- ipc->type = g_ipc->type;
ipc->ip_port = g_ipc->ip_port;
- if (g_ipc->ip_addr)
- strncpy (ipc->ip_addr, g_ipc->ip_addr, MAX_IP_ADDR_LEN);
- if (g_ipc->ip_mask)
- strncpy (ipc->ip_mask, g_ipc->ip_mask, MAX_IP_ADDR_LEN);
+ ipc->ip_version = g_ipc->ip_version;
+ ipc->addr_u.ip_addr4 = g_ipc->addr_u.ip_addr4;
LOG_EXIT ();
return ;
@@ -946,20 +937,15 @@
MAX_NODE_NAME_LENGTH))
chg = 1;
- if (!chg && ipc->type != g_ipc->type)
+ if (!chg && (ipc->ip_version != g_ipc->ip_version))
chg = 1;
- if (!chg && ipc->ip_port != g_ipc->ip_port)
+ if (!chg && (ipc->ip_port != g_ipc->ip_port))
chg = 1;
- if (!chg && g_ipc->ip_addr &&
- strncmp (ipc->ip_addr, g_ipc->ip_addr, MAX_IP_ADDR_LEN))
+ if (!chg && (ipc->addr_u.ip_addr4 != g_ipc->addr_u.ip_addr4))
chg = 1;
- if (!chg && g_ipc->ip_mask &&
- strncmp (ipc->ip_mask, g_ipc->ip_mask, MAX_IP_ADDR_LEN))
- chg = 1;
-
LOG_EXIT_INT (chg);
return chg;
} /* ocfs_has_node_config_changed */
@@ -1025,9 +1011,11 @@
if (!node || node->node_name[0] == '\0')
continue;
- LOG_TRACE_ARGS ("Node (%u) is (%s)\n", i, node->node_name);
- LOG_TRACE_ARGS ("ip=%s, port=%d\n", node->ipc_config.ip_addr,
- node->ipc_config.ip_port);
+ LOG_TRACE_ARGS ("Node (%u) is (%s)\n", i,
+ node->node_name);
+ LOG_TRACE_ARGS ("ip=0x%08u, port=%d\n",
+ ntohl(node->ipc_config.addr_u.ip_addr4),
+ ntohs(node->ipc_config.ip_port));
}
return;
Modified: branches/format-changes/src/vote.c
===================================================================
--- branches/format-changes/src/vote.c 2004-06-15 22:55:33 UTC (rev 1106)
+++ branches/format-changes/src/vote.c 2004-06-15 23:56:11 UTC (rev 1107)
@@ -151,6 +151,21 @@
return status;
} /* ocfs_recv_udp_msg */
+
+static inline int ocfs2_comm_ip_version_to_family(u16 ip_version)
+{
+ switch (ntohs(ip_version)) {
+ case 4:
+ return PF_INET;
+ case 6:
+ return PF_INET6;
+ default:
+ BUG();
+ }
+
+ return 4;
+}
+
/*
* ocfs_send_bcast()
*
@@ -177,15 +192,16 @@
if (!node)
continue;
- LOG_TRACE_ARGS ("Sending msg to node=%u, name=%s\n",
- num, node->node_name);
+ LOG_TRACE_ARGS("Sending msg to node=%u, name=%s\n",
+ num, node->node_name);
memset (&sin, 0, sizeof (sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = in_aton(node->ipc_config.ip_addr);
- sin.sin_port = htons(node->ipc_config.ip_port);
+ sin.sin_family = ocfs2_comm_ip_version_to_family(node->ipc_config.ip_version);
+ sin.sin_addr.s_addr = node->ipc_config.addr_u.ip_addr4;
+ sin.sin_port = node->ipc_config.ip_port;
- LOG_TRACE_ARGS ("about to send to %s:%u\n", node->ipc_config.ip_addr,
- node->ipc_config.ip_port);
+ LOG_TRACE_ARGS("about to send to 0x%08u:%u\n",
+ ntohl(node->ipc_config.addr_u.ip_addr4),
+ ntohs(node->ipc_config.ip_port));
status = -EFAIL;
if (OcfsIpcCtxt.send_sock) {
@@ -226,7 +242,8 @@
* ocfs_init_udp_sock()
*
*/
-int ocfs_init_udp_sock (struct socket **send_sock, struct socket **recv_sock)
+int ocfs_init_udp_sock(struct socket **send_sock,
+ struct socket **recv_sock)
{
struct sockaddr_in sin;
int status = -EFAIL;
@@ -234,43 +251,50 @@
LOG_ENTRY ();
+ comm = &(OcfsGlobalCtxt.comm_info);
+
/* Create Send Socket */
- status = sock_create (PF_INET, SOCK_DGRAM, IPPROTO_UDP, send_sock);
+ status = sock_create(ocfs2_comm_ip_version_to_family(comm->ip_version),
+ SOCK_DGRAM, IPPROTO_UDP,
+ send_sock);
if (status < 0) {
LOG_ERROR_ARGS ("unable to create socket, error=%d", status);
goto bail;
}
/* Bind Send Socket */
- memset (&sin, 0, sizeof (sin));
- sin.sin_family = AF_INET;
+ memset(&sin, 0, sizeof (sin));
+ sin.sin_family = ocfs2_comm_ip_version_to_family(comm->ip_version);
sin.sin_addr.s_addr = htonl (INADDR_ANY);
- sin.sin_port = htons (0);
+ sin.sin_port = htons(0);
- status = (*send_sock)->ops->bind (*send_sock, (struct sockaddr *) &sin,
- sizeof (sin));
+ status = (*send_sock)->ops->bind(*send_sock,
+ (struct sockaddr *)&sin,
+ sizeof(sin));
if (status < 0) {
LOG_ERROR_ARGS ("unable to bind socket, error=%d", status);
goto bail;
}
/* Create Receive Socket */
- status = sock_create (PF_INET, SOCK_DGRAM, IPPROTO_UDP, recv_sock);
+ status = sock_create(ocfs2_comm_ip_version_to_family(comm->ip_version),
+ SOCK_DGRAM, IPPROTO_UDP,
+ recv_sock);
if (status < 0) {
LOG_ERROR_ARGS ("unable to create socket, error=%d", status);
goto bail;
}
- comm = &(OcfsGlobalCtxt.comm_info);
/* Bind Receive Socket */
- memset (&sin, 0, sizeof (sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = htonl (INADDR_ANY);
- sin.sin_port = htons (comm->ip_port);
+ memset(&sin, 0, sizeof(sin));
+ sin.sin_family = ocfs2_comm_ip_version_to_family(comm->ip_version);
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ sin.sin_port = comm->ip_port;
- status = (*recv_sock)->ops->bind (*recv_sock, (struct sockaddr *) &sin,
- sizeof (sin));
+ status = (*recv_sock)->ops->bind(*recv_sock,
+ (struct sockaddr *)&sin,
+ sizeof(sin));
if (status < 0) {
LOG_ERROR_ARGS ("unable to bind socket, error=%d", status);
goto bail;
More information about the Ocfs2-commits
mailing list