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>
Este cometimento está contido em:

cometido por
Linus Torvalds

ascendente
29418aa4bd
cometimento
a564b8f039
@@ -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;
|
||||
|
Criar uma nova questão referindo esta
Bloquear um utilizador