-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define DEBUG_SUBSYSTEM S_LNET
#include <lnet/lib-lnet.h>
-#if defined(__KERNEL__) || defined(HAVE_PTHREAD)
+#if defined(__KERNEL__) || defined(HAVE_LIBPTHREAD)
static int accept_port = 988;
static int accept_backlog = 127;
static int accept_timeout = 5;
struct {
- int pta_shutdown;
- cfs_socket_t *pta_sock;
-#ifdef __KERNEL__
- cfs_completion_t pta_signal;
-#else
- cfs_mt_completion_t pta_signal;
-#endif
+ int pta_shutdown;
+ cfs_socket_t *pta_sock;
+ struct completion pta_signal;
} lnet_acceptor_state;
int
#ifdef __KERNEL__
-#define cfs_mt_init_completion(c) cfs_init_completion(c)
-#define cfs_mt_wait_for_completion(c) cfs_wait_for_completion(c)
-#define cfs_mt_complete(c) cfs_complete(c)
-#define cfs_mt_fini_completion(c) cfs_fini_completion(c)
-#define cfs_create_thread(func, a) cfs_kernel_thread(func, a, 0)
-
EXPORT_SYMBOL(lnet_acceptor_port);
static char *accept = "secure";
switch (rc) {
/* "normal" errors */
case -ECONNREFUSED:
- CDEBUG(D_NETERROR, "Connection to %s at host %u.%u.%u.%u "
- "on port %d was refused: "
- "check that Lustre is running on that node.\n",
- libcfs_nid2str(peer_nid),
- HIPQUAD(peer_ip), peer_port);
+ CNETERR("Connection to %s at host %u.%u.%u.%u on port %d was "
+ "refused: check that Lustre is running on that node.\n",
+ libcfs_nid2str(peer_nid),
+ HIPQUAD(peer_ip), peer_port);
break;
case -EHOSTUNREACH:
case -ENETUNREACH:
- CDEBUG(D_NETERROR, "Connection to %s at host %u.%u.%u.%u "
- "was unreachable: the network or that node may "
- "be down, or Lustre may be misconfigured.\n",
- libcfs_nid2str(peer_nid), HIPQUAD(peer_ip));
+ CNETERR("Connection to %s at host %u.%u.%u.%u "
+ "was unreachable: the network or that node may "
+ "be down, or Lustre may be misconfigured.\n",
+ libcfs_nid2str(peer_nid), HIPQUAD(peer_ip));
break;
case -ETIMEDOUT:
- CDEBUG(D_NETERROR, "Connection to %s at host %u.%u.%u.%u on "
- "port %d took too long: that node may be hung "
- "or experiencing high load.\n",
- libcfs_nid2str(peer_nid),
- HIPQUAD(peer_ip), peer_port);
+ CNETERR("Connection to %s at host %u.%u.%u.%u on "
+ "port %d took too long: that node may be hung "
+ "or experiencing high load.\n",
+ libcfs_nid2str(peer_nid),
+ HIPQUAD(peer_ip), peer_port);
break;
case -ECONNRESET:
LCONSOLE_ERROR_MSG(0x11b, "Connection to %s at host %u.%u.%u.%u"
if (the_lnet.ln_testprotocompat != 0) {
/* single-shot proto check */
- LNET_LOCK();
+ lnet_net_lock(LNET_LOCK_EX);
if ((the_lnet.ln_testprotocompat & 4) != 0) {
cr.acr_version++;
the_lnet.ln_testprotocompat &= ~4;
cr.acr_magic = LNET_PROTO_MAGIC;
the_lnet.ln_testprotocompat &= ~8;
}
- LNET_UNLOCK();
+ lnet_net_unlock(LNET_LOCK_EX);
}
rc = libcfs_sock_write(sock, &cr, sizeof(cr),
str = "'old' socknal/tcpnal";
else if (lnet_accept_magic(magic, LNET_PROTO_RA_MAGIC))
str = "'old' ranal";
- else if (lnet_accept_magic(magic, LNET_PROTO_OPENIB_MAGIC))
- str = "'old' openibnal";
else
str = "unrecognised";
int
lnet_acceptor(void *arg)
{
- char name[16];
cfs_socket_t *newsock;
int rc;
__u32 magic;
LASSERT (lnet_acceptor_state.pta_sock == NULL);
- snprintf(name, sizeof(name), "acceptor_%03d", accept_port);
- cfs_daemonize(name);
cfs_block_allsigs();
rc = libcfs_sock_listen(&lnet_acceptor_state.pta_sock,
LCONSOLE(0, "Accept %s, port %d\n", accept_type, accept_port);
}
- /* set init status and unblock parent */
- lnet_acceptor_state.pta_shutdown = rc;
- cfs_mt_complete(&lnet_acceptor_state.pta_signal);
+ /* set init status and unblock parent */
+ lnet_acceptor_state.pta_shutdown = rc;
+ complete(&lnet_acceptor_state.pta_signal);
if (rc != 0)
return rc;
libcfs_sock_release(lnet_acceptor_state.pta_sock);
lnet_acceptor_state.pta_sock = NULL;
- LCONSOLE(0, "Acceptor stopping\n");
+ CDEBUG(D_NET, "Acceptor stopping\n");
- /* unblock lnet_acceptor_stop() */
- cfs_mt_complete(&lnet_acceptor_state.pta_signal);
- return 0;
+ /* unblock lnet_acceptor_stop() */
+ complete(&lnet_acceptor_state.pta_signal);
+ return 0;
}
static inline int
int
lnet_acceptor_start(void)
{
+ struct task_struct *task;
int rc;
long rc2;
long secure;
return 0;
#endif
- cfs_mt_init_completion(&lnet_acceptor_state.pta_signal);
- rc = accept2secure(accept_type, &secure);
- if (rc <= 0) {
- cfs_mt_fini_completion(&lnet_acceptor_state.pta_signal);
- return rc;
- }
+ init_completion(&lnet_acceptor_state.pta_signal);
+ rc = accept2secure(accept_type, &secure);
+ if (rc <= 0) {
+ fini_completion(&lnet_acceptor_state.pta_signal);
+ return rc;
+ }
- if (lnet_count_acceptor_nis() == 0) /* not required */
- return 0;
+ if (lnet_count_acceptor_nis() == 0) /* not required */
+ return 0;
- rc2 = cfs_create_thread(lnet_acceptor, (void *)(ulong_ptr_t)secure);
- if (rc2 < 0) {
- CERROR("Can't start acceptor thread: %d\n", rc);
- cfs_mt_fini_completion(&lnet_acceptor_state.pta_signal);
+ task = kthread_run(lnet_acceptor, (void *)(ulong_ptr_t)secure,
+ "acceptor_%03ld", secure);
+ if (IS_ERR(task)) {
+ rc2 = PTR_ERR(task);
+ CERROR("Can't start acceptor thread: %ld\n", rc2);
+ fini_completion(&lnet_acceptor_state.pta_signal);
- return -ESRCH;
- }
+ return -ESRCH;
+ }
- /* wait for acceptor to startup */
- cfs_mt_wait_for_completion(&lnet_acceptor_state.pta_signal);
+ /* wait for acceptor to startup */
+ wait_for_completion(&lnet_acceptor_state.pta_signal);
- if (!lnet_acceptor_state.pta_shutdown) {
- /* started OK */
- LASSERT (lnet_acceptor_state.pta_sock != NULL);
- return 0;
- }
+ if (!lnet_acceptor_state.pta_shutdown) {
+ /* started OK */
+ LASSERT(lnet_acceptor_state.pta_sock != NULL);
+ return 0;
+ }
- LASSERT (lnet_acceptor_state.pta_sock == NULL);
- cfs_mt_fini_completion(&lnet_acceptor_state.pta_signal);
+ LASSERT(lnet_acceptor_state.pta_sock == NULL);
+ fini_completion(&lnet_acceptor_state.pta_signal);
- return -ENETDOWN;
+ return -ENETDOWN;
}
void
lnet_acceptor_stop(void)
{
- if (lnet_acceptor_state.pta_sock == NULL) /* not running */
- return;
+ if (lnet_acceptor_state.pta_sock == NULL) /* not running */
+ return;
- lnet_acceptor_state.pta_shutdown = 1;
- libcfs_sock_abort_accept(lnet_acceptor_state.pta_sock);
+ lnet_acceptor_state.pta_shutdown = 1;
+ libcfs_sock_abort_accept(lnet_acceptor_state.pta_sock);
- /* block until acceptor signals exit */
- cfs_mt_wait_for_completion(&lnet_acceptor_state.pta_signal);
+ /* block until acceptor signals exit */
+ wait_for_completion(&lnet_acceptor_state.pta_signal);
- cfs_mt_fini_completion(&lnet_acceptor_state.pta_signal);
+ fini_completion(&lnet_acceptor_state.pta_signal);
}
#else /* single-threaded user-space */
int
lnet_acceptor_start(void)
{
- return 0;
+ return 0;
}
void
lnet_acceptor_stop(void)
{
}
-#endif /* defined(__KERNEL__) || defined(HAVE_PTHREAD) */
+#endif /* defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) */