hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/ocfs2/cluster/tcp.c
....@@ -1,23 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* -*- mode: c; c-basic-offset: 8; -*-
23 *
34 * vim: noexpandtab sw=8 ts=8 sts=0:
45 *
56 * Copyright (C) 2004 Oracle. All rights reserved.
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2 of the License, or (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public
18
- * License along with this program; if not, write to the
19
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
- * Boston, MA 021110-1307, USA.
217 *
228 * ----
239 *
....@@ -916,7 +902,7 @@
916902 {
917903 struct kvec vec = { .iov_len = len, .iov_base = data, };
918904 struct msghdr msg = { .msg_flags = MSG_DONTWAIT, };
919
- iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, len);
905
+ iov_iter_kvec(&msg.msg_iter, READ, &vec, 1, len);
920906 return sock_recvmsg(sock, &msg, MSG_DONTWAIT);
921907 }
922908
....@@ -1455,22 +1441,6 @@
14551441 sc_put(sc);
14561442 }
14571443
1458
-static int o2net_set_nodelay(struct socket *sock)
1459
-{
1460
- int val = 1;
1461
-
1462
- return kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
1463
- (void *)&val, sizeof(val));
1464
-}
1465
-
1466
-static int o2net_set_usertimeout(struct socket *sock)
1467
-{
1468
- int user_timeout = O2NET_TCP_USER_TIMEOUT;
1469
-
1470
- return kernel_setsockopt(sock, SOL_TCP, TCP_USER_TIMEOUT,
1471
- (void *)&user_timeout, sizeof(user_timeout));
1472
-}
1473
-
14741444 static void o2net_initialize_handshake(void)
14751445 {
14761446 o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32(
....@@ -1584,15 +1554,13 @@
15841554 struct sockaddr_in myaddr = {0, }, remoteaddr = {0, };
15851555 int ret = 0, stop;
15861556 unsigned int timeout;
1587
- unsigned int noio_flag;
1557
+ unsigned int nofs_flag;
15881558
15891559 /*
1590
- * sock_create allocates the sock with GFP_KERNEL. We must set
1591
- * per-process flag PF_MEMALLOC_NOIO so that all allocations done
1592
- * by this process are done as if GFP_NOIO was specified. So we
1593
- * are not reentering filesystem while doing memory reclaim.
1560
+ * sock_create allocates the sock with GFP_KERNEL. We must
1561
+ * prevent the filesystem from being reentered by memory reclaim.
15941562 */
1595
- noio_flag = memalloc_noio_save();
1563
+ nofs_flag = memalloc_nofs_save();
15961564 /* if we're greater we initiate tx, otherwise we accept */
15971565 if (o2nm_this_node() <= o2net_num_from_nn(nn))
15981566 goto out;
....@@ -1652,17 +1620,8 @@
16521620 goto out;
16531621 }
16541622
1655
- ret = o2net_set_nodelay(sc->sc_sock);
1656
- if (ret) {
1657
- mlog(ML_ERROR, "setting TCP_NODELAY failed with %d\n", ret);
1658
- goto out;
1659
- }
1660
-
1661
- ret = o2net_set_usertimeout(sock);
1662
- if (ret) {
1663
- mlog(ML_ERROR, "set TCP_USER_TIMEOUT failed with %d\n", ret);
1664
- goto out;
1665
- }
1623
+ tcp_sock_set_nodelay(sc->sc_sock->sk);
1624
+ tcp_sock_set_user_timeout(sock->sk, O2NET_TCP_USER_TIMEOUT);
16661625
16671626 o2net_register_callbacks(sc->sc_sock->sk, sc);
16681627
....@@ -1697,7 +1656,7 @@
16971656 if (mynode)
16981657 o2nm_node_put(mynode);
16991658
1700
- memalloc_noio_restore(noio_flag);
1659
+ memalloc_nofs_restore(nofs_flag);
17011660 return;
17021661 }
17031662
....@@ -1776,7 +1735,7 @@
17761735 (msecs_to_jiffies(o2net_reconnect_delay()) + 1);
17771736
17781737 if (node_num != o2nm_this_node()) {
1779
- /* believe it or not, accept and node hearbeating testing
1738
+ /* believe it or not, accept and node heartbeating testing
17801739 * can succeed for this node before we got here.. so
17811740 * only use set_nn_state to clear the persistent error
17821741 * if that hasn't already happened */
....@@ -1824,15 +1783,13 @@
18241783 struct o2nm_node *local_node = NULL;
18251784 struct o2net_sock_container *sc = NULL;
18261785 struct o2net_node *nn;
1827
- unsigned int noio_flag;
1786
+ unsigned int nofs_flag;
18281787
18291788 /*
1830
- * sock_create_lite allocates the sock with GFP_KERNEL. We must set
1831
- * per-process flag PF_MEMALLOC_NOIO so that all allocations done
1832
- * by this process are done as if GFP_NOIO was specified. So we
1833
- * are not reentering filesystem while doing memory reclaim.
1789
+ * sock_create_lite allocates the sock with GFP_KERNEL. We must
1790
+ * prevent the filesystem from being reentered by memory reclaim.
18341791 */
1835
- noio_flag = memalloc_noio_save();
1792
+ nofs_flag = memalloc_nofs_save();
18361793
18371794 BUG_ON(sock == NULL);
18381795 *more = 0;
....@@ -1850,17 +1807,8 @@
18501807 *more = 1;
18511808 new_sock->sk->sk_allocation = GFP_ATOMIC;
18521809
1853
- ret = o2net_set_nodelay(new_sock);
1854
- if (ret) {
1855
- mlog(ML_ERROR, "setting TCP_NODELAY failed with %d\n", ret);
1856
- goto out;
1857
- }
1858
-
1859
- ret = o2net_set_usertimeout(new_sock);
1860
- if (ret) {
1861
- mlog(ML_ERROR, "set TCP_USER_TIMEOUT failed with %d\n", ret);
1862
- goto out;
1863
- }
1810
+ tcp_sock_set_nodelay(new_sock->sk);
1811
+ tcp_sock_set_user_timeout(new_sock->sk, O2NET_TCP_USER_TIMEOUT);
18641812
18651813 ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin, 1);
18661814 if (ret < 0)
....@@ -1948,7 +1896,7 @@
19481896 if (sc)
19491897 sc_put(sc);
19501898
1951
- memalloc_noio_restore(noio_flag);
1899
+ memalloc_nofs_restore(nofs_flag);
19521900 return ret;
19531901 }
19541902
....@@ -1962,7 +1910,6 @@
19621910 {
19631911 struct socket *sock = o2net_listen_sock;
19641912 int more;
1965
- int err;
19661913
19671914 /*
19681915 * It is critical to note that due to interrupt moderation
....@@ -1977,7 +1924,7 @@
19771924 */
19781925
19791926 for (;;) {
1980
- err = o2net_accept_one(sock, &more);
1927
+ o2net_accept_one(sock, &more);
19811928 if (!more)
19821929 break;
19831930 cond_resched();
....@@ -2143,8 +2090,7 @@
21432090
21442091 o2quo_init();
21452092
2146
- if (o2net_debugfs_init())
2147
- goto out;
2093
+ o2net_debugfs_init();
21482094
21492095 o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL);
21502096 o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL);