2015-06-03 19:57:29

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 0/7] staging:lustre: remove tcpip abstraction from libcfs

Since libcfs no longer builds for user land we can
move the TCPIP abstraction that exist to the LNET
layer which is the only place that uses it. Also
the migrated code will use native linux kernel
APIs directly instead of with wrappers.

Signed-off-by: James Simmons <[email protected]>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/13760
Reviewed-by: John L. Hammond <[email protected]>
Reviewed-by: Isaac Huang <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>

James Simmons (7):
staging:lustre: move tcpip abstraction
staging:lustre: remove useless libcfs_sock_release
staging:lustre: remove useless libcfs_sock_abort_accept
staging:lustre: rename tcpip handling functions to lnet_* prefix
staging:lustre: use available kernel wrappers in lib-socket.c
staging:lustre: style cleanups for lib-socket.c
staging:lustre: Update license and copyright for lib-socket.c

.../staging/lustre/include/linux/libcfs/libcfs.h | 17 -
.../staging/lustre/include/linux/lnet/lib-lnet.h | 16 +
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 17 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.h | 2 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 6 +-
.../lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 15 +-
.../lustre/lnet/klnds/socklnd/socklnd_proto.c | 43 +-
drivers/staging/lustre/lnet/lnet/Makefile | 7 +-
drivers/staging/lustre/lnet/lnet/acceptor.c | 55 +-
drivers/staging/lustre/lnet/lnet/config.c | 21 +-
drivers/staging/lustre/lnet/lnet/lib-socket.c | 595 +++++++++++++++++++
drivers/staging/lustre/lustre/libcfs/Makefile | 1 -
.../lustre/lustre/libcfs/linux/linux-tcpip.c | 623 --------------------
14 files changed, 688 insertions(+), 732 deletions(-)
create mode 100644 drivers/staging/lustre/lnet/lnet/lib-socket.c
delete mode 100644 drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c


2015-06-03 19:57:38

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 1/7] staging:lustre: move tcpip abstraction

Rename libcfs/linux/linux-tcpip.c to lnet/lnet/lib-socket.c

Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/lnet/Makefile | 7 +-
drivers/staging/lustre/lnet/lnet/lib-socket.c | 624 ++++++++++++++++++++
drivers/staging/lustre/lustre/libcfs/Makefile | 1 -
.../lustre/lustre/libcfs/linux/linux-tcpip.c | 623 -------------------
4 files changed, 628 insertions(+), 627 deletions(-)
create mode 100644 drivers/staging/lustre/lnet/lnet/lib-socket.c
delete mode 100644 drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c

diff --git a/drivers/staging/lustre/lnet/lnet/Makefile b/drivers/staging/lustre/lnet/lnet/Makefile
index 336b8ea..52492fb 100644
--- a/drivers/staging/lustre/lnet/lnet/Makefile
+++ b/drivers/staging/lustre/lnet/lnet/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_LNET) += lnet.o

-lnet-y := api-ni.o config.o lib-me.o lib-msg.o lib-eq.o \
- lib-md.o lib-ptl.o lib-move.o module.o lo.o router.o \
- router_proc.o acceptor.o peer.o
+lnet-y := api-ni.o config.o \
+ lib-me.o lib-msg.o lib-eq.o lib-md.o lib-ptl.o \
+ lib-socket.o lib-move.o module.o lo.o \
+ router.o router_proc.o acceptor.o peer.o
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
new file mode 100644
index 0000000..7f80612
--- /dev/null
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -0,0 +1,624 @@
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit http://www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ */
+#define DEBUG_SUBSYSTEM S_LNET
+
+#include "../../include/linux/libcfs/libcfs.h"
+#include "../../include/linux/lnet/lib-lnet.h"
+
+#include <linux/if.h>
+#include <linux/in.h>
+#include <linux/file.h>
+/* For sys_open & sys_close */
+#include <linux/syscalls.h>
+
+static int
+libcfs_sock_ioctl(int cmd, unsigned long arg)
+{
+ mm_segment_t oldmm = get_fs();
+ struct socket *sock;
+ int rc;
+ struct file *sock_filp;
+
+ rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
+ if (rc != 0) {
+ CERROR ("Can't create socket: %d\n", rc);
+ return rc;
+ }
+
+ sock_filp = sock_alloc_file(sock, 0, NULL);
+ if (IS_ERR(sock_filp)) {
+ sock_release(sock);
+ rc = PTR_ERR(sock_filp);
+ goto out;
+ }
+
+ set_fs(KERNEL_DS);
+ if (sock_filp->f_op->unlocked_ioctl)
+ rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg);
+ set_fs(oldmm);
+
+ fput(sock_filp);
+out:
+ return rc;
+}
+
+int
+libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
+{
+ struct ifreq ifr;
+ int nob;
+ int rc;
+ __u32 val;
+
+ nob = strnlen(name, IFNAMSIZ);
+ if (nob == IFNAMSIZ) {
+ CERROR("Interface name %s too long\n", name);
+ return -EINVAL;
+ }
+
+ CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
+
+ strcpy(ifr.ifr_name, name);
+ rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
+
+ if (rc != 0) {
+ CERROR("Can't get flags for interface %s\n", name);
+ return rc;
+ }
+
+ if ((ifr.ifr_flags & IFF_UP) == 0) {
+ CDEBUG(D_NET, "Interface %s down\n", name);
+ *up = 0;
+ *ip = *mask = 0;
+ return 0;
+ }
+
+ *up = 1;
+
+ strcpy(ifr.ifr_name, name);
+ ifr.ifr_addr.sa_family = AF_INET;
+ rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
+
+ if (rc != 0) {
+ CERROR("Can't get IP address for interface %s\n", name);
+ return rc;
+ }
+
+ val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
+ *ip = ntohl(val);
+
+ strcpy(ifr.ifr_name, name);
+ ifr.ifr_addr.sa_family = AF_INET;
+ rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
+
+ if (rc != 0) {
+ CERROR("Can't get netmask for interface %s\n", name);
+ return rc;
+ }
+
+ val = ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr;
+ *mask = ntohl(val);
+
+ return 0;
+}
+
+EXPORT_SYMBOL(libcfs_ipif_query);
+
+int
+libcfs_ipif_enumerate (char ***namesp)
+{
+ /* Allocate and fill in 'names', returning # interfaces/error */
+ char **names;
+ int toobig;
+ int nalloc;
+ int nfound;
+ struct ifreq *ifr;
+ struct ifconf ifc;
+ int rc;
+ int nob;
+ int i;
+
+
+ nalloc = 16; /* first guess at max interfaces */
+ toobig = 0;
+ for (;;) {
+ if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) {
+ toobig = 1;
+ nalloc = PAGE_CACHE_SIZE/sizeof(*ifr);
+ CWARN("Too many interfaces: only enumerating first %d\n",
+ nalloc);
+ }
+
+ LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr));
+ if (ifr == NULL) {
+ CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc);
+ rc = -ENOMEM;
+ goto out0;
+ }
+
+ ifc.ifc_buf = (char *)ifr;
+ ifc.ifc_len = nalloc * sizeof(*ifr);
+
+ rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
+
+ if (rc < 0) {
+ CERROR ("Error %d enumerating interfaces\n", rc);
+ goto out1;
+ }
+
+ LASSERT (rc == 0);
+
+ nfound = ifc.ifc_len/sizeof(*ifr);
+ LASSERT (nfound <= nalloc);
+
+ if (nfound < nalloc || toobig)
+ break;
+
+ LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
+ nalloc *= 2;
+ }
+
+ if (nfound == 0)
+ goto out1;
+
+ LIBCFS_ALLOC(names, nfound * sizeof(*names));
+ if (names == NULL) {
+ rc = -ENOMEM;
+ goto out1;
+ }
+
+ for (i = 0; i < nfound; i++) {
+
+ nob = strnlen (ifr[i].ifr_name, IFNAMSIZ);
+ if (nob == IFNAMSIZ) {
+ /* no space for terminating NULL */
+ CERROR("interface name %.*s too long (%d max)\n",
+ nob, ifr[i].ifr_name, IFNAMSIZ);
+ rc = -ENAMETOOLONG;
+ goto out2;
+ }
+
+ LIBCFS_ALLOC(names[i], IFNAMSIZ);
+ if (names[i] == NULL) {
+ rc = -ENOMEM;
+ goto out2;
+ }
+
+ memcpy(names[i], ifr[i].ifr_name, nob);
+ names[i][nob] = 0;
+ }
+
+ *namesp = names;
+ rc = nfound;
+
+ out2:
+ if (rc < 0)
+ libcfs_ipif_free_enumeration(names, nfound);
+ out1:
+ LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
+ out0:
+ return rc;
+}
+
+EXPORT_SYMBOL(libcfs_ipif_enumerate);
+
+void
+libcfs_ipif_free_enumeration (char **names, int n)
+{
+ int i;
+
+ LASSERT (n > 0);
+
+ for (i = 0; i < n && names[i] != NULL; i++)
+ LIBCFS_FREE(names[i], IFNAMSIZ);
+
+ LIBCFS_FREE(names, n * sizeof(*names));
+}
+
+EXPORT_SYMBOL(libcfs_ipif_free_enumeration);
+
+int
+libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
+{
+ int rc;
+ long ticks = timeout * HZ;
+ unsigned long then;
+ struct timeval tv;
+
+ LASSERT (nob > 0);
+ /* Caller may pass a zero timeout if she thinks the socket buffer is
+ * empty enough to take the whole message immediately */
+
+ for (;;) {
+ struct kvec iov = {
+ .iov_base = buffer,
+ .iov_len = nob
+ };
+ struct msghdr msg = {
+ .msg_flags = (timeout == 0) ? MSG_DONTWAIT : 0
+ };
+
+ if (timeout != 0) {
+ /* Set send timeout to remaining time */
+ tv = (struct timeval) {
+ .tv_sec = ticks / HZ,
+ .tv_usec = ((ticks % HZ) * 1000000) / HZ
+ };
+ rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
+ (char *)&tv, sizeof(tv));
+ if (rc != 0) {
+ CERROR("Can't set socket send timeout %ld.%06d: %d\n",
+ (long)tv.tv_sec, (int)tv.tv_usec, rc);
+ return rc;
+ }
+ }
+
+ then = jiffies;
+ rc = kernel_sendmsg(sock, &msg, &iov, 1, nob);
+ ticks -= jiffies - then;
+
+ if (rc == nob)
+ return 0;
+
+ if (rc < 0)
+ return rc;
+
+ if (rc == 0) {
+ CERROR ("Unexpected zero rc\n");
+ return -ECONNABORTED;
+ }
+
+ if (ticks <= 0)
+ return -EAGAIN;
+
+ buffer = ((char *)buffer) + rc;
+ nob -= rc;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(libcfs_sock_write);
+
+int
+libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
+{
+ int rc;
+ long ticks = timeout * HZ;
+ unsigned long then;
+ struct timeval tv;
+
+ LASSERT (nob > 0);
+ LASSERT (ticks > 0);
+
+ for (;;) {
+ struct kvec iov = {
+ .iov_base = buffer,
+ .iov_len = nob
+ };
+ struct msghdr msg = {
+ .msg_flags = 0
+ };
+
+ /* Set receive timeout to remaining time */
+ tv = (struct timeval) {
+ .tv_sec = ticks / HZ,
+ .tv_usec = ((ticks % HZ) * 1000000) / HZ
+ };
+ rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
+ (char *)&tv, sizeof(tv));
+ if (rc != 0) {
+ CERROR("Can't set socket recv timeout %ld.%06d: %d\n",
+ (long)tv.tv_sec, (int)tv.tv_usec, rc);
+ return rc;
+ }
+
+ then = jiffies;
+ rc = kernel_recvmsg(sock, &msg, &iov, 1, nob, 0);
+ ticks -= jiffies - then;
+
+ if (rc < 0)
+ return rc;
+
+ if (rc == 0)
+ return -ECONNRESET;
+
+ buffer = ((char *)buffer) + rc;
+ nob -= rc;
+
+ if (nob == 0)
+ return 0;
+
+ if (ticks <= 0)
+ return -ETIMEDOUT;
+ }
+}
+
+EXPORT_SYMBOL(libcfs_sock_read);
+
+static int
+libcfs_sock_create (struct socket **sockp, int *fatal,
+ __u32 local_ip, int local_port)
+{
+ struct sockaddr_in locaddr;
+ struct socket *sock;
+ int rc;
+ int option;
+
+ /* All errors are fatal except bind failure if the port is in use */
+ *fatal = 1;
+
+ rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
+ *sockp = sock;
+ if (rc != 0) {
+ CERROR ("Can't create socket: %d\n", rc);
+ return rc;
+ }
+
+ option = 1;
+ rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+ (char *)&option, sizeof (option));
+ if (rc != 0) {
+ CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc);
+ goto failed;
+ }
+
+ if (local_ip != 0 || local_port != 0) {
+ memset(&locaddr, 0, sizeof(locaddr));
+ locaddr.sin_family = AF_INET;
+ locaddr.sin_port = htons(local_port);
+ locaddr.sin_addr.s_addr = (local_ip == 0) ?
+ INADDR_ANY : htonl(local_ip);
+
+ rc = sock->ops->bind(sock, (struct sockaddr *)&locaddr,
+ sizeof(locaddr));
+ if (rc == -EADDRINUSE) {
+ CDEBUG(D_NET, "Port %d already in use\n", local_port);
+ *fatal = 0;
+ goto failed;
+ }
+ if (rc != 0) {
+ CERROR("Error trying to bind to port %d: %d\n",
+ local_port, rc);
+ goto failed;
+ }
+ }
+
+ return 0;
+
+ failed:
+ sock_release(sock);
+ return rc;
+}
+
+int
+libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
+{
+ int option;
+ int rc;
+
+ if (txbufsize != 0) {
+ option = txbufsize;
+ rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
+ (char *)&option, sizeof (option));
+ if (rc != 0) {
+ CERROR ("Can't set send buffer %d: %d\n",
+ option, rc);
+ return rc;
+ }
+ }
+
+ if (rxbufsize != 0) {
+ option = rxbufsize;
+ rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
+ (char *)&option, sizeof (option));
+ if (rc != 0) {
+ CERROR ("Can't set receive buffer %d: %d\n",
+ option, rc);
+ return rc;
+ }
+ }
+
+ return 0;
+}
+
+EXPORT_SYMBOL(libcfs_sock_setbuf);
+
+int
+libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
+{
+ struct sockaddr_in sin;
+ int len = sizeof (sin);
+ int rc;
+
+ rc = sock->ops->getname (sock, (struct sockaddr *)&sin, &len,
+ remote ? 2 : 0);
+ if (rc != 0) {
+ CERROR ("Error %d getting sock %s IP/port\n",
+ rc, remote ? "peer" : "local");
+ return rc;
+ }
+
+ if (ip != NULL)
+ *ip = ntohl (sin.sin_addr.s_addr);
+
+ if (port != NULL)
+ *port = ntohs (sin.sin_port);
+
+ return 0;
+}
+
+EXPORT_SYMBOL(libcfs_sock_getaddr);
+
+int
+libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
+{
+
+ if (txbufsize != NULL) {
+ *txbufsize = sock->sk->sk_sndbuf;
+ }
+
+ if (rxbufsize != NULL) {
+ *rxbufsize = sock->sk->sk_rcvbuf;
+ }
+
+ return 0;
+}
+
+EXPORT_SYMBOL(libcfs_sock_getbuf);
+
+int
+libcfs_sock_listen (struct socket **sockp,
+ __u32 local_ip, int local_port, int backlog)
+{
+ int fatal;
+ int rc;
+
+ rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port);
+ if (rc != 0) {
+ if (!fatal)
+ CERROR("Can't create socket: port %d already in use\n",
+ local_port);
+ return rc;
+ }
+
+ rc = (*sockp)->ops->listen(*sockp, backlog);
+ if (rc == 0)
+ return 0;
+
+ CERROR("Can't set listen backlog %d: %d\n", backlog, rc);
+ sock_release(*sockp);
+ return rc;
+}
+
+EXPORT_SYMBOL(libcfs_sock_listen);
+
+int
+libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
+{
+ wait_queue_t wait;
+ struct socket *newsock;
+ int rc;
+
+ init_waitqueue_entry(&wait, current);
+
+ /* XXX this should add a ref to sock->ops->owner, if
+ * TCP could be a module */
+ rc = sock_create_lite(PF_PACKET, sock->type, IPPROTO_TCP, &newsock);
+ if (rc) {
+ CERROR("Can't allocate socket\n");
+ return rc;
+ }
+
+ newsock->ops = sock->ops;
+
+ rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
+ if (rc == -EAGAIN) {
+ /* Nothing ready, so wait for activity */
+ set_current_state(TASK_INTERRUPTIBLE);
+ add_wait_queue(sk_sleep(sock->sk), &wait);
+ schedule();
+ remove_wait_queue(sk_sleep(sock->sk), &wait);
+ set_current_state(TASK_RUNNING);
+ rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
+ }
+
+ if (rc != 0)
+ goto failed;
+
+ *newsockp = newsock;
+ return 0;
+
+ failed:
+ sock_release(newsock);
+ return rc;
+}
+
+EXPORT_SYMBOL(libcfs_sock_accept);
+
+void
+libcfs_sock_abort_accept (struct socket *sock)
+{
+ wake_up_all(sk_sleep(sock->sk));
+}
+
+EXPORT_SYMBOL(libcfs_sock_abort_accept);
+
+int
+libcfs_sock_connect (struct socket **sockp, int *fatal,
+ __u32 local_ip, int local_port,
+ __u32 peer_ip, int peer_port)
+{
+ struct sockaddr_in srvaddr;
+ int rc;
+
+ rc = libcfs_sock_create(sockp, fatal, local_ip, local_port);
+ if (rc != 0)
+ return rc;
+
+ memset (&srvaddr, 0, sizeof (srvaddr));
+ srvaddr.sin_family = AF_INET;
+ srvaddr.sin_port = htons(peer_port);
+ srvaddr.sin_addr.s_addr = htonl(peer_ip);
+
+ rc = (*sockp)->ops->connect(*sockp,
+ (struct sockaddr *)&srvaddr, sizeof(srvaddr),
+ 0);
+ if (rc == 0)
+ return 0;
+
+ /* EADDRNOTAVAIL probably means we're already connected to the same
+ * peer/port on the same local port on a differently typed
+ * connection. Let our caller retry with a different local
+ * port... */
+ *fatal = !(rc == -EADDRNOTAVAIL);
+
+ CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET,
+ "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc,
+ &local_ip, local_port, &peer_ip, peer_port);
+
+ sock_release(*sockp);
+ return rc;
+}
+
+EXPORT_SYMBOL(libcfs_sock_connect);
+
+void
+libcfs_sock_release (struct socket *sock)
+{
+ sock_release(sock);
+}
+
+EXPORT_SYMBOL(libcfs_sock_release);
diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile
index fabdd3e..ec98f44 100644
--- a/drivers/staging/lustre/lustre/libcfs/Makefile
+++ b/drivers/staging/lustre/lustre/libcfs/Makefile
@@ -2,7 +2,6 @@ obj-$(CONFIG_LUSTRE_FS) += libcfs.o

libcfs-linux-objs := linux-tracefile.o linux-debug.o
libcfs-linux-objs += linux-prim.o linux-cpu.o
-libcfs-linux-objs += linux-tcpip.o
libcfs-linux-objs += linux-curproc.o
libcfs-linux-objs += linux-module.o
libcfs-linux-objs += linux-crypto.o
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c
deleted file mode 100644
index f2462e7..0000000
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit http://www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include "../../../include/linux/libcfs/libcfs.h"
-
-#include <linux/if.h>
-#include <linux/in.h>
-#include <linux/file.h>
-/* For sys_open & sys_close */
-#include <linux/syscalls.h>
-
-static int
-libcfs_sock_ioctl(int cmd, unsigned long arg)
-{
- mm_segment_t oldmm = get_fs();
- struct socket *sock;
- int rc;
- struct file *sock_filp;
-
- rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
- if (rc != 0) {
- CERROR ("Can't create socket: %d\n", rc);
- return rc;
- }
-
- sock_filp = sock_alloc_file(sock, 0, NULL);
- if (IS_ERR(sock_filp)) {
- sock_release(sock);
- rc = PTR_ERR(sock_filp);
- goto out;
- }
-
- set_fs(KERNEL_DS);
- if (sock_filp->f_op->unlocked_ioctl)
- rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg);
- set_fs(oldmm);
-
- fput(sock_filp);
-out:
- return rc;
-}
-
-int
-libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
-{
- struct ifreq ifr;
- int nob;
- int rc;
- __u32 val;
-
- nob = strnlen(name, IFNAMSIZ);
- if (nob == IFNAMSIZ) {
- CERROR("Interface name %s too long\n", name);
- return -EINVAL;
- }
-
- CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
-
- strcpy(ifr.ifr_name, name);
- rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
-
- if (rc != 0) {
- CERROR("Can't get flags for interface %s\n", name);
- return rc;
- }
-
- if ((ifr.ifr_flags & IFF_UP) == 0) {
- CDEBUG(D_NET, "Interface %s down\n", name);
- *up = 0;
- *ip = *mask = 0;
- return 0;
- }
-
- *up = 1;
-
- strcpy(ifr.ifr_name, name);
- ifr.ifr_addr.sa_family = AF_INET;
- rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
-
- if (rc != 0) {
- CERROR("Can't get IP address for interface %s\n", name);
- return rc;
- }
-
- val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
- *ip = ntohl(val);
-
- strcpy(ifr.ifr_name, name);
- ifr.ifr_addr.sa_family = AF_INET;
- rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
-
- if (rc != 0) {
- CERROR("Can't get netmask for interface %s\n", name);
- return rc;
- }
-
- val = ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr;
- *mask = ntohl(val);
-
- return 0;
-}
-
-EXPORT_SYMBOL(libcfs_ipif_query);
-
-int
-libcfs_ipif_enumerate (char ***namesp)
-{
- /* Allocate and fill in 'names', returning # interfaces/error */
- char **names;
- int toobig;
- int nalloc;
- int nfound;
- struct ifreq *ifr;
- struct ifconf ifc;
- int rc;
- int nob;
- int i;
-
-
- nalloc = 16; /* first guess at max interfaces */
- toobig = 0;
- for (;;) {
- if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) {
- toobig = 1;
- nalloc = PAGE_CACHE_SIZE/sizeof(*ifr);
- CWARN("Too many interfaces: only enumerating first %d\n",
- nalloc);
- }
-
- LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr));
- if (ifr == NULL) {
- CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc);
- rc = -ENOMEM;
- goto out0;
- }
-
- ifc.ifc_buf = (char *)ifr;
- ifc.ifc_len = nalloc * sizeof(*ifr);
-
- rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
-
- if (rc < 0) {
- CERROR ("Error %d enumerating interfaces\n", rc);
- goto out1;
- }
-
- LASSERT (rc == 0);
-
- nfound = ifc.ifc_len/sizeof(*ifr);
- LASSERT (nfound <= nalloc);
-
- if (nfound < nalloc || toobig)
- break;
-
- LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
- nalloc *= 2;
- }
-
- if (nfound == 0)
- goto out1;
-
- LIBCFS_ALLOC(names, nfound * sizeof(*names));
- if (names == NULL) {
- rc = -ENOMEM;
- goto out1;
- }
-
- for (i = 0; i < nfound; i++) {
-
- nob = strnlen (ifr[i].ifr_name, IFNAMSIZ);
- if (nob == IFNAMSIZ) {
- /* no space for terminating NULL */
- CERROR("interface name %.*s too long (%d max)\n",
- nob, ifr[i].ifr_name, IFNAMSIZ);
- rc = -ENAMETOOLONG;
- goto out2;
- }
-
- LIBCFS_ALLOC(names[i], IFNAMSIZ);
- if (names[i] == NULL) {
- rc = -ENOMEM;
- goto out2;
- }
-
- memcpy(names[i], ifr[i].ifr_name, nob);
- names[i][nob] = 0;
- }
-
- *namesp = names;
- rc = nfound;
-
- out2:
- if (rc < 0)
- libcfs_ipif_free_enumeration(names, nfound);
- out1:
- LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
- out0:
- return rc;
-}
-
-EXPORT_SYMBOL(libcfs_ipif_enumerate);
-
-void
-libcfs_ipif_free_enumeration (char **names, int n)
-{
- int i;
-
- LASSERT (n > 0);
-
- for (i = 0; i < n && names[i] != NULL; i++)
- LIBCFS_FREE(names[i], IFNAMSIZ);
-
- LIBCFS_FREE(names, n * sizeof(*names));
-}
-
-EXPORT_SYMBOL(libcfs_ipif_free_enumeration);
-
-int
-libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
-{
- int rc;
- long ticks = timeout * HZ;
- unsigned long then;
- struct timeval tv;
-
- LASSERT (nob > 0);
- /* Caller may pass a zero timeout if she thinks the socket buffer is
- * empty enough to take the whole message immediately */
-
- for (;;) {
- struct kvec iov = {
- .iov_base = buffer,
- .iov_len = nob
- };
- struct msghdr msg = {
- .msg_flags = (timeout == 0) ? MSG_DONTWAIT : 0
- };
-
- if (timeout != 0) {
- /* Set send timeout to remaining time */
- tv = (struct timeval) {
- .tv_sec = ticks / HZ,
- .tv_usec = ((ticks % HZ) * 1000000) / HZ
- };
- rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
- (char *)&tv, sizeof(tv));
- if (rc != 0) {
- CERROR("Can't set socket send timeout %ld.%06d: %d\n",
- (long)tv.tv_sec, (int)tv.tv_usec, rc);
- return rc;
- }
- }
-
- then = jiffies;
- rc = kernel_sendmsg(sock, &msg, &iov, 1, nob);
- ticks -= jiffies - then;
-
- if (rc == nob)
- return 0;
-
- if (rc < 0)
- return rc;
-
- if (rc == 0) {
- CERROR ("Unexpected zero rc\n");
- return -ECONNABORTED;
- }
-
- if (ticks <= 0)
- return -EAGAIN;
-
- buffer = ((char *)buffer) + rc;
- nob -= rc;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(libcfs_sock_write);
-
-int
-libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
-{
- int rc;
- long ticks = timeout * HZ;
- unsigned long then;
- struct timeval tv;
-
- LASSERT (nob > 0);
- LASSERT (ticks > 0);
-
- for (;;) {
- struct kvec iov = {
- .iov_base = buffer,
- .iov_len = nob
- };
- struct msghdr msg = {
- .msg_flags = 0
- };
-
- /* Set receive timeout to remaining time */
- tv = (struct timeval) {
- .tv_sec = ticks / HZ,
- .tv_usec = ((ticks % HZ) * 1000000) / HZ
- };
- rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
- (char *)&tv, sizeof(tv));
- if (rc != 0) {
- CERROR("Can't set socket recv timeout %ld.%06d: %d\n",
- (long)tv.tv_sec, (int)tv.tv_usec, rc);
- return rc;
- }
-
- then = jiffies;
- rc = kernel_recvmsg(sock, &msg, &iov, 1, nob, 0);
- ticks -= jiffies - then;
-
- if (rc < 0)
- return rc;
-
- if (rc == 0)
- return -ECONNRESET;
-
- buffer = ((char *)buffer) + rc;
- nob -= rc;
-
- if (nob == 0)
- return 0;
-
- if (ticks <= 0)
- return -ETIMEDOUT;
- }
-}
-
-EXPORT_SYMBOL(libcfs_sock_read);
-
-static int
-libcfs_sock_create (struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port)
-{
- struct sockaddr_in locaddr;
- struct socket *sock;
- int rc;
- int option;
-
- /* All errors are fatal except bind failure if the port is in use */
- *fatal = 1;
-
- rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
- *sockp = sock;
- if (rc != 0) {
- CERROR ("Can't create socket: %d\n", rc);
- return rc;
- }
-
- option = 1;
- rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
- (char *)&option, sizeof (option));
- if (rc != 0) {
- CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc);
- goto failed;
- }
-
- if (local_ip != 0 || local_port != 0) {
- memset(&locaddr, 0, sizeof(locaddr));
- locaddr.sin_family = AF_INET;
- locaddr.sin_port = htons(local_port);
- locaddr.sin_addr.s_addr = (local_ip == 0) ?
- INADDR_ANY : htonl(local_ip);
-
- rc = sock->ops->bind(sock, (struct sockaddr *)&locaddr,
- sizeof(locaddr));
- if (rc == -EADDRINUSE) {
- CDEBUG(D_NET, "Port %d already in use\n", local_port);
- *fatal = 0;
- goto failed;
- }
- if (rc != 0) {
- CERROR("Error trying to bind to port %d: %d\n",
- local_port, rc);
- goto failed;
- }
- }
-
- return 0;
-
- failed:
- sock_release(sock);
- return rc;
-}
-
-int
-libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
-{
- int option;
- int rc;
-
- if (txbufsize != 0) {
- option = txbufsize;
- rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
- (char *)&option, sizeof (option));
- if (rc != 0) {
- CERROR ("Can't set send buffer %d: %d\n",
- option, rc);
- return rc;
- }
- }
-
- if (rxbufsize != 0) {
- option = rxbufsize;
- rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
- (char *)&option, sizeof (option));
- if (rc != 0) {
- CERROR ("Can't set receive buffer %d: %d\n",
- option, rc);
- return rc;
- }
- }
-
- return 0;
-}
-
-EXPORT_SYMBOL(libcfs_sock_setbuf);
-
-int
-libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
-{
- struct sockaddr_in sin;
- int len = sizeof (sin);
- int rc;
-
- rc = sock->ops->getname (sock, (struct sockaddr *)&sin, &len,
- remote ? 2 : 0);
- if (rc != 0) {
- CERROR ("Error %d getting sock %s IP/port\n",
- rc, remote ? "peer" : "local");
- return rc;
- }
-
- if (ip != NULL)
- *ip = ntohl (sin.sin_addr.s_addr);
-
- if (port != NULL)
- *port = ntohs (sin.sin_port);
-
- return 0;
-}
-
-EXPORT_SYMBOL(libcfs_sock_getaddr);
-
-int
-libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
-{
-
- if (txbufsize != NULL) {
- *txbufsize = sock->sk->sk_sndbuf;
- }
-
- if (rxbufsize != NULL) {
- *rxbufsize = sock->sk->sk_rcvbuf;
- }
-
- return 0;
-}
-
-EXPORT_SYMBOL(libcfs_sock_getbuf);
-
-int
-libcfs_sock_listen (struct socket **sockp,
- __u32 local_ip, int local_port, int backlog)
-{
- int fatal;
- int rc;
-
- rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port);
- if (rc != 0) {
- if (!fatal)
- CERROR("Can't create socket: port %d already in use\n",
- local_port);
- return rc;
- }
-
- rc = (*sockp)->ops->listen(*sockp, backlog);
- if (rc == 0)
- return 0;
-
- CERROR("Can't set listen backlog %d: %d\n", backlog, rc);
- sock_release(*sockp);
- return rc;
-}
-
-EXPORT_SYMBOL(libcfs_sock_listen);
-
-int
-libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
-{
- wait_queue_t wait;
- struct socket *newsock;
- int rc;
-
- init_waitqueue_entry(&wait, current);
-
- /* XXX this should add a ref to sock->ops->owner, if
- * TCP could be a module */
- rc = sock_create_lite(PF_PACKET, sock->type, IPPROTO_TCP, &newsock);
- if (rc) {
- CERROR("Can't allocate socket\n");
- return rc;
- }
-
- newsock->ops = sock->ops;
-
- rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
- if (rc == -EAGAIN) {
- /* Nothing ready, so wait for activity */
- set_current_state(TASK_INTERRUPTIBLE);
- add_wait_queue(sk_sleep(sock->sk), &wait);
- schedule();
- remove_wait_queue(sk_sleep(sock->sk), &wait);
- set_current_state(TASK_RUNNING);
- rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
- }
-
- if (rc != 0)
- goto failed;
-
- *newsockp = newsock;
- return 0;
-
- failed:
- sock_release(newsock);
- return rc;
-}
-
-EXPORT_SYMBOL(libcfs_sock_accept);
-
-void
-libcfs_sock_abort_accept (struct socket *sock)
-{
- wake_up_all(sk_sleep(sock->sk));
-}
-
-EXPORT_SYMBOL(libcfs_sock_abort_accept);
-
-int
-libcfs_sock_connect (struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port,
- __u32 peer_ip, int peer_port)
-{
- struct sockaddr_in srvaddr;
- int rc;
-
- rc = libcfs_sock_create(sockp, fatal, local_ip, local_port);
- if (rc != 0)
- return rc;
-
- memset (&srvaddr, 0, sizeof (srvaddr));
- srvaddr.sin_family = AF_INET;
- srvaddr.sin_port = htons(peer_port);
- srvaddr.sin_addr.s_addr = htonl(peer_ip);
-
- rc = (*sockp)->ops->connect(*sockp,
- (struct sockaddr *)&srvaddr, sizeof(srvaddr),
- 0);
- if (rc == 0)
- return 0;
-
- /* EADDRNOTAVAIL probably means we're already connected to the same
- * peer/port on the same local port on a differently typed
- * connection. Let our caller retry with a different local
- * port... */
- *fatal = !(rc == -EADDRNOTAVAIL);
-
- CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET,
- "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc,
- &local_ip, local_port, &peer_ip, peer_port);
-
- sock_release(*sockp);
- return rc;
-}
-
-EXPORT_SYMBOL(libcfs_sock_connect);
-
-void
-libcfs_sock_release (struct socket *sock)
-{
- sock_release(sock);
-}
-
-EXPORT_SYMBOL(libcfs_sock_release);
--
1.7.1

