.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
---|
2 | 3 | * |
---|
3 | 4 | * vim: noexpandtab sw=8 ts=8 sts=0: |
---|
4 | 5 | * |
---|
5 | 6 | * 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. |
---|
21 | 7 | * |
---|
22 | 8 | * ---- |
---|
23 | 9 | * |
---|
.. | .. |
---|
916 | 902 | { |
---|
917 | 903 | struct kvec vec = { .iov_len = len, .iov_base = data, }; |
---|
918 | 904 | 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); |
---|
920 | 906 | return sock_recvmsg(sock, &msg, MSG_DONTWAIT); |
---|
921 | 907 | } |
---|
922 | 908 | |
---|
.. | .. |
---|
1455 | 1441 | sc_put(sc); |
---|
1456 | 1442 | } |
---|
1457 | 1443 | |
---|
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 | | - |
---|
1474 | 1444 | static void o2net_initialize_handshake(void) |
---|
1475 | 1445 | { |
---|
1476 | 1446 | o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32( |
---|
.. | .. |
---|
1584 | 1554 | struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; |
---|
1585 | 1555 | int ret = 0, stop; |
---|
1586 | 1556 | unsigned int timeout; |
---|
1587 | | - unsigned int noio_flag; |
---|
| 1557 | + unsigned int nofs_flag; |
---|
1588 | 1558 | |
---|
1589 | 1559 | /* |
---|
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. |
---|
1594 | 1562 | */ |
---|
1595 | | - noio_flag = memalloc_noio_save(); |
---|
| 1563 | + nofs_flag = memalloc_nofs_save(); |
---|
1596 | 1564 | /* if we're greater we initiate tx, otherwise we accept */ |
---|
1597 | 1565 | if (o2nm_this_node() <= o2net_num_from_nn(nn)) |
---|
1598 | 1566 | goto out; |
---|
.. | .. |
---|
1652 | 1620 | goto out; |
---|
1653 | 1621 | } |
---|
1654 | 1622 | |
---|
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); |
---|
1666 | 1625 | |
---|
1667 | 1626 | o2net_register_callbacks(sc->sc_sock->sk, sc); |
---|
1668 | 1627 | |
---|
.. | .. |
---|
1697 | 1656 | if (mynode) |
---|
1698 | 1657 | o2nm_node_put(mynode); |
---|
1699 | 1658 | |
---|
1700 | | - memalloc_noio_restore(noio_flag); |
---|
| 1659 | + memalloc_nofs_restore(nofs_flag); |
---|
1701 | 1660 | return; |
---|
1702 | 1661 | } |
---|
1703 | 1662 | |
---|
.. | .. |
---|
1776 | 1735 | (msecs_to_jiffies(o2net_reconnect_delay()) + 1); |
---|
1777 | 1736 | |
---|
1778 | 1737 | 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 |
---|
1780 | 1739 | * can succeed for this node before we got here.. so |
---|
1781 | 1740 | * only use set_nn_state to clear the persistent error |
---|
1782 | 1741 | * if that hasn't already happened */ |
---|
.. | .. |
---|
1824 | 1783 | struct o2nm_node *local_node = NULL; |
---|
1825 | 1784 | struct o2net_sock_container *sc = NULL; |
---|
1826 | 1785 | struct o2net_node *nn; |
---|
1827 | | - unsigned int noio_flag; |
---|
| 1786 | + unsigned int nofs_flag; |
---|
1828 | 1787 | |
---|
1829 | 1788 | /* |
---|
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. |
---|
1834 | 1791 | */ |
---|
1835 | | - noio_flag = memalloc_noio_save(); |
---|
| 1792 | + nofs_flag = memalloc_nofs_save(); |
---|
1836 | 1793 | |
---|
1837 | 1794 | BUG_ON(sock == NULL); |
---|
1838 | 1795 | *more = 0; |
---|
.. | .. |
---|
1850 | 1807 | *more = 1; |
---|
1851 | 1808 | new_sock->sk->sk_allocation = GFP_ATOMIC; |
---|
1852 | 1809 | |
---|
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); |
---|
1864 | 1812 | |
---|
1865 | 1813 | ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin, 1); |
---|
1866 | 1814 | if (ret < 0) |
---|
.. | .. |
---|
1948 | 1896 | if (sc) |
---|
1949 | 1897 | sc_put(sc); |
---|
1950 | 1898 | |
---|
1951 | | - memalloc_noio_restore(noio_flag); |
---|
| 1899 | + memalloc_nofs_restore(nofs_flag); |
---|
1952 | 1900 | return ret; |
---|
1953 | 1901 | } |
---|
1954 | 1902 | |
---|
.. | .. |
---|
1962 | 1910 | { |
---|
1963 | 1911 | struct socket *sock = o2net_listen_sock; |
---|
1964 | 1912 | int more; |
---|
1965 | | - int err; |
---|
1966 | 1913 | |
---|
1967 | 1914 | /* |
---|
1968 | 1915 | * It is critical to note that due to interrupt moderation |
---|
.. | .. |
---|
1977 | 1924 | */ |
---|
1978 | 1925 | |
---|
1979 | 1926 | for (;;) { |
---|
1980 | | - err = o2net_accept_one(sock, &more); |
---|
| 1927 | + o2net_accept_one(sock, &more); |
---|
1981 | 1928 | if (!more) |
---|
1982 | 1929 | break; |
---|
1983 | 1930 | cond_resched(); |
---|
.. | .. |
---|
2143 | 2090 | |
---|
2144 | 2091 | o2quo_init(); |
---|
2145 | 2092 | |
---|
2146 | | - if (o2net_debugfs_init()) |
---|
2147 | | - goto out; |
---|
| 2093 | + o2net_debugfs_init(); |
---|
2148 | 2094 | |
---|
2149 | 2095 | o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); |
---|
2150 | 2096 | o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); |
---|