kcom patch
"Matt Dew" <[email protected]>
| Newsgroups | gmane.linux.cluster.openmosix.devel |
|---|---|
| Message-ID | <[email protected]> |
Tab, Here are the first two patches for the git tree. Support functions for kcomd, pkt_data_read and pkt_hdr_read. Created a new file, kcom.c and move the support functions in there. kcomd is still kcomd.c but called functions are in kcom.c The second patch is the header file. Matt ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ openMosix-devel mailing list openMosix-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/openmosix-devel
2.6.17_01.patch
(text/plain, 3.1 KB)
diff -Naur a/hpc/kcom.c b/hpc/kcom.c --- a/hpc/kcom.c 1969-12-31 17:00:00.000000000 -0700 +++ b/hpc/kcom.c 2006-08-28 14:38:30.000000000 -0600 @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2006 Matt Dew <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 only. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <linux/sched.h> +#include <linux/socket.h> +#include <linux/in.h> +#include <linux/in6.h> +#include <linux/net.h> +#include <linux/syscalls.h> +#include <net/sock.h> +#include <net/tcp.h> +#define _HPC_KCOMC_H 1 +#include <hpc/kcom.h> +#include <hpc/prototype.h> + + +/** + * pkt_data_read + * + * Description: + * read the data that was send following the pkt header. + * wait until all data has been read. + * The ->len field = size of the data in bytes. + **/ +int pkt_data_read(struct kcom_node *node, struct kcom_pkt *pkt, int len, char *data) +{ + struct socket *sock=node->sock; + struct iovec iov; + struct msghdr msg = { NULL, 0, &iov, 1, NULL, 0, MSG_WAITALL | MSG_NOSIGNAL }; + mm_segment_t oldfs; + int i; + char buf[32]; + + iov.iov_base = data; + iov.iov_len = len; + + // Too small of a packet gets delayed before being sent. Even with TCP_NODELAY + if (len < 32) { + iov.iov_base = &buf; + iov.iov_len = 32; + } + + oldfs = get_fs(); + set_fs(KERNEL_DS); + + while (iov.iov_len > 0) { + i = sock_recvmsg(sock, &msg, iov.iov_len, msg.msg_flags); + if ((i == -ENOSPC) || (i == -EAGAIN)) { + schedule_timeout(HZ/1000); + continue; + } + if (i < 0) { + printk("ERROR %d receiving data.\n", i); + return -1; + } + iov.iov_base += i; + } + + set_fs(oldfs); + + if (len < 32) { + memcpy(data, buf, len); + } + + return len; +} +EXPORT_SYMBOL_GPL(pkt_data_read); + +/** + * pkt_hdr_read + * + * Description: + * read the pkt header of the data transmission. + * The hdr indicates the type and size of the data. + * All packet headers are the same size. + **/ +struct kcom_pkt* pkt_hdr_read(struct kcom_node *node) +{ + struct iovec iov; + struct msghdr msg = { NULL, 0, &iov, 1, NULL, 0, MSG_WAITALL | MSG_NOSIGNAL }; + struct kcom_pkt *recv_kcom_pkt; + mm_segment_t oldfs; + struct socket *sock=node->sock; + int i; + + recv_kcom_pkt=kmem_cache_alloc(kcom_pkt_cachep, SLAB_KERNEL); + iov.iov_base = recv_kcom_pkt; + iov.iov_len = sizeof(*recv_kcom_pkt); + + oldfs = get_fs(); + set_fs(KERNEL_DS); + while ( iov.iov_len > 0 ) { + i = sock_recvmsg(sock, &msg, iov.iov_len, msg.msg_flags); + if ((i == -ENOSPC) || (i == -EAGAIN)) { + schedule_timeout(HZ/1000); + continue; + } + if (i < 0) { + printk("ERROR %d receiving header.\n", i); + return NULL; + } + iov.iov_base += i; + } + set_fs(oldfs); + + if (iov.iov_len==0) // all expected data received. + return recv_kcom_pkt; + else + return NULL; +} +EXPORT_SYMBOL_GPL(pkt_hdr_read); +
2.6.17_02.patch
(text/plain, 3.8 KB)
diff -Naur a/include/hpc/kcom.h b/include/hpc/kcom.h --- a/include/hpc/kcom.h 1969-12-31 17:00:00.000000000 -0700 +++ b/include/hpc/kcom.h 2006-08-28 16:11:29.000000000 -0600 @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2006 Matt Dew <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 only. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _HPC_KCOM_H +#define _HPC_KCOM_H + +#include <linux/sched.h> +#include <net/sock.h> +#include <hpc/comm.h> + +#include <linux/in.h> + +#include <hpc/protocol.h> + +#define DAEMON_IP4_PORT 0xB55 // 2901 +#define DAEMON_IP6_PORT 0xB56 // 2902 + +/* PROTOTYPES */ +#ifdef _HPC_KCOMC_H + DEFINE_SPINLOCK(kcom_nodes_lock); + EXPORT_SYMBOL(kcom_nodes_lock); + + struct list_head kcom_nodes = LIST_HEAD_INIT(kcom_nodes); + EXPORT_SYMBOL(kcom_nodes); + + fd_set_bits sockets_fds; + EXPORT_SYMBOL(sockets_fds); + + char *sockets_fds_bitmap = NULL; + EXPORT_SYMBOL(sockets_fds_bitmap); + + int maxfds = -1; + EXPORT_SYMBOL(maxfds); + + struct socket *lsock4=NULL, *lsock6=NULL; + EXPORT_SYMBOL(lsock4); + EXPORT_SYMBOL(lsock6); + + int fd4, fd6; + EXPORT_SYMBOL(fd4); + EXPORT_SYMBOL(fd6); + + // pid_t kcom_pid; + // EXPORT_SYMBOL(kcom_pid); + + task_t *kcomd_task=NULL; + EXPORT_SYMBOL(kcomd_task); + + unsigned int kcom_msgid=0; + EXPORT_SYMBOL(kcom_msgid); + + kmem_cache_t *kcom_data_cachep; + EXPORT_SYMBOL(kcom_data_cachep); + + kmem_cache_t *kcom_pkt_cachep; + EXPORT_SYMBOL(kcom_pkt_cachep); + + kmem_cache_t *kcom_task_cachep; + EXPORT_SYMBOL(kcom_task_cachep); + + kmem_cache_t *kcom_node_cachep; + EXPORT_SYMBOL(kcom_node_cachep); + + kmem_cache_t *kcom_saddr_cachep; + EXPORT_SYMBOL(kcom_saddr_cachep); + + +#else /* _HPC_KCOMC_H */ + extern int maxfds; + extern spinlock_t kcom_nodes_lock; + extern struct list_head kcom_nodes; + + extern fd_set_bits sockets_fds; + extern char *sockets_fds_bitmap; + extern struct socket *lsock4; + extern struct socket *lsock6; + extern int fd4; + extern int fd6; + + //extern pid_t kcom_pid; + extern task_t *kcomd_task; + extern kmem_cache_t *kcom_data_cachep; + extern kmem_cache_t *kcom_pkt_cachep; + extern kmem_cache_t *kcom_task_cachep; + extern kmem_cache_t *kcom_node_cachep; + extern kmem_cache_t *kcom_saddr_cachep; +#endif /* _HPC_KCOMC_H */ + + +struct kcom_pkt +{ + pid_t hpid; /* home pid of the this process */ + pid_t rpid; /* remote pid of 'that' other node process */ + int len; /* len of data */ + int type; /* type of data */ + // int ack; /* new msg, ack or response */ + unsigned long addr; /* used by mm pages */ + unsigned int msgid; + struct list_head list; + char *data; /* ptr of data */ + char *resp; /* ptr of response */ +}; + +struct kcom_node +{ + int fd; /* fd to send packet */ + struct socket *sock; /* socket */ + struct sockaddr addr; /* addr of this node */ + spinlock_t tasks_lock; /* lock for the list */ + struct list_head tasks; /* list of task */ + struct list_head list; /* list of nodes */ + spinlock_t spinlock; +}; + +struct kcom_task +{ + pid_t hpid; /* pid of the home node process owning this struct */ + pid_t rpid; /* pid of remote node process */ + struct kcom_node *node; /* node of the process to send/recv */ + struct list_head list; /* list of process using some node */ + + struct list_head out_packs; + // struct kcom_pkt in_packs; + struct list_head in_packs; + spinlock_t spinlock; // FIXME: ?? two spinlocks? in_packs, out_packs +}; + +#endif /* _HPC_KCOM_H */