diff options
Diffstat (limited to 'drivers/staging/lustre/lnet/lnet')
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/Makefile | 7 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/acceptor.c | 91 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/api-ni.c | 325 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/config.c | 310 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-eq.c | 46 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-md.c | 32 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-me.c | 26 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-move.c | 264 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-msg.c | 52 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-ptl.c | 116 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-socket.c | 594 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lo.c | 2 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/module.c | 28 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/peer.c | 50 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/router.c | 355 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/router_proc.c | 210 |
16 files changed, 1387 insertions, 1121 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/Makefile b/drivers/staging/lustre/lnet/lnet/Makefile index 336b8ea4fdf6..52492fb10f85 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/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 72fd1bf70ca0..99f8396f3822 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -35,9 +35,9 @@ */ #define DEBUG_SUBSYSTEM S_LNET +#include <linux/completion.h> #include "../../include/linux/lnet/lib-lnet.h" - static int accept_port = 988; static int accept_backlog = 127; static int accept_timeout = 5; @@ -143,10 +143,10 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, __u32 local_ip, __u32 peer_ip, int peer_port) { lnet_acceptor_connreq_t cr; - struct socket *sock; - int rc; - int port; - int fatal; + struct socket *sock; + int rc; + int port; + int fatal; CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */ @@ -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; @@ -197,7 +195,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; @@ -211,16 +209,16 @@ static int lnet_accept(struct socket *sock, __u32 magic) { lnet_acceptor_connreq_t cr; - __u32 peer_ip; - int peer_port; - int rc; - int flip; - lnet_ni_t *ni; - char *str; + __u32 peer_ip; + int peer_port; + int rc; + int flip; + lnet_ni_t *ni; + char *str; 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", @@ -245,8 +243,6 @@ lnet_accept(struct socket *sock, __u32 magic) if (magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) str = "'old' socknal/tcpnal"; - else if (lnet_accept_magic(magic, LNET_PROTO_RA_MAGIC)) - str = "'old' ranal"; else str = "unrecognised"; @@ -257,9 +253,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 +275,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); @@ -333,18 +326,18 @@ static int lnet_acceptor(void *arg) { struct socket *newsock; - int rc; - __u32 magic; - __u32 peer_ip; - int peer_port; - int secure = (int)((long_ptr_t)arg); + int rc; + __u32 magic; + __u32 peer_ip; + int peer_port; + int secure = (int)((long_ptr_t)arg); LASSERT(lnet_acceptor_state.pta_sock == NULL); 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 +360,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); @@ -377,13 +370,13 @@ 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) { - libcfs_sock_release(newsock); + sock_release(newsock); 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 +388,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); @@ -410,10 +403,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"); @@ -444,7 +437,7 @@ accept2secure(const char *acc, long *sec) int lnet_acceptor_start(void) { - int rc; + int rc; long rc2; long secure; @@ -493,7 +486,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/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 4a14e5109821..d14fe70a56df 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -35,13 +35,14 @@ */ #define DEBUG_SUBSYSTEM S_LNET -#include "../../include/linux/lnet/lib-lnet.h" #include <linux/log2.h> #include <linux/ktime.h> +#include "../../include/linux/lnet/lib-lnet.h" + #define D_LNI D_CONSOLE -lnet_t the_lnet; /* THE state of the network */ +lnet_t the_lnet; /* THE state of the network */ EXPORT_SYMBOL(the_lnet); @@ -70,8 +71,8 @@ lnet_get_routes(void) static char * lnet_get_networks(void) { - char *nets; - int rc; + char *nets; + int rc; if (*networks != 0 && *ip2nets != 0) { LCONSOLE_ERROR_MSG(0x101, "Please specify EITHER 'networks' or 'ip2nets' but not both at once\n"); @@ -98,17 +99,11 @@ lnet_init_locks(void) mutex_init(&the_lnet.ln_api_mutex); } -static void -lnet_fini_locks(void) -{ -} - - static int lnet_create_remote_nets_table(void) { - int i; - struct list_head *hash; + int i; + struct list_head *hash; LASSERT(the_lnet.ln_remote_nets_hash == NULL); LASSERT(the_lnet.ln_remote_nets_hbits > 0); @@ -153,8 +148,6 @@ lnet_destroy_locks(void) cfs_percpt_lock_free(the_lnet.ln_net_lock); the_lnet.ln_net_lock = NULL; } - - lnet_fini_locks(); } static int @@ -273,8 +266,8 @@ static void lnet_assert_wire_constants(void) static lnd_t * lnet_find_lnd_by_type(int type) { - lnd_t *lnd; - struct list_head *tmp; + lnd_t *lnd; + struct list_head *tmp; /* holding lnd mutex */ list_for_each(tmp, &the_lnet.ln_lnds) { @@ -290,7 +283,7 @@ lnet_find_lnd_by_type(int type) void lnet_register_lnd(lnd_t *lnd) { - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); LASSERT(the_lnet.ln_init); LASSERT(libcfs_isknown_lnd(lnd->lnd_type)); @@ -301,14 +294,14 @@ lnet_register_lnd(lnd_t *lnd) CDEBUG(D_NET, "%s LND registered\n", libcfs_lnd2str(lnd->lnd_type)); - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); } EXPORT_SYMBOL(lnet_register_lnd); void lnet_unregister_lnd(lnd_t *lnd) { - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); LASSERT(the_lnet.ln_init); LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == lnd); @@ -317,7 +310,7 @@ lnet_unregister_lnd(lnd_t *lnd) list_del(&lnd->lnd_list); CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type)); - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); } EXPORT_SYMBOL(lnet_unregister_lnd); @@ -325,7 +318,7 @@ void lnet_counters_get(lnet_counters_t *counters) { lnet_counters_t *ctr; - int i; + int i; memset(counters, 0, sizeof(*counters)); @@ -353,7 +346,7 @@ void lnet_counters_reset(void) { lnet_counters_t *counters; - int i; + int i; lnet_net_lock(LNET_LOCK_EX); @@ -364,56 +357,6 @@ lnet_counters_reset(void) } EXPORT_SYMBOL(lnet_counters_reset); -#ifdef LNET_USE_LIB_FREELIST - -int -lnet_freelist_init(lnet_freelist_t *fl, int n, int size) -{ - char *space; - - LASSERT(n > 0); - - size += offsetof(lnet_freeobj_t, fo_contents); - - LIBCFS_ALLOC(space, n * size); - if (space == NULL) - return -ENOMEM; - - INIT_LIST_HEAD(&fl->fl_list); - fl->fl_objs = space; - fl->fl_nobjs = n; - fl->fl_objsize = size; - - do { - memset(space, 0, size); - list_add((struct list_head *)space, &fl->fl_list); - space += size; - } while (--n != 0); - - return 0; -} - -void -lnet_freelist_fini(lnet_freelist_t *fl) -{ - struct list_head *el; - int count; - - if (fl->fl_nobjs == 0) - return; - - count = 0; - for (el = fl->fl_list.next; el != &fl->fl_list; el = el->next) - count++; - - LASSERT(count == fl->fl_nobjs); - - LIBCFS_FREE(fl->fl_objs, fl->fl_nobjs * fl->fl_objsize); - memset(fl, 0, sizeof(*fl)); -} - -#endif /* LNET_USE_LIB_FREELIST */ - static __u64 lnet_create_interface_cookie(void) { @@ -441,7 +384,7 @@ lnet_res_type2str(int type) static void lnet_res_container_cleanup(struct lnet_res_container *rec) { - int count = 0; + int count = 0; if (rec->rec_type == 0) /* not set yet, it's uninitialized */ return; @@ -470,9 +413,6 @@ lnet_res_container_cleanup(struct lnet_res_container *rec) count, lnet_res_type2str(rec->rec_type)); } -#ifdef LNET_USE_LIB_FREELIST - lnet_freelist_fini(&rec->rec_freelist); -#endif if (rec->rec_lh_hash != NULL) { LIBCFS_FREE(rec->rec_lh_hash, LNET_LH_HASH_SIZE * sizeof(rec->rec_lh_hash[0])); @@ -483,23 +423,15 @@ lnet_res_container_cleanup(struct lnet_res_container *rec) } static int -lnet_res_container_setup(struct lnet_res_container *rec, - int cpt, int type, int objnum, int objsz) +lnet_res_container_setup(struct lnet_res_container *rec, int cpt, int type) { - int rc = 0; - int i; + int rc = 0; + int i; LASSERT(rec->rec_type == 0); rec->rec_type = type; INIT_LIST_HEAD(&rec->rec_active); - -#ifdef LNET_USE_LIB_FREELIST - memset(&rec->rec_freelist, 0, sizeof(rec->rec_freelist)); - rc = lnet_freelist_init(&rec->rec_freelist, objnum, objsz); - if (rc != 0) - goto out; -#endif rec->rec_lh_cookie = (cpt << LNET_COOKIE_TYPE_BITS) | type; /* Arbitrary choice of hash table size */ @@ -525,8 +457,8 @@ out: static void lnet_res_containers_destroy(struct lnet_res_container **recs) { - struct lnet_res_container *rec; - int i; + struct lnet_res_container *rec; + int i; cfs_percpt_for_each(rec, i, recs) lnet_res_container_cleanup(rec); @@ -535,12 +467,12 @@ lnet_res_containers_destroy(struct lnet_res_container **recs) } static struct lnet_res_container ** -lnet_res_containers_create(int type, int objnum, int objsz) +lnet_res_containers_create(int type) { - struct lnet_res_container **recs; - struct lnet_res_container *rec; - int rc; - int i; + struct lnet_res_container **recs; + struct lnet_res_container *rec; + int rc; + int i; recs = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*rec)); if (recs == NULL) { @@ -550,7 +482,7 @@ lnet_res_containers_create(int type, int objnum, int objsz) } cfs_percpt_for_each(rec, i, recs) { - rc = lnet_res_container_setup(rec, i, type, objnum, objsz); + rc = lnet_res_container_setup(rec, i, type); if (rc != 0) { lnet_res_containers_destroy(recs); return NULL; @@ -564,9 +496,9 @@ lnet_libhandle_t * lnet_res_lh_lookup(struct lnet_res_container *rec, __u64 cookie) { /* ALWAYS called with lnet_res_lock held */ - struct list_head *head; - lnet_libhandle_t *lh; - unsigned int hash; + struct list_head *head; + lnet_libhandle_t *lh; + unsigned int hash; if ((cookie & LNET_COOKIE_MASK) != rec->rec_type) return NULL; @@ -586,8 +518,8 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_libhandle_t *lh) { /* ALWAYS called with lnet_res_lock held */ - unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS; - unsigned int hash; + unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS; + unsigned int hash; lh->lh_cookie = rec->rec_lh_cookie; rec->rec_lh_cookie += 1 << ibits; @@ -605,7 +537,7 @@ lnet_prepare(lnet_pid_t requested_pid) { /* Prepare to bring up the network */ struct lnet_res_container **recs; - int rc = 0; + int rc = 0; LASSERT(the_lnet.ln_refcount == 0); @@ -643,13 +575,11 @@ lnet_prepare(lnet_pid_t requested_pid) goto failed; rc = lnet_res_container_setup(&the_lnet.ln_eq_container, 0, - LNET_COOKIE_TYPE_EQ, LNET_FL_MAX_EQS, - sizeof(lnet_eq_t)); + LNET_COOKIE_TYPE_EQ); if (rc != 0) goto failed; - recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, LNET_FL_MAX_MES, - sizeof(lnet_me_t)); + recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME); if (recs == NULL) { rc = -ENOMEM; goto failed; @@ -657,8 +587,7 @@ lnet_prepare(lnet_pid_t requested_pid) the_lnet.ln_me_containers = recs; - recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS, - sizeof(lnet_libmd_t)); + recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD); if (recs == NULL) { rc = -ENOMEM; goto failed; @@ -725,8 +654,8 @@ lnet_unprepare(void) lnet_ni_t * lnet_net2ni_locked(__u32 net, int cpt) { - struct list_head *tmp; - lnet_ni_t *ni; + struct list_head *tmp; + lnet_ni_t *ni; LASSERT(cpt != LNET_LOCK_EX); @@ -758,8 +687,8 @@ EXPORT_SYMBOL(lnet_net2ni); static unsigned int lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number) { - __u64 key = nid; - unsigned int val; + __u64 key = nid; + unsigned int val; LASSERT(number >= 1 && number <= LNET_CPT_NUMBER); @@ -801,8 +730,8 @@ lnet_cpt_of_nid_locked(lnet_nid_t nid) int lnet_cpt_of_nid(lnet_nid_t nid) { - int cpt; - int cpt2; + int cpt; + int cpt2; if (LNET_CPT_NUMBER == 1) return 0; /* the only one */ @@ -821,8 +750,8 @@ EXPORT_SYMBOL(lnet_cpt_of_nid); int lnet_islocalnet(__u32 net) { - struct lnet_ni *ni; - int cpt; + struct lnet_ni *ni; + int cpt; cpt = lnet_net_lock_current(); @@ -838,8 +767,8 @@ lnet_islocalnet(__u32 net) lnet_ni_t * lnet_nid2ni_locked(lnet_nid_t nid, int cpt) { - struct lnet_ni *ni; - struct list_head *tmp; + struct lnet_ni *ni; + struct list_head *tmp; LASSERT(cpt != LNET_LOCK_EX); @@ -858,8 +787,8 @@ lnet_nid2ni_locked(lnet_nid_t nid, int cpt) int lnet_islocalnid(lnet_nid_t nid) { - struct lnet_ni *ni; - int cpt; + struct lnet_ni *ni; + int cpt; cpt = lnet_net_lock_current(); ni = lnet_nid2ni_locked(nid, cpt); @@ -874,10 +803,10 @@ int lnet_count_acceptor_nis(void) { /* Return the # of NIs that need the acceptor. */ - int count = 0; - struct list_head *tmp; - struct lnet_ni *ni; - int cpt; + int count = 0; + struct list_head *tmp; + struct lnet_ni *ni; + int cpt; cpt = lnet_net_lock_current(); list_for_each(tmp, &the_lnet.ln_nis) { @@ -895,7 +824,7 @@ lnet_count_acceptor_nis(void) static int lnet_ni_tq_credits(lnet_ni_t *ni) { - int credits; + int credits; LASSERT(ni->ni_ncpts >= 1); @@ -912,9 +841,9 @@ lnet_ni_tq_credits(lnet_ni_t *ni) static void lnet_shutdown_lndnis(void) { - int i; - int islo; - lnet_ni_t *ni; + int i; + int islo; + lnet_ni_t *ni; /* NB called holding the global mutex */ @@ -968,8 +897,8 @@ lnet_shutdown_lndnis(void) * and shut them down in guaranteed thread context */ i = 2; while (!list_empty(&the_lnet.ln_nis_zombie)) { - int *ref; - int j; + int *ref; + int j; ni = list_entry(the_lnet.ln_nis_zombie.next, lnet_ni_t, ni_list); @@ -1029,15 +958,15 @@ lnet_shutdown_lndnis(void) static int lnet_startup_lndnis(void) { - lnd_t *lnd; - struct lnet_ni *ni; - struct lnet_tx_queue *tq; - struct list_head nilist; - int i; - int rc = 0; - int lnd_type; - int nicount = 0; - char *nets = lnet_get_networks(); + lnd_t *lnd; + struct lnet_ni *ni; + struct lnet_tx_queue *tq; + struct list_head nilist; + int i; + int rc = 0; + int lnd_type; + int nicount = 0; + char *nets = lnet_get_networks(); INIT_LIST_HEAD(&nilist); @@ -1063,18 +992,18 @@ lnet_startup_lndnis(void) goto failed; } - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); lnd = lnet_find_lnd_by_type(lnd_type); if (lnd == NULL) { - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); rc = request_module("%s", libcfs_lnd2modname(lnd_type)); - LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex); + mutex_lock(&the_lnet.ln_lnd_mutex); lnd = lnet_find_lnd_by_type(lnd_type); if (lnd == NULL) { - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); CERROR("Can't load LND %s, module %s, rc=%d\n", libcfs_lnd2str(lnd_type), libcfs_lnd2modname(lnd_type), rc); @@ -1090,7 +1019,7 @@ lnet_startup_lndnis(void) rc = (lnd->lnd_startup)(ni); - LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex); + mutex_unlock(&the_lnet.ln_lnd_mutex); if (rc != 0) { LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s\n", @@ -1172,16 +1101,16 @@ lnet_startup_lndnis(void) * Initialize LNet library. * * Only userspace program needs to call this function - it's automatically - * called in the kernel at module loading time. Caller has to call LNetFini() - * after a call to LNetInit(), if and only if the latter returned 0. It must + * called in the kernel at module loading time. Caller has to call lnet_fini() + * after a call to lnet_init(), if and only if the latter returned 0. It must * be called exactly once. * * \return 0 on success, and -ve on failures. */ int -LNetInit(void) +lnet_init(void) { - int rc; + int rc; lnet_assert_wire_constants(); LASSERT(!the_lnet.ln_init); @@ -1232,7 +1161,7 @@ LNetInit(void) lnet_register_lnd(&the_lolnd); return 0; } -EXPORT_SYMBOL(LNetInit); +EXPORT_SYMBOL(lnet_init); /** * Finalize LNet library. @@ -1240,11 +1169,11 @@ EXPORT_SYMBOL(LNetInit); * Only userspace program needs to call this function. It can be called * at most once. * - * \pre LNetInit() called with success. + * \pre lnet_init() called with success. * \pre All LNet users called LNetNIFini() for matching LNetNIInit() calls. */ void -LNetFini(void) +lnet_fini(void) { LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount == 0); @@ -1256,12 +1185,12 @@ LNetFini(void) the_lnet.ln_init = 0; } -EXPORT_SYMBOL(LNetFini); +EXPORT_SYMBOL(lnet_fini); /** * Set LNet PID and start LNet interfaces, routing, and forwarding. * - * Userspace program should call this after a successful call to LNetInit(). + * Userspace program should call this after a successful call to lnet_init(). * Users must call this function at least once before any other functions. * For each successful call there must be a corresponding call to * LNetNIFini(). For subsequent calls to LNetNIInit(), \a requested_pid is @@ -1277,10 +1206,10 @@ EXPORT_SYMBOL(LNetFini); int LNetNIInit(lnet_pid_t requested_pid) { - int im_a_router = 0; - int rc; + int im_a_router = 0; + int rc; - LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); + mutex_lock(&the_lnet.ln_api_mutex); LASSERT(the_lnet.ln_init); CDEBUG(D_OTHER, "refs %d\n", the_lnet.ln_refcount); @@ -1290,8 +1219,6 @@ LNetNIInit(lnet_pid_t requested_pid) goto out; } - lnet_get_tunables(); - if (requested_pid == LNET_PID_ANY) { /* Don't instantiate LNET just for me */ rc = -ENETDOWN; @@ -1351,7 +1278,7 @@ LNetNIInit(lnet_pid_t requested_pid) failed0: LASSERT(rc < 0); out: - LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex); + mutex_unlock(&the_lnet.ln_api_mutex); return rc; } EXPORT_SYMBOL(LNetNIInit); @@ -1368,7 +1295,7 @@ EXPORT_SYMBOL(LNetNIInit); int LNetNIFini(void) { - LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); + mutex_lock(&the_lnet.ln_api_mutex); LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -1391,7 +1318,7 @@ LNetNIFini(void) lnet_unprepare(); } - LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex); + mutex_unlock(&the_lnet.ln_api_mutex); return 0; } EXPORT_SYMBOL(LNetNIFini); @@ -1413,9 +1340,9 @@ int LNetCtl(unsigned int cmd, void *arg) { struct libcfs_ioctl_data *data = arg; - lnet_process_id_t id = {0}; - lnet_ni_t *ni; - int rc; + lnet_process_id_t id = {0}; + lnet_ni_t *ni; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -1531,10 +1458,10 @@ EXPORT_SYMBOL(LNetCtl); int LNetGetId(unsigned int index, lnet_process_id_t *id) { - struct lnet_ni *ni; - struct list_head *tmp; - int cpt; - int rc = -ENOENT; + struct lnet_ni *ni; + struct list_head *tmp; + int cpt; + int rc = -ENOENT; LASSERT(the_lnet.ln_init); @@ -1575,11 +1502,11 @@ EXPORT_SYMBOL(LNetSnprintHandle); static int lnet_create_ping_info(void) { - int i; - int n; - int rc; - unsigned int infosz; - lnet_ni_t *ni; + int i; + int n; + int rc; + unsigned int infosz; + lnet_ni_t *ni; lnet_process_id_t id; lnet_ping_info_t *pinfo; @@ -1633,7 +1560,7 @@ lnet_create_ping_info(void) static void lnet_destroy_ping_info(void) { - struct lnet_ni *ni; + struct lnet_ni *ni; lnet_net_lock(0); @@ -1654,12 +1581,12 @@ lnet_destroy_ping_info(void) int lnet_ping_target_init(void) { - lnet_md_t md = { NULL }; - lnet_handle_me_t meh; + lnet_md_t md = { NULL }; + lnet_handle_me_t meh; lnet_process_id_t id; - int rc; - int rc2; - int infosz; + int rc; + int rc2; + int infosz; rc = lnet_create_ping_info(); if (rc != 0) @@ -1722,11 +1649,11 @@ lnet_ping_target_init(void) void lnet_ping_target_fini(void) { - lnet_event_t event; - int rc; - int which; - int timeout_ms = 1000; - sigset_t blocked = cfs_block_allsigs(); + lnet_event_t event; + int rc; + int which; + int timeout_ms = 1000; + sigset_t blocked = cfs_block_allsigs(); LNetMDUnlink(the_lnet.ln_ping_target_md); /* NB md could be busy; this just starts the unlink */ @@ -1759,22 +1686,22 @@ lnet_ping_target_fini(void) int lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_ids) { - lnet_handle_eq_t eqh; - lnet_handle_md_t mdh; - lnet_event_t event; - lnet_md_t md = { NULL }; - int which; - int unlinked = 0; - int replied = 0; - const int a_long_time = 60000; /* mS */ - int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]); - lnet_ping_info_t *info; - lnet_process_id_t tmpid; - int i; - int nob; - int rc; - int rc2; - sigset_t blocked; + lnet_handle_eq_t eqh; + lnet_handle_md_t mdh; + lnet_event_t event; + lnet_md_t md = { NULL }; + int which; + int unlinked = 0; + int replied = 0; + const int a_long_time = 60000; /* mS */ + int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]); + lnet_ping_info_t *info; + lnet_process_id_t tmpid; + int i; + int nob; + int rc; + int rc2; + sigset_t blocked; if (n_ids <= 0 || id.nid == LNET_NID_ANY || diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 2dc4c4a1afd0..9c576ce2f455 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -38,9 +38,9 @@ #include "../../include/linux/lnet/lib-lnet.h" struct lnet_text_buf_t { /* tmp struct for parsing routes */ - struct list_head ltb_list; /* stash on lists */ - int ltb_size; /* allocated size */ - char ltb_text[0]; /* text buffer */ + struct list_head ltb_list; /* stash on lists */ + int ltb_size; /* allocated size */ + char ltb_text[0]; /* text buffer */ }; static int lnet_tbnob; /* track text buf allocation */ @@ -80,8 +80,8 @@ lnet_issep(char c) static int lnet_net_unique(__u32 net, struct list_head *nilist) { - struct list_head *tmp; - lnet_ni_t *ni; + struct list_head *tmp; + lnet_ni_t *ni; list_for_each(tmp, nilist) { ni = list_entry(tmp, lnet_ni_t, ni_list); @@ -111,10 +111,10 @@ lnet_ni_free(struct lnet_ni *ni) static lnet_ni_t * lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) { - struct lnet_tx_queue *tq; - struct lnet_ni *ni; - int rc; - int i; + struct lnet_tx_queue *tq; + struct lnet_ni *ni; + int rc; + int i; if (!lnet_net_unique(net, nilist)) { LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n", @@ -178,13 +178,13 @@ int lnet_parse_networks(struct list_head *nilist, char *networks) { struct cfs_expr_list *el = NULL; - int tokensize = strlen(networks) + 1; - char *tokens; - char *str; - char *tmp; - struct lnet_ni *ni; - __u32 net; - int nnets = 0; + int tokensize = strlen(networks) + 1; + char *tokens; + char *str; + char *tmp; + struct lnet_ni *ni; + __u32 net; + int nnets = 0; if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) { /* _WAY_ conservative */ @@ -210,12 +210,12 @@ lnet_parse_networks(struct list_head *nilist, char *networks) goto failed; while (str != NULL && *str != 0) { - char *comma = strchr(str, ','); - char *bracket = strchr(str, '('); - char *square = strchr(str, '['); - char *iface; - int niface; - int rc; + char *comma = strchr(str, ','); + char *bracket = strchr(str, '('); + char *square = strchr(str, '['); + char *iface; + int niface; + int rc; /* NB we don't check interface conflicts here; it's the LNDs * responsibility (if it cares at all) */ @@ -369,7 +369,7 @@ static struct lnet_text_buf_t * lnet_new_text_buf(int str_len) { struct lnet_text_buf_t *ltb; - int nob; + int nob; /* NB allocate space for the terminating 0 */ nob = offsetof(struct lnet_text_buf_t, ltb_text[str_len + 1]); @@ -404,7 +404,7 @@ lnet_free_text_buf(struct lnet_text_buf_t *ltb) static void lnet_free_text_bufs(struct list_head *tbs) { - struct lnet_text_buf_t *ltb; + struct lnet_text_buf_t *ltb; while (!list_empty(tbs)) { ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list); @@ -417,11 +417,11 @@ lnet_free_text_bufs(struct list_head *tbs) static int lnet_str2tbs_sep(struct list_head *tbs, char *str) { - struct list_head pending; - char *sep; - int nob; - int i; - struct lnet_text_buf_t *ltb; + struct list_head pending; + char *sep; + int nob; + int i; + struct lnet_text_buf_t *ltb; INIT_LIST_HEAD(&pending); @@ -477,8 +477,8 @@ lnet_expand1tb(struct list_head *list, char *str, char *sep1, char *sep2, char *item, int itemlen) { - int len1 = (int)(sep1 - str); - int len2 = strlen(sep2 + 1); + int len1 = (int)(sep1 - str); + int len2 = strlen(sep2 + 1); struct lnet_text_buf_t *ltb; LASSERT(*sep1 == '['); @@ -500,18 +500,18 @@ lnet_expand1tb(struct list_head *list, static int lnet_str2tbs_expand(struct list_head *tbs, char *str) { - char num[16]; - struct list_head pending; - char *sep; - char *sep2; - char *parsed; - char *enditem; - int lo; - int hi; - int stride; - int i; - int nob; - int scanned; + char num[16]; + struct list_head pending; + char *sep; + char *sep2; + char *parsed; + char *enditem; + int lo; + int hi; + int stride; + int i; + int nob; + int scanned; INIT_LIST_HEAD(&pending); @@ -584,8 +584,8 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str) static int lnet_parse_hops(char *str, unsigned int *hops) { - int len = strlen(str); - int nob = len; + int len = strlen(str); + int nob = len; return (sscanf(str, "%u%n", hops, &nob) >= 1 && nob == len && @@ -597,9 +597,9 @@ lnet_parse_hops(char *str, unsigned int *hops) static int lnet_parse_priority(char *str, unsigned int *priority, char **token) { - int nob; + int nob; char *sep; - int len; + int len; sep = strchr(str, LNET_PRIORITY_SEPARATOR); if (sep == NULL) { @@ -628,23 +628,23 @@ static int lnet_parse_route(char *str, int *im_a_router) { /* static scratch buffer OK (single threaded) */ - static char cmd[LNET_SINGLE_TEXTBUF_NOB]; - - struct list_head nets; - struct list_head gateways; - struct list_head *tmp1; - struct list_head *tmp2; - __u32 net; - lnet_nid_t nid; - struct lnet_text_buf_t *ltb; - int rc; - char *sep; - char *token = str; - int ntokens = 0; - int myrc = -1; - unsigned int hops; - int got_hops = 0; - unsigned int priority = 0; + static char cmd[LNET_SINGLE_TEXTBUF_NOB]; + + struct list_head nets; + struct list_head gateways; + struct list_head *tmp1; + struct list_head *tmp2; + __u32 net; + lnet_nid_t nid; + struct lnet_text_buf_t *ltb; + int rc; + char *sep; + char *token = str; + int ntokens = 0; + int myrc = -1; + unsigned int hops; + int got_hops = 0; + unsigned int priority = 0; INIT_LIST_HEAD(&gateways); INIT_LIST_HEAD(&nets); @@ -772,7 +772,7 @@ lnet_parse_route(char *str, int *im_a_router) static int lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router) { - struct lnet_text_buf_t *ltb; + struct lnet_text_buf_t *ltb; while (!list_empty(tbs)) { ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list); @@ -792,8 +792,8 @@ lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router) int lnet_parse_routes(char *routes, int *im_a_router) { - struct list_head tbs; - int rc = 0; + struct list_head tbs; + int rc = 0; *im_a_router = 0; @@ -814,8 +814,8 @@ static int lnet_match_network_token(char *token, int len, __u32 *ipaddrs, int nip) { LIST_HEAD(list); - int rc; - int i; + int rc; + int i; rc = cfs_ip_addr_parse(token, len, &list); if (rc != 0) @@ -834,13 +834,13 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip) { static char tokens[LNET_SINGLE_TEXTBUF_NOB]; - int matched = 0; - int ntokens = 0; - int len; + int matched = 0; + int ntokens = 0; + int len; char *net = NULL; char *sep; char *token; - int rc; + int rc; LASSERT(strlen(net_entry) < sizeof(tokens)); @@ -889,8 +889,8 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip) static __u32 lnet_netspec2net(char *netspec) { - char *bracket = strchr(netspec, '('); - __u32 net; + char *bracket = strchr(netspec, '('); + __u32 net; if (bracket != NULL) *bracket = 0; @@ -906,15 +906,15 @@ lnet_netspec2net(char *netspec) static int lnet_splitnets(char *source, struct list_head *nets) { - int offset = 0; - int offset2; - int len; - struct lnet_text_buf_t *tb; - struct lnet_text_buf_t *tb2; - struct list_head *t; - char *sep; - char *bracket; - __u32 net; + int offset = 0; + int offset2; + int len; + struct lnet_text_buf_t *tb; + struct lnet_text_buf_t *tb2; + struct list_head *t; + char *sep; + char *bracket; + __u32 net; LASSERT(!list_empty(nets)); LASSERT(nets->next == nets->prev); /* single entry */ @@ -986,22 +986,22 @@ lnet_splitnets(char *source, struct list_head *nets) static int lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip) { - static char networks[LNET_SINGLE_TEXTBUF_NOB]; - static char source[LNET_SINGLE_TEXTBUF_NOB]; - - struct list_head raw_entries; - struct list_head matched_nets; - struct list_head current_nets; - struct list_head *t; - struct list_head *t2; - struct lnet_text_buf_t *tb; - struct lnet_text_buf_t *tb2; - __u32 net1; - __u32 net2; - int len; - int count; - int dup; - int rc; + static char networks[LNET_SINGLE_TEXTBUF_NOB]; + static char source[LNET_SINGLE_TEXTBUF_NOB]; + + struct list_head raw_entries; + struct list_head matched_nets; + struct list_head current_nets; + struct list_head *t; + struct list_head *t2; + struct lnet_text_buf_t *tb; + struct lnet_text_buf_t *tb2; + __u32 net1; + __u32 net2; + int len; + int count; + int dup; + int rc; INIT_LIST_HEAD(&raw_entries); if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) { @@ -1112,15 +1112,15 @@ lnet_ipaddr_free_enumeration(__u32 *ipaddrs, int nip) static int lnet_ipaddr_enumerate(__u32 **ipaddrsp) { - int up; - __u32 netmask; - __u32 *ipaddrs; - __u32 *ipaddrs2; - int nip; - char **ifnames; - int nif = libcfs_ipif_enumerate(&ifnames); - int i; - int rc; + int up; + __u32 netmask; + __u32 *ipaddrs; + __u32 *ipaddrs2; + int nip; + char **ifnames; + int nif = lnet_ipif_enumerate(&ifnames); + int i; + int rc; if (nif <= 0) return nif; @@ -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; @@ -1178,9 +1177,9 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp) int lnet_parse_ip2nets(char **networksp, char *ip2nets) { - __u32 *ipaddrs = NULL; - int nip = lnet_ipaddr_enumerate(&ipaddrs); - int rc; + __u32 *ipaddrs = NULL; + int nip = lnet_ipaddr_enumerate(&ipaddrs); + int rc; if (nip < 0) { LCONSOLE_ERROR_MSG(0x117, @@ -1211,82 +1210,3 @@ lnet_parse_ip2nets(char **networksp, char *ip2nets) return 0; } - -int -lnet_set_ip_niaddr(lnet_ni_t *ni) -{ - __u32 net = LNET_NIDNET(ni->ni_nid); - char **names; - int n; - __u32 ip; - __u32 netmask; - int up; - int i; - int rc; - - /* Convenience for LNDs that use the IP address of a local interface as - * the local address part of their NID */ - - if (ni->ni_interfaces[0] != NULL) { - - CLASSERT(LNET_MAX_INTERFACES > 1); - - if (ni->ni_interfaces[1] != NULL) { - CERROR("Net %s doesn't support multiple interfaces\n", - libcfs_net2str(net)); - return -EPERM; - } - - rc = libcfs_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); - return -EPERM; - } - - if (!up) { - CERROR("Net %s can't use interface %s: it's down\n", - libcfs_net2str(net), ni->ni_interfaces[0]); - return -ENETDOWN; - } - - ni->ni_nid = LNET_MKNID(net, ip); - return 0; - } - - n = libcfs_ipif_enumerate(&names); - if (n <= 0) { - CERROR("Net %s can't enumerate interfaces: %d\n", - libcfs_net2str(net), n); - return 0; - } - - for (i = 0; i < n; i++) { - if (!strcmp(names[i], "lo")) /* skip the loopback IF */ - continue; - - rc = libcfs_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); - continue; - } - - if (!up) { - CWARN("Net %s ignoring interface %s (down)\n", - libcfs_net2str(net), names[i]); - continue; - } - - libcfs_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); - return -ENOENT; -} -EXPORT_SYMBOL(lnet_set_ip_niaddr); diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 5470148f5b64..f19ce9ae6a9a 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -70,7 +70,7 @@ int LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, lnet_handle_eq_t *handle) { - lnet_eq_t *eq; + lnet_eq_t *eq; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -79,7 +79,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, * overflow, they don't skip entries, so the queue has the same * apparent capacity at all times */ - count = cfs_power2_roundup(count); + count = roundup_pow_of_two(count); if (callback != LNET_EQ_HANDLER_NONE && count != 0) CWARN("EQ callback is guaranteed to get every event, do you still want to set eqcount %d for polling event which will have locking overhead? Please contact with developer to confirm\n", count); @@ -151,13 +151,13 @@ EXPORT_SYMBOL(LNetEQAlloc); int LNetEQFree(lnet_handle_eq_t eqh) { - struct lnet_eq *eq; - lnet_event_t *events = NULL; - int **refs = NULL; - int *ref; - int rc = 0; - int size = 0; - int i; + struct lnet_eq *eq; + lnet_event_t *events = NULL; + int **refs = NULL; + int *ref; + int rc = 0; + int size = 0; + int i; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -185,13 +185,13 @@ LNetEQFree(lnet_handle_eq_t eqh) } /* stash for free after lock dropped */ - events = eq->eq_events; - size = eq->eq_size; - refs = eq->eq_refs; + events = eq->eq_events; + size = eq->eq_size; + refs = eq->eq_refs; lnet_res_lh_invalidate(&eq->eq_lh); list_del(&eq->eq_list); - lnet_eq_free_locked(eq); + lnet_eq_free(eq); out: lnet_eq_wait_unlock(); lnet_res_unlock(LNET_LOCK_EX); @@ -237,9 +237,9 @@ lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev) static int lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) { - int new_index = eq->eq_deq_seq & (eq->eq_size - 1); - lnet_event_t *new_event = &eq->eq_events[new_index]; - int rc; + int new_index = eq->eq_deq_seq & (eq->eq_size - 1); + lnet_event_t *new_event = &eq->eq_events[new_index]; + int rc; /* must called with lnet_eq_wait_lock hold */ if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence)) @@ -323,10 +323,10 @@ static int lnet_eq_wait_locked(int *timeout_ms) __must_hold(&the_lnet.ln_eq_wait_lock) { - int tms = *timeout_ms; - int wait; - wait_queue_t wl; - unsigned long now; + int tms = *timeout_ms; + int wait; + wait_queue_t wl; + unsigned long now; if (tms == 0) return -1; /* don't want to wait and no new event */ @@ -392,9 +392,9 @@ int LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, lnet_event_t *event, int *which) { - int wait = 1; - int rc; - int i; + int wait = 1; + int rc; + int i; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index 89d660fefd48..758f5bedef7e 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -74,7 +74,7 @@ lnet_md_unlink(lnet_libmd_t *md) CDEBUG(D_NET, "Unlinking md %p\n", md); if (md->md_eq != NULL) { - int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie); + int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie); LASSERT(*md->md_eq->eq_refs[cpt] > 0); (*md->md_eq->eq_refs[cpt])--; @@ -82,15 +82,15 @@ lnet_md_unlink(lnet_libmd_t *md) LASSERT(!list_empty(&md->md_list)); list_del_init(&md->md_list); - lnet_md_free_locked(md); + lnet_md_free(md); } static int lnet_md_build(lnet_libmd_t *lmd, lnet_md_t *umd, int unlink) { - int i; + int i; unsigned int niov; - int total_length = 0; + int total_length = 0; lmd->md_me = NULL; lmd->md_start = umd->start; @@ -268,10 +268,10 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, { LIST_HEAD(matches); LIST_HEAD(drops); - struct lnet_me *me; - struct lnet_libmd *md; - int cpt; - int rc; + struct lnet_me *me; + struct lnet_libmd *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -320,7 +320,7 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, return 0; failed: - lnet_md_free_locked(md); + lnet_md_free(md); lnet_res_unlock(cpt); return rc; @@ -346,9 +346,9 @@ EXPORT_SYMBOL(LNetMDAttach); int LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle) { - lnet_libmd_t *md; - int cpt; - int rc; + lnet_libmd_t *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -381,7 +381,7 @@ LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle) return 0; failed: - lnet_md_free_locked(md); + lnet_md_free(md); lnet_res_unlock(cpt); return rc; @@ -421,9 +421,9 @@ EXPORT_SYMBOL(LNetMDBind); int LNetMDUnlink(lnet_handle_md_t mdh) { - lnet_event_t ev; - lnet_libmd_t *md; - int cpt; + lnet_event_t ev; + lnet_libmd_t *md; + int cpt; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index a3f929244711..42fc99ef9f80 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -80,8 +80,8 @@ LNetMEAttach(unsigned int portal, lnet_handle_me_t *handle) { struct lnet_match_table *mtable; - struct lnet_me *me; - struct list_head *head; + struct lnet_me *me; + struct list_head *head; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -151,10 +151,10 @@ LNetMEInsert(lnet_handle_me_t current_meh, lnet_unlink_t unlink, lnet_ins_pos_t pos, lnet_handle_me_t *handle) { - struct lnet_me *current_me; - struct lnet_me *new_me; - struct lnet_portal *ptl; - int cpt; + struct lnet_me *current_me; + struct lnet_me *new_me; + struct lnet_portal *ptl; + int cpt; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -172,7 +172,7 @@ LNetMEInsert(lnet_handle_me_t current_meh, current_me = lnet_handle2me(¤t_meh); if (current_me == NULL) { - lnet_me_free_locked(new_me); + lnet_me_free(new_me); lnet_res_unlock(cpt); return -ENOENT; @@ -183,7 +183,7 @@ LNetMEInsert(lnet_handle_me_t current_meh, ptl = the_lnet.ln_portals[current_me->me_portal]; if (lnet_ptl_is_unique(ptl)) { /* nosense to insertion on unique portal */ - lnet_me_free_locked(new_me); + lnet_me_free(new_me); lnet_res_unlock(cpt); return -EPERM; } @@ -228,10 +228,10 @@ EXPORT_SYMBOL(LNetMEInsert); int LNetMEUnlink(lnet_handle_me_t meh) { - lnet_me_t *me; - lnet_libmd_t *md; - lnet_event_t ev; - int cpt; + lnet_me_t *me; + lnet_libmd_t *md; + lnet_event_t ev; + int cpt; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -276,7 +276,7 @@ lnet_me_unlink(lnet_me_t *me) } lnet_res_lh_invalidate(&me->me_lh); - lnet_me_free_locked(me); + lnet_me_free(me); } #if 0 diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index c2fb70e5fc4e..433faae9a2ff 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -49,10 +49,10 @@ MODULE_PARM_DESC(local_nid_dist_zero, "Reserved"); int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) { - lnet_test_peer_t *tp; - struct list_head *el; - struct list_head *next; - struct list_head cull; + lnet_test_peer_t *tp; + struct list_head *el; + struct list_head *next; + struct list_head cull; LASSERT(the_lnet.ln_init); @@ -103,10 +103,10 @@ static int fail_peer(lnet_nid_t nid, int outgoing) { lnet_test_peer_t *tp; - struct list_head *el; - struct list_head *next; - struct list_head cull; - int fail = 0; + struct list_head *el; + struct list_head *next; + struct list_head cull; + int fail = 0; INIT_LIST_HEAD(&cull); @@ -175,7 +175,7 @@ lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset, unsigned int nob) { /* NB diov, siov are READ-ONLY */ - unsigned int this_nob; + unsigned int this_nob; if (nob == 0) return; @@ -236,8 +236,8 @@ lnet_extract_iov(int dst_niov, struct kvec *dst, /* Initialise 'dst' to the subset of 'src' starting at 'offset', * for exactly 'len' bytes, and return the number of entries. * NB not destructive to 'src' */ - unsigned int frag_len; - unsigned int niov; + unsigned int frag_len; + unsigned int niov; if (len == 0) /* no data => */ return 0; /* no frags */ @@ -279,7 +279,7 @@ EXPORT_SYMBOL(lnet_extract_iov); unsigned int lnet_kiov_nob(unsigned int niov, lnet_kiov_t *kiov) { - unsigned int nob = 0; + unsigned int nob = 0; while (niov-- > 0) nob += (kiov++)->kiov_len; @@ -294,9 +294,9 @@ lnet_copy_kiov2kiov(unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset, unsigned int nob) { /* NB diov, siov are READ-ONLY */ - unsigned int this_nob; - char *daddr = NULL; - char *saddr = NULL; + unsigned int this_nob; + char *daddr = NULL; + char *saddr = NULL; if (nob == 0) return; @@ -376,8 +376,8 @@ lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov, unsigned int iovoffset, unsigned int kiovoffset, unsigned int nob) { /* NB iov, kiov are READ-ONLY */ - unsigned int this_nob; - char *addr = NULL; + unsigned int this_nob; + char *addr = NULL; if (nob == 0) return; @@ -447,8 +447,8 @@ lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov, unsigned int nob) { /* NB kiov, iov are READ-ONLY */ - unsigned int this_nob; - char *addr = NULL; + unsigned int this_nob; + char *addr = NULL; if (nob == 0) return; @@ -518,8 +518,8 @@ lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst, /* Initialise 'dst' to the subset of 'src' starting at 'offset', * for exactly 'len' bytes, and return the number of entries. * NB not destructive to 'src' */ - unsigned int frag_len; - unsigned int niov; + unsigned int frag_len; + unsigned int niov; if (len == 0) /* no data => */ return 0; /* no frags */ @@ -565,10 +565,10 @@ static void lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen) { - unsigned int niov = 0; + unsigned int niov = 0; struct kvec *iov = NULL; - lnet_kiov_t *kiov = NULL; - int rc; + lnet_kiov_t *kiov = NULL; + int rc; LASSERT(!in_interrupt()); LASSERT(mlen == 0 || msg != NULL); @@ -642,8 +642,8 @@ lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target, static void lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg) { - void *priv = msg->msg_private; - int rc; + void *priv = msg->msg_private; + int rc; LASSERT(!in_interrupt()); LASSERT(LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND || @@ -657,7 +657,7 @@ lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg) { - int rc; + int rc; LASSERT(!msg->msg_sending); LASSERT(msg->msg_receiving); @@ -700,7 +700,7 @@ lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp) static inline int lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now) { - int alive; + int alive; unsigned long deadline; LASSERT(lnet_peer_aliveness_enabled(lp)); @@ -785,10 +785,10 @@ lnet_peer_alive_locked(lnet_peer_t *lp) static int lnet_post_send_locked(lnet_msg_t *msg, int do_send) { - lnet_peer_t *lp = msg->msg_txpeer; - lnet_ni_t *ni = lp->lp_ni; - int cpt = msg->msg_tx_cpt; - struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt]; + lnet_peer_t *lp = msg->msg_txpeer; + lnet_ni_t *ni = lp->lp_ni; + int cpt = msg->msg_tx_cpt; + struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt]; /* non-lnet_send() callers have checked before */ LASSERT(!do_send || msg->msg_tx_delayed); @@ -871,8 +871,8 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) static lnet_rtrbufpool_t * lnet_msg2bufpool(lnet_msg_t *msg) { - lnet_rtrbufpool_t *rbp; - int cpt; + lnet_rtrbufpool_t *rbp; + int cpt; LASSERT(msg->msg_rx_committed); @@ -894,9 +894,9 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) /* lnet_parse is going to lnet_net_unlock immediately after this, so it * sets do_recv FALSE and I don't do the unlock/send/lock bit. I * return EAGAIN if msg blocked and 0 if received or OK to receive */ - lnet_peer_t *lp = msg->msg_rxpeer; - lnet_rtrbufpool_t *rbp; - lnet_rtrbuf_t *rb; + lnet_peer_t *lp = msg->msg_rxpeer; + lnet_rtrbufpool_t *rbp; + lnet_rtrbuf_t *rb; LASSERT(msg->msg_iov == NULL); LASSERT(msg->msg_kiov == NULL); @@ -967,11 +967,11 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) void lnet_return_tx_credits_locked(lnet_msg_t *msg) { - lnet_peer_t *txpeer = msg->msg_txpeer; - lnet_msg_t *msg2; + lnet_peer_t *txpeer = msg->msg_txpeer; + lnet_msg_t *msg2; if (msg->msg_txcredit) { - struct lnet_ni *ni = txpeer->lp_ni; + struct lnet_ni *ni = txpeer->lp_ni; struct lnet_tx_queue *tq = ni->ni_tx_queues[msg->msg_tx_cpt]; /* give back NI txcredits */ @@ -1025,12 +1025,12 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg) void lnet_return_rx_credits_locked(lnet_msg_t *msg) { - lnet_peer_t *rxpeer = msg->msg_rxpeer; - lnet_msg_t *msg2; + lnet_peer_t *rxpeer = msg->msg_rxpeer; + lnet_msg_t *msg2; if (msg->msg_rtrcredit) { /* give back global router credits */ - lnet_rtrbuf_t *rb; + lnet_rtrbuf_t *rb; lnet_rtrbufpool_t *rbp; /* NB If a msg ever blocks for a buffer in rbp_msgs, it stays @@ -1122,13 +1122,13 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2) static lnet_peer_t * lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) { - lnet_remotenet_t *rnet; - lnet_route_t *rtr; - lnet_route_t *rtr_best; - lnet_route_t *rtr_last; - struct lnet_peer *lp_best; - struct lnet_peer *lp; - int rc; + lnet_remotenet_t *rnet; + lnet_route_t *rtr; + lnet_route_t *rtr_best; + lnet_route_t *rtr_last; + struct lnet_peer *lp_best; + struct lnet_peer *lp; + int rc; /* If @rtr_nid is not LNET_NID_ANY, return the gateway with * rtr_nid nid, otherwise find the best gateway I can use */ @@ -1182,13 +1182,13 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) int lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid) { - lnet_nid_t dst_nid = msg->msg_target.nid; - struct lnet_ni *src_ni; - struct lnet_ni *local_ni; - struct lnet_peer *lp; - int cpt; - int cpt2; - int rc; + lnet_nid_t dst_nid = msg->msg_target.nid; + struct lnet_ni *src_ni; + struct lnet_ni *local_ni; + struct lnet_peer *lp; + int cpt; + int cpt2; + int rc; /* NB: rtr_nid is set to LNET_NID_ANY for all current use-cases, * but we might want to use pre-determined router for ACK/REPLY @@ -1364,7 +1364,7 @@ lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, unsigned int nob) static void lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_hdr_t *hdr = &msg->msg_hdr; if (msg->msg_wanted != 0) lnet_setpayloadbuffer(msg); @@ -1383,9 +1383,9 @@ lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; - struct lnet_match_info info; - int rc; + lnet_hdr_t *hdr = &msg->msg_hdr; + struct lnet_match_info info; + int rc; /* Convert put fields to host byte order */ hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits); @@ -1433,24 +1433,24 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get) { - struct lnet_match_info info; - lnet_hdr_t *hdr = &msg->msg_hdr; - lnet_handle_wire_t reply_wmd; - int rc; + struct lnet_match_info info; + lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_handle_wire_t reply_wmd; + int rc; /* Convert get fields to host byte order */ - hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits); - hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index); - hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length); - hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset); - - info.mi_id.nid = hdr->src_nid; - info.mi_id.pid = hdr->src_pid; - info.mi_opc = LNET_MD_OP_GET; - info.mi_portal = hdr->msg.get.ptl_index; - info.mi_rlength = hdr->msg.get.sink_length; - info.mi_roffset = hdr->msg.get.src_offset; - info.mi_mbits = hdr->msg.get.match_bits; + hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits); + hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index); + hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length); + hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset); + + info.mi_id.nid = hdr->src_nid; + info.mi_id.pid = hdr->src_pid; + info.mi_opc = LNET_MD_OP_GET; + info.mi_portal = hdr->msg.get.ptl_index; + info.mi_rlength = hdr->msg.get.sink_length; + info.mi_roffset = hdr->msg.get.src_offset; + info.mi_mbits = hdr->msg.get.match_bits; rc = lnet_ptl_match_md(&info, msg); if (rc == LNET_MATCHMD_DROP) { @@ -1497,13 +1497,13 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get) static int lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) { - void *private = msg->msg_private; - lnet_hdr_t *hdr = &msg->msg_hdr; + void *private = msg->msg_private; + lnet_hdr_t *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; - lnet_libmd_t *md; - int rlength; - int mlength; - int cpt; + lnet_libmd_t *md; + int rlength; + int mlength; + int cpt; cpt = lnet_cpt_of_cookie(hdr->msg.reply.dst_wmd.wh_object_cookie); lnet_res_lock(cpt); @@ -1562,10 +1562,10 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_hdr_t *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; - lnet_libmd_t *md; - int cpt; + lnet_libmd_t *md; + int cpt; src.nid = hdr->src_nid; src.pid = hdr->src_pid; @@ -1612,7 +1612,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg) { - int rc = 0; + int rc = 0; if (msg->msg_rxpeer->lp_rtrcredits <= 0 || lnet_msg2bufpool(msg)->rbp_credits <= 0) { @@ -1713,15 +1713,15 @@ int lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, void *private, int rdma_req) { - int rc = 0; - int cpt; - int for_me; - struct lnet_msg *msg; - lnet_pid_t dest_pid; - lnet_nid_t dest_nid; - lnet_nid_t src_nid; - __u32 payload_length; - __u32 type; + int rc = 0; + int cpt; + int for_me; + struct lnet_msg *msg; + lnet_pid_t dest_pid; + lnet_nid_t dest_nid; + lnet_nid_t src_nid; + __u32 payload_length; + __u32 type; LASSERT(!in_interrupt()); @@ -1945,8 +1945,8 @@ void lnet_drop_delayed_msg_list(struct list_head *head, char *reason) { while (!list_empty(head)) { - lnet_process_id_t id = {0}; - lnet_msg_t *msg; + lnet_process_id_t id = {0}; + lnet_msg_t *msg; msg = list_entry(head->next, lnet_msg_t, msg_list); list_del(&msg->msg_list); @@ -1986,8 +1986,8 @@ void lnet_recv_delayed_msg_list(struct list_head *head) { while (!list_empty(head)) { - lnet_msg_t *msg; - lnet_process_id_t id; + lnet_msg_t *msg; + lnet_process_id_t id; msg = list_entry(head->next, lnet_msg_t, msg_list); list_del(&msg->msg_list); @@ -2063,10 +2063,10 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack, __u64 match_bits, unsigned int offset, __u64 hdr_data) { - struct lnet_msg *msg; - struct lnet_libmd *md; - int cpt; - int rc; + struct lnet_msg *msg; + struct lnet_libmd *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -2153,10 +2153,10 @@ lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *getmsg) * CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when * lnet_finalize() is called on it, so the LND must call this first */ - struct lnet_msg *msg = lnet_msg_alloc(); - struct lnet_libmd *getmd = getmsg->msg_md; - lnet_process_id_t peer_id = getmsg->msg_target; - int cpt; + struct lnet_msg *msg = lnet_msg_alloc(); + struct lnet_libmd *getmd = getmsg->msg_md; + lnet_process_id_t peer_id = getmsg->msg_target; + int cpt; LASSERT(!getmsg->msg_target_is_router); LASSERT(!getmsg->msg_routing); @@ -2263,10 +2263,10 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh, lnet_process_id_t target, unsigned int portal, __u64 match_bits, unsigned int offset) { - struct lnet_msg *msg; - struct lnet_libmd *md; - int cpt; - int rc; + struct lnet_msg *msg; + struct lnet_libmd *md; + int cpt; + int rc; LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -2353,14 +2353,14 @@ EXPORT_SYMBOL(LNetGet); int LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) { - struct list_head *e; - struct lnet_ni *ni; - lnet_remotenet_t *rnet; - __u32 dstnet = LNET_NIDNET(dstnid); - int hops; - int cpt; - __u32 order = 2; - struct list_head *rn_list; + struct list_head *e; + struct lnet_ni *ni; + lnet_remotenet_t *rnet; + __u32 dstnet = LNET_NIDNET(dstnid); + int hops; + int cpt; + __u32 order = 2; + struct list_head *rn_list; /* if !local_nid_dist_zero, I don't return a distance of 0 ever * (when lustre sees a distance of 0, it substitutes 0@lo), so I @@ -2434,27 +2434,3 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) return -EHOSTUNREACH; } EXPORT_SYMBOL(LNetDist); - -/** - * Set the number of asynchronous messages expected from a target process. - * - * This function is only meaningful for userspace callers. It's a no-op when - * called from kernel. - * - * Asynchronous messages are those that can come from a target when the - * userspace process is not waiting for IO to complete; e.g., AST callbacks - * from Lustre servers. Specifying the expected number of such messages - * allows them to be eagerly received when user process is not running in - * LNet; otherwise network errors may occur. - * - * \param id Process ID of the target process. - * \param nasync Number of asynchronous messages expected from the target. - * - * \return 0 on success, and an error code otherwise. - */ -int -LNetSetAsync(lnet_process_id_t id, int nasync) -{ - return 0; -} -EXPORT_SYMBOL(LNetSetAsync); diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index a46ccbf6608f..43977e8dffbb 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -60,8 +60,8 @@ lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev) void lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) { - lnet_hdr_t *hdr = &msg->msg_hdr; - lnet_event_t *ev = &msg->msg_ev; + lnet_hdr_t *hdr = &msg->msg_hdr; + lnet_event_t *ev = &msg->msg_ev; LASSERT(!msg->msg_routing); @@ -73,7 +73,7 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) ev->target.pid = le32_to_cpu(hdr->dest_pid); ev->initiator.nid = LNET_NID_ANY; ev->initiator.pid = the_lnet.ln_pid; - ev->sender = LNET_NID_ANY; + ev->sender = LNET_NID_ANY; } else { /* event for passive message */ @@ -82,9 +82,9 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) ev->initiator.pid = hdr->src_pid; ev->initiator.nid = hdr->src_nid; ev->rlength = hdr->payload_length; - ev->sender = msg->msg_from; - ev->mlength = msg->msg_wanted; - ev->offset = msg->msg_offset; + ev->sender = msg->msg_from; + ev->mlength = msg->msg_wanted; + ev->offset = msg->msg_offset; } switch (ev_type) { @@ -137,7 +137,7 @@ void lnet_msg_commit(lnet_msg_t *msg, int cpt) { struct lnet_msg_container *container = the_lnet.ln_msg_containers[cpt]; - lnet_counters_t *counters = the_lnet.ln_counters[cpt]; + lnet_counters_t *counters = the_lnet.ln_counters[cpt]; /* routed message can be committed for both receiving and sending */ LASSERT(!msg->msg_tx_committed); @@ -170,7 +170,7 @@ static void lnet_msg_decommit_tx(lnet_msg_t *msg, int status) { lnet_counters_t *counters; - lnet_event_t *ev = &msg->msg_ev; + lnet_event_t *ev = &msg->msg_ev; LASSERT(msg->msg_tx_committed); if (status != 0) @@ -219,8 +219,8 @@ lnet_msg_decommit_tx(lnet_msg_t *msg, int status) static void lnet_msg_decommit_rx(lnet_msg_t *msg, int status) { - lnet_counters_t *counters; - lnet_event_t *ev = &msg->msg_ev; + lnet_counters_t *counters; + lnet_event_t *ev = &msg->msg_ev; LASSERT(!msg->msg_tx_committed); /* decommitted or never committed */ LASSERT(msg->msg_rx_committed); @@ -273,7 +273,7 @@ lnet_msg_decommit_rx(lnet_msg_t *msg, int status) void lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status) { - int cpt2 = cpt; + int cpt2 = cpt; LASSERT(msg->msg_tx_committed || msg->msg_rx_committed); LASSERT(msg->msg_onactivelist); @@ -335,8 +335,8 @@ lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md, void lnet_msg_detach_md(lnet_msg_t *msg, int status) { - lnet_libmd_t *md = msg->msg_md; - int unlink; + lnet_libmd_t *md = msg->msg_md; + int unlink; /* Now it's safe to drop my caller's ref */ md->md_refcount--; @@ -359,8 +359,8 @@ static int lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) { lnet_handle_wire_t ack_wmd; - int rc; - int status = msg->msg_ev.status; + int rc; + int status = msg->msg_ev.status; LASSERT(msg->msg_onactivelist); @@ -427,18 +427,18 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) } lnet_msg_decommit(msg, cpt, status); - lnet_msg_free_locked(msg); + lnet_msg_free(msg); return 0; } void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status) { - struct lnet_msg_container *container; - int my_slot; - int cpt; - int rc; - int i; + struct lnet_msg_container *container; + int my_slot; + int cpt; + int rc; + int i; LASSERT(!in_interrupt()); @@ -534,7 +534,7 @@ EXPORT_SYMBOL(lnet_finalize); void lnet_msg_container_cleanup(struct lnet_msg_container *container) { - int count = 0; + int count = 0; if (container->msc_init == 0) return; @@ -568,7 +568,7 @@ lnet_msg_container_cleanup(struct lnet_msg_container *container) int lnet_msg_container_setup(struct lnet_msg_container *container, int cpt) { - int rc; + int rc; container->msc_init = 1; @@ -608,7 +608,7 @@ void lnet_msg_containers_destroy(void) { struct lnet_msg_container *container; - int i; + int i; if (the_lnet.ln_msg_containers == NULL) return; @@ -624,8 +624,8 @@ int lnet_msg_containers_create(void) { struct lnet_msg_container *container; - int rc; - int i; + int rc; + int i; the_lnet.ln_msg_containers = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*container)); diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 3ba0da919b41..84707c5cb464 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -39,7 +39,7 @@ #include "../../include/linux/lnet/lib-lnet.h" /* NB: add /proc interfaces in upcoming patches */ -int portal_rotor = LNET_PTL_ROTOR_HASH_RT; +int portal_rotor = LNET_PTL_ROTOR_HASH_RT; module_param(portal_rotor, int, 0644); MODULE_PARM_DESC(portal_rotor, "redirect PUTs to different cpu-partitions"); @@ -47,8 +47,8 @@ static int lnet_ptl_match_type(unsigned int index, lnet_process_id_t match_id, __u64 mbits, __u64 ignore_bits) { - struct lnet_portal *ptl = the_lnet.ln_portals[index]; - int unique; + struct lnet_portal *ptl = the_lnet.ln_portals[index]; + int unique; unique = ignore_bits == 0 && match_id.nid != LNET_NID_ANY && @@ -89,7 +89,7 @@ static void lnet_ptl_enable_mt(struct lnet_portal *ptl, int cpt) { struct lnet_match_table *mtable = ptl->ptl_mtables[cpt]; - int i; + int i; /* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */ LASSERT(lnet_ptl_is_wildcard(ptl)); @@ -114,7 +114,7 @@ static void lnet_ptl_disable_mt(struct lnet_portal *ptl, int cpt) { struct lnet_match_table *mtable = ptl->ptl_mtables[cpt]; - int i; + int i; /* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */ LASSERT(lnet_ptl_is_wildcard(ptl)); @@ -141,9 +141,9 @@ lnet_try_match_md(lnet_libmd_t *md, { /* ALWAYS called holding the lnet_res_lock, and can't lnet_res_unlock; * lnet_match_blocked_msg() relies on this to avoid races */ - unsigned int offset; - unsigned int mlength; - lnet_me_t *me = md->md_me; + unsigned int offset; + unsigned int mlength; + lnet_me_t *me = md->md_me; /* MD exhausted */ if (lnet_md_exhausted(md)) @@ -227,7 +227,7 @@ struct lnet_match_table * lnet_mt_of_attach(unsigned int index, lnet_process_id_t id, __u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos) { - struct lnet_portal *ptl; + struct lnet_portal *ptl; struct lnet_match_table *mtable; /* NB: called w/o lock */ @@ -261,11 +261,11 @@ static struct lnet_match_table * lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg) { struct lnet_match_table *mtable; - struct lnet_portal *ptl; - unsigned int nmaps; - unsigned int rotor; - unsigned int cpt; - bool routed; + struct lnet_portal *ptl; + unsigned int nmaps; + unsigned int rotor; + unsigned int cpt; + bool routed; /* NB: called w/o lock */ LASSERT(info->mi_portal < the_lnet.ln_nportals); @@ -312,8 +312,8 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg) static int lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos) { - __u64 *bmap; - int i; + __u64 *bmap; + int i; if (!lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal])) return 0; @@ -337,7 +337,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos) static void lnet_mt_set_exhausted(struct lnet_match_table *mtable, int pos, int exhausted) { - __u64 *bmap; + __u64 *bmap; LASSERT(lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal])); LASSERT(pos <= LNET_MT_HASH_IGNORE); @@ -373,11 +373,11 @@ int lnet_mt_match_md(struct lnet_match_table *mtable, struct lnet_match_info *info, struct lnet_msg *msg) { - struct list_head *head; - lnet_me_t *me; - lnet_me_t *tmp; - int exhausted = 0; - int rc; + struct list_head *head; + lnet_me_t *me; + lnet_me_t *tmp; + int exhausted = 0; + int rc; /* any ME with ignore bits? */ if (!list_empty(&mtable->mt_mhash[LNET_MT_HASH_IGNORE])) @@ -428,7 +428,7 @@ lnet_mt_match_md(struct lnet_match_table *mtable, static int lnet_ptl_match_early(struct lnet_portal *ptl, struct lnet_msg *msg) { - int rc; + int rc; /* message arrived before any buffer posting on this portal, * simply delay or drop this message */ @@ -461,9 +461,9 @@ static int lnet_ptl_match_delay(struct lnet_portal *ptl, struct lnet_match_info *info, struct lnet_msg *msg) { - int first = ptl->ptl_mt_maps[0]; /* read w/o lock */ - int rc = 0; - int i; + int first = ptl->ptl_mt_maps[0]; /* read w/o lock */ + int rc = 0; + int i; /* steal buffer from other CPTs, and delay it if nothing to steal, * this function is more expensive than a regular match, but we @@ -472,7 +472,7 @@ lnet_ptl_match_delay(struct lnet_portal *ptl, for (i = 0; i < LNET_CPT_NUMBER; i++) { struct lnet_match_table *mtable; - int cpt; + int cpt; cpt = (first + i) % LNET_CPT_NUMBER; mtable = ptl->ptl_mtables[cpt]; @@ -536,8 +536,8 @@ int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg) { struct lnet_match_table *mtable; - struct lnet_portal *ptl; - int rc; + struct lnet_portal *ptl; + int rc; CDEBUG(D_NET, "Request from %s of length %d into portal %d MB=%#llx\n", libcfs_id2str(info->mi_id), info->mi_rlength, info->mi_portal, @@ -622,13 +622,13 @@ void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, struct list_head *matches, struct list_head *drops) { - struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal]; + struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal]; struct lnet_match_table *mtable; - struct list_head *head; - lnet_msg_t *tmp; - lnet_msg_t *msg; - int exhausted = 0; - int cpt; + struct list_head *head; + lnet_msg_t *tmp; + lnet_msg_t *msg; + int exhausted = 0; + int cpt; LASSERT(md->md_refcount == 0); /* a brand new MD */ @@ -647,20 +647,20 @@ lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, head = &ptl->ptl_msg_stealing; again: list_for_each_entry_safe(msg, tmp, head, msg_list) { - struct lnet_match_info info; - lnet_hdr_t *hdr; - int rc; + struct lnet_match_info info; + lnet_hdr_t *hdr; + int rc; LASSERT(msg->msg_rx_delayed || head == &ptl->ptl_msg_stealing); - hdr = &msg->msg_hdr; - info.mi_id.nid = hdr->src_nid; - info.mi_id.pid = hdr->src_pid; - info.mi_opc = LNET_MD_OP_PUT; - info.mi_portal = hdr->msg.put.ptl_index; - info.mi_rlength = hdr->payload_length; - info.mi_roffset = hdr->msg.put.offset; - info.mi_mbits = hdr->msg.put.match_bits; + hdr = &msg->msg_hdr; + info.mi_id.nid = hdr->src_nid; + info.mi_id.pid = hdr->src_pid; + info.mi_opc = LNET_MD_OP_PUT; + info.mi_portal = hdr->msg.put.ptl_index; + info.mi_rlength = hdr->payload_length; + info.mi_roffset = hdr->msg.put.offset; + info.mi_mbits = hdr->msg.put.match_bits; rc = lnet_try_match_md(md, &info, msg); @@ -715,7 +715,7 @@ static void lnet_ptl_cleanup(struct lnet_portal *ptl) { struct lnet_match_table *mtable; - int i; + int i; if (ptl->ptl_mtables == NULL) /* uninitialized portal */ return; @@ -723,9 +723,9 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) LASSERT(list_empty(&ptl->ptl_msg_delayed)); LASSERT(list_empty(&ptl->ptl_msg_stealing)); cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) { - struct list_head *mhash; - lnet_me_t *me; - int j; + struct list_head *mhash; + lnet_me_t *me; + int j; if (mtable->mt_mhash == NULL) /* uninitialized match-table */ continue; @@ -753,9 +753,9 @@ static int lnet_ptl_setup(struct lnet_portal *ptl, int index) { struct lnet_match_table *mtable; - struct list_head *mhash; - int i; - int j; + struct list_head *mhash; + int i; + int j; ptl->ptl_mtables = cfs_percpt_alloc(lnet_cpt_table(), sizeof(struct lnet_match_table)); @@ -798,7 +798,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index) void lnet_portals_destroy(void) { - int i; + int i; if (the_lnet.ln_portals == NULL) return; @@ -813,8 +813,8 @@ lnet_portals_destroy(void) int lnet_portals_create(void) { - int size; - int i; + int size; + int i; size = offsetof(struct lnet_portal, ptl_mt_maps[LNET_CPT_NUMBER]); @@ -898,8 +898,8 @@ EXPORT_SYMBOL(LNetSetLazyPortal); int LNetClearLazyPortal(int portal) { - struct lnet_portal *ptl; - LIST_HEAD (zombies); + struct lnet_portal *ptl; + LIST_HEAD(zombies); if (portal < 0 || portal >= the_lnet.ln_nportals) return -EINVAL; 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 000000000000..6f7ef4c737cd --- /dev/null +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -0,0 +1,594 @@ +/* + * 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.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2012, 2015 Intel Corporation. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Seagate, Inc. + */ +#define DEBUG_SUBSYSTEM S_LNET + +#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) +{ + struct file *sock_filp; + struct socket *sock; + int rc; + + 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; + } + + rc = kernel_sock_unlocked_ioctl(sock_filp, cmd, arg); + + fput(sock_filp); +out: + return rc; +} + +int +lnet_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 = lnet_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 = lnet_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 = lnet_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(lnet_ipif_query); + +int +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; + + 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 = lnet_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) + lnet_ipif_free_enumeration(names, nfound); +out1: + LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); +out0: + return rc; +} +EXPORT_SYMBOL(lnet_ipif_enumerate); + +void +lnet_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(lnet_ipif_free_enumeration); + +int +lnet_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(lnet_sock_write); + +int +lnet_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(lnet_sock_read); + +static int +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; + + /* 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 = kernel_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 +lnet_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(lnet_sock_setbuf); + +int +lnet_sock_getaddr(struct socket *sock, bool remote, __u32 *ip, int *port) +{ + struct sockaddr_in sin; + 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"); + return rc; + } + + if (ip != NULL) + *ip = ntohl(sin.sin_addr.s_addr); + + if (port != NULL) + *port = ntohs(sin.sin_port); + + return 0; +} +EXPORT_SYMBOL(lnet_sock_getaddr); + +int +lnet_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(lnet_sock_getbuf); + +int +lnet_sock_listen(struct socket **sockp, __u32 local_ip, int local_port, + int backlog) +{ + int fatal; + int rc; + + 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", + local_port); + return rc; + } + + rc = kernel_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(lnet_sock_listen); + +int +lnet_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(lnet_sock_accept); + +int +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 = lnet_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 = kernel_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(lnet_sock_connect); diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index f708c2e649d7..2a137f46800f 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -111,7 +111,7 @@ lnd_t the_lolnd = { /* .lnd_type = */ LOLND, /* .lnd_startup = */ lolnd_startup, /* .lnd_shutdown = */ lolnd_shutdown, - /* .lnt_ctl = */ NULL, + /* .lnt_ctl = */ NULL, /* .lnd_send = */ lolnd_send, /* .lnd_recv = */ lolnd_recv, /* .lnd_eager_recv = */ NULL, diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index 72b7fbc83718..576201a8390c 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -47,9 +47,9 @@ static int lnet_configure(void *arg) { /* 'arg' only there so I can be passed to cfs_create_thread() */ - int rc = 0; + int rc = 0; - LNET_MUTEX_LOCK(&lnet_config_mutex); + mutex_lock(&lnet_config_mutex); if (!the_lnet.ln_niinit_self) { rc = LNetNIInit(LUSTRE_SRV_LNET_PID); @@ -59,34 +59,34 @@ lnet_configure(void *arg) } } - LNET_MUTEX_UNLOCK(&lnet_config_mutex); + mutex_unlock(&lnet_config_mutex); return rc; } static int lnet_unconfigure(void) { - int refcount; + int refcount; - LNET_MUTEX_LOCK(&lnet_config_mutex); + mutex_lock(&lnet_config_mutex); if (the_lnet.ln_niinit_self) { the_lnet.ln_niinit_self = 0; LNetNIFini(); } - LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); + mutex_lock(&the_lnet.ln_api_mutex); refcount = the_lnet.ln_refcount; - LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex); + mutex_unlock(&the_lnet.ln_api_mutex); - LNET_MUTEX_UNLOCK(&lnet_config_mutex); + mutex_unlock(&lnet_config_mutex); return (refcount == 0) ? 0 : -EBUSY; } static int lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data) { - int rc; + int rc; switch (cmd) { case IOC_LIBCFS_CONFIGURE: @@ -113,13 +113,13 @@ static DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl); static int __init init_lnet(void) { - int rc; + int rc; mutex_init(&lnet_config_mutex); - rc = LNetInit(); + rc = lnet_init(); if (rc != 0) { - CERROR("LNetInit: error %d\n", rc); + CERROR("lnet_init: error %d\n", rc); return rc; } @@ -143,11 +143,11 @@ fini_lnet(void) rc = libcfs_deregister_ioctl(&lnet_ioctl_handler); LASSERT(rc == 0); - LNetFini(); + lnet_fini(); } MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>"); -MODULE_DESCRIPTION("Portals v3.1"); +MODULE_DESCRIPTION("LNet v3.1"); MODULE_LICENSE("GPL"); MODULE_VERSION("1.0.0"); diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index 45b5742f1bd2..1fceed3c8fc0 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -43,10 +43,10 @@ int lnet_peer_tables_create(void) { - struct lnet_peer_table *ptable; - struct list_head *hash; - int i; - int j; + struct lnet_peer_table *ptable; + struct list_head *hash; + int i; + int j; the_lnet.ln_peer_tables = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*ptable)); @@ -77,10 +77,10 @@ lnet_peer_tables_create(void) void lnet_peer_tables_destroy(void) { - struct lnet_peer_table *ptable; - struct list_head *hash; - int i; - int j; + struct lnet_peer_table *ptable; + struct list_head *hash; + int i; + int j; if (the_lnet.ln_peer_tables == NULL) return; @@ -106,9 +106,9 @@ lnet_peer_tables_destroy(void) void lnet_peer_tables_cleanup(void) { - struct lnet_peer_table *ptable; - int i; - int j; + struct lnet_peer_table *ptable; + int i; + int j; LASSERT(the_lnet.ln_shutdown); /* i.e. no new peers */ @@ -133,7 +133,7 @@ lnet_peer_tables_cleanup(void) cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) { LIST_HEAD(deathrow); - lnet_peer_t *lp; + lnet_peer_t *lp; lnet_net_lock(i); @@ -186,8 +186,8 @@ lnet_destroy_peer_locked(lnet_peer_t *lp) lnet_peer_t * lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid) { - struct list_head *peers; - lnet_peer_t *lp; + struct list_head *peers; + lnet_peer_t *lp; LASSERT(!the_lnet.ln_shutdown); @@ -205,11 +205,11 @@ lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid) int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) { - struct lnet_peer_table *ptable; - lnet_peer_t *lp = NULL; - lnet_peer_t *lp2; - int cpt2; - int rc = 0; + struct lnet_peer_table *ptable; + lnet_peer_t *lp = NULL; + lnet_peer_t *lp2; + int cpt2; + int rc = 0; *lpp = NULL; if (the_lnet.ln_shutdown) /* it's shutting down */ @@ -287,8 +287,8 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) goto out; } - lp->lp_txcredits = - lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits; + lp->lp_txcredits = + lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits; lp->lp_rtrcredits = lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni); @@ -308,10 +308,10 @@ out: void lnet_debug_peer(lnet_nid_t nid) { - char *aliveness = "NA"; - lnet_peer_t *lp; - int rc; - int cpt; + char *aliveness = "NA"; + lnet_peer_t *lp; + int rc; + int cpt; cpt = lnet_cpt_of_nid(nid); lnet_net_lock(cpt); diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 8510bae4822a..4fbae5ef44a9 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -24,8 +24,6 @@ #define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/lnet/lib-lnet.h" -#if defined(LNET_ROUTER) - #define LNET_NRB_TINY_MIN 512 /* min value for each CPT */ #define LNET_NRB_TINY (LNET_NRB_TINY_MIN * 4) #define LNET_NRB_SMALL_MIN 4096 /* min value for each CPT */ @@ -70,15 +68,6 @@ lnet_peer_buffer_credits(lnet_ni_t *ni) /* forward ref's */ static int lnet_router_checker(void *); -#else - -int -lnet_peer_buffer_credits(lnet_ni_t *ni) -{ - return 0; -} - -#endif static int check_routers_before_use; module_param(check_routers_before_use, int, 0444); @@ -139,8 +128,8 @@ lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, static void lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) { - int alive; - int notifylnd; + int alive; + int notifylnd; /* Notify only in 1 thread at any time to ensure ordered notification. * NB individual events can be missed; the only guarantee is that you @@ -152,7 +141,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) lp->lp_notifying = 1; while (lp->lp_notify) { - alive = lp->lp_alive; + alive = lp->lp_alive; notifylnd = lp->lp_notifylnd; lp->lp_notifylnd = 0; @@ -228,9 +217,9 @@ lnet_rtr_decref_locked(lnet_peer_t *lp) lnet_remotenet_t * lnet_find_net_locked(__u32 net) { - lnet_remotenet_t *rnet; - struct list_head *tmp; - struct list_head *rn_list; + lnet_remotenet_t *rnet; + struct list_head *tmp; + struct list_head *rn_list; LASSERT(!the_lnet.ln_shutdown); @@ -276,9 +265,9 @@ static void lnet_shuffle_seed(void) static void lnet_add_route_to_rnet(lnet_remotenet_t *rnet, lnet_route_t *route) { - unsigned int len = 0; - unsigned int offset = 0; - struct list_head *e; + unsigned int len = 0; + unsigned int offset = 0; + struct list_head *e; lnet_shuffle_seed(); @@ -304,13 +293,13 @@ int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, unsigned int priority) { - struct list_head *e; - lnet_remotenet_t *rnet; - lnet_remotenet_t *rnet2; - lnet_route_t *route; - lnet_ni_t *ni; - int add_route; - int rc; + struct list_head *e; + lnet_remotenet_t *rnet; + lnet_remotenet_t *rnet2; + lnet_route_t *route; + lnet_ni_t *ni; + int add_route; + int rc; CDEBUG(D_NET, "Add route: net %s hops %u priority %u gw %s\n", libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway)); @@ -416,14 +405,14 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, int lnet_check_routes(void) { - lnet_remotenet_t *rnet; - lnet_route_t *route; - lnet_route_t *route2; - struct list_head *e1; - struct list_head *e2; - int cpt; - struct list_head *rn_list; - int i; + lnet_remotenet_t *rnet; + lnet_route_t *route; + lnet_route_t *route2; + struct list_head *e1; + struct list_head *e2; + int cpt; + struct list_head *rn_list; + int i; cpt = lnet_net_lock_current(); @@ -434,9 +423,9 @@ lnet_check_routes(void) route2 = NULL; list_for_each(e2, &rnet->lrn_routes) { - lnet_nid_t nid1; - lnet_nid_t nid2; - int net; + lnet_nid_t nid1; + lnet_nid_t nid2; + int net; route = list_entry(e2, lnet_route_t, lr_list); @@ -472,14 +461,14 @@ lnet_check_routes(void) int lnet_del_route(__u32 net, lnet_nid_t gw_nid) { - struct lnet_peer *gateway; - lnet_remotenet_t *rnet; - lnet_route_t *route; - struct list_head *e1; - struct list_head *e2; - int rc = -ENOENT; - struct list_head *rn_list; - int idx = 0; + struct lnet_peer *gateway; + lnet_remotenet_t *rnet; + lnet_route_t *route; + struct list_head *e1; + struct list_head *e2; + int rc = -ENOENT; + struct list_head *rn_list; + int idx = 0; CDEBUG(D_NET, "Del route: net %s : gw %s\n", libcfs_net2str(net), libcfs_nid2str(gw_nid)); @@ -554,13 +543,13 @@ int lnet_get_route(int idx, __u32 *net, __u32 *hops, lnet_nid_t *gateway, __u32 *alive, __u32 *priority) { - struct list_head *e1; - struct list_head *e2; - lnet_remotenet_t *rnet; - lnet_route_t *route; - int cpt; - int i; - struct list_head *rn_list; + struct list_head *e1; + struct list_head *e2; + lnet_remotenet_t *rnet; + lnet_route_t *route; + int cpt; + int i; + struct list_head *rn_list; cpt = lnet_net_lock_current(); @@ -574,11 +563,11 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, lr_list); if (idx-- == 0) { - *net = rnet->lrn_net; - *hops = route->lr_hops; + *net = rnet->lrn_net; + *hops = route->lr_hops; *priority = route->lr_priority; *gateway = route->lr_gateway->lp_nid; - *alive = route->lr_gateway->lp_alive; + *alive = route->lr_gateway->lp_alive; lnet_net_unlock(cpt); return 0; } @@ -593,7 +582,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, void lnet_swap_pinginfo(lnet_ping_info_t *info) { - int i; + int i; lnet_ni_status_t *stat; __swab32s(&info->pi_magic); @@ -614,9 +603,9 @@ lnet_swap_pinginfo(lnet_ping_info_t *info) static void lnet_parse_rc_info(lnet_rc_data_t *rcd) { - lnet_ping_info_t *info = rcd->rcd_pinginfo; - struct lnet_peer *gw = rcd->rcd_gateway; - lnet_route_t *rtr; + lnet_ping_info_t *info = rcd->rcd_pinginfo; + struct lnet_peer *gw = rcd->rcd_gateway; + lnet_route_t *rtr; if (!gw->lp_alive) return; @@ -643,14 +632,14 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) return; /* can't carry NI status info */ list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) { - int ptl_status = LNET_NI_STATUS_INVALID; - int down = 0; - int up = 0; - int i; + int ptl_status = LNET_NI_STATUS_INVALID; + int down = 0; + int up = 0; + int i; for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) { lnet_ni_status_t *stat = &info->pi_ni[i]; - lnet_nid_t nid = stat->ns_nid; + lnet_nid_t nid = stat->ns_nid; if (nid == LNET_NID_ANY) { CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n", @@ -699,8 +688,8 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) static void lnet_router_checker_event(lnet_event_t *event) { - lnet_rc_data_t *rcd = event->md.user_ptr; - struct lnet_peer *lp; + lnet_rc_data_t *rcd = event->md.user_ptr; + struct lnet_peer *lp; LASSERT(rcd != NULL); @@ -752,14 +741,14 @@ lnet_router_checker_event(lnet_event_t *event) static void lnet_wait_known_routerstate(void) { - lnet_peer_t *rtr; - struct list_head *entry; - int all_known; + lnet_peer_t *rtr; + struct list_head *entry; + int all_known; LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); for (;;) { - int cpt = lnet_net_lock_current(); + int cpt = lnet_net_lock_current(); all_known = 1; list_for_each(entry, &the_lnet.ln_routers) { @@ -799,9 +788,9 @@ lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net) static void lnet_update_ni_status_locked(void) { - lnet_ni_t *ni; - long now; - int timeout; + lnet_ni_t *ni; + long now; + int timeout; LASSERT(the_lnet.ln_routing); @@ -860,10 +849,10 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd) static lnet_rc_data_t * lnet_create_rc_data_locked(lnet_peer_t *gateway) { - lnet_rc_data_t *rcd = NULL; - lnet_ping_info_t *pi; - int rc; - int i; + lnet_rc_data_t *rcd = NULL; + lnet_ping_info_t *pi; + int rc; + int i; lnet_net_unlock(gateway->lp_cpt); @@ -943,8 +932,8 @@ static void lnet_ping_router_locked(lnet_peer_t *rtr) { lnet_rc_data_t *rcd = NULL; - unsigned long now = cfs_time_current(); - int secs; + unsigned long now = cfs_time_current(); + int secs; lnet_peer_addref_locked(rtr); @@ -979,9 +968,9 @@ lnet_ping_router_locked(lnet_peer_t *rtr) if (secs != 0 && !rtr->lp_ping_notsent && cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp, cfs_time_seconds(secs)))) { - int rc; + int rc; lnet_process_id_t id; - lnet_handle_md_t mdh; + lnet_handle_md_t mdh; id.nid = rtr->lp_nid; id.pid = LUSTRE_SRV_LNET_PID; @@ -1013,8 +1002,8 @@ lnet_ping_router_locked(lnet_peer_t *rtr) int lnet_router_checker_start(void) { - int rc; - int eqsz; + int rc; + int eqsz; LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN); @@ -1085,11 +1074,11 @@ lnet_router_checker_stop(void) static void lnet_prune_rc_data(int wait_unlink) { - lnet_rc_data_t *rcd; - lnet_rc_data_t *tmp; - lnet_peer_t *lp; - struct list_head head; - int i = 2; + lnet_rc_data_t *rcd; + lnet_rc_data_t *tmp; + lnet_peer_t *lp; + struct list_head head; + int i = 2; if (likely(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING && list_empty(&the_lnet.ln_rcd_deathrow) && @@ -1163,23 +1152,20 @@ lnet_prune_rc_data(int wait_unlink) lnet_net_unlock(LNET_LOCK_EX); } - -#if defined(LNET_ROUTER) - static int lnet_router_checker(void *arg) { - lnet_peer_t *rtr; - struct list_head *entry; + lnet_peer_t *rtr; + struct list_head *entry; cfs_block_allsigs(); LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) { - __u64 version; - int cpt; - int cpt2; + __u64 version; + int cpt; + int cpt2; cpt = lnet_net_lock_current(); rescan: @@ -1245,11 +1231,11 @@ lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages) static lnet_rtrbuf_t * lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) { - int npages = rbp->rbp_npages; - int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); - struct page *page; + int npages = rbp->rbp_npages; + int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); + struct page *page; lnet_rtrbuf_t *rb; - int i; + int i; LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz); if (rb == NULL) @@ -1280,9 +1266,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) static void lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp) { - int npages = rbp->rbp_npages; - int nbuffers = 0; - lnet_rtrbuf_t *rb; + int npages = rbp->rbp_npages; + int nbuffers = 0; + lnet_rtrbuf_t *rb; if (rbp->rbp_nbuffers == 0) /* not initialized or already freed */ return; @@ -1310,7 +1296,7 @@ static int lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) { lnet_rtrbuf_t *rb; - int i; + int i; if (rbp->rbp_nbuffers != 0) { LASSERT(rbp->rbp_nbuffers == nbufs); @@ -1355,7 +1341,7 @@ void lnet_rtrpools_free(void) { lnet_rtrbufpool_t *rtrp; - int i; + int i; if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */ return; @@ -1373,7 +1359,7 @@ lnet_rtrpools_free(void) static int lnet_nrb_tiny_calculate(int npages) { - int nrbs = LNET_NRB_TINY; + int nrbs = LNET_NRB_TINY; if (tiny_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, @@ -1392,7 +1378,7 @@ lnet_nrb_tiny_calculate(int npages) static int lnet_nrb_small_calculate(int npages) { - int nrbs = LNET_NRB_SMALL; + int nrbs = LNET_NRB_SMALL; if (small_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, @@ -1411,7 +1397,7 @@ lnet_nrb_small_calculate(int npages) static int lnet_nrb_large_calculate(int npages) { - int nrbs = LNET_NRB_LARGE; + int nrbs = LNET_NRB_LARGE; if (large_router_buffers < 0) { LCONSOLE_ERROR_MSG(0x10c, @@ -1431,13 +1417,13 @@ int lnet_rtrpools_alloc(int im_a_router) { lnet_rtrbufpool_t *rtrp; - int large_pages; - int small_pages = 1; - int nrb_tiny; - int nrb_small; - int nrb_large; - int rc; - int i; + int large_pages; + int small_pages = 1; + int nrb_tiny; + int nrb_small; + int nrb_large; + int rc; + int i; large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; @@ -1507,9 +1493,9 @@ lnet_rtrpools_alloc(int im_a_router) int lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) { - struct lnet_peer *lp = NULL; - unsigned long now = cfs_time_current(); - int cpt = lnet_cpt_of_nid(nid); + struct lnet_peer *lp = NULL; + unsigned long now = cfs_time_current(); + int cpt = lnet_cpt_of_nid(nid); LASSERT(!in_interrupt ()); @@ -1573,134 +1559,3 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) return 0; } EXPORT_SYMBOL(lnet_notify); - -void -lnet_get_tunables(void) -{ -} - -#else - -int -lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) -{ - return -EOPNOTSUPP; -} - -void -lnet_router_checker(void) -{ - static time_t last; - static int running; - - time_t now = get_seconds(); - int interval = now - last; - int rc; - __u64 version; - lnet_peer_t *rtr; - - /* It's no use to call me again within a sec - all intervals and - * timeouts are measured in seconds */ - if (last != 0 && interval < 2) - return; - - if (last != 0 && - interval > max(live_router_check_interval, - dead_router_check_interval)) - CNETERR("Checker(%d/%d) not called for %d seconds\n", - live_router_check_interval, dead_router_check_interval, - interval); - - LASSERT(LNET_CPT_NUMBER == 1); - - lnet_net_lock(0); - LASSERT(!running); /* recursion check */ - running = 1; - lnet_net_unlock(0); - - last = now; - - if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING) - lnet_prune_rc_data(0); /* unlink all rcd and nowait */ - - /* consume all pending events */ - while (1) { - int i; - lnet_event_t ev; - - /* NB ln_rc_eqh must be the 1st in 'eventqs' otherwise the - * recursion breaker in LNetEQPoll would fail */ - rc = LNetEQPoll(&the_lnet.ln_rc_eqh, 1, 0, &ev, &i); - if (rc == 0) /* no event pending */ - break; - - /* NB a lost SENT prevents me from pinging a router again */ - if (rc == -EOVERFLOW) { - CERROR("Dropped an event!!!\n"); - abort(); - } - - LASSERT(rc == 1); - - lnet_router_checker_event(&ev); - } - - if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING) { - lnet_prune_rc_data(1); /* release rcd */ - the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN; - running = 0; - return; - } - - LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); - - lnet_net_lock(0); - - version = the_lnet.ln_routers_version; - list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) { - lnet_ping_router_locked(rtr); - LASSERT(version == the_lnet.ln_routers_version); - } - - lnet_net_unlock(0); - - running = 0; /* lock only needed for the recursion check */ -} - -/* NB lnet_peers_start_down depends on me, - * so must be called before any peer creation */ -void -lnet_get_tunables(void) -{ - char *s; - - s = getenv("LNET_ROUTER_PING_TIMEOUT"); - if (s != NULL) - router_ping_timeout = atoi(s); - - s = getenv("LNET_LIVE_ROUTER_CHECK_INTERVAL"); - if (s != NULL) - live_router_check_interval = atoi(s); - - s = getenv("LNET_DEAD_ROUTER_CHECK_INTERVAL"); - if (s != NULL) - dead_router_check_interval = atoi(s); - - /* This replaces old lnd_notify mechanism */ - check_routers_before_use = 1; - if (dead_router_check_interval <= 0) - dead_router_check_interval = 30; -} - -void -lnet_rtrpools_free(void) -{ -} - -int -lnet_rtrpools_alloc(int im_a_arouter) -{ - return 0; -} - -#endif diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index c055afc86eb4..ee902dc43823 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -112,11 +112,11 @@ static int proc_call_handler(void *data, int write, loff_t *ppos, static int __proc_lnet_stats(void *data, int write, loff_t pos, void __user *buffer, int nob) { - int rc; + int rc; lnet_counters_t *ctrs; - int len; - char *tmpstr; - const int tmpsiz = 256; /* 7 %u and 4 %llu */ + int len; + char *tmpstr; + const int tmpsiz = 256; /* 7 %u and 4 %llu */ if (write) { lnet_counters_reset(); @@ -167,13 +167,13 @@ static int proc_lnet_stats(struct ctl_table *table, int write, static int proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - const int tmpsiz = 256; - char *tmpstr; - char *s; - int rc = 0; - int len; - int ver; - int off; + const int tmpsiz = 256; + char *tmpstr; + char *s; + int rc = 0; + int len; + int ver; + int off; CLASSERT(sizeof(loff_t) >= 4); @@ -205,13 +205,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write, lnet_net_unlock(0); *ppos = LNET_PROC_POS_MAKE(0, ver, 0, off); } else { - struct list_head *n; - struct list_head *r; - lnet_route_t *route = NULL; - lnet_remotenet_t *rnet = NULL; - int skip = off - 1; - struct list_head *rn_list; - int i; + struct list_head *n; + struct list_head *r; + lnet_route_t *route = NULL; + lnet_remotenet_t *rnet = NULL; + int skip = off - 1; + struct list_head *rn_list; + int i; lnet_net_lock(0); @@ -251,11 +251,11 @@ static int proc_lnet_routes(struct ctl_table *table, int write, } if (route != NULL) { - __u32 net = rnet->lrn_net; - unsigned int hops = route->lr_hops; - unsigned int priority = route->lr_priority; - lnet_nid_t nid = route->lr_gateway->lp_nid; - int alive = route->lr_gateway->lp_alive; + __u32 net = rnet->lrn_net; + unsigned int hops = route->lr_hops; + unsigned int priority = route->lr_priority; + lnet_nid_t nid = route->lr_gateway->lp_nid; + int alive = route->lr_gateway->lp_alive; s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4u %8u %7s %s\n", @@ -293,13 +293,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write, static int proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int rc = 0; - char *tmpstr; - char *s; - const int tmpsiz = 256; - int len; - int ver; - int off; + int rc = 0; + char *tmpstr; + char *s; + const int tmpsiz = 256; + int len; + int ver; + int off; off = LNET_PROC_HOFF_GET(*ppos); ver = LNET_PROC_VER_GET(*ppos); @@ -328,9 +328,9 @@ static int proc_lnet_routers(struct ctl_table *table, int write, lnet_net_unlock(0); *ppos = LNET_PROC_POS_MAKE(0, ver, 0, off); } else { - struct list_head *r; - struct lnet_peer *peer = NULL; - int skip = off - 1; + struct list_head *r; + struct lnet_peer *peer = NULL; + int skip = off - 1; lnet_net_lock(0); @@ -360,14 +360,14 @@ static int proc_lnet_routers(struct ctl_table *table, int write, lnet_nid_t nid = peer->lp_nid; unsigned long now = cfs_time_current(); unsigned long deadline = peer->lp_ping_deadline; - int nrefs = peer->lp_refcount; - int nrtrrefs = peer->lp_rtr_refcount; + int nrefs = peer->lp_refcount; + int nrtrrefs = peer->lp_rtr_refcount; int alive_cnt = peer->lp_alive_count; - int alive = peer->lp_alive; - int pingsent = !peer->lp_ping_notsent; + int alive = peer->lp_alive; + int pingsent = !peer->lp_ping_notsent; int last_ping = cfs_duration_sec(cfs_time_sub(now, peer->lp_ping_timestamp)); - int down_ni = 0; + int down_ni = 0; lnet_route_t *rtr; if ((peer->lp_ping_feats & @@ -428,16 +428,16 @@ static int proc_lnet_routers(struct ctl_table *table, int write, static int proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - const int tmpsiz = 256; - struct lnet_peer_table *ptable; - char *tmpstr; - char *s; - int cpt = LNET_PROC_CPT_GET(*ppos); - int ver = LNET_PROC_VER_GET(*ppos); - int hash = LNET_PROC_HASH_GET(*ppos); - int hoff = LNET_PROC_HOFF_GET(*ppos); - int rc = 0; - int len; + const int tmpsiz = 256; + struct lnet_peer_table *ptable; + char *tmpstr; + char *s; + int cpt = LNET_PROC_CPT_GET(*ppos); + int ver = LNET_PROC_VER_GET(*ppos); + int hash = LNET_PROC_HASH_GET(*ppos); + int hoff = LNET_PROC_HOFF_GET(*ppos); + int rc = 0; + int len; CLASSERT(LNET_PROC_HASH_BITS >= LNET_PEER_HASH_BITS); LASSERT(!write); @@ -465,9 +465,9 @@ static int proc_lnet_peers(struct ctl_table *table, int write, hoff++; } else { - struct lnet_peer *peer; - struct list_head *p; - int skip; + struct lnet_peer *peer; + struct list_head *p; + int skip; again: p = NULL; peer = NULL; @@ -521,23 +521,23 @@ static int proc_lnet_peers(struct ctl_table *table, int write, } if (peer != NULL) { - lnet_nid_t nid = peer->lp_nid; - int nrefs = peer->lp_refcount; - int lastalive = -1; - char *aliveness = "NA"; - int maxcr = peer->lp_ni->ni_peertxcredits; - int txcr = peer->lp_txcredits; - int mintxcr = peer->lp_mintxcredits; - int rtrcr = peer->lp_rtrcredits; - int minrtrcr = peer->lp_minrtrcredits; - int txqnob = peer->lp_txqnob; + lnet_nid_t nid = peer->lp_nid; + int nrefs = peer->lp_refcount; + int lastalive = -1; + char *aliveness = "NA"; + int maxcr = peer->lp_ni->ni_peertxcredits; + int txcr = peer->lp_txcredits; + int mintxcr = peer->lp_mintxcredits; + int rtrcr = peer->lp_rtrcredits; + int minrtrcr = peer->lp_minrtrcredits; + int txqnob = peer->lp_txqnob; if (lnet_isrouter(peer) || lnet_peer_aliveness_enabled(peer)) aliveness = peer->lp_alive ? "up" : "down"; if (lnet_peer_aliveness_enabled(peer)) { - unsigned long now = cfs_time_current(); + unsigned long now = cfs_time_current(); long delta; delta = cfs_time_sub(now, peer->lp_last_alive); @@ -595,13 +595,13 @@ static int proc_lnet_peers(struct ctl_table *table, int write, static int __proc_lnet_buffers(void *data, int write, loff_t pos, void __user *buffer, int nob) { - char *s; - char *tmpstr; - int tmpsiz; - int idx; - int len; - int rc; - int i; + char *s; + char *tmpstr; + int tmpsiz; + int idx; + int len; + int rc; + int i; LASSERT(!write); @@ -660,11 +660,11 @@ static int proc_lnet_buffers(struct ctl_table *table, int write, static int proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int tmpsiz = 128 * LNET_CPT_NUMBER; - int rc = 0; - char *tmpstr; - char *s; - int len; + int tmpsiz = 128 * LNET_CPT_NUMBER; + int rc = 0; + char *tmpstr; + char *s; + int len; LASSERT(!write); @@ -684,9 +684,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write, "rtr", "max", "tx", "min"); LASSERT(tmpstr + tmpsiz - s > 0); } else { - struct list_head *n; - lnet_ni_t *ni = NULL; - int skip = *ppos - 1; + struct list_head *n; + lnet_ni_t *ni = NULL; + int skip = *ppos - 1; lnet_net_lock(0); @@ -705,12 +705,12 @@ static int proc_lnet_nis(struct ctl_table *table, int write, } if (ni != NULL) { - struct lnet_tx_queue *tq; - char *stat; - long now = get_seconds(); - int last_alive = -1; - int i; - int j; + struct lnet_tx_queue *tq; + char *stat; + long now = get_seconds(); + int last_alive = -1; + int i; + int j; if (the_lnet.ln_routing) last_alive = now - ni->ni_last_alive; @@ -777,9 +777,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write, } struct lnet_portal_rotors { - int pr_value; - const char *pr_name; - const char *pr_desc; + int pr_value; + const char *pr_name; + const char *pr_desc; }; static struct lnet_portal_rotors portal_rotors[] = { @@ -815,11 +815,11 @@ extern int portal_rotor; static int __proc_lnet_portal_rotor(void *data, int write, loff_t pos, void __user *buffer, int nob) { - const int buf_len = 128; - char *buf; - char *tmp; - int rc; - int i; + const int buf_len = 128; + char *buf; + char *tmp; + int rc; + int i; LIBCFS_ALLOC(buf, buf_len); if (buf == NULL) @@ -887,38 +887,38 @@ static struct ctl_table lnet_table[] = { * to go via /proc for portability. */ { - .procname = "stats", - .mode = 0644, + .procname = "stats", + .mode = 0644, .proc_handler = &proc_lnet_stats, }, { - .procname = "routes", - .mode = 0444, + .procname = "routes", + .mode = 0444, .proc_handler = &proc_lnet_routes, }, { - .procname = "routers", - .mode = 0444, + .procname = "routers", + .mode = 0444, .proc_handler = &proc_lnet_routers, }, { - .procname = "peers", - .mode = 0444, + .procname = "peers", + .mode = 0444, .proc_handler = &proc_lnet_peers, }, { - .procname = "buffers", - .mode = 0444, + .procname = "buffers", + .mode = 0444, .proc_handler = &proc_lnet_buffers, }, { - .procname = "nis", - .mode = 0444, + .procname = "nis", + .mode = 0444, .proc_handler = &proc_lnet_nis, }, { - .procname = "portal_rotor", - .mode = 0644, + .procname = "portal_rotor", + .mode = 0644, .proc_handler = &proc_lnet_portal_rotor, }, { |