From fb8af14977f0893941b026fde32cfb0ea3dff6cc Mon Sep 17 00:00:00 2001 From: liangzhen Date: Wed, 30 Jul 2008 06:09:41 +0000 Subject: [PATCH] Branch HEAD i=isaac - Reversing list operations of LNetMEInsert - Removing trailing space --- lnet/lnet/api-ni.c | 128 ++++++++++++++++++++++++++--------------------------- lnet/lnet/lib-me.c | 20 ++++----- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index cccc2ce..e2bfe89 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -80,7 +80,7 @@ lnet_get_networks(void) "'ip2nets' but not both at once\n"); return NULL; } - + if (*ip2nets != 0) { rc = lnet_parse_ip2nets(&nets, ip2nets); return (rc == 0) ? nets : NULL; @@ -107,7 +107,7 @@ lnet_get_portals_compatibility(void) if (!strcmp(portals_compatibility, "strong")) { return 2; LCONSOLE_WARN("Starting in strong portals-compatible mode\n"); - } + } LCONSOLE_ERROR_MSG(0x102, "portals_compatibility=\"%s\" not supported\n", portals_compatibility); @@ -134,7 +134,7 @@ char * lnet_get_routes(void) { char *str = getenv("LNET_ROUTES"); - + return (str == NULL) ? "" : str; } @@ -175,21 +175,21 @@ lnet_get_networks (void) str = default_networks; *str = 0; sep = ""; - + list_for_each (tmp, &the_lnet.ln_lnds) { - lnd_t *lnd = list_entry(tmp, lnd_t, lnd_list); - - nob = snprintf(str, len, "%s%s", sep, - libcfs_lnd2str(lnd->lnd_type)); - len -= nob; - if (len < 0) { - /* overflowed the string; leave it where it was */ - *str = 0; - break; - } - - str += nob; - sep = ","; + lnd_t *lnd = list_entry(tmp, lnd_t, lnd_list); + + nob = snprintf(str, len, "%s%s", sep, + libcfs_lnd2str(lnd->lnd_type)); + len -= nob; + if (len < 0) { + /* overflowed the string; leave it where it was */ + *str = 0; + break; + } + + str += nob; + sep = ","; } return default_networks; @@ -332,7 +332,7 @@ void lnet_assert_wire_constants (void) } lnd_t * -lnet_find_lnd_by_type (int type) +lnet_find_lnd_by_type (int type) { lnd_t *lnd; struct list_head *tmp; @@ -344,7 +344,7 @@ lnet_find_lnd_by_type (int type) if (lnd->lnd_type == type) return lnd; } - + return NULL; } @@ -356,7 +356,7 @@ lnet_register_lnd (lnd_t *lnd) LASSERT (the_lnet.ln_init); LASSERT (libcfs_isknown_lnd(lnd->lnd_type)); LASSERT (lnet_find_lnd_by_type(lnd->lnd_type) == NULL); - + list_add_tail (&lnd->lnd_list, &the_lnet.ln_lnds); lnd->lnd_refcount = 0; @@ -373,7 +373,7 @@ lnet_unregister_lnd (lnd_t *lnd) LASSERT (the_lnet.ln_init); LASSERT (lnet_find_lnd_by_type(lnd->lnd_type) == lnd); LASSERT (lnd->lnd_refcount == 0); - + list_del (&lnd->lnd_list); CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type)); @@ -507,10 +507,10 @@ lnet_create_interface_cookie (void) } int -lnet_setup_handle_hash (void) +lnet_setup_handle_hash (void) { int i; - + /* Arbitrary choice of hash table size */ #ifdef __KERNEL__ the_lnet.ln_lh_hash_size = CFS_PAGE_SIZE / sizeof (struct list_head); @@ -521,12 +521,12 @@ lnet_setup_handle_hash (void) the_lnet.ln_lh_hash_size * sizeof (struct list_head)); if (the_lnet.ln_lh_hash_table == NULL) return (-ENOMEM); - + for (i = 0; i < the_lnet.ln_lh_hash_size; i++) CFS_INIT_LIST_HEAD (&the_lnet.ln_lh_hash_table[i]); the_lnet.ln_next_object_cookie = LNET_COOKIE_TYPES; - + return (0); } @@ -535,13 +535,13 @@ lnet_cleanup_handle_hash (void) { if (the_lnet.ln_lh_hash_table == NULL) return; - + LIBCFS_FREE(the_lnet.ln_lh_hash_table, the_lnet.ln_lh_hash_size * sizeof (struct list_head)); } lnet_libhandle_t * -lnet_lookup_cookie (__u64 cookie, int type) +lnet_lookup_cookie (__u64 cookie, int type) { /* ALWAYS called with LNET_LOCK held */ struct list_head *list; @@ -550,23 +550,23 @@ lnet_lookup_cookie (__u64 cookie, int type) if ((cookie & (LNET_COOKIE_TYPES - 1)) != type) return (NULL); - + hash = ((unsigned int)cookie) % the_lnet.ln_lh_hash_size; list = &the_lnet.ln_lh_hash_table[hash]; - + list_for_each (el, list) { lnet_libhandle_t *lh = list_entry (el, lnet_libhandle_t, lh_hash_chain); - + if (lh->lh_cookie == cookie) return (lh); } - + return (NULL); } void -lnet_initialise_handle (lnet_libhandle_t *lh, int type) +lnet_initialise_handle (lnet_libhandle_t *lh, int type) { /* ALWAYS called with LNET_LOCK held */ unsigned int hash; @@ -574,7 +574,7 @@ lnet_initialise_handle (lnet_libhandle_t *lh, int type) LASSERT (type >= 0 && type < LNET_COOKIE_TYPES); lh->lh_cookie = the_lnet.ln_next_object_cookie | type; the_lnet.ln_next_object_cookie += LNET_COOKIE_TYPES; - + hash = ((unsigned int)lh->lh_cookie) % the_lnet.ln_lh_hash_size; list_add (&lh->lh_hash_chain, &the_lnet.ln_lh_hash_table[hash]); } @@ -595,7 +595,7 @@ lnet_init_finalizers(void) the_lnet.ln_nfinalizers = num_online_cpus(); LIBCFS_ALLOC(the_lnet.ln_finalizers, - the_lnet.ln_nfinalizers * + the_lnet.ln_nfinalizers * sizeof(*the_lnet.ln_finalizers)); if (the_lnet.ln_finalizers == NULL) { CERROR("Can't allocate ln_finalizers\n"); @@ -617,7 +617,7 @@ lnet_fini_finalizers(void) { #ifdef __KERNEL__ int i; - + for (i = 0; i < the_lnet.ln_nfinalizers; i++) LASSERT (the_lnet.ln_finalizers[i] == NULL); @@ -639,7 +639,7 @@ void lnet_server_mode() { the_lnet.ln_server_mode_flag = 1; } -#endif +#endif int lnet_prepare(lnet_pid_t requested_pid) @@ -658,7 +658,7 @@ lnet_prepare(lnet_pid_t requested_pid) #else if (the_lnet.ln_server_mode_flag) {/* server case (uOSS) */ LASSERT ((requested_pid & LNET_PID_USERFLAG) == 0); - + if (cfs_curproc_uid())/* Only root can run user-space server */ return -EPERM; the_lnet.ln_pid = requested_pid; @@ -667,14 +667,14 @@ lnet_prepare(lnet_pid_t requested_pid) /* My PID must be unique on this node and flag I'm userspace */ the_lnet.ln_pid = getpid() | LNET_PID_USERFLAG; - } + } #endif rc = lnet_descriptor_setup(); if (rc != 0) goto failed0; - memset(&the_lnet.ln_counters, 0, + memset(&the_lnet.ln_counters, 0, sizeof(the_lnet.ln_counters)); CFS_INIT_LIST_HEAD (&the_lnet.ln_active_msgs); @@ -703,8 +703,8 @@ lnet_prepare(lnet_pid_t requested_pid) goto failed2; the_lnet.ln_nportals = MAX_PORTALS; - LIBCFS_ALLOC(the_lnet.ln_portals, - the_lnet.ln_nportals * + LIBCFS_ALLOC(the_lnet.ln_portals, + the_lnet.ln_nportals * sizeof(*the_lnet.ln_portals)); if (the_lnet.ln_portals == NULL) { rc = -ENOMEM; @@ -718,7 +718,7 @@ lnet_prepare(lnet_pid_t requested_pid) } return 0; - + failed3: lnet_fini_finalizers(); failed2: @@ -734,7 +734,7 @@ int lnet_unprepare (void) { int idx; - + /* NB no LNET_LOCK since this is the last reference. All LND instances * have shut down already, so it is safe to unlink and free all * descriptors, even those that appear committed to a network op (eg MD @@ -747,7 +747,7 @@ lnet_unprepare (void) LASSERT (list_empty(&the_lnet.ln_nis)); LASSERT (list_empty(&the_lnet.ln_zombie_nis)); LASSERT (the_lnet.ln_nzombie_nis == 0); - + for (idx = 0; idx < the_lnet.ln_nportals; idx++) { LASSERT (list_empty(&the_lnet.ln_portals[idx].ptl_msgq)); @@ -816,7 +816,7 @@ lnet_net2ni_locked (__u32 net) return ni; } } - + return NULL; } @@ -824,7 +824,7 @@ int lnet_islocalnet (__u32 net) { lnet_ni_t *ni; - + LNET_LOCK(); ni = lnet_net2ni_locked(net); if (ni != NULL) @@ -848,7 +848,7 @@ lnet_nid2ni_locked (lnet_nid_t nid) return ni; } } - + return NULL; } @@ -856,7 +856,7 @@ int lnet_islocalnid (lnet_nid_t nid) { lnet_ni_t *ni; - + LNET_LOCK(); ni = lnet_nid2ni_locked(nid); if (ni != NULL) @@ -890,7 +890,7 @@ lnet_count_acceptor_nis (lnet_ni_t **first_ni) count++; } } - + LNET_UNLOCK(); #endif /* defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) */ @@ -1133,7 +1133,7 @@ lnet_startup_lndnis (void) } libcfs_setnet0alias(lnd->lnd_type); } - + nicount++; } @@ -1337,21 +1337,21 @@ LNetCtl(unsigned int cmd, void *arg) case IOC_LIBCFS_FAIL_NID: return lnet_fail_nid(data->ioc_nid, data->ioc_count); - + case IOC_LIBCFS_ADD_ROUTE: - rc = lnet_add_route(data->ioc_net, data->ioc_count, + rc = lnet_add_route(data->ioc_net, data->ioc_count, data->ioc_nid); return (rc != 0) ? rc : lnet_check_routes(); - + case IOC_LIBCFS_DEL_ROUTE: return lnet_del_route(data->ioc_net, data->ioc_nid); case IOC_LIBCFS_GET_ROUTE: - return lnet_get_route(data->ioc_count, - &data->ioc_net, &data->ioc_count, + return lnet_get_route(data->ioc_count, + &data->ioc_net, &data->ioc_count, &data->ioc_nid, &data->ioc_flags); case IOC_LIBCFS_NOTIFY_ROUTER: - return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, + return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, (time_t)data->ioc_u64[0]); case IOC_LIBCFS_PORTALS_COMPATIBILITY: @@ -1361,7 +1361,7 @@ LNetCtl(unsigned int cmd, void *arg) rc = LNetDist(data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1]); if (rc < 0 && rc != -EHOSTUNREACH) return rc; - + data->ioc_u32[0] = rc; return 0; @@ -1399,12 +1399,12 @@ LNetCtl(unsigned int cmd, void *arg) } else { (void)ni->ni_lnd->lnd_ctl(ni, cmd, arg); } - + lnet_ni_decref(ni); } return 0; } - + default: ni = lnet_net2ni(data->ioc_net); if (ni == NULL) @@ -1436,7 +1436,7 @@ LNetGetId(unsigned int index, lnet_process_id_t *id) list_for_each(tmp, &the_lnet.ln_nis) { if (index-- != 0) continue; - + ni = list_entry(tmp, lnet_ni_t, ni_list); id->nid = ni->ni_nid; @@ -1467,7 +1467,7 @@ lnet_ping_target_init(void) int n; int infosz; int i; - + for (n = 0; ; n++) { rc = LNetGetId(n, &id); if (rc == -ENOENT) @@ -1493,7 +1493,7 @@ lnet_ping_target_init(void) LASSERT (rc == 0); the_lnet.ln_ping_info->pi_nid[i] = id.nid; } - + /* We can have a tiny EQ since we only need to see the unlink event on * teardown, which by definition is the last one! */ rc = LNetEQAlloc(2, LNET_EQ_HANDLER_NONE, &the_lnet.ln_ping_target_eq); @@ -1734,7 +1734,7 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i } if (nob < offsetof(lnet_ping_info_t, pi_nid[0])) { - CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id), + CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id), nob, (int)offsetof(lnet_ping_info_t, pi_nid[0])); goto out_1; } @@ -1743,7 +1743,7 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i n_ids = info->pi_nnids; if (nob < offsetof(lnet_ping_info_t, pi_nid[n_ids])) { - CERROR("%s: Short reply %d(%d expected)\n", libcfs_id2str(id), + CERROR("%s: Short reply %d(%d expected)\n", libcfs_id2str(id), nob, (int)offsetof(lnet_ping_info_t, pi_nid[n_ids])); goto out_1; } diff --git a/lnet/lnet/lib-me.c b/lnet/lnet/lib-me.c index eaa1576..6ca286a 100644 --- a/lnet/lnet/lib-me.c +++ b/lnet/lnet/lib-me.c @@ -44,16 +44,16 @@ int LNetMEAttach(unsigned int portal, - lnet_process_id_t match_id, + lnet_process_id_t match_id, __u64 match_bits, __u64 ignore_bits, - lnet_unlink_t unlink, lnet_ins_pos_t pos, + lnet_unlink_t unlink, lnet_ins_pos_t pos, lnet_handle_me_t *handle) { lnet_me_t *me; LASSERT (the_lnet.ln_init); LASSERT (the_lnet.ln_refcount > 0); - + if (portal >= the_lnet.ln_nportals) return -EINVAL; @@ -84,9 +84,9 @@ LNetMEAttach(unsigned int portal, return 0; } -int -LNetMEInsert(lnet_handle_me_t current_meh, - lnet_process_id_t match_id, +int +LNetMEInsert(lnet_handle_me_t current_meh, + lnet_process_id_t match_id, __u64 match_bits, __u64 ignore_bits, lnet_unlink_t unlink, lnet_ins_pos_t pos, lnet_handle_me_t *handle) @@ -94,9 +94,9 @@ LNetMEInsert(lnet_handle_me_t current_meh, lnet_me_t *current_me; lnet_me_t *new_me; - LASSERT (the_lnet.ln_init); + LASSERT (the_lnet.ln_init); LASSERT (the_lnet.ln_refcount > 0); - + new_me = lnet_me_alloc(); if (new_me == NULL) return -ENOMEM; @@ -121,9 +121,9 @@ LNetMEInsert(lnet_handle_me_t current_meh, lnet_initialise_handle (&new_me->me_lh, LNET_COOKIE_TYPE_ME); if (pos == LNET_INS_AFTER) - list_add_tail(&new_me->me_list, ¤t_me->me_list); - else list_add(&new_me->me_list, ¤t_me->me_list); + else + list_add_tail(&new_me->me_list, ¤t_me->me_list); lnet_me2handle(handle, new_me); -- 1.8.3.1