Whamcloud - gitweb
LU-12477 lnet: Remove obsolete config options
[fs/lustre-release.git] / lnet / lnet / lib-socket.c
index 4a8bf1a..642d8b5 100644 (file)
@@ -68,7 +68,7 @@ int
 lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
 {
        int             rc;
-       long            jiffies_left = timeout * msecs_to_jiffies(MSEC_PER_SEC);
+       long            jiffies_left = cfs_time_seconds(timeout);
        unsigned long   then;
        struct timeval  tv;
 
@@ -87,15 +87,7 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
 
                if (timeout != 0) {
                        /* Set send timeout to remaining time */
-                       tv = (struct timeval) {
-                               .tv_sec = jiffies_left /
-                                         msecs_to_jiffies(MSEC_PER_SEC),
-                               .tv_usec = ((jiffies_left %
-                                            msecs_to_jiffies(MSEC_PER_SEC)) *
-                                            USEC_PER_SEC) /
-                                            msecs_to_jiffies(MSEC_PER_SEC)
-                       };
-
+                       jiffies_to_timeval(jiffies_left, &tv);
                        rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
                                               (char *)&tv, sizeof(tv));
                        if (rc != 0) {
@@ -135,7 +127,7 @@ int
 lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
 {
        int             rc;
-       long            jiffies_left = timeout * msecs_to_jiffies(MSEC_PER_SEC);
+       long            jiffies_left = cfs_time_seconds(timeout);
        unsigned long   then;
        struct timeval  tv;
 
@@ -152,13 +144,7 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
                };
 
                /* Set receive timeout to remaining time */
-               tv = (struct timeval) {
-                       .tv_sec = jiffies_left / msecs_to_jiffies(MSEC_PER_SEC),
-                       .tv_usec = ((jiffies_left %
-                                       msecs_to_jiffies(MSEC_PER_SEC)) *
-                                       USEC_PER_SEC) /
-                                       msecs_to_jiffies(MSEC_PER_SEC)
-               };
+               jiffies_to_timeval(jiffies_left, &tv);
                rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
                                       (char *)&tv, sizeof(tv));
                if (rc != 0) {
@@ -191,7 +177,7 @@ EXPORT_SYMBOL(lnet_sock_read);
 
 static int
 lnet_sock_create(struct socket **sockp, int *fatal,
-                __u32 local_ip, int local_port)
+                __u32 local_ip, int local_port, struct net *ns)
 {
        struct sockaddr_in  locaddr;
        struct socket      *sock;
@@ -202,7 +188,7 @@ lnet_sock_create(struct socket **sockp, int *fatal,
        *fatal = 1;
 
 #ifdef HAVE_SOCK_CREATE_KERN_USE_NET
-       rc = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, 0, &sock);
+       rc = sock_create_kern(ns, PF_INET, SOCK_STREAM, 0, &sock);
 #else
        rc = sock_create_kern(PF_INET, SOCK_STREAM, 0, &sock);
 #endif
@@ -324,12 +310,12 @@ EXPORT_SYMBOL(lnet_sock_getbuf);
 
 int
 lnet_sock_listen(struct socket **sockp,
-                  __u32 local_ip, int local_port, int backlog)
+                  __u32 local_ip, int local_port, int backlog, struct net *ns)
 {
        int      fatal;
        int      rc;
 
-       rc = lnet_sock_create(sockp, &fatal, local_ip, local_port);
+       rc = lnet_sock_create(sockp, &fatal, local_ip, local_port, ns);
        if (rc != 0) {
                if (!fatal)
                        CERROR("Can't create socket: port %d already in use\n",
@@ -346,13 +332,6 @@ lnet_sock_listen(struct socket **sockp,
        return rc;
 }
 
-#ifndef HAVE_SK_SLEEP
-static inline wait_queue_head_t *sk_sleep(struct sock *sk)
-{
-       return sk->sk_sleep;
-}
-#endif
-
 int
 lnet_sock_accept(struct socket **newsockp, struct socket *sock)
 {
@@ -403,12 +382,13 @@ failed:
 int
 lnet_sock_connect(struct socket **sockp, int *fatal,
                  __u32 local_ip, int local_port,
-                 __u32 peer_ip, int peer_port)
+                 __u32 peer_ip, int peer_port,
+                 struct net *ns)
 {
        struct sockaddr_in  srvaddr;
        int                 rc;
 
-       rc = lnet_sock_create(sockp, fatal, local_ip, local_port);
+       rc = lnet_sock_create(sockp, fatal, local_ip, local_port, ns);
        if (rc != 0)
                return rc;