aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/file.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@primarydata.com>2014-09-10 09:03:55 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-09-10 15:47:04 -0400
commitdad2b015bb85799f8005da637954f8eafb83f34c (patch)
tree1121c2a5ac8e973410879268f2a20f6a9e841e82 /fs/nfs/file.c
parent08a899d5d9532efb7dea99aad44dc9af39627a92 (diff)
nfs: fix RCU cl_xprt handling in nfs_swap_activate/deactivate
sparse says: fs/nfs/file.c:543:60: warning: incorrect type in argument 1 (different address spaces) fs/nfs/file.c:543:60: expected struct rpc_xprt *xprt fs/nfs/file.c:543:60: got struct rpc_xprt [noderef] <asn:4>*cl_xprt fs/nfs/file.c:548:53: warning: incorrect type in argument 1 (different address spaces) fs/nfs/file.c:548:53: expected struct rpc_xprt *xprt fs/nfs/file.c:548:53: got struct rpc_xprt [noderef] <asn:4>*cl_xprt cl_xprt is RCU-managed, so we need to take care to dereference and use it while holding the RCU read lock. Cc: Mel Gorman <mgorman@suse.de> Signed-off-by: Jeff Layton <jlayton@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r--fs/nfs/file.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 05ef7dcc5f21..23e5f0ea5c83 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -546,13 +546,25 @@ static int nfs_launder_page(struct page *page)
546static int nfs_swap_activate(struct swap_info_struct *sis, struct file *file, 546static int nfs_swap_activate(struct swap_info_struct *sis, struct file *file,
547 sector_t *span) 547 sector_t *span)
548{ 548{
549 int ret;
550 struct rpc_clnt *clnt = NFS_CLIENT(file->f_mapping->host);
551
549 *span = sis->pages; 552 *span = sis->pages;
550 return xs_swapper(NFS_CLIENT(file->f_mapping->host)->cl_xprt, 1); 553
554 rcu_read_lock();
555 ret = xs_swapper(rcu_dereference(clnt->cl_xprt), 1);
556 rcu_read_unlock();
557
558 return ret;
551} 559}
552 560
553static void nfs_swap_deactivate(struct file *file) 561static void nfs_swap_deactivate(struct file *file)
554{ 562{
555 xs_swapper(NFS_CLIENT(file->f_mapping->host)->cl_xprt, 0); 563 struct rpc_clnt *clnt = NFS_CLIENT(file->f_mapping->host);
564
565 rcu_read_lock();
566 xs_swapper(rcu_dereference(clnt->cl_xprt), 0);
567 rcu_read_unlock();
556} 568}
557#endif 569#endif
558 570