mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
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. [[email protected]: Restore PF_MEMALLOC task flags in all cases] [[email protected]: Fix handling of multiple swap files] [[email protected]: Original patch] Signed-off-by: Mel Gorman <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: David S. Miller <[email protected]> Cc: Eric B Munson <[email protected]> Cc: Eric Paris <[email protected]> Cc: James Morris <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Mike Christie <[email protected]> Cc: Neil Brown <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: Trond Myklebust <[email protected]> Cc: Xiaotian Feng <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
29418aa4bd
commit
a564b8f039
9 changed files with 149 additions and 34 deletions
|
|
@ -21,6 +21,11 @@ config SUNRPC_XPRT_RDMA
|
|||
|
||||
If unsure, say N.
|
||||
|
||||
config SUNRPC_SWAP
|
||||
bool
|
||||
depends on SUNRPC
|
||||
select NETVM
|
||||
|
||||
config RPCSEC_GSS_KRB5
|
||||
tristate "Secure RPC: Kerberos V mechanism"
|
||||
depends on SUNRPC && CRYPTO
|
||||
|
|
|
|||
|
|
@ -717,6 +717,15 @@ void rpc_task_set_client(struct rpc_task *task, struct rpc_clnt *clnt)
|
|||
atomic_inc(&clnt->cl_count);
|
||||
if (clnt->cl_softrtry)
|
||||
task->tk_flags |= RPC_TASK_SOFT;
|
||||
if (sk_memalloc_socks()) {
|
||||
struct rpc_xprt *xprt;
|
||||
|
||||
rcu_read_lock();
|
||||
xprt = rcu_dereference(clnt->cl_xprt);
|
||||
if (xprt->swapper)
|
||||
task->tk_flags |= RPC_TASK_SWAPPER;
|
||||
rcu_read_unlock();
|
||||
}
|
||||
/* Add to the client's list of all tasks */
|
||||
spin_lock(&clnt->cl_lock);
|
||||
list_add_tail(&task->tk_task, &clnt->cl_tasks);
|
||||
|
|
|
|||
|
|
@ -812,7 +812,10 @@ static void rpc_async_schedule(struct work_struct *work)
|
|||
void *rpc_malloc(struct rpc_task *task, size_t size)
|
||||
{
|
||||
struct rpc_buffer *buf;
|
||||
gfp_t gfp = RPC_IS_SWAPPER(task) ? GFP_ATOMIC : GFP_NOWAIT;
|
||||
gfp_t gfp = GFP_NOWAIT;
|
||||
|
||||
if (RPC_IS_SWAPPER(task))
|
||||
gfp |= __GFP_MEMALLOC;
|
||||
|
||||
size += sizeof(struct rpc_buffer);
|
||||
if (size <= RPC_BUFFER_MAXSIZE)
|
||||
|
|
@ -886,7 +889,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
|
|||
static struct rpc_task *
|
||||
rpc_alloc_task(void)
|
||||
{
|
||||
return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOFS);
|
||||
return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOIO);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1927,6 +1927,45 @@ out:
|
|||
xprt_wake_pending_tasks(xprt, status);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SUNRPC_SWAP
|
||||
static void xs_set_memalloc(struct rpc_xprt *xprt)
|
||||
{
|
||||
struct sock_xprt *transport = container_of(xprt, struct sock_xprt,
|
||||
xprt);
|
||||
|
||||
if (xprt->swapper)
|
||||
sk_set_memalloc(transport->inet);
|
||||
}
|
||||
|
||||
/**
|
||||
* xs_swapper - Tag this transport as being used for swap.
|
||||
* @xprt: transport to tag
|
||||
* @enable: enable/disable
|
||||
*
|
||||
*/
|
||||
int xs_swapper(struct rpc_xprt *xprt, int enable)
|
||||
{
|
||||
struct sock_xprt *transport = container_of(xprt, struct sock_xprt,
|
||||
xprt);
|
||||
int err = 0;
|
||||
|
||||
if (enable) {
|
||||
xprt->swapper++;
|
||||
xs_set_memalloc(xprt);
|
||||
} else if (xprt->swapper) {
|
||||
xprt->swapper--;
|
||||
sk_clear_memalloc(transport->inet);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xs_swapper);
|
||||
#else
|
||||
static void xs_set_memalloc(struct rpc_xprt *xprt)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
|
||||
{
|
||||
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)
|
|||
transport->sock = sock;
|
||||
transport->inet = sk;
|
||||
|
||||
xs_set_memalloc(xprt);
|
||||
|
||||
write_unlock_bh(&sk->sk_callback_lock);
|
||||
}
|
||||
xs_udp_do_set_buffer_size(xprt);
|
||||
|
|
@ -2075,6 +2116,8 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
|
|||
if (!xprt_bound(xprt))
|
||||
goto out;
|
||||
|
||||
xs_set_memalloc(xprt);
|
||||
|
||||
/* Tell the socket layer to start connecting... */
|
||||
xprt->stat.connect_count++;
|
||||
xprt->stat.connect_start = jiffies;
|
||||
|
|
|
|||
Loading…
Reference in a new issue