From 6d5488effa37cb012860c080d789cc30cdfd210c Mon Sep 17 00:00:00 2001 From: eeb Date: Thu, 13 Nov 2003 18:49:21 +0000 Subject: [PATCH] * Changed liblustre/libtest to call into lctl for interactive echo tests * 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 | 2 ++ lnet/include/lnet/ptlctl.h | 2 ++ lnet/ulnds/connection.c | 12 ++++++++++++ lnet/ulnds/socklnd/connection.c | 12 ++++++++++++ lnet/utils/l_ioctl.c | 25 +++++++++++++++++++------ lustre/portals/include/portals/ptlctl.h | 2 ++ lustre/portals/unals/connection.c | 12 ++++++++++++ lustre/portals/utils/l_ioctl.c | 25 +++++++++++++++++++------ 8 files changed, 80 insertions(+), 12 deletions(-) diff --git a/lnet/include/lnet/lnetctl.h b/lnet/include/lnet/lnetctl.h index a9942aa..f581e72 100644 --- a/lnet/include/lnet/lnetctl.h +++ b/lnet/include/lnet/lnetctl.h @@ -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); diff --git a/lnet/include/lnet/ptlctl.h b/lnet/include/lnet/ptlctl.h index a9942aa..f581e72 100644 --- a/lnet/include/lnet/ptlctl.h +++ b/lnet/include/lnet/ptlctl.h @@ -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); diff --git a/lnet/ulnds/connection.c b/lnet/ulnds/connection.c index 6ba1c22..3e64b33 100644 --- a/lnet/ulnds/connection.c +++ b/lnet/ulnds/connection.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/lnet/ulnds/socklnd/connection.c b/lnet/ulnds/socklnd/connection.c index 6ba1c22..3e64b33 100644 --- a/lnet/ulnds/socklnd/connection.c +++ b/lnet/ulnds/socklnd/connection.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/lnet/utils/l_ioctl.c b/lnet/utils/l_ioctl.c index 96cd050..16e398d 100644 --- a/lnet/utils/l_ioctl.c +++ b/lnet/utils/l_ioctl.c @@ -41,6 +41,9 @@ #include #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 diff --git a/lustre/portals/include/portals/ptlctl.h b/lustre/portals/include/portals/ptlctl.h index a9942aa..f581e72 100644 --- a/lustre/portals/include/portals/ptlctl.h +++ b/lustre/portals/include/portals/ptlctl.h @@ -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); diff --git a/lustre/portals/unals/connection.c b/lustre/portals/unals/connection.c index 6ba1c22..3e64b33 100644 --- a/lustre/portals/unals/connection.c +++ b/lustre/portals/unals/connection.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/lustre/portals/utils/l_ioctl.c b/lustre/portals/utils/l_ioctl.c index 96cd050..16e398d 100644 --- a/lustre/portals/utils/l_ioctl.c +++ b/lustre/portals/utils/l_ioctl.c @@ -41,6 +41,9 @@ #include #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 -- 1.8.3.1