2015-06-03 19:59:46

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 2/7] staging:lustre: remove useless libcfs_sock_release

There is no reason to have a one line exported function
libcfs_sock_release. Instead we can call sock_release directly.

Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/include/linux/libcfs/libcfs.h | 1 -
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.h | 2 +-
drivers/staging/lustre/lnet/lnet/acceptor.c | 8 ++++----
drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 --------
5 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index a789559..f469333 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -80,7 +80,6 @@ int libcfs_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
int libcfs_sock_getaddr(struct socket *socket, int remote, __u32 *ip, int *port);
int libcfs_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
int libcfs_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
-void libcfs_sock_release(struct socket *sock);

/* need both kernel and user-land acceptor */
#define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7b5d407..38e831f 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1386,7 +1386,7 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
LIBCFS_FREE(conn, sizeof(*conn));

failed_0:
- libcfs_sock_release(sock);
+ sock_release(sock);
return rc;
}

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index c34378c..06531c1 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -519,7 +519,7 @@ ksocknal_connsock_decref(ksock_conn_t *conn)
LASSERT(atomic_read(&conn->ksnc_sock_refcount) > 0);
if (atomic_dec_and_test(&conn->ksnc_sock_refcount)) {
LASSERT(conn->ksnc_closing);
- libcfs_sock_release(conn->ksnc_sock);
+ sock_release(conn->ksnc_sock);
conn->ksnc_sock = NULL;
ksocknal_finalize_zcreq(conn);
}
diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
index 69d4b19..bc212f5 100644
--- a/drivers/staging/lustre/lnet/lnet/acceptor.c
+++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
@@ -197,7 +197,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
goto failed;

failed_sock:
- libcfs_sock_release(sock);
+ sock_release(sock);
failed:
lnet_connect_console_error(rc, peer_nid, peer_ip, peer_port);
return rc;
@@ -379,7 +379,7 @@ lnet_acceptor(void *arg)

/* maybe we're waken up with libcfs_sock_abort_accept() */
if (lnet_acceptor_state.pta_shutdown) {
- libcfs_sock_release(newsock);
+ sock_release(newsock);
break;
}

@@ -410,10 +410,10 @@ lnet_acceptor(void *arg)
continue;

failed:
- libcfs_sock_release(newsock);
+ sock_release(newsock);
}

- libcfs_sock_release(lnet_acceptor_state.pta_sock);
+ sock_release(lnet_acceptor_state.pta_sock);
lnet_acceptor_state.pta_sock = NULL;

CDEBUG(D_NET, "Acceptor stopping\n");
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 7f80612..259db61 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -614,11 +614,3 @@ libcfs_sock_connect (struct socket **sockp, int *fatal,
}

EXPORT_SYMBOL(libcfs_sock_connect);
-
-void
-libcfs_sock_release (struct socket *sock)
-{
- sock_release(sock);
-}
-
-EXPORT_SYMBOL(libcfs_sock_release);
--
1.7.1

2015-06-03 19:57:49

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 3/7] staging:lustre: remove useless libcfs_sock_abort_accept

Another one of those silly one line wrappers which is not
needed. Replace libcfs_sock_abort_accept wrapper with a
direct call to wake_up_all on the lnet_acceptor_state sock.

Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/include/linux/libcfs/libcfs.h | 1 -
drivers/staging/lustre/lnet/lnet/acceptor.c | 4 ++--
drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 --------
3 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index f469333..457ce9a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -71,7 +71,6 @@ int libcfs_ipif_enumerate(char ***names);
void libcfs_ipif_free_enumeration(char **names, int n);
int libcfs_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
int libcfs_sock_accept(struct socket **newsockp, struct socket *sock);
-void libcfs_sock_abort_accept(struct socket *sock);
int libcfs_sock_connect(struct socket **sockp, int *fatal,
__u32 local_ip, int local_port,
__u32 peer_ip, int peer_port);
diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
index bc212f5..5187e65 100644
--- a/drivers/staging/lustre/lnet/lnet/acceptor.c
+++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
@@ -377,7 +377,7 @@ lnet_acceptor(void *arg)
continue;
}

- /* maybe we're waken up with libcfs_sock_abort_accept() */
+ /* maybe the LNet acceptor thread has been waken */
if (lnet_acceptor_state.pta_shutdown) {
sock_release(newsock);
break;
@@ -493,7 +493,7 @@ lnet_acceptor_stop(void)
return;

lnet_acceptor_state.pta_shutdown = 1;
- libcfs_sock_abort_accept(lnet_acceptor_state.pta_sock);
+ wake_up_all(sk_sleep(lnet_acceptor_state.pta_sock->sk));

/* block until acceptor signals exit */
wait_for_completion(&lnet_acceptor_state.pta_signal);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 259db61..bb8d9c2 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -568,14 +568,6 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)

EXPORT_SYMBOL(libcfs_sock_accept);

-void
-libcfs_sock_abort_accept (struct socket *sock)
-{
- wake_up_all(sk_sleep(sock->sk));
-}
-
-EXPORT_SYMBOL(libcfs_sock_abort_accept);
-
int
libcfs_sock_connect (struct socket **sockp, int *fatal,
__u32 local_ip, int local_port,
--
1.7.1

2015-06-03 19:57:53

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 4/7] staging:lustre: rename tcpip handling functions to lnet_* prefix

With all the TCPIP handling done in the lnet layer we should
rename all the functions with the prefix lnet_*. One other
change done was changing the remove argument of lnet_sock_getaddr
from a int to a bool.

Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/include/linux/libcfs/libcfs.h | 15 -----
.../staging/lustre/include/linux/lnet/lib-lnet.h | 16 +++++
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +-
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 11 ++--
.../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 6 +-
.../lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 15 ++---
.../lustre/lnet/klnds/socklnd/socklnd_proto.c | 43 ++++++-------
drivers/staging/lustre/lnet/lnet/acceptor.c | 43 ++++++-------
drivers/staging/lustre/lnet/lnet/config.c | 21 +++----
drivers/staging/lustre/lnet/lnet/lib-socket.c | 66 +++++++++----------
10 files changed, 110 insertions(+), 128 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 457ce9a..5dd9cdf 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -65,21 +65,6 @@ static inline int __is_po2(unsigned long long val)
int libcfs_arch_init(void);
void libcfs_arch_cleanup(void);

-/* libcfs tcpip */
-int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
-int libcfs_ipif_enumerate(char ***names);
-void libcfs_ipif_free_enumeration(char **names, int n);
-int libcfs_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
-int libcfs_sock_accept(struct socket **newsockp, struct socket *sock);
-int libcfs_sock_connect(struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port,
- __u32 peer_ip, int peer_port);
-int libcfs_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
-int libcfs_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
-int libcfs_sock_getaddr(struct socket *socket, int remote, __u32 *ip, int *port);
-int libcfs_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
-int libcfs_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
-
/* need both kernel and user-land acceptor */
#define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
#define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index d84aa9a..ff07703 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -844,6 +844,22 @@ int lnet_acceptor_port(void);
int lnet_acceptor_start(void);
void lnet_acceptor_stop(void);

+int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
+int lnet_ipif_enumerate(char ***names);
+void lnet_ipif_free_enumeration(char **names, int n);
+int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
+int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
+int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port);
+int lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
+int lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
+
+int lnet_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
+int lnet_sock_accept(struct socket **newsockp, struct socket *sock);
+int lnet_sock_connect(struct socket **sockp, int *fatal,
+ __u32 local_ip, int local_port,
+ __u32 peer_ip, int peer_port);
+void libcfs_sock_release(struct socket *sock);
+
void lnet_get_tunables(void);
int lnet_peers_start_down(void);
int lnet_peer_buffer_credits(lnet_ni_t *ni);
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index a57c5c3..060b739 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -2617,7 +2617,7 @@ static kib_dev_t *kiblnd_create_dev(char *ifname)
int up;
int rc;

