Whamcloud - gitweb
LU-15136 socklnd: default conns_per_peer to 0
[fs/lustre-release.git] / lnet / selftest / console.c
index f250043..d2863b0 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lnet/selftest/conctl.c
  *
@@ -855,24 +854,22 @@ lstcon_batch_add(char *name)
                 return -ENOMEM;
         }
 
-       LIBCFS_ALLOC(bat->bat_cli_hash,
-                    sizeof(struct list_head) * LST_NODE_HASHSIZE);
+       CFS_ALLOC_PTR_ARRAY(bat->bat_cli_hash, LST_NODE_HASHSIZE);
        if (bat->bat_cli_hash == NULL) {
                CERROR("Can't allocate hash for batch %s\n", name);
                LIBCFS_FREE(bat, sizeof(*bat));
 
-                return -ENOMEM;
-        }
+               return -ENOMEM;
+       }
 
-        LIBCFS_ALLOC(bat->bat_srv_hash,
-                    sizeof(struct list_head) * LST_NODE_HASHSIZE);
-        if (bat->bat_srv_hash == NULL) {
-                CERROR("Can't allocate hash for batch %s\n", name);
-                LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE);
+       CFS_ALLOC_PTR_ARRAY(bat->bat_srv_hash, LST_NODE_HASHSIZE);
+       if (bat->bat_srv_hash == NULL) {
+               CERROR("Can't allocate hash for batch %s\n", name);
+               LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE);
                LIBCFS_FREE(bat, sizeof(*bat));
 
-                return -ENOMEM;
-        }
+               return -ENOMEM;
+       }
 
        if (strlen(name) > sizeof(bat->bat_name)-1) {
                LIBCFS_FREE(bat->bat_srv_hash, LST_NODE_HASHSIZE);
@@ -1491,11 +1488,9 @@ static int
 lstcon_ndlist_stat(struct list_head *ndlist,
                   int timeout, struct list_head __user *result_up)
 {
-       struct list_head    head;
+       LIST_HEAD(head);
        struct lstcon_rpc_trans *trans;
-       int                 rc;
-
-       INIT_LIST_HEAD(&head);
+       int rc;
 
         rc = lstcon_rpc_trans_ndlist(ndlist, &head,
                                      LST_TRANS_STATQRY, NULL, NULL, &trans);
@@ -2027,8 +2022,8 @@ lstcon_console_init(void)
        INIT_LIST_HEAD(&console_session.ses_bat_list);
        INIT_LIST_HEAD(&console_session.ses_trans_list);
 
-       LIBCFS_ALLOC(console_session.ses_ndl_hash,
-                    sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
+       CFS_ALLOC_PTR_ARRAY(console_session.ses_ndl_hash,
+                              LST_GLOBAL_HASHSIZE);
        if (console_session.ses_ndl_hash == NULL)
                return -ENOMEM;
 
@@ -2042,8 +2037,8 @@ lstcon_console_init(void)
        rc = srpc_add_service(&lstcon_acceptor_service);
        LASSERT(rc != -EBUSY);
        if (rc != 0) {
-               LIBCFS_FREE(console_session.ses_ndl_hash,
-                           sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
+               CFS_FREE_PTR_ARRAY(console_session.ses_ndl_hash,
+                                  LST_GLOBAL_HASHSIZE);
                return rc;
        }
 
@@ -2065,8 +2060,7 @@ out:
        srpc_shutdown_service(&lstcon_acceptor_service);
        srpc_remove_service(&lstcon_acceptor_service);
 
-       LIBCFS_FREE(console_session.ses_ndl_hash,
-                   sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
+       CFS_FREE_PTR_ARRAY(console_session.ses_ndl_hash, LST_GLOBAL_HASHSIZE);
 
        srpc_wait_service_shutdown(&lstcon_acceptor_service);
 
@@ -2101,8 +2095,8 @@ lstcon_console_fini(void)
        for (i = 0; i < LST_NODE_HASHSIZE; i++)
                LASSERT(list_empty(&console_session.ses_ndl_hash[i]));
 
-       LIBCFS_FREE(console_session.ses_ndl_hash,
-                   sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
+       CFS_FREE_PTR_ARRAY(console_session.ses_ndl_hash,
+                          LST_GLOBAL_HASHSIZE);
 
        srpc_wait_service_shutdown(&lstcon_acceptor_service);