Whamcloud - gitweb
* Changed liblustre/libtest to call into lctl for interactive echo tests
authoreeb <eeb>
Thu, 13 Nov 2003 18:49:21 +0000 (18:49 +0000)
committereeb <eeb>
Thu, 13 Nov 2003 18:49:21 +0000 (18:49 +0000)
*    Changed some global names in the utilities to avoid conflicts

*    Added set_ioc_handler() to allow portals/obd ioctl redirects to
     the liblustre handler (as well as dumping to a file)

lnet/include/lnet/lnetctl.h
lnet/include/lnet/ptlctl.h
lnet/ulnds/connection.c
lnet/ulnds/socklnd/connection.c
lnet/utils/l_ioctl.c
lustre/portals/include/portals/ptlctl.h
lustre/portals/unals/connection.c
lustre/portals/utils/l_ioctl.c

index a9942aa..f581e72 100644 (file)
@@ -75,6 +75,8 @@ int jt_dbg_panic(int argc, char **argv);
 int ptl_set_cfg_record_cb(cfg_record_cb_t cb);
 
 /* l_ioctl.c */
+typedef int (ioc_handler_t)(int dev_id, int opc, void *buf);
+void set_ioc_handler(ioc_handler_t *handler);
 int register_ioc_dev(int dev_id, const char * dev_name);
 void unregister_ioc_dev(int dev_id);
 int set_ioctl_dump(char * file);
index a9942aa..f581e72 100644 (file)
@@ -75,6 +75,8 @@ int jt_dbg_panic(int argc, char **argv);
 int ptl_set_cfg_record_cb(cfg_record_cb_t cb);
 
 /* l_ioctl.c */
+typedef int (ioc_handler_t)(int dev_id, int opc, void *buf);
+void set_ioc_handler(ioc_handler_t *handler);
 int register_ioc_dev(int dev_id, const char * dev_name);
 void unregister_ioc_dev(int dev_id);
 int set_ioctl_dump(char * file);
index 6ba1c22..3e64b33 100644 (file)
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <portals/types.h>
 #include <portals/list.h>
 #include <portals/lib-types.h>
@@ -324,6 +325,7 @@ connection force_tcp_connection(manager m,
     conn = hash_table_find(m->connections, id);
     if (!conn) {
         int fd;
+        int option;
         ptl_nid_t peernid = PTL_NID_ANY;
 
         bzero((char *) &addr, sizeof(addr));
@@ -340,6 +342,16 @@ connection force_tcp_connection(manager m,
             perror("tcpnal connect");
             return(0);
         }
+
+#if 1
+        option = 1;
+        setsockopt(fd, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
+        option = 1<<20;
+        setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &option, sizeof(option));
+        option = 1<<20;
+        setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option));
+#endif
+   
         /* say hello */
         if (tcpnal_hello(fd, &peernid, SOCKNAL_CONN_ANY, 0))
             exit(-1);
index 6ba1c22..3e64b33 100644 (file)
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <portals/types.h>
 #include <portals/list.h>
 #include <portals/lib-types.h>
@@ -324,6 +325,7 @@ connection force_tcp_connection(manager m,
     conn = hash_table_find(m->connections, id);
     if (!conn) {
         int fd;
+        int option;
         ptl_nid_t peernid = PTL_NID_ANY;
 
         bzero((char *) &addr, sizeof(addr));
@@ -340,6 +342,16 @@ connection force_tcp_connection(manager m,
             perror("tcpnal connect");
             return(0);
         }
+
+#if 1
+        option = 1;
+        setsockopt(fd, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
+        option = 1<<20;
+        setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &option, sizeof(option));
+        option = 1<<20;
+        setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option));
+#endif
+   
         /* say hello */
         if (tcpnal_hello(fd, &peernid, SOCKNAL_CONN_ANY, 0))
             exit(-1);
index 96cd050..16e398d 100644 (file)
@@ -41,6 +41,9 @@
  #include <windef.h>
 #endif
 
