[sheepdog] [PATCH] sbd: use kernel_setsockopt helper

Liu Yuan namei.unix at gmail.com
Mon May 4 10:46:17 CEST 2015


From: Liu Yuan <liuyuan at cmss.chinamobile.com>

Signed-off-by: Liu Yuan <liuyuan at cmss.chinamobile.com>
---
 sbd/sheep.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sbd/sheep.c b/sbd/sheep.c
index bfc935b..8b74b59 100644
--- a/sbd/sheep.c
+++ b/sbd/sheep.c
@@ -34,7 +34,6 @@ static struct sbd_device *sheep_aiocb_to_device(struct sheep_aiocb *aiocb)
 static int socket_create(struct socket **sock, const char *ip_addr, int port)
 {
 	struct sockaddr_in addr;
-	mm_segment_t oldmm = get_fs();
 	struct linger linger_opt = {1, 0};
 	int ret, nodelay = 1;
 
@@ -44,19 +43,15 @@ static int socket_create(struct socket **sock, const char *ip_addr, int port)
 		return ret;
 	}
 
-	set_fs(KERNEL_DS);
-	ret = sock_setsockopt(*sock, SOL_SOCKET, SO_LINGER,
-			      (char *)&linger_opt, sizeof(linger_opt));
-	set_fs(oldmm);
+	ret = kernel_setsockopt(*sock, SOL_SOCKET, SO_LINGER,
+				(char *)&linger_opt, sizeof(linger_opt));
 	if (ret != 0) {
 		pr_err("Can't set SO_LINGER: %d\n", ret);
 		goto shutdown;
 	}
 
-	set_fs(KERNEL_DS);
-	ret = sock_setsockopt(*sock, SOL_TCP, TCP_NODELAY,
-			      (char *)&nodelay, sizeof(nodelay));
-	set_fs(oldmm);
+	ret = kernel_setsockopt(*sock, SOL_TCP, TCP_NODELAY,
+				(char *)&nodelay, sizeof(nodelay));
 	if (ret != 0) {
 		pr_err("Can't set nodelay: %d\n", ret);
 		goto shutdown;
-- 
1.9.1




More information about the sheepdog mailing list