staging: lustre use kernel socket sockopt apis

Change old way of ops->setsockopt or ops->getsockopt in kernel
to kernel_setsockopt or kernel_getsockopt.

Signed-off-by: Fredrick John Berchmans <fredrickprashanth@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Fredrick John Berchmans 2014-05-02 19:50:15 -07:00 committed by Greg Kroah-Hartman
parent 1d316792ac
commit 80db2734ac
2 changed files with 17 additions and 71 deletions

View File

@ -188,7 +188,6 @@ void
ksocknal_lib_eager_ack (ksock_conn_t *conn) ksocknal_lib_eager_ack (ksock_conn_t *conn)
{ {
int opt = 1; int opt = 1;
mm_segment_t oldmm = get_fs();
struct socket *sock = conn->ksnc_sock; struct socket *sock = conn->ksnc_sock;
/* Remind the socket to ACK eagerly. If I don't, the socket might /* Remind the socket to ACK eagerly. If I don't, the socket might
@ -196,10 +195,8 @@ ksocknal_lib_eager_ack (ksock_conn_t *conn)
* on, introducing delay in completing zero-copy sends in my * on, introducing delay in completing zero-copy sends in my
* peer. */ * peer. */
set_fs(KERNEL_DS); kernel_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
sock->ops->setsockopt (sock, SOL_TCP, TCP_QUICKACK,
(char *)&opt, sizeof (opt)); (char *)&opt, sizeof (opt));
set_fs(oldmm);
} }
int int
@ -428,7 +425,6 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx)
int int
ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle) ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle)
{ {
mm_segment_t oldmm = get_fs ();
struct socket *sock = conn->ksnc_sock; struct socket *sock = conn->ksnc_sock;
int len; int len;
int rc; int rc;
@ -443,10 +439,8 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int
rc = libcfs_sock_getbuf(sock, txmem, rxmem); rc = libcfs_sock_getbuf(sock, txmem, rxmem);
if (rc == 0) { if (rc == 0) {
len = sizeof(*nagle); len = sizeof(*nagle);
set_fs(KERNEL_DS); rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY,
rc = sock->ops->getsockopt(sock, SOL_TCP, TCP_NODELAY,
(char *)nagle, &len); (char *)nagle, &len);
set_fs(oldmm);
} }
ksocknal_connsock_decref(conn); ksocknal_connsock_decref(conn);
@ -462,7 +456,6 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int
int int
ksocknal_lib_setup_sock (struct socket *sock) ksocknal_lib_setup_sock (struct socket *sock)
{ {
mm_segment_t oldmm = get_fs ();
int rc; int rc;
int option; int option;
int keep_idle; int keep_idle;
@ -479,20 +472,16 @@ ksocknal_lib_setup_sock (struct socket *sock)
linger.l_onoff = 0; linger.l_onoff = 0;
linger.l_linger = 0; linger.l_linger = 0;
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_SOCKET, SO_LINGER,
rc = sock_setsockopt (sock, SOL_SOCKET, SO_LINGER,
(char *)&linger, sizeof (linger)); (char *)&linger, sizeof (linger));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set SO_LINGER: %d\n", rc); CERROR ("Can't set SO_LINGER: %d\n", rc);
return (rc); return (rc);
} }
option = -1; option = -1;
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_TCP, TCP_LINGER2,
rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_LINGER2,
(char *)&option, sizeof (option)); (char *)&option, sizeof (option));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set SO_LINGER2: %d\n", rc); CERROR ("Can't set SO_LINGER2: %d\n", rc);
return (rc); return (rc);
@ -501,10 +490,8 @@ ksocknal_lib_setup_sock (struct socket *sock)
if (!*ksocknal_tunables.ksnd_nagle) { if (!*ksocknal_tunables.ksnd_nagle) {
option = 1; option = 1;
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_NODELAY,
(char *)&option, sizeof (option)); (char *)&option, sizeof (option));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't disable nagle: %d\n", rc); CERROR ("Can't disable nagle: %d\n", rc);
return (rc); return (rc);
@ -531,10 +518,8 @@ ksocknal_lib_setup_sock (struct socket *sock)
do_keepalive = (keep_idle > 0 && keep_count > 0 && keep_intvl > 0); do_keepalive = (keep_idle > 0 && keep_count > 0 && keep_intvl > 0);
option = (do_keepalive ? 1 : 0); option = (do_keepalive ? 1 : 0);
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
rc = sock_setsockopt (sock, SOL_SOCKET, SO_KEEPALIVE,
(char *)&option, sizeof (option)); (char *)&option, sizeof (option));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set SO_KEEPALIVE: %d\n", rc); CERROR ("Can't set SO_KEEPALIVE: %d\n", rc);
return (rc); return (rc);
@ -543,28 +528,22 @@ ksocknal_lib_setup_sock (struct socket *sock)
if (!do_keepalive) if (!do_keepalive)
return (0); return (0);
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE,
rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPIDLE,
(char *)&keep_idle, sizeof (keep_idle)); (char *)&keep_idle, sizeof (keep_idle));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set TCP_KEEPIDLE: %d\n", rc); CERROR ("Can't set TCP_KEEPIDLE: %d\n", rc);
return (rc); return (rc);
} }
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL,
rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPINTVL,
(char *)&keep_intvl, sizeof (keep_intvl)); (char *)&keep_intvl, sizeof (keep_intvl));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set TCP_KEEPINTVL: %d\n", rc); CERROR ("Can't set TCP_KEEPINTVL: %d\n", rc);
return (rc); return (rc);
} }
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT,
rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPCNT,
(char *)&keep_count, sizeof (keep_count)); (char *)&keep_count, sizeof (keep_count));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set TCP_KEEPCNT: %d\n", rc); CERROR ("Can't set TCP_KEEPCNT: %d\n", rc);
return (rc); return (rc);
@ -581,7 +560,6 @@ ksocknal_lib_push_conn (ksock_conn_t *conn)
int nonagle; int nonagle;
int val = 1; int val = 1;
int rc; int rc;
mm_segment_t oldmm;
rc = ksocknal_connsock_addref(conn); rc = ksocknal_connsock_addref(conn);
if (rc != 0) /* being shut down */ if (rc != 0) /* being shut down */
@ -595,15 +573,10 @@ ksocknal_lib_push_conn (ksock_conn_t *conn)
tp->nonagle = 1; tp->nonagle = 1;
release_sock (sk); release_sock (sk);
oldmm = get_fs (); rc = kernel_setsockopt(conn->ksnc_sock, SOL_TCP, TCP_NODELAY,
set_fs (KERNEL_DS);
rc = sk->sk_prot->setsockopt (sk, SOL_TCP, TCP_NODELAY,
(char *)&val, sizeof (val)); (char *)&val, sizeof (val));
LASSERT (rc == 0); LASSERT (rc == 0);
set_fs (oldmm);
lock_sock (sk); lock_sock (sk);
tp->nonagle = nonagle; tp->nonagle = nonagle;
release_sock (sk); release_sock (sk);

View File

@ -56,21 +56,8 @@ libcfs_sock_ioctl(int cmd, unsigned long arg)
CERROR ("Can't create socket: %d\n", rc); CERROR ("Can't create socket: %d\n", rc);
return rc; return rc;
} }
rc = kernel_sock_ioctl(sock, cmd, arg);
sock_filp = sock_alloc_file(sock, 0, NULL);
if (IS_ERR(sock_filp)) {
sock_release(sock); sock_release(sock);
rc = PTR_ERR(sock_filp);
goto out;
}
set_fs(KERNEL_DS);
if (sock_filp->f_op->unlocked_ioctl)
rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg);
set_fs(oldmm);
fput(sock_filp);
out:
return rc; return rc;
} }
@ -255,7 +242,6 @@ int
libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
{ {
int rc; int rc;
mm_segment_t oldmm = get_fs();
long ticks = timeout * HZ; long ticks = timeout * HZ;
unsigned long then; unsigned long then;
struct timeval tv; struct timeval tv;
@ -279,10 +265,8 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
.tv_sec = ticks / HZ, .tv_sec = ticks / HZ,
.tv_usec = ((ticks % HZ) * 1000000) / HZ .tv_usec = ((ticks % HZ) * 1000000) / HZ
}; };
set_fs(KERNEL_DS); rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
rc = sock_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
(char *)&tv, sizeof(tv)); (char *)&tv, sizeof(tv));
set_fs(oldmm);
if (rc != 0) { if (rc != 0) {
CERROR("Can't set socket send timeout " CERROR("Can't set socket send timeout "
"%ld.%06d: %d\n", "%ld.%06d: %d\n",
@ -321,7 +305,6 @@ int
libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
{ {
int rc; int rc;
mm_segment_t oldmm = get_fs();
long ticks = timeout * HZ; long ticks = timeout * HZ;
unsigned long then; unsigned long then;
struct timeval tv; struct timeval tv;
@ -343,10 +326,8 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
.tv_sec = ticks / HZ, .tv_sec = ticks / HZ,
.tv_usec = ((ticks % HZ) * 1000000) / HZ .tv_usec = ((ticks % HZ) * 1000000) / HZ
}; };
set_fs(KERNEL_DS); rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
rc = sock_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
(char *)&tv, sizeof(tv)); (char *)&tv, sizeof(tv));
set_fs(oldmm);
if (rc != 0) { if (rc != 0) {
CERROR("Can't set socket recv timeout %ld.%06d: %d\n", CERROR("Can't set socket recv timeout %ld.%06d: %d\n",
(long)tv.tv_sec, (int)tv.tv_usec, rc); (long)tv.tv_sec, (int)tv.tv_usec, rc);
@ -384,7 +365,6 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
struct socket *sock; struct socket *sock;
int rc; int rc;
int option; int option;
mm_segment_t oldmm = get_fs();
/* All errors are fatal except bind failure if the port is in use */ /* All errors are fatal except bind failure if the port is in use */
*fatal = 1; *fatal = 1;
@ -396,11 +376,9 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
return (rc); return (rc);
} }
set_fs (KERNEL_DS);
option = 1; option = 1;
rc = sock_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(char *)&option, sizeof (option)); (char *)&option, sizeof (option));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc); CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc);
goto failed; goto failed;
@ -437,16 +415,13 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
int int
libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
{ {
mm_segment_t oldmm = get_fs();
int option; int option;
int rc; int rc;
if (txbufsize != 0) { if (txbufsize != 0) {
option = txbufsize; option = txbufsize;
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
rc = sock_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
(char *)&option, sizeof (option)); (char *)&option, sizeof (option));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set send buffer %d: %d\n", CERROR ("Can't set send buffer %d: %d\n",
option, rc); option, rc);
@ -456,10 +431,8 @@ libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
if (rxbufsize != 0) { if (rxbufsize != 0) {
option = rxbufsize; option = rxbufsize;
set_fs (KERNEL_DS); rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
rc = sock_setsockopt (sock, SOL_SOCKET, SO_RCVBUF,
(char *)&option, sizeof (option)); (char *)&option, sizeof (option));
set_fs (oldmm);
if (rc != 0) { if (rc != 0) {
CERROR ("Can't set receive buffer %d: %d\n", CERROR ("Can't set receive buffer %d: %d\n",
option, rc); option, rc);