- rc = libcfs_ipif_query(ifname, &up, &ip, &netmask);
+ rc = lnet_ipif_query(ifname, &up, &ip, &netmask);
if (rc != 0) {
CERROR("Can't query IPoIB interface %s: %d\n",
ifname, rc);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 38e831f..ee5cf35 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -968,7 +968,7 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
__u32 peer_ip;
int peer_port;

- rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
+ rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
LASSERT(rc == 0); /* we succeeded before */

LIBCFS_ALLOC(cr, sizeof(*cr));
@@ -2594,7 +2594,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
int rc;
int n;

- n = libcfs_ipif_enumerate(&names);
+ n = lnet_ipif_enumerate(&names);
if (n <= 0) {
CERROR("Can't enumerate interfaces: %d\n", n);
return n;
@@ -2608,7 +2608,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
continue;

- rc = libcfs_ipif_query(names[i], &up, &ip, &mask);
+ rc = lnet_ipif_query(names[i], &up, &ip, &mask);
if (rc != 0) {
CWARN("Can't get interface %s info: %d\n",
names[i], rc);
@@ -2634,7 +2634,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
j++;
}

- libcfs_ipif_free_enumeration(names, n);
+ lnet_ipif_free_enumeration(names, n);

if (j == 0)
CERROR("Can't find any usable interfaces\n");
@@ -2796,8 +2796,7 @@ ksocknal_startup(lnet_ni_t *ni)
if (ni->ni_interfaces[i] == NULL)
break;

- rc = libcfs_ipif_query(
- ni->ni_interfaces[i], &up,
+ rc = lnet_ipif_query(ni->ni_interfaces[i], &up,
&net->ksnn_interfaces[i].ksni_ipaddr,
&net->ksnn_interfaces[i].ksni_netmask);

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index a1a4ac0..fe2a83a 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -1707,7 +1707,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
timeout = active ? *ksocknal_tunables.ksnd_timeout :
lnet_acceptor_timeout();

- rc = libcfs_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
+ rc = lnet_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
if (rc != 0) {
CERROR("Error %d reading HELLO from %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -1726,8 +1726,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
return -EPROTO;
}

- rc = libcfs_sock_read(sock, &hello->kshm_version,
- sizeof(hello->kshm_version), timeout);
+ rc = lnet_sock_read(sock, &hello->kshm_version,
+ sizeof(hello->kshm_version), timeout);
if (rc != 0) {
CERROR("Error %d reading HELLO from %pI4h\n",
rc, &conn->ksnc_ipaddr);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
index caeb347..34c6a72 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
@@ -39,9 +39,8 @@
int
ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
{
- int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1,
- &conn->ksnc_ipaddr,
- &conn->ksnc_port);
+ int rc = lnet_sock_getaddr(conn->ksnc_sock, 1, &conn->ksnc_ipaddr,
+ &conn->ksnc_port);

/* Didn't need the {get,put}connsock dance to deref ksnc_sock... */
LASSERT(!conn->ksnc_closing);
@@ -51,8 +50,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
return rc;
}

- rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
- &conn->ksnc_myipaddr, NULL);
+ rc = lnet_sock_getaddr(conn->ksnc_sock, 0, &conn->ksnc_myipaddr, NULL);
if (rc != 0) {
CERROR("Error %d getting sock local IP\n", rc);
return rc;
@@ -436,7 +434,7 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *
return -ESHUTDOWN;
}

- rc = libcfs_sock_getbuf(sock, txmem, rxmem);
+ rc = lnet_sock_getbuf(sock, txmem, rxmem);
if (rc == 0) {
len = sizeof(*nagle);
rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY,
@@ -498,9 +496,8 @@ ksocknal_lib_setup_sock(struct socket *sock)
}
}

- rc = libcfs_sock_setbuf(sock,
- *ksocknal_tunables.ksnd_tx_buffer_size,
- *ksocknal_tunables.ksnd_rx_buffer_size);
+ rc = lnet_sock_setbuf(sock, *ksocknal_tunables.ksnd_tx_buffer_size,
+ *ksocknal_tunables.ksnd_rx_buffer_size);
if (rc != 0) {
CERROR("Can't set buffer tx %d, rx %d buffers: %d\n",
*ksocknal_tunables.ksnd_tx_buffer_size,
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
index 1938d6a..986bce4 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
@@ -495,9 +495,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);

- rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),
- lnet_acceptor_timeout());
-
+ rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
@@ -511,9 +509,9 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]);
}

- rc = libcfs_sock_write(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32),
- lnet_acceptor_timeout());
+ rc = lnet_sock_write(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32),
+ lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
rc, hello->kshm_nips,
@@ -544,9 +542,8 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
LNET_UNLOCK();
}

- rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
- lnet_acceptor_timeout());
-
+ rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
+ lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
@@ -556,9 +553,9 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
if (hello->kshm_nips == 0)
return 0;

- rc = libcfs_sock_write(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32),
- lnet_acceptor_timeout());
+ rc = lnet_sock_write(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32),
+ lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
rc, hello->kshm_nips,
@@ -583,9 +580,9 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
return -ENOMEM;
}