+static ioc_handler_t  do_ioctl;                 /* forward ref */
+static ioc_handler_t *current_ioc_handler = &do_ioctl;
+
 struct ioc_dev {
        const char * dev_name;
        int dev_fd;
@@ -54,7 +57,16 @@ struct dump_hdr {
        int opc;
 };
 
-char * dump_filename;
+char *dump_filename;
+
+void
+set_ioc_handler (ioc_handler_t *handler)
+{
+        if (handler == NULL)
+                current_ioc_handler = do_ioctl;
+        else
+                current_ioc_handler = handler;
+}
 
 static int
 open_ioc_dev(int dev_id) 
@@ -147,7 +159,7 @@ dump(int dev_id, int opc, void *buf)
                         strerror(errno));
                 return -EINVAL;
         }
-                                                                                                                        
+
         return 0;
 }
 
@@ -190,16 +202,17 @@ set_ioctl_dump(char * file)
                free(dump_filename);
        
        dump_filename = strdup(file);
+        if (dump_filename == NULL)
+                abort();
+
+        set_ioc_handler(&dump);
        return 0;
 }
 
 int
 l_ioctl(int dev_id, int opc, void *buf)
 {
-       if (dump_filename) 
-               return dump(dev_id, opc, buf);
-       else 
-               return do_ioctl(dev_id, opc, buf);
+        return current_ioc_handler(dev_id, opc, buf);
 }
 
 /* Read an ioctl dump file, and call the ioc_func for each ioctl buffer
index a9942aa..f581e72 100644 (file)
@@ -75,6 +75,8 @@ int jt_dbg_panic(int argc, char **argv);
 int ptl_set_cfg_record_cb(cfg_record_cb_t cb);
 
 /* l_ioctl.c */
+typedef int (ioc_handler_t)(int dev_id, int opc, void *buf);
+void set_ioc_handler(ioc_handler_t *handler);
 int register_ioc_dev(int dev_id, const char * dev_name);
 void unregister_ioc_dev(int dev_id);
 int set_ioctl_dump(char * file);
index 6ba1c22..3e64b33 100644 (file)
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <portals/types.h>
 #include <portals/list.h>
 #include <portals/lib-types.h>
@@ -324,6 +325,7 @@ connection force_tcp_connection(manager m,
     conn = hash_table_find(m->connections, id);
     if (!conn) {
         int fd;
+        int option;
         ptl_nid_t peernid = PTL_NID_ANY;
 
         bzero((char *) &addr, sizeof(addr));
@@ -340,6 +342,16 @@ connection force_tcp_connection(manager m,
             perror("tcpnal connect");
             return(0);
         }
+
+#if 1
+        option = 1;
+        setsockopt(fd, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
+        option = 1<<20;
+        setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &option, sizeof(option));
+        option = 1<<20;
+        setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option));
+#endif
+   
         /* say hello */
         if (tcpnal_hello(fd, &peernid, SOCKNAL_CONN_ANY, 0))
             exit(-1);
index 96cd050..16e398d 100644 (file)
@@ -41,6 +41,9 @@
  #include <windef.h>
 #endif
 
+static ioc_handler_t  do_ioctl;                 /* forward ref */
+static ioc_handler_t *current_ioc_handler = &do_ioctl;
+
 struct ioc_dev {
        const char * dev_name;
        int dev_fd;
@@ -54,7 +57,16 @@ struct dump_hdr {
        int opc;
 };
 
-char * dump_filename;
+char *dump_filename;
+
+void
+set_ioc_handler (ioc_handler_t *handler)
+{
+        if (handler == NULL)
+                current_ioc_handler = do_ioctl;
+        else
+                current_ioc_handler = handler;
+}
 
 static int
 open_ioc_dev(int dev_id) 
@@ -147,7 +159,7 @@ dump(int dev_id, int opc, void *buf)
                         strerror(errno));
                 return -EINVAL;
         }
-                                                                                                                        
+
         return 0;
 }
 
@@ -190,16 +202,17 @@ set_ioctl_dump(char * file)
                free(dump_filename);
        
        dump_filename = strdup(file);
+        if (dump_filename == NULL)
+                abort();
+
+        set_ioc_handler(&dump);
        return 0;
 }
 
 int
 l_ioctl(int dev_id, int opc, void *buf)
 {
-       if (dump_filename) 
-               return dump(dev_id, opc, buf);
-       else 
-               return do_ioctl(dev_id, opc, buf);
+        return current_ioc_handler(dev_id, opc, buf);
 }
 
 /* Read an ioctl dump file, and call the ioc_func for each ioctl buffer