aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2012-07-31 19:45:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:48 -0400
commita564b8f0398636ba30b07c0eaebdef7ff7837249 (patch)
tree10478aa5cfb2a3696db34618a479413b358c3831 /net/sunrpc/xprtsock.c
parent29418aa4bd487c82016733ef5c6a06d656ed3c7d (diff)
nfs: enable swap on NFS
Implement the new swapfile a_ops for NFS and hook up ->direct_IO. This will set the NFS socket to SOCK_MEMALLOC and run socket reconnect under PF_MEMALLOC as well as reset SOCK_MEMALLOC before engaging the protocol ->connect() method. PF_MEMALLOC should allow the allocation of struct socket and related objects and the early (re)setting of SOCK_MEMALLOC should allow us to receive the packets required for the TCP connection buildup. [jlayton@redhat.com: Restore PF_MEMALLOC task flags in all cases] [dfeng@redhat.com: Fix handling of multiple swap files] [a.p.zijlstra@chello.nl: Original patch] Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: Rik van Riel <riel@redhat.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: David S. Miller <davem@davemloft.net> Cc: Eric B Munson <emunson@mgebm.net> Cc: Eric Paris <eparis@redhat.com> Cc: James Morris <jmorris@namei.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Mike Christie <michaelc@cs.wisc.edu> Cc: Neil Brown <neilb@suse.de> Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: Xiaotian Feng <dfeng@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 62d0dac8f780..bd59d01f035b 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1927,6 +1927,45 @@ out:
1927 xprt_wake_pending_tasks(xprt, status); 1927 xprt_wake_pending_tasks(xprt, status);
1928} 1928}
1929 1929
1930#ifdef CONFIG_SUNRPC_SWAP
1931static void xs_set_memalloc(struct rpc_xprt *xprt)
1932{
1933 struct sock_xprt *transport = container_of(xprt, struct sock_xprt,
1934 xprt);
1935
1936 if (xprt->swapper)
1937 sk_set_memalloc(transport->inet);
1938}
1939
1940/**
1941 * xs_swapper - Tag this transport as being used for swap.
1942 * @xprt: transport to tag
1943 * @enable: enable/disable
1944 *
1945 */
1946int xs_swapper(struct rpc_xprt *xprt, int enable)
1947{
1948 struct sock_xprt *transport = container_of(xprt, struct sock_xprt,
1949 xprt);
1950 int err = 0;
1951
1952 if (enable) {
1953 xprt->swapper++;
1954 xs_set_memalloc(xprt);
1955 } else if (xprt->swapper) {
1956 xprt->swapper--;
1957 sk_clear_memalloc(transport->inet);
1958 }
1959
1960 return err;
1961}
1962EXPORT_SYMBOL_GPL(xs_swapper);
1963#else
1964static void xs_set_memalloc(struct rpc_xprt *xprt)
1965{
1966}
1967#endif
1968
1930static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) 1969static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
1931{ 1970{
1932 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); 1971 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
@@ -1951,6 +1990,8 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
1951 transport->sock = sock; 1990 transport->sock = sock;
1952 transport->inet = sk; 1991 transport->inet = sk;
1953 1992
1993 xs_set_memalloc(xprt);
1994
1954 write_unlock_bh(&sk->sk_callback_lock); 1995 write_unlock_bh(&sk->sk_callback_lock);
1955 } 1996 }
1956 xs_udp_do_set_buffer_size(xprt); 1997 xs_udp_do_set_buffer_size(xprt);
@@ -2075,6 +2116,8 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
2075 if (!xprt_bound(xprt)) 2116 if (!xprt_bound(xprt))
2076 goto out; 2117 goto out;
2077 2118
2119 xs_set_memalloc(xprt);
2120
2078 /* Tell the socket layer to start connecting... */ 2121 /* Tell the socket layer to start connecting... */
2079 xprt->stat.connect_count++; 2122 xprt->stat.connect_count++;
2080 xprt->stat.connect_start = jiffies; 2123 xprt->stat.connect_start = jiffies;