- rc = libcfs_sock_read(sock, &hdr->src_nid,
- sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
- timeout);
+ rc = lnet_sock_read(sock, &hdr->src_nid,
+ sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
+ timeout);
if (rc != 0) {
CERROR("Error %d reading rest of HELLO hdr from %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -619,8 +616,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
if (hello->kshm_nips == 0)
goto out;

- rc = libcfs_sock_read(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32), timeout);
+ rc = lnet_sock_read(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32), timeout);
if (rc != 0) {
CERROR("Error %d reading IPs from ip %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -656,10 +653,10 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout
else
conn->ksnc_flip = 1;

- rc = libcfs_sock_read(sock, &hello->kshm_src_nid,
- offsetof(ksock_hello_msg_t, kshm_ips) -
- offsetof(ksock_hello_msg_t, kshm_src_nid),
- timeout);
+ rc = lnet_sock_read(sock, &hello->kshm_src_nid,
+ offsetof(ksock_hello_msg_t, kshm_ips) -
+ offsetof(ksock_hello_msg_t, kshm_src_nid),
+ timeout);
if (rc != 0) {
CERROR("Error %d reading HELLO from %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -687,8 +684,8 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout
if (hello->kshm_nips == 0)
return 0;

- rc = libcfs_sock_read(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32), timeout);
+ rc = lnet_sock_read(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32), timeout);
if (rc != 0) {
CERROR("Error %d reading IPs from ip %pI4h\n",
rc, &conn->ksnc_ipaddr);
diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
index 5187e65..1dc7c8a 100644
--- a/drivers/staging/lustre/lnet/lnet/acceptor.c
+++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
@@ -155,9 +155,8 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
--port) {
/* Iterate through reserved ports. */

- rc = libcfs_sock_connect(&sock, &fatal,
- local_ip, port,
- peer_ip, peer_port);
+ rc = lnet_sock_connect(&sock, &fatal, local_ip, port, peer_ip,
+ peer_port);
if (rc != 0) {
if (fatal)
goto failed;
@@ -184,8 +183,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
lnet_net_unlock(LNET_LOCK_EX);
}

- rc = libcfs_sock_write(sock, &cr, sizeof(cr),
- accept_timeout);
+ rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
if (rc != 0)
goto failed_sock;

@@ -220,7 +218,7 @@ lnet_accept(struct socket *sock, __u32 magic)

LASSERT(sizeof(cr) <= 16); /* not too big for the stack */

- rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
+ rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
LASSERT(rc == 0); /* we succeeded before */

if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) {
@@ -234,8 +232,8 @@ lnet_accept(struct socket *sock, __u32 magic)
memset(&cr, 0, sizeof(cr));
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
- rc = libcfs_sock_write(sock, &cr, sizeof(cr),
- accept_timeout);
+ rc = lnet_sock_write(sock, &cr, sizeof(cr),
+ accept_timeout);

if (rc != 0)
CERROR("Error sending magic+version in response to LNET magic from %pI4h: %d\n",
@@ -257,9 +255,8 @@ lnet_accept(struct socket *sock, __u32 magic)

flip = (magic != LNET_PROTO_ACCEPTOR_MAGIC);

- rc = libcfs_sock_read(sock, &cr.acr_version,
- sizeof(cr.acr_version),
- accept_timeout);
+ rc = lnet_sock_read(sock, &cr.acr_version, sizeof(cr.acr_version),
+ accept_timeout);
if (rc != 0) {
CERROR("Error %d reading connection request version from %pI4h\n",
rc, &peer_ip);
@@ -280,19 +277,17 @@ lnet_accept(struct socket *sock, __u32 magic)
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;

- rc = libcfs_sock_write(sock, &cr, sizeof(cr),
- accept_timeout);
-
+ rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
if (rc != 0)
CERROR("Error sending magic+version in response to version %d from %pI4h: %d\n",
peer_version, &peer_ip, rc);
return -EPROTO;
}

- rc = libcfs_sock_read(sock, &cr.acr_nid,
- sizeof(cr) -
- offsetof(lnet_acceptor_connreq_t, acr_nid),
- accept_timeout);
+ rc = lnet_sock_read(sock, &cr.acr_nid,
+ sizeof(cr) -
+ offsetof(lnet_acceptor_connreq_t, acr_nid),
+ accept_timeout);
if (rc != 0) {
CERROR("Error %d reading connection request from %pI4h\n",
rc, &peer_ip);
@@ -343,8 +338,8 @@ lnet_acceptor(void *arg)

cfs_block_allsigs();

- rc = libcfs_sock_listen(&lnet_acceptor_state.pta_sock,
- 0, accept_port, accept_backlog);
+ rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock, 0, accept_port,
+ accept_backlog);
if (rc != 0) {
if (rc == -EADDRINUSE)
LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port %d: port already in use\n",
@@ -367,7 +362,7 @@ lnet_acceptor(void *arg)

while (!lnet_acceptor_state.pta_shutdown) {

- rc = libcfs_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
+ rc = lnet_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
if (rc != 0) {
if (rc != -EAGAIN) {
CWARN("Accept error %d: pausing...\n", rc);
@@ -383,7 +378,7 @@ lnet_acceptor(void *arg)
break;
}

- rc = libcfs_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
+ rc = lnet_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
if (rc != 0) {
CERROR("Can't determine new connection's address\n");
goto failed;
@@ -395,8 +390,8 @@ lnet_acceptor(void *arg)
goto failed;
}

- rc = libcfs_sock_read(newsock, &magic, sizeof(magic),
- accept_timeout);
+ rc = lnet_sock_read(newsock, &magic, sizeof(magic),
+ accept_timeout);
if (rc != 0) {
CERROR("Error %d reading connection request from %pI4h\n",
rc, &peer_ip);
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 70bc809..efbb74a 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -1118,7 +1118,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
__u32 *ipaddrs2;
int nip;
char **ifnames;
- int nif = libcfs_ipif_enumerate(&ifnames);
+ int nif = lnet_ipif_enumerate(&ifnames);
int i;
int rc;

@@ -1128,7 +1128,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
if (ipaddrs == NULL) {
CERROR("Can't allocate ipaddrs[%d]\n", nif);
- libcfs_ipif_free_enumeration(ifnames, nif);
+ lnet_ipif_free_enumeration(ifnames, nif);
return -ENOMEM;
}

@@ -1136,8 +1136,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
if (!strcmp(ifnames[i], "lo"))
continue;

- rc = libcfs_ipif_query(ifnames[i], &up,
- &ipaddrs[nip], &netmask);
+ rc = lnet_ipif_query(ifnames[i], &up, &ipaddrs[nip], &netmask);
if (rc != 0) {
CWARN("Can't query interface %s: %d\n",
ifnames[i], rc);
@@ -1153,7 +1152,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
nip++;
}

- libcfs_ipif_free_enumeration(ifnames, nif);
+ lnet_ipif_free_enumeration(ifnames, nif);

if (nip == nif) {
*ipaddrsp = ipaddrs;
@@ -1237,8 +1236,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
return -EPERM;
}

- rc = libcfs_ipif_query(ni->ni_interfaces[0],
- &up, &ip, &netmask);
+ rc = lnet_ipif_query(ni->ni_interfaces[0], &up, &ip, &netmask);
if (rc != 0) {
CERROR("Net %s can't query interface %s: %d\n",
libcfs_net2str(net), ni->ni_interfaces[0], rc);
@@ -1255,7 +1253,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
return 0;
}

- n = libcfs_ipif_enumerate(&names);
+ n = lnet_ipif_enumerate(&names);
if (n <= 0) {
CERROR("Net %s can't enumerate interfaces: %d\n",
libcfs_net2str(net), n);
@@ -1266,8 +1264,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
continue;

- rc = libcfs_ipif_query(names[i], &up, &ip, &netmask);
-
+ rc = lnet_ipif_query(names[i], &up, &ip, &netmask);
if (rc != 0) {
CWARN("Net %s can't query interface %s: %d\n",
libcfs_net2str(net), names[i], rc);
@@ -1280,13 +1277,13 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
continue;
}

- libcfs_ipif_free_enumeration(names, n);
+ lnet_ipif_free_enumeration(names, n);
ni->ni_nid = LNET_MKNID(net, ip);
return 0;
}

CERROR("Net %s can't find any interfaces\n", libcfs_net2str(net));
- libcfs_ipif_free_enumeration(names, n);
+ lnet_ipif_free_enumeration(names, n);
return -ENOENT;
}
EXPORT_SYMBOL(lnet_set_ip_niaddr);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index bb8d9c2..2e87168 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -45,7 +45,7 @@
#include <linux/syscalls.h>

static int
-libcfs_sock_ioctl(int cmd, unsigned long arg)
+lnet_sock_ioctl(int cmd, unsigned long arg)
{
mm_segment_t oldmm = get_fs();
struct socket *sock;
@@ -76,7 +76,7 @@ out:
}

int
-libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
+lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
{
struct ifreq ifr;
int nob;
@@ -92,8 +92,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);

strcpy(ifr.ifr_name, name);
- rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
-
+ rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
if (rc != 0) {
CERROR("Can't get flags for interface %s\n", name);
return rc;
@@ -110,8 +109,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)

strcpy(ifr.ifr_name, name);
ifr.ifr_addr.sa_family = AF_INET;
- rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
-
+ rc = lnet_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
if (rc != 0) {
CERROR("Can't get IP address for interface %s\n", name);
return rc;
@@ -122,8 +120,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)

strcpy(ifr.ifr_name, name);
ifr.ifr_addr.sa_family = AF_INET;
- rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
-
+ rc = lnet_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
if (rc != 0) {
CERROR("Can't get netmask for interface %s\n", name);
return rc;
@@ -135,10 +132,10 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
return 0;
}

-EXPORT_SYMBOL(libcfs_ipif_query);
+EXPORT_SYMBOL(lnet_ipif_query);

int
-libcfs_ipif_enumerate (char ***namesp)
+lnet_ipif_enumerate (char ***namesp)
{
/* Allocate and fill in 'names', returning # interfaces/error */
char **names;
@@ -172,8 +169,7 @@ libcfs_ipif_enumerate (char ***namesp)
ifc.ifc_buf = (char *)ifr;
ifc.ifc_len = nalloc * sizeof(*ifr);

- rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
-
+ rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
if (rc < 0) {
CERROR ("Error %d enumerating interfaces\n", rc);
goto out1;
@@ -226,17 +222,17 @@ libcfs_ipif_enumerate (char ***namesp)

out2:
if (rc < 0)
- libcfs_ipif_free_enumeration(names, nfound);
+ lnet_ipif_free_enumeration(names, nfound);
out1:
LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
out0:
return rc;
}

-EXPORT_SYMBOL(libcfs_ipif_enumerate);
+EXPORT_SYMBOL(lnet_ipif_enumerate);

void
-libcfs_ipif_free_enumeration (char **names, int n)
+lnet_ipif_free_enumeration (char **names, int n)
{
int i;

@@ -248,10 +244,10 @@ libcfs_ipif_free_enumeration (char **names, int n)
LIBCFS_FREE(names, n * sizeof(*names));
}

-EXPORT_SYMBOL(libcfs_ipif_free_enumeration);
+EXPORT_SYMBOL(lnet_ipif_free_enumeration);

int
-libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
+lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
{
int rc;
long ticks = timeout * HZ;
@@ -310,10 +306,10 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)

return 0;
}
-EXPORT_SYMBOL(libcfs_sock_write);
+EXPORT_SYMBOL(lnet_sock_write);

int
-libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
+lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
{
int rc;
long ticks = timeout * HZ;
@@ -366,10 +362,10 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
}
}

-EXPORT_SYMBOL(libcfs_sock_read);
+EXPORT_SYMBOL(lnet_sock_read);

static int
-libcfs_sock_create (struct socket **sockp, int *fatal,
+lnet_sock_create (struct socket **sockp, int *fatal,
__u32 local_ip, int local_port)
{
struct sockaddr_in locaddr;
@@ -424,7 +420,7 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
}

int
-libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
+lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
{
int option;
int rc;
@@ -454,10 +450,10 @@ libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
return 0;
}

-EXPORT_SYMBOL(libcfs_sock_setbuf);
+EXPORT_SYMBOL(lnet_sock_setbuf);

int
-libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
+lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port)
{
struct sockaddr_in sin;
int len = sizeof (sin);
@@ -480,10 +476,10 @@ libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
return 0;
}

-EXPORT_SYMBOL(libcfs_sock_getaddr);
+EXPORT_SYMBOL(lnet_sock_getaddr);

int
-libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
+lnet_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
{

if (txbufsize != NULL) {
@@ -497,16 +493,16 @@ libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
return 0;
}

-EXPORT_SYMBOL(libcfs_sock_getbuf);
+EXPORT_SYMBOL(lnet_sock_getbuf);

int
-libcfs_sock_listen (struct socket **sockp,
+lnet_sock_listen (struct socket **sockp,
__u32 local_ip, int local_port, int backlog)
{
int fatal;
int rc;

- rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port);
+ rc = lnet_sock_create(sockp, &fatal, local_ip, local_port);
if (rc != 0) {
if (!fatal)
CERROR("Can't create socket: port %d already in use\n",
@@ -523,10 +519,10 @@ libcfs_sock_listen (struct socket **sockp,
return rc;
}

-EXPORT_SYMBOL(libcfs_sock_listen);
+EXPORT_SYMBOL(lnet_sock_listen);

int
-libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
+lnet_sock_accept (struct socket **newsockp, struct socket *sock)
{
wait_queue_t wait;
struct socket *newsock;
@@ -566,17 +562,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
return rc;
}

-EXPORT_SYMBOL(libcfs_sock_accept);
+EXPORT_SYMBOL(lnet_sock_accept);

int
-libcfs_sock_connect (struct socket **sockp, int *fatal,
+lnet_sock_connect (struct socket **sockp, int *fatal,
__u32 local_ip, int local_port,
__u32 peer_ip, int peer_port)
{
struct sockaddr_in srvaddr;
int rc;

- rc = libcfs_sock_create(sockp, fatal, local_ip, local_port);
+ rc = lnet_sock_create(sockp, fatal, local_ip, local_port);
if (rc != 0)
return rc;

@@ -605,4 +601,4 @@ libcfs_sock_connect (struct socket **sockp, int *fatal,
return rc;
}

-EXPORT_SYMBOL(libcfs_sock_connect);
+EXPORT_SYMBOL(lnet_sock_connect);
--
1.7.1

2015-06-03 19:59:34

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 5/7] staging:lustre: use available kernel wrappers in lib-socket.c

Instead of handling calls to struct proto ourselves we can use
equivalent kernel wrappers. No wrapper exist for unlocked ioctl
handling so we create one here for our use. I expect some day
that function will be integrated into sock.c.

Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/lnet/lib-socket.c | 47 ++++++++++++++++---------
1 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 2e87168..2d46a69 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -35,22 +35,37 @@
*/
#define DEBUG_SUBSYSTEM S_LNET

-#include "../../include/linux/libcfs/libcfs.h"
-#include "../../include/linux/lnet/lib-lnet.h"
-
#include <linux/if.h>
#include <linux/in.h>
+#include <linux/net.h>
#include <linux/file.h>
+#include <linux/pagemap.h>
/* For sys_open & sys_close */
#include <linux/syscalls.h>
+#include <net/sock.h>
+
+#include "../../include/linux/libcfs/libcfs.h"
+#include "../../include/linux/lnet/lib-lnet.h"
+
+static int
+kernel_sock_unlocked_ioctl(struct file *filp, int cmd, unsigned long arg)
+{
+ mm_segment_t oldfs = get_fs();
+ int err;
+
+ set_fs(KERNEL_DS);
+ err = filp->f_op->unlocked_ioctl(filp, cmd, arg);
+ set_fs(oldfs);
+
+ return err;
+}

static int
lnet_sock_ioctl(int cmd, unsigned long arg)
{
- mm_segment_t oldmm = get_fs();
+ struct file *sock_filp;
struct socket *sock;
int rc;
- struct file *sock_filp;

rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
if (rc != 0) {
@@ -65,10 +80,7 @@ lnet_sock_ioctl(int cmd, unsigned long arg)
goto out;
}

- set_fs(KERNEL_DS);
- if (sock_filp->f_op->unlocked_ioctl)
- rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg);
- set_fs(oldmm);
+ rc = kernel_sock_unlocked_ioctl(sock_filp, cmd, arg);

fput(sock_filp);
out:
@@ -398,8 +410,8 @@ lnet_sock_create (struct socket **sockp, int *fatal,
locaddr.sin_addr.s_addr = (local_ip == 0) ?
INADDR_ANY : htonl(local_ip);

- rc = sock->ops->bind(sock, (struct sockaddr *)&locaddr,
- sizeof(locaddr));
+ rc = kernel_bind(sock, (struct sockaddr *)&locaddr,
+ sizeof(locaddr));
if (rc == -EADDRINUSE) {
CDEBUG(D_NET, "Port %d already in use\n", local_port);
*fatal = 0;
@@ -459,8 +471,10 @@ lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port)
int len = sizeof (sin);
int rc;

- rc = sock->ops->getname (sock, (struct sockaddr *)&sin, &len,
- remote ? 2 : 0);
+ if (remote)
+ rc = kernel_getpeername(sock, (struct sockaddr *)&sin, &len);
+ else
+ rc = kernel_getsockname(sock, (struct sockaddr *)&sin, &len);
if (rc != 0) {
CERROR ("Error %d getting sock %s IP/port\n",
rc, remote ? "peer" : "local");
@@ -510,7 +524,7 @@ lnet_sock_listen (struct socket **sockp,
return rc;
}

- rc = (*sockp)->ops->listen(*sockp, backlog);
+ rc = kernel_listen(*sockp, backlog);
if (rc == 0)
return 0;

@@ -581,9 +595,8 @@ lnet_sock_connect (struct socket **sockp, int *fatal,
srvaddr.sin_port = htons(peer_port);
srvaddr.sin_addr.s_addr = htonl(peer_ip);

- rc = (*sockp)->ops->connect(*sockp,
- (struct sockaddr *)&srvaddr, sizeof(srvaddr),
- 0);
+ rc = kernel_connect(*sockp, (struct sockaddr *)&srvaddr,
+ sizeof(srvaddr), 0);
if (rc == 0)
return 0;

--
1.7.1

2015-06-03 19:58:25

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 6/7] staging:lustre: style cleanups for lib-socket.c

Handle all the style issues reported by checkpatch.pl.
Remove general white spaces, spaces in function calls,
etc.

Signed-off-by: James Simmons <[email protected]>
---
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 +-
drivers/staging/lustre/lnet/lnet/lib-socket.c | 207 +++++++++-----------
2 files changed, 96 insertions(+), 115 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index ee5cf35..4128a92 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1378,14 +1378,14 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
ksocknal_txlist_done(ni, &zombies, 1);
ksocknal_peer_decref(peer);

- failed_1:
+failed_1:
if (hello != NULL)
LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t,
kshm_ips[LNET_MAX_INTERFACES]));

LIBCFS_FREE(conn, sizeof(*conn));

- failed_0:
+failed_0:
sock_release(sock);
return rc;
}
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 2d46a69..b126068 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -63,13 +63,13 @@ kernel_sock_unlocked_ioctl(struct file *filp, int cmd, unsigned long arg)
static int
lnet_sock_ioctl(int cmd, unsigned long arg)
{
- struct file *sock_filp;
- struct socket *sock;
- int rc;
+ struct file *sock_filp;
+ struct socket *sock;
+ int rc;

- rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
+ rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock);
if (rc != 0) {
- CERROR ("Can't create socket: %d\n", rc);
+ CERROR("Can't create socket: %d\n", rc);
return rc;
}

@@ -88,12 +88,12 @@ out:
}

int
-lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
+lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask)
{
- struct ifreq ifr;
- int nob;
- int rc;
- __u32 val;
+ struct ifreq ifr;
+ int nob;
+ int rc;
+ __u32 val;

nob = strnlen(name, IFNAMSIZ);
if (nob == IFNAMSIZ) {
@@ -101,7 +101,7 @@ lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
return -EINVAL;
}

- CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
+ CLASSERT(sizeof(ifr.ifr_name) >= IFNAMSIZ);

strcpy(ifr.ifr_name, name);
rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
@@ -116,7 +116,6 @@ lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
*ip = *mask = 0;
return 0;
}
-
*up = 1;

strcpy(ifr.ifr_name, name);
@@ -143,23 +142,21 @@ lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)

return 0;
}
-
EXPORT_SYMBOL(lnet_ipif_query);

int
-lnet_ipif_enumerate (char ***namesp)
+lnet_ipif_enumerate(char ***namesp)
{
/* Allocate and fill in 'names', returning # interfaces/error */
- char **names;
- int toobig;
- int nalloc;
- int nfound;
- struct ifreq *ifr;
- struct ifconf ifc;
- int rc;
- int nob;
- int i;
-
+ char **names;
+ int toobig;
+ int nalloc;
+ int nfound;
+ struct ifreq *ifr;
+ struct ifconf ifc;
+ int rc;
+ int nob;
+ int i;

nalloc = 16; /* first guess at max interfaces */
toobig = 0;
@@ -167,13 +164,14 @@ lnet_ipif_enumerate (char ***namesp)
if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) {
toobig = 1;
nalloc = PAGE_CACHE_SIZE/sizeof(*ifr);
- CWARN("Too many interfaces: only enumerating first %d\n",
- nalloc);
+ CWARN("Too many interfaces: only enumerating "
+ "first %d\n", nalloc);
}

LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr));
if (ifr == NULL) {
- CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc);
+ CERROR("ENOMEM enumerating up to %d interfaces\n",
+ nalloc);
rc = -ENOMEM;
goto out0;
}
@@ -183,14 +181,14 @@ lnet_ipif_enumerate (char ***namesp)

rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
if (rc < 0) {
- CERROR ("Error %d enumerating interfaces\n", rc);
+ CERROR("Error %d enumerating interfaces\n", rc);
goto out1;
}

- LASSERT (rc == 0);
+ LASSERT(rc == 0);

nfound = ifc.ifc_len/sizeof(*ifr);
- LASSERT (nfound <= nalloc);
+ LASSERT(nfound <= nalloc);

if (nfound < nalloc || toobig)
break;
@@ -209,8 +207,7 @@ lnet_ipif_enumerate (char ***namesp)
}

for (i = 0; i < nfound; i++) {
-
- nob = strnlen (ifr[i].ifr_name, IFNAMSIZ);
+ nob = strnlen(ifr[i].ifr_name, IFNAMSIZ);
if (nob == IFNAMSIZ) {
/* no space for terminating NULL */
CERROR("interface name %.*s too long (%d max)\n",
@@ -232,41 +229,39 @@ lnet_ipif_enumerate (char ***namesp)
*namesp = names;
rc = nfound;

- out2:
+out2:
if (rc < 0)
lnet_ipif_free_enumeration(names, nfound);
- out1:
+out1:
LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
- out0:
+out0:
return rc;
}
-
EXPORT_SYMBOL(lnet_ipif_enumerate);

void
-lnet_ipif_free_enumeration (char **names, int n)
+lnet_ipif_free_enumeration(char **names, int n)
{
- int i;
+ int i;

- LASSERT (n > 0);
+ LASSERT(n > 0);

for (i = 0; i < n && names[i] != NULL; i++)
LIBCFS_FREE(names[i], IFNAMSIZ);

LIBCFS_FREE(names, n * sizeof(*names));
}
-
EXPORT_SYMBOL(lnet_ipif_free_enumeration);

int
-lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
+lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
{
- int rc;
- long ticks = timeout * HZ;
- unsigned long then;
+ int rc;
+ long ticks = timeout * HZ;
+ unsigned long then;
struct timeval tv;

- LASSERT (nob > 0);
+ LASSERT(nob > 0);
/* Caller may pass a zero timeout if she thinks the socket buffer is
* empty enough to take the whole message immediately */

@@ -286,7 +281,7 @@ lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
.tv_usec = ((ticks % HZ) * 1000000) / HZ
};
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
- (char *)&tv, sizeof(tv));
+ (char *)&tv, sizeof(tv));
if (rc != 0) {
CERROR("Can't set socket send timeout %ld.%06d: %d\n",
(long)tv.tv_sec, (int)tv.tv_usec, rc);
@@ -305,7 +300,7 @@ lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
return rc;

if (rc == 0) {
- CERROR ("Unexpected zero rc\n");
+ CERROR("Unexpected zero rc\n");
return -ECONNABORTED;
}

@@ -315,21 +310,20 @@ lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
buffer = ((char *)buffer) + rc;
nob -= rc;
}
-
return 0;
}
EXPORT_SYMBOL(lnet_sock_write);

int
-lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
+lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
{
- int rc;
- long ticks = timeout * HZ;
- unsigned long then;
+ int rc;
+ long ticks = timeout * HZ;
+ unsigned long then;
struct timeval tv;

- LASSERT (nob > 0);
- LASSERT (ticks > 0);
+ LASSERT(nob > 0);
+ LASSERT(ticks > 0);

for (;;) {
struct kvec iov = {
@@ -337,7 +331,7 @@ lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
.iov_len = nob
};
struct msghdr msg = {
- .msg_flags = 0
+ .msg_flags = 0
};

/* Set receive timeout to remaining time */
@@ -346,7 +340,7 @@ lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
.tv_usec = ((ticks % HZ) * 1000000) / HZ
};
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
- (char *)&tv, sizeof(tv));
+ (char *)&tv, sizeof(tv));
if (rc != 0) {
CERROR("Can't set socket recv timeout %ld.%06d: %d\n",
(long)tv.tv_sec, (int)tv.tv_usec, rc);
@@ -373,31 +367,30 @@ lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
return -ETIMEDOUT;
}
}
-
EXPORT_SYMBOL(lnet_sock_read);

static int
-lnet_sock_create (struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port)
+lnet_sock_create(struct socket **sockp, int *fatal, __u32 local_ip,
+ int local_port)
{
- struct sockaddr_in locaddr;
- struct socket *sock;
- int rc;
- int option;
+ struct sockaddr_in locaddr;
+ struct socket *sock;
+ int rc;
+ int option;

/* All errors are fatal except bind failure if the port is in use */
*fatal = 1;

- rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
+ rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock);
*sockp = sock;
if (rc != 0) {
- CERROR ("Can't create socket: %d\n", rc);
+ CERROR("Can't create socket: %d\n", rc);
return rc;
}

option = 1;
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
- (char *)&option, sizeof (option));
+ (char *)&option, sizeof(option));
if (rc != 0) {
CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc);
goto failed;
@@ -423,27 +416,26 @@ lnet_sock_create (struct socket **sockp, int *fatal,
goto failed;
}
}
-
return 0;

- failed:
+failed:
sock_release(sock);
return rc;
}

int
-lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
+lnet_sock_setbuf(struct socket *sock, int txbufsize, int rxbufsize)
{
- int option;
- int rc;
+ int option;
+ int rc;

if (txbufsize != 0) {
option = txbufsize;
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
- (char *)&option, sizeof (option));
+ (char *)&option, sizeof(option));
if (rc != 0) {
- CERROR ("Can't set send buffer %d: %d\n",
- option, rc);
+ CERROR("Can't set send buffer %d: %d\n",
+ option, rc);
return rc;
}
}
@@ -451,70 +443,63 @@ lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
if (rxbufsize != 0) {
option = rxbufsize;
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
- (char *)&option, sizeof (option));
+ (char *)&option, sizeof(option));
if (rc != 0) {
- CERROR ("Can't set receive buffer %d: %d\n",
- option, rc);
+ CERROR("Can't set receive buffer %d: %d\n",
+ option, rc);
return rc;
}
}
-
return 0;
}
-
EXPORT_SYMBOL(lnet_sock_setbuf);

int
-lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port)
+lnet_sock_getaddr(struct socket *sock, bool remote, __u32 *ip, int *port)
{
struct sockaddr_in sin;
- int len = sizeof (sin);
- int rc;
+ int len = sizeof(sin);
+ int rc;

if (remote)
rc = kernel_getpeername(sock, (struct sockaddr *)&sin, &len);
else
rc = kernel_getsockname(sock, (struct sockaddr *)&sin, &len);
if (rc != 0) {
- CERROR ("Error %d getting sock %s IP/port\n",
- rc, remote ? "peer" : "local");
+ CERROR("Error %d getting sock %s IP/port\n",
+ rc, remote ? "peer" : "local");
return rc;
}

if (ip != NULL)
- *ip = ntohl (sin.sin_addr.s_addr);
+ *ip = ntohl(sin.sin_addr.s_addr);

if (port != NULL)
- *port = ntohs (sin.sin_port);
+ *port = ntohs(sin.sin_port);

return 0;
}
-
EXPORT_SYMBOL(lnet_sock_getaddr);

int
-lnet_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
+lnet_sock_getbuf(struct socket *sock, int *txbufsize, int *rxbufsize)
{
-
- if (txbufsize != NULL) {
+ if (txbufsize != NULL)
*txbufsize = sock->sk->sk_sndbuf;
- }

- if (rxbufsize != NULL) {
+ if (rxbufsize != NULL)
*rxbufsize = sock->sk->sk_rcvbuf;
- }

return 0;
}
-
EXPORT_SYMBOL(lnet_sock_getbuf);

int
-lnet_sock_listen (struct socket **sockp,
- __u32 local_ip, int local_port, int backlog)
+lnet_sock_listen(struct socket **sockp, __u32 local_ip, int local_port,
+ int backlog)
{
- int fatal;
- int rc;
+ int fatal;
+ int rc;

rc = lnet_sock_create(sockp, &fatal, local_ip, local_port);
if (rc != 0) {
@@ -532,15 +517,14 @@ lnet_sock_listen (struct socket **sockp,
sock_release(*sockp);
return rc;
}
-
EXPORT_SYMBOL(lnet_sock_listen);

int
-lnet_sock_accept (struct socket **newsockp, struct socket *sock)
+lnet_sock_accept(struct socket **newsockp, struct socket *sock)
{
- wait_queue_t wait;
+ wait_queue_t wait;
struct socket *newsock;
- int rc;
+ int rc;

init_waitqueue_entry(&wait, current);

@@ -571,26 +555,24 @@ lnet_sock_accept (struct socket **newsockp, struct socket *sock)
*newsockp = newsock;
return 0;

- failed:
+failed:
sock_release(newsock);
return rc;
}
-
EXPORT_SYMBOL(lnet_sock_accept);

int
-lnet_sock_connect (struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port,
- __u32 peer_ip, int peer_port)
+lnet_sock_connect(struct socket **sockp, int *fatal, __u32 local_ip,
+ int local_port, __u32 peer_ip, int peer_port)
{
- struct sockaddr_in srvaddr;
- int rc;
+ struct sockaddr_in srvaddr;
+ int rc;

rc = lnet_sock_create(sockp, fatal, local_ip, local_port);
if (rc != 0)
return rc;

- memset (&srvaddr, 0, sizeof (srvaddr));
+ memset(&srvaddr, 0, sizeof(srvaddr));
srvaddr.sin_family = AF_INET;
srvaddr.sin_port = htons(peer_port);
srvaddr.sin_addr.s_addr = htonl(peer_ip);
@@ -607,11 +589,10 @@ lnet_sock_connect (struct socket **sockp, int *fatal,
*fatal = !(rc == -EADDRNOTAVAIL);

CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET,
- "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc,
- &local_ip, local_port, &peer_ip, peer_port);
+ "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc,
+ &local_ip, local_port, &peer_ip, peer_port);

sock_release(*sockp);
return rc;
}
-
EXPORT_SYMBOL(lnet_sock_connect);
--
1.7.1

2015-06-03 19:58:15

by James Simmons

[permalink] [raw]
Subject: [PATCH v4 7/7] staging:lustre: Update license and copyright for lib-socket.c

Point to the right place for GNU license. Update Intel copyright.

Signed-off-by: James Simmons <[email protected]>
---
drivers/staging/lustre/lnet/lnet/lib-socket.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index f0b187d..2f8443c 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -15,11 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit http://www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
@@ -27,11 +23,11 @@
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2015 Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*/
#define DEBUG_SUBSYSTEM S_LNET

--
1.7.1

2015-06-04 05:36:08

by Sudip Mukherjee

[permalink] [raw]
Subject: Re: [PATCH v4 1/7] staging:lustre: move tcpip abstraction

On Wed, Jun 03, 2015 at 03:57:07PM -0400, James Simmons wrote:
> Rename libcfs/linux/linux-tcpip.c to lnet/lnet/lib-socket.c
looks like you have not just renamed the file, but there was also a change
in the #include which is not mentioned in the commit message.

--- drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.old 2015-06-04 11:01:01.862374309 +0530
+++ drivers/staging/lustre/lnet/lnet/lib-socket.c 2015-06-04 11:01:37.082375681 +0530
@@ -35,7 +35,8 @@
*/
#define DEBUG_SUBSYSTEM S_LNET

-#include "../../../include/linux/libcfs/libcfs.h"
+#include "../../include/linux/libcfs/libcfs.h"
+#include "../../include/linux/lnet/lib-lnet.h"

#include <linux/if.h>
#include <linux/in.h>

regards
sudip

2015-06-04 05:57:30

by Sudip Mukherjee

[permalink] [raw]
Subject: Re: [PATCH v4 4/7] staging:lustre: rename tcpip handling functions to lnet_* prefix

On Wed, Jun 03, 2015 at 03:57:10PM -0400, James Simmons wrote:
> With all the TCPIP handling done in the lnet layer we should
> rename all the functions with the prefix lnet_*. One other
> change done was changing the remove argument of lnet_sock_getaddr
> from a int to a bool.
thats two different change.
and apart from this:
1) the function declarations were renamed and moved from
lustre/include/linux/libcfs/libcfs.h to drivers/staging/lustre/include/linux/lnet/lib-lnet.h

2) some functions you have changed the coding style. like:
- rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
- &conn->ksnc_myipaddr, NULL);
+ rc = lnet_sock_getaddr(conn->ksnc_sock, 0, &conn->ksnc_myipaddr, NULL);

regards
sudip



>
> Signed-off-by: James Simmons <[email protected]>
> ---
> .../staging/lustre/include/linux/libcfs/libcfs.h | 15 -----
> .../staging/lustre/include/linux/lnet/lib-lnet.h | 16 +++++
> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +-
> .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 11 ++--
> .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 6 +-
> .../lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 15 ++---
> .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 43 ++++++-------
> drivers/staging/lustre/lnet/lnet/acceptor.c | 43 ++++++-------
> drivers/staging/lustre/lnet/lnet/config.c | 21 +++----
> drivers/staging/lustre/lnet/lnet/lib-socket.c | 66 +++++++++----------
> 10 files changed, 110 insertions(+), 128 deletions(-)
>
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 457ce9a..5dd9cdf 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -65,21 +65,6 @@ static inline int __is_po2(unsigned long long val)
> int libcfs_arch_init(void);
> void libcfs_arch_cleanup(void);
>
> -/* libcfs tcpip */
> -int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
> -int libcfs_ipif_enumerate(char ***names);
> -void libcfs_ipif_free_enumeration(char **names, int n);
> -int libcfs_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
> -int libcfs_sock_accept(struct socket **newsockp, struct socket *sock);
> -int libcfs_sock_connect(struct socket **sockp, int *fatal,
> - __u32 local_ip, int local_port,
> - __u32 peer_ip, int peer_port);
> -int libcfs_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
> -int libcfs_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
> -int libcfs_sock_getaddr(struct socket *socket, int remote, __u32 *ip, int *port);
> -int libcfs_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
> -int libcfs_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
> -
> /* need both kernel and user-land acceptor */
> #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
> #define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> index d84aa9a..ff07703 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> @@ -844,6 +844,22 @@ int lnet_acceptor_port(void);
> int lnet_acceptor_start(void);
> void lnet_acceptor_stop(void);
>
> +int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
> +int lnet_ipif_enumerate(char ***names);
> +void lnet_ipif_free_enumeration(char **names, int n);
> +int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
> +int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
> +int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port);
> +int lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
> +int lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
> +
> +int lnet_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
> +int lnet_sock_accept(struct socket **newsockp, struct socket *sock);
> +int lnet_sock_connect(struct socket **sockp, int *fatal,
> + __u32 local_ip, int local_port,
> + __u32 peer_ip, int peer_port);
> +void libcfs_sock_release(struct socket *sock);
> +
> void lnet_get_tunables(void);
> int lnet_peers_start_down(void);
> int lnet_peer_buffer_credits(lnet_ni_t *ni);
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index a57c5c3..060b739 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -2617,7 +2617,7 @@ static kib_dev_t *kiblnd_create_dev(char *ifname)
> int up;
> int rc;
>
> - rc = libcfs_ipif_query(ifname, &up, &ip, &netmask);
> + rc = lnet_ipif_query(ifname, &up, &ip, &netmask);
> if (rc != 0) {
> CERROR("Can't query IPoIB interface %s: %d\n",
> ifname, rc);
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 38e831f..ee5cf35 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -968,7 +968,7 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
> __u32 peer_ip;
> int peer_port;
>
> - rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
> + rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
> LASSERT(rc == 0); /* we succeeded before */
>
> LIBCFS_ALLOC(cr, sizeof(*cr));
> @@ -2594,7 +2594,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
> int rc;
> int n;
>
> - n = libcfs_ipif_enumerate(&names);
> + n = lnet_ipif_enumerate(&names);
> if (n <= 0) {
> CERROR("Can't enumerate interfaces: %d\n", n);
> return n;
> @@ -2608,7 +2608,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
> if (!strcmp(names[i], "lo")) /* skip the loopback IF */
> continue;
>
> - rc = libcfs_ipif_query(names[i], &up, &ip, &mask);
> + rc = lnet_ipif_query(names[i], &up, &ip, &mask);
> if (rc != 0) {
> CWARN("Can't get interface %s info: %d\n",
> names[i], rc);
> @@ -2634,7 +2634,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
> j++;
> }
>
> - libcfs_ipif_free_enumeration(names, n);
> + lnet_ipif_free_enumeration(names, n);
>
> if (j == 0)
> CERROR("Can't find any usable interfaces\n");
> @@ -2796,8 +2796,7 @@ ksocknal_startup(lnet_ni_t *ni)
> if (ni->ni_interfaces[i] == NULL)
> break;
>
> - rc = libcfs_ipif_query(
> - ni->ni_interfaces[i], &up,
> + rc = lnet_ipif_query(ni->ni_interfaces[i], &up,
> &net->ksnn_interfaces[i].ksni_ipaddr,
> &net->ksnn_interfaces[i].ksni_netmask);
>
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index a1a4ac0..fe2a83a 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -1707,7 +1707,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
> timeout = active ? *ksocknal_tunables.ksnd_timeout :
> lnet_acceptor_timeout();
>
> - rc = libcfs_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
> + rc = lnet_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
> if (rc != 0) {
> CERROR("Error %d reading HELLO from %pI4h\n",
> rc, &conn->ksnc_ipaddr);
> @@ -1726,8 +1726,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
> return -EPROTO;
> }
>
> - rc = libcfs_sock_read(sock, &hello->kshm_version,
> - sizeof(hello->kshm_version), timeout);
> + rc = lnet_sock_read(sock, &hello->kshm_version,
> + sizeof(hello->kshm_version), timeout);
> if (rc != 0) {
> CERROR("Error %d reading HELLO from %pI4h\n",
> rc, &conn->ksnc_ipaddr);
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
> index caeb347..34c6a72 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
> @@ -39,9 +39,8 @@
> int
> ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
> {
> - int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1,
> - &conn->ksnc_ipaddr,
> - &conn->ksnc_port);
> + int rc = lnet_sock_getaddr(conn->ksnc_sock, 1, &conn->ksnc_ipaddr,
> + &conn->ksnc_port);
>
> /* Didn't need the {get,put}connsock dance to deref ksnc_sock... */
> LASSERT(!conn->ksnc_closing);
> @@ -51,8 +50,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
> return rc;
> }
>
> - rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
> - &conn->ksnc_myipaddr, NULL);
> + rc = lnet_sock_getaddr(conn->ksnc_sock, 0, &conn->ksnc_myipaddr, NULL);
> if (rc != 0) {
> CERROR("Error %d getting sock local IP\n", rc);
> return rc;
> @@ -436,7 +434,7 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *
> return -ESHUTDOWN;
> }
>
> - rc = libcfs_sock_getbuf(sock, txmem, rxmem);
> + rc = lnet_sock_getbuf(sock, txmem, rxmem);
> if (rc == 0) {
> len = sizeof(*nagle);
> rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY,
> @@ -498,9 +496,8 @@ ksocknal_lib_setup_sock(struct socket *sock)
> }
> }
>
> - rc = libcfs_sock_setbuf(sock,
> - *ksocknal_tunables.ksnd_tx_buffer_size,
> - *ksocknal_tunables.ksnd_rx_buffer_size);
> + rc = lnet_sock_setbuf(sock, *ksocknal_tunables.ksnd_tx_buffer_size,
> + *ksocknal_tunables.ksnd_rx_buffer_size);
> if (rc != 0) {
> CERROR("Can't set buffer tx %d, rx %d buffers: %d\n",
> *ksocknal_tunables.ksnd_tx_buffer_size,
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
> index 1938d6a..986bce4 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
> @@ -495,9 +495,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
> hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
> hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
>
> - rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),
> - lnet_acceptor_timeout());
> -
> + rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
> if (rc != 0) {
> CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
> rc, &conn->ksnc_ipaddr, conn->ksnc_port);
> @@ -511,9 +509,9 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
> hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]);
> }
>
> - rc = libcfs_sock_write(sock, hello->kshm_ips,
> - hello->kshm_nips * sizeof(__u32),
> - lnet_acceptor_timeout());
> + rc = lnet_sock_write(sock, hello->kshm_ips,
> + hello->kshm_nips * sizeof(__u32),
> + lnet_acceptor_timeout());
> if (rc != 0) {
> CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
> rc, hello->kshm_nips,
> @@ -544,9 +542,8 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
> LNET_UNLOCK();
> }
>
> - rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
> - lnet_acceptor_timeout());
> -
> + rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
> + lnet_acceptor_timeout());
> if (rc != 0) {
> CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
> rc, &conn->ksnc_ipaddr, conn->ksnc_port);
> @@ -556,9 +553,9 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
> if (hello->kshm_nips == 0)
> return 0;
>
> - rc = libcfs_sock_write(sock, hello->kshm_ips,
> - hello->kshm_nips * sizeof(__u32),
> - lnet_acceptor_timeout());
> + rc = lnet_sock_write(sock, hello->kshm_ips,
> + hello->kshm_nips * sizeof(__u32),
> + lnet_acceptor_timeout());
> if (rc != 0) {
> CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
> rc, hello->kshm_nips,
> @@ -583,9 +580,9 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
> return -ENOMEM;
> }
>
> - rc = libcfs_sock_read(sock, &hdr->src_nid,
> - sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
> - timeout);
> + rc = lnet_sock_read(sock, &hdr->src_nid,
> + sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
> + timeout);
> if (rc != 0) {
> CERROR("Error %d reading rest of HELLO hdr from %pI4h\n",
> rc, &conn->ksnc_ipaddr);
> @@ -619,8 +616,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
> if (hello->kshm_nips == 0)
> goto out;
>
> - rc = libcfs_sock_read(sock, hello->kshm_ips,
> - hello->kshm_nips * sizeof(__u32), timeout);
> + rc = lnet_sock_read(sock, hello->kshm_ips,
> + hello->kshm_nips * sizeof(__u32), timeout);
> if (rc != 0) {
> CERROR("Error %d reading IPs from ip %pI4h\n",
> rc, &conn->ksnc_ipaddr);
> @@ -656,10 +653,10 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout
> else
> conn->ksnc_flip = 1;
>
> - rc = libcfs_sock_read(sock, &hello->kshm_src_nid,
> - offsetof(ksock_hello_msg_t, kshm_ips) -
> - offsetof(ksock_hello_msg_t, kshm_src_nid),
> - timeout);
> + rc = lnet_sock_read(sock, &hello->kshm_src_nid,
> + offsetof(ksock_hello_msg_t, kshm_ips) -
> + offsetof(ksock_hello_msg_t, kshm_src_nid),
> + timeout);
> if (rc != 0) {
> CERROR("Error %d reading HELLO from %pI4h\n",
> rc, &conn->ksnc_ipaddr);
> @@ -687,8 +684,8 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout
> if (hello->kshm_nips == 0)
> return 0;
>
> - rc = libcfs_sock_read(sock, hello->kshm_ips,
> - hello->kshm_nips * sizeof(__u32), timeout);
> + rc = lnet_sock_read(sock, hello->kshm_ips,
> + hello->kshm_nips * sizeof(__u32), timeout);
> if (rc != 0) {
> CERROR("Error %d reading IPs from ip %pI4h\n",
> rc, &conn->ksnc_ipaddr);
> diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
> index 5187e65..1dc7c8a 100644
> --- a/drivers/staging/lustre/lnet/lnet/acceptor.c
> +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
> @@ -155,9 +155,8 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
> --port) {
> /* Iterate through reserved ports. */
>
> - rc = libcfs_sock_connect(&sock, &fatal,
> - local_ip, port,
> - peer_ip, peer_port);
> + rc = lnet_sock_connect(&sock, &fatal, local_ip, port, peer_ip,
> + peer_port);
> if (rc != 0) {
> if (fatal)
> goto failed;
> @@ -184,8 +183,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
> lnet_net_unlock(LNET_LOCK_EX);
> }
>
> - rc = libcfs_sock_write(sock, &cr, sizeof(cr),
> - accept_timeout);
> + rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
> if (rc != 0)
> goto failed_sock;
>
> @@ -220,7 +218,7 @@ lnet_accept(struct socket *sock, __u32 magic)
>
> LASSERT(sizeof(cr) <= 16); /* not too big for the stack */
>
> - rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
> + rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
> LASSERT(rc == 0); /* we succeeded before */
>
> if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) {
> @@ -234,8 +232,8 @@ lnet_accept(struct socket *sock, __u32 magic)
> memset(&cr, 0, sizeof(cr));
> cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
> cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
> - rc = libcfs_sock_write(sock, &cr, sizeof(cr),
> - accept_timeout);
> + rc = lnet_sock_write(sock, &cr, sizeof(cr),
> + accept_timeout);
>
> if (rc != 0)
> CERROR("Error sending magic+version in response to LNET magic from %pI4h: %d\n",
> @@ -257,9 +255,8 @@ lnet_accept(struct socket *sock, __u32 magic)
>
> flip = (magic != LNET_PROTO_ACCEPTOR_MAGIC);
>
> - rc = libcfs_sock_read(sock, &cr.acr_version,
> - sizeof(cr.acr_version),
> - accept_timeout);
> + rc = lnet_sock_read(sock, &cr.acr_version, sizeof(cr.acr_version),
> + accept_timeout);
> if (rc != 0) {
> CERROR("Error %d reading connection request version from %pI4h\n",
> rc, &peer_ip);
> @@ -280,19 +277,17 @@ lnet_accept(struct socket *sock, __u32 magic)
> cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
> cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
>
> - rc = libcfs_sock_write(sock, &cr, sizeof(cr),
> - accept_timeout);
> -
> + rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
> if (rc != 0)
> CERROR("Error sending magic+version in response to version %d from %pI4h: %d\n",
> peer_version, &peer_ip, rc);
> return -EPROTO;
> }
>
> - rc = libcfs_sock_read(sock, &cr.acr_nid,
> - sizeof(cr) -
> - offsetof(lnet_acceptor_connreq_t, acr_nid),
> - accept_timeout);
> + rc = lnet_sock_read(sock, &cr.acr_nid,
> + sizeof(cr) -
> + offsetof(lnet_acceptor_connreq_t, acr_nid),
> + accept_timeout);
> if (rc != 0) {
> CERROR("Error %d reading connection request from %pI4h\n",
> rc, &peer_ip);
> @@ -343,8 +338,8 @@ lnet_acceptor(void *arg)
>
> cfs_block_allsigs();
>
> - rc = libcfs_sock_listen(&lnet_acceptor_state.pta_sock,
> - 0, accept_port, accept_backlog);
> + rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock, 0, accept_port,
> + accept_backlog);
> if (rc != 0) {
> if (rc == -EADDRINUSE)
> LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port %d: port already in use\n",
> @@ -367,7 +362,7 @@ lnet_acceptor(void *arg)
>
> while (!lnet_acceptor_state.pta_shutdown) {
>
> - rc = libcfs_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
> + rc = lnet_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
> if (rc != 0) {
> if (rc != -EAGAIN) {
> CWARN("Accept error %d: pausing...\n", rc);
> @@ -383,7 +378,7 @@ lnet_acceptor(void *arg)
> break;
> }
>
> - rc = libcfs_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
> + rc = lnet_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
> if (rc != 0) {
> CERROR("Can't determine new connection's address\n");
> goto failed;
> @@ -395,8 +390,8 @@ lnet_acceptor(void *arg)
> goto failed;
> }
>
> - rc = libcfs_sock_read(newsock, &magic, sizeof(magic),
> - accept_timeout);
> + rc = lnet_sock_read(newsock, &magic, sizeof(magic),
> + accept_timeout);
> if (rc != 0) {
> CERROR("Error %d reading connection request from %pI4h\n",
> rc, &peer_ip);
> diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
> index 70bc809..efbb74a 100644
> --- a/drivers/staging/lustre/lnet/lnet/config.c
> +++ b/drivers/staging/lustre/lnet/lnet/config.c
> @@ -1118,7 +1118,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
> __u32 *ipaddrs2;
> int nip;
> char **ifnames;
> - int nif = libcfs_ipif_enumerate(&ifnames);
> + int nif = lnet_ipif_enumerate(&ifnames);
> int i;
> int rc;
>
> @@ -1128,7 +1128,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
> LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
> if (ipaddrs == NULL) {
> CERROR("Can't allocate ipaddrs[%d]\n", nif);
> - libcfs_ipif_free_enumeration(ifnames, nif);
> + lnet_ipif_free_enumeration(ifnames, nif);
> return -ENOMEM;
> }
>
> @@ -1136,8 +1136,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
> if (!strcmp(ifnames[i], "lo"))
> continue;
>
> - rc = libcfs_ipif_query(ifnames[i], &up,
> - &ipaddrs[nip], &netmask);
> + rc = lnet_ipif_query(ifnames[i], &up, &ipaddrs[nip], &netmask);
> if (rc != 0) {
> CWARN("Can't query interface %s: %d\n",
> ifnames[i], rc);
> @@ -1153,7 +1152,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
> nip++;
> }
>
> - libcfs_ipif_free_enumeration(ifnames, nif);
> + lnet_ipif_free_enumeration(ifnames, nif);
>
> if (nip == nif) {
> *ipaddrsp = ipaddrs;
> @@ -1237,8 +1236,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
> return -EPERM;
> }
>
> - rc = libcfs_ipif_query(ni->ni_interfaces[0],
> - &up, &ip, &netmask);
> + rc = lnet_ipif_query(ni->ni_interfaces[0], &up, &ip, &netmask);
> if (rc != 0) {
> CERROR("Net %s can't query interface %s: %d\n",
> libcfs_net2str(net), ni->ni_interfaces[0], rc);
> @@ -1255,7 +1253,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
> return 0;
> }
>
> - n = libcfs_ipif_enumerate(&names);
> + n = lnet_ipif_enumerate(&names);
> if (n <= 0) {
> CERROR("Net %s can't enumerate interfaces: %d\n",
> libcfs_net2str(net), n);
> @@ -1266,8 +1264,7 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
> if (!strcmp(names[i], "lo")) /* skip the loopback IF */
> continue;
>
> - rc = libcfs_ipif_query(names[i], &up, &ip, &netmask);
> -
> + rc = lnet_ipif_query(names[i], &up, &ip, &netmask);
> if (rc != 0) {
> CWARN("Net %s can't query interface %s: %d\n",
> libcfs_net2str(net), names[i], rc);
> @@ -1280,13 +1277,13 @@ lnet_set_ip_niaddr(lnet_ni_t *ni)
> continue;
> }
>
> - libcfs_ipif_free_enumeration(names, n);
> + lnet_ipif_free_enumeration(names, n);
> ni->ni_nid = LNET_MKNID(net, ip);
> return 0;
> }
>
> CERROR("Net %s can't find any interfaces\n", libcfs_net2str(net));
> - libcfs_ipif_free_enumeration(names, n);
> + lnet_ipif_free_enumeration(names, n);
> return -ENOENT;
> }
> EXPORT_SYMBOL(lnet_set_ip_niaddr);
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
> index bb8d9c2..2e87168 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
> @@ -45,7 +45,7 @@
> #include <linux/syscalls.h>
>
> static int
> -libcfs_sock_ioctl(int cmd, unsigned long arg)
> +lnet_sock_ioctl(int cmd, unsigned long arg)
> {
> mm_segment_t oldmm = get_fs();
> struct socket *sock;
> @@ -76,7 +76,7 @@ out:
> }
>
> int
> -libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
> +lnet_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
> {
> struct ifreq ifr;
> int nob;
> @@ -92,8 +92,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
> CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
>
> strcpy(ifr.ifr_name, name);
> - rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
> -
> + rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
> if (rc != 0) {
> CERROR("Can't get flags for interface %s\n", name);
> return rc;
> @@ -110,8 +109,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
>
> strcpy(ifr.ifr_name, name);
> ifr.ifr_addr.sa_family = AF_INET;
> - rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
> -
> + rc = lnet_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
> if (rc != 0) {
> CERROR("Can't get IP address for interface %s\n", name);
> return rc;
> @@ -122,8 +120,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
>
> strcpy(ifr.ifr_name, name);
> ifr.ifr_addr.sa_family = AF_INET;
> - rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
> -
> + rc = lnet_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
> if (rc != 0) {
> CERROR("Can't get netmask for interface %s\n", name);
> return rc;
> @@ -135,10 +132,10 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
> return 0;
> }
>
> -EXPORT_SYMBOL(libcfs_ipif_query);
> +EXPORT_SYMBOL(lnet_ipif_query);
>
> int
> -libcfs_ipif_enumerate (char ***namesp)
> +lnet_ipif_enumerate (char ***namesp)
> {
> /* Allocate and fill in 'names', returning # interfaces/error */
> char **names;
> @@ -172,8 +169,7 @@ libcfs_ipif_enumerate (char ***namesp)
> ifc.ifc_buf = (char *)ifr;
> ifc.ifc_len = nalloc * sizeof(*ifr);
>
> - rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
> -
> + rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
> if (rc < 0) {
> CERROR ("Error %d enumerating interfaces\n", rc);
> goto out1;
> @@ -226,17 +222,17 @@ libcfs_ipif_enumerate (char ***namesp)
>
> out2:
> if (rc < 0)
> - libcfs_ipif_free_enumeration(names, nfound);
> + lnet_ipif_free_enumeration(names, nfound);
> out1:
> LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
> out0:
> return rc;
> }
>
> -EXPORT_SYMBOL(libcfs_ipif_enumerate);
> +EXPORT_SYMBOL(lnet_ipif_enumerate);
>
> void
> -libcfs_ipif_free_enumeration (char **names, int n)
> +lnet_ipif_free_enumeration (char **names, int n)
> {
> int i;
>
> @@ -248,10 +244,10 @@ libcfs_ipif_free_enumeration (char **names, int n)
> LIBCFS_FREE(names, n * sizeof(*names));
> }
>
> -EXPORT_SYMBOL(libcfs_ipif_free_enumeration);
> +EXPORT_SYMBOL(lnet_ipif_free_enumeration);
>
> int
> -libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
> +lnet_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
> {
> int rc;
> long ticks = timeout * HZ;
> @@ -310,10 +306,10 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
>
> return 0;
> }
> -EXPORT_SYMBOL(libcfs_sock_write);
> +EXPORT_SYMBOL(lnet_sock_write);
>
> int
> -libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
> +lnet_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
> {
> int rc;
> long ticks = timeout * HZ;
> @@ -366,10 +362,10 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
> }
> }
>
> -EXPORT_SYMBOL(libcfs_sock_read);
> +EXPORT_SYMBOL(lnet_sock_read);
>
> static int
> -libcfs_sock_create (struct socket **sockp, int *fatal,
> +lnet_sock_create (struct socket **sockp, int *fatal,
> __u32 local_ip, int local_port)
> {
> struct sockaddr_in locaddr;
> @@ -424,7 +420,7 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
> }
>
> int
> -libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
> +lnet_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
> {
> int option;
> int rc;
> @@ -454,10 +450,10 @@ libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
> return 0;
> }
>
> -EXPORT_SYMBOL(libcfs_sock_setbuf);
> +EXPORT_SYMBOL(lnet_sock_setbuf);
>
> int
> -libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
> +lnet_sock_getaddr (struct socket *sock, bool remote, __u32 *ip, int *port)
> {
> struct sockaddr_in sin;
> int len = sizeof (sin);
> @@ -480,10 +476,10 @@ libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
> return 0;
> }
>
> -EXPORT_SYMBOL(libcfs_sock_getaddr);
> +EXPORT_SYMBOL(lnet_sock_getaddr);
>
> int
> -libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
> +lnet_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
> {
>
> if (txbufsize != NULL) {
> @@ -497,16 +493,16 @@ libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
> return 0;
> }
>
> -EXPORT_SYMBOL(libcfs_sock_getbuf);
> +EXPORT_SYMBOL(lnet_sock_getbuf);
>
> int
> -libcfs_sock_listen (struct socket **sockp,
> +lnet_sock_listen (struct socket **sockp,
> __u32 local_ip, int local_port, int backlog)
> {
> int fatal;
> int rc;
>
> - rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port);
> + rc = lnet_sock_create(sockp, &fatal, local_ip, local_port);
> if (rc != 0) {
> if (!fatal)
> CERROR("Can't create socket: port %d already in use\n",
> @@ -523,10 +519,10 @@ libcfs_sock_listen (struct socket **sockp,
> return rc;
> }
>
> -EXPORT_SYMBOL(libcfs_sock_listen);
> +EXPORT_SYMBOL(lnet_sock_listen);
>
> int
> -libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
> +lnet_sock_accept (struct socket **newsockp, struct socket *sock)
> {
> wait_queue_t wait;
> struct socket *newsock;
> @@ -566,17 +562,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
> return rc;
> }
>
> -EXPORT_SYMBOL(libcfs_sock_accept);
> +EXPORT_SYMBOL(lnet_sock_accept);
>
> int
> -libcfs_sock_connect (struct socket **sockp, int *fatal,
> +lnet_sock_connect (struct socket **sockp, int *fatal,
> __u32 local_ip, int local_port,
> __u32 peer_ip, int peer_port)
> {
> struct sockaddr_in srvaddr;
> int rc;
>
> - rc = libcfs_sock_create(sockp, fatal, local_ip, local_port);
> + rc = lnet_sock_create(sockp, fatal, local_ip, local_port);
> if (rc != 0)
> return rc;
>
> @@ -605,4 +601,4 @@ libcfs_sock_connect (struct socket **sockp, int *fatal,
> return rc;
> }
>
> -EXPORT_SYMBOL(libcfs_sock_connect);
> +EXPORT_SYMBOL(lnet_sock_connect);
> --
> 1.7.1
>
> _______________________________________________
> devel mailing list
> [email protected]
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

2015-06-04 06:03:02

by Sudip Mukherjee

[permalink] [raw]
Subject: Re: [PATCH v4 6/7] staging:lustre: style cleanups for lib-socket.c

On Wed, Jun 03, 2015 at 03:57:12PM -0400, James Simmons wrote:
> Handle all the style issues reported by checkpatch.pl.
> Remove general white spaces, spaces in function calls,
> etc.
>
> Signed-off-by: James Simmons <[email protected]>
> ---
<snip>
> @@ -167,13 +164,14 @@ lnet_ipif_enumerate (char ***namesp)
> if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) {
> toobig = 1;
> nalloc = PAGE_CACHE_SIZE/sizeof(*ifr);
> - CWARN("Too many interfaces: only enumerating first %d\n",
> - nalloc);
> + CWARN("Too many interfaces: only enumerating "
> + "first %d\n", nalloc);
oops. Joe told you not to break the user visible strings.

The CodingStyle says: "However, never break user-visible strings such as
printk messages, because that breaks the ability to grep for them."

regards
sudip

2015-06-04 07:35:22

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH v4 1/7] staging:lustre: move tcpip abstraction

On Thu, Jun 04, 2015 at 11:05:54AM +0530, Sudip Mukherjee wrote:
> On Wed, Jun 03, 2015 at 03:57:07PM -0400, James Simmons wrote:
> > Rename libcfs/linux/linux-tcpip.c to lnet/lnet/lib-socket.c
> looks like you have not just renamed the file, but there was also a change
> in the #include which is not mentioned in the commit message.
>

That's obviously going to be part of moving the file.

regards,
dan carpenter

2015-06-04 07:42:06

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH v4 4/7] staging:lustre: rename tcpip handling functions to lnet_* prefix

On Thu, Jun 04, 2015 at 11:27:10AM +0530, Sudip Mukherjee wrote:
> On Wed, Jun 03, 2015 at 03:57:10PM -0400, James Simmons wrote:
> > With all the TCPIP handling done in the lnet layer we should
> > rename all the functions with the prefix lnet_*. One other
> > change done was changing the remove argument of lnet_sock_getaddr
> > from a int to a bool.
> thats two different change.
> and apart from this:
> 1) the function declarations were renamed and moved from
> lustre/include/linux/libcfs/libcfs.h to drivers/staging/lustre/include/linux/lnet/lib-lnet.h
>
> 2) some functions you have changed the coding style. like:
> - rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
> - &conn->ksnc_myipaddr, NULL);
> + rc = lnet_sock_getaddr(conn->ksnc_sock, 0, &conn->ksnc_myipaddr, NULL);
>

Those are tiny related changes. They're fine. When you rename
functions you normally have to change the indenting as well.

regards,
dan carpenter

2015-06-04 07:45:54

by Sudip Mukherjee

[permalink] [raw]
Subject: Re: [PATCH v4 1/7] staging:lustre: move tcpip abstraction

On Thu, Jun 04, 2015 at 10:34:20AM +0300, Dan Carpenter wrote:
> On Thu, Jun 04, 2015 at 11:05:54AM +0530, Sudip Mukherjee wrote:
> > On Wed, Jun 03, 2015 at 03:57:07PM -0400, James Simmons wrote:
> > > Rename libcfs/linux/linux-tcpip.c to lnet/lnet/lib-socket.c
> > looks like you have not just renamed the file, but there was also a change
> > in the #include which is not mentioned in the commit message.
> >
>
> That's obviously going to be part of moving the file.
yes. path changed for libcfs.h. so that was updated.
but there was also a new line
#include "../../include/linux/lnet/lib-lnet.h"

should that be part of moving the file also?

regards
sudip

>
>

2015-06-04 07:54:56

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH v4 6/7] staging:lustre: style cleanups for lib-socket.c

On Wed, Jun 03, 2015 at 03:57:12PM -0400, James Simmons wrote:
> Handle all the style issues reported by checkpatch.pl.
> Remove general white spaces, spaces in function calls,
> etc.
>

What Sudip said but mostly "all the style" issues is a taboo phrase
which pretty much gaurantees the change will be rejected. :(

regards,
dan carpenter

2015-06-08 19:34:07

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v4 1/7] staging:lustre: move tcpip abstraction

On Wed, Jun 03, 2015 at 03:57:07PM -0400, James Simmons wrote:
> Rename libcfs/linux/linux-tcpip.c to lnet/lnet/lib-socket.c
>
> Signed-off-by: James Simmons <[email protected]>
> ---
> drivers/staging/lustre/lnet/lnet/Makefile | 7 +-
> drivers/staging/lustre/lnet/lnet/lib-socket.c | 624 ++++++++++++++++++++
> drivers/staging/lustre/lustre/libcfs/Makefile | 1 -
> .../lustre/lustre/libcfs/linux/linux-tcpip.c | 623 -------------------
> 4 files changed, 628 insertions(+), 627 deletions(-)
> create mode 100644 drivers/staging/lustre/lnet/lnet/lib-socket.c
> delete mode 100644 drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c

Please generate patches in -M format, so I can see the rename properly,
as it is, this is too messy for me to review.

Please fix up and resend.

thanks,

greg k-h

2015-06-08 19:58:00

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v4 1/7] staging:lustre: move tcpip abstraction

On Mon, 2015-06-08 at 12:33 -0700, Greg Kroah-Hartman wrote:
> Please generate patches in -M format, so I can see the rename properly,
> as it is, this is too messy for me to review.

Adding this to the .gitconfig works too

[diff]
renames = true

That should probably be mentioned in SubmittingPatches.

Something like:
---
Documentation/SubmittingPatches | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index 27e7e5e..d86cf89 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -715,6 +715,13 @@ the top of the kernel source tree and don't use too much horizontal
space (easily fit in 80 columns, maybe with some indentation). (git
generates appropriate diffstats by default.)

+Another good thing is to generate shorter patches whenever a file rename
+has been done. Using "git format-patch -M" does this appropriately.
+Adding a [diff] section as below to .gitconfig can also do this:
+
+ [diff]
+ renames = true
+
See more details on the proper patch format in the following
references.


2015-06-09 13:39:04

by Simmons, James A.

[permalink] [raw]
Subject: RE: [lustre-devel] [PATCH v4 1/7] staging:lustre: move tcpip abstraction

>On Thu, Jun 04, 2015 at 10:34:20AM +0300, Dan Carpenter wrote:
>> On Thu, Jun 04, 2015 at 11:05:54AM +0530, Sudip Mukherjee wrote:
>> > On Wed, Jun 03, 2015 at 03:57:07PM -0400, James Simmons wrote:
>> > > Rename libcfs/linux/linux-tcpip.c to lnet/lnet/lib-socket.c
>> > looks like you have not just renamed the file, but there was also a change
>> > in the #include which is not mentioned in the commit message.
>> >
>>
>> That's obviously going to be part of moving the file.
>yes. path changed for libcfs.h. so that was updated.
>but there was also a new line
>#include "../../include/linux/lnet/lib-lnet.h"
>
>should that be part of moving the file also?

That is handle the move of some of the LNet function declarations in libcfs.h
to lib-lnet.h. That happens in patch number 4 of this series. I was trying to
minimize the diff between the tip of the Lustre development branch and
the upstream client.