--- /dev/null
+From 051ac3848a94f21cfdec899cc9c65ce7f9f116fa Mon Sep 17 00:00:00 2001
+From: Pratyush Anand <panand@redhat.com>
+Date: Thu, 27 Aug 2015 10:01:33 +0530
+Subject: net: sunrpc: fix tracepoint Warning: unknown op '->'
+
+From: Pratyush Anand <panand@redhat.com>
+
+commit 051ac3848a94f21cfdec899cc9c65ce7f9f116fa upstream.
+
+`perf stat -e sunrpc:svc_xprt_do_enqueue true` results in
+
+Warning: unknown op '->'
+Warning: [sunrpc:svc_xprt_do_enqueue] unknown op '->'
+
+Similar warning for svc_handle_xprt as well.
+
+Actually TP_printk() should never dereference an address saved in the ring
+buffer that points somewhere in the kernel. There's no guarantee that that
+object still exists (with the exception of static strings).
+
+Therefore change all the arguments for TP_printk(), so that it references
+values existing in the ring buffer only.
+
+While doing that, also fix another possible bug when argument xprt could be
+NULL and TP_fast_assign() tries to access it's elements.
+
+Signed-off-by: Pratyush Anand <panand@redhat.com>
+Reviewed-by: Jeff Layton <jeff.layton@primarydata.com>
+Acked-by: Steven Rostedt <rostedt@goodmis.org>
+Fixes: 83a712e0afef "sunrpc: add some tracepoints around ..."
+Signed-off-by: J. Bruce Fields <bfields@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/trace/events/sunrpc.h | 21 ++++++++++++++-------
+ 1 file changed, 14 insertions(+), 7 deletions(-)
+
+--- a/include/trace/events/sunrpc.h
++++ b/include/trace/events/sunrpc.h
+@@ -529,18 +529,21 @@ TRACE_EVENT(svc_xprt_do_enqueue,
+
+ TP_STRUCT__entry(
+ __field(struct svc_xprt *, xprt)
+- __field(struct svc_rqst *, rqst)
++ __field_struct(struct sockaddr_storage, ss)
++ __field(int, pid)
++ __field(unsigned long, flags)
+ ),
+
+ TP_fast_assign(
+ __entry->xprt = xprt;
+- __entry->rqst = rqst;
++ xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss));
++ __entry->pid = rqst? rqst->rq_task->pid : 0;
++ __entry->flags = xprt ? xprt->xpt_flags : 0;
+ ),
+
+ TP_printk("xprt=0x%p addr=%pIScp pid=%d flags=%s", __entry->xprt,
+- (struct sockaddr *)&__entry->xprt->xpt_remote,
+- __entry->rqst ? __entry->rqst->rq_task->pid : 0,
+- show_svc_xprt_flags(__entry->xprt->xpt_flags))
++ (struct sockaddr *)&__entry->ss,
++ __entry->pid, show_svc_xprt_flags(__entry->flags))
+ );
+
+ TRACE_EVENT(svc_xprt_dequeue,
+@@ -589,16 +592,20 @@ TRACE_EVENT(svc_handle_xprt,
+ TP_STRUCT__entry(
+ __field(struct svc_xprt *, xprt)
+ __field(int, len)
++ __field_struct(struct sockaddr_storage, ss)
++ __field(unsigned long, flags)
+ ),
+
+ TP_fast_assign(
+ __entry->xprt = xprt;
++ xprt ? memcpy(&__entry->ss, &xprt->xpt_remote, sizeof(__entry->ss)) : memset(&__entry->ss, 0, sizeof(__entry->ss));
+ __entry->len = len;
++ __entry->flags = xprt ? xprt->xpt_flags : 0;
+ ),
+
+ TP_printk("xprt=0x%p addr=%pIScp len=%d flags=%s", __entry->xprt,
+- (struct sockaddr *)&__entry->xprt->xpt_remote, __entry->len,
+- show_svc_xprt_flags(__entry->xprt->xpt_flags))
++ (struct sockaddr *)&__entry->ss,
++ __entry->len, show_svc_xprt_flags(__entry->flags))
+ );
+ #endif /* _TRACE_SUNRPC_H */
+
--- /dev/null
+From 18e3b739fdc826481c6a1335ce0c5b19b3d415da Mon Sep 17 00:00:00 2001
+From: Kinglong Mee <kinglongmee@gmail.com>
+Date: Sat, 15 Aug 2015 21:52:10 +0800
+Subject: NFS: Fix a NULL pointer dereference of migration recovery ops for v4.2 client
+
+From: Kinglong Mee <kinglongmee@gmail.com>
+
+commit 18e3b739fdc826481c6a1335ce0c5b19b3d415da upstream.
+
+---Steps to Reproduce--
+<nfs-server>
+# cat /etc/exports
+/nfs/referal *(rw,insecure,no_subtree_check,no_root_squash,crossmnt)
+/nfs/old *(ro,insecure,subtree_check,root_squash,crossmnt)
+
+<nfs-client>
+# mount -t nfs nfs-server:/nfs/ /mnt/
+# ll /mnt/*/
+
+<nfs-server>
+# cat /etc/exports
+/nfs/referal *(rw,insecure,no_subtree_check,no_root_squash,crossmnt,refer=/nfs/old/@nfs-server)
+/nfs/old *(ro,insecure,subtree_check,root_squash,crossmnt)
+# service nfs restart
+
+<nfs-client>
+# ll /mnt/*/ --->>>>> oops here
+
+[ 5123.102925] BUG: unable to handle kernel NULL pointer dereference at (null)
+[ 5123.103363] IP: [<ffffffffa03ed38b>] nfs4_proc_get_locations+0x9b/0x120 [nfsv4]
+[ 5123.103752] PGD 587b9067 PUD 3cbf5067 PMD 0
+[ 5123.104131] Oops: 0000 [#1]
+[ 5123.104529] Modules linked in: nfsv4(OE) nfs(OE) fscache(E) nfsd(OE) xfs libcrc32c iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi coretemp crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel ppdev vmw_balloon parport_pc parport i2c_piix4 shpchp auth_rpcgss nfs_acl vmw_vmci lockd grace sunrpc vmwgfx drm_kms_helper ttm drm mptspi serio_raw scsi_transport_spi e1000 mptscsih mptbase ata_generic pata_acpi [last unloaded: nfsd]
+[ 5123.105887] CPU: 0 PID: 15853 Comm: ::1-manager Tainted: G OE 4.2.0-rc6+ #214
+[ 5123.106358] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/20/2014
+[ 5123.106860] task: ffff88007620f300 ti: ffff88005877c000 task.ti: ffff88005877c000
+[ 5123.107363] RIP: 0010:[<ffffffffa03ed38b>] [<ffffffffa03ed38b>] nfs4_proc_get_locations+0x9b/0x120 [nfsv4]
+[ 5123.107909] RSP: 0018:ffff88005877fdb8 EFLAGS: 00010246
+[ 5123.108435] RAX: ffff880053f3bc00 RBX: ffff88006ce6c908 RCX: ffff880053a0d240
+[ 5123.108968] RDX: ffffea0000e6d940 RSI: ffff8800399a0000 RDI: ffff88006ce6c908
+[ 5123.109503] RBP: ffff88005877fe28 R08: ffffffff81c708a0 R09: 0000000000000000
+[ 5123.110045] R10: 00000000000001a2 R11: ffff88003ba7f5c8 R12: ffff880054c55800
+[ 5123.110618] R13: 0000000000000000 R14: ffff880053a0d240 R15: ffff880053a0d240
+[ 5123.111169] FS: 0000000000000000(0000) GS:ffffffff81c27000(0000) knlGS:0000000000000000
+[ 5123.111726] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[ 5123.112286] CR2: 0000000000000000 CR3: 0000000054cac000 CR4: 00000000001406f0
+[ 5123.112888] Stack:
+[ 5123.113458] ffffea0000e6d940 ffff8800399a0000 00000000000167d0 0000000000000000
+[ 5123.114049] 0000000000000000 0000000000000000 0000000000000000 00000000a7ec82c6
+[ 5123.114662] ffff88005877fe18 ffffea0000e6d940 ffff8800399a0000 ffff880054c55800
+[ 5123.115264] Call Trace:
+[ 5123.115868] [<ffffffffa03fb44b>] nfs4_try_migration+0xbb/0x220 [nfsv4]
+[ 5123.116487] [<ffffffffa03fcb3b>] nfs4_run_state_manager+0x4ab/0x7b0 [nfsv4]
+[ 5123.117104] [<ffffffffa03fc690>] ? nfs4_do_reclaim+0x510/0x510 [nfsv4]
+[ 5123.117813] [<ffffffff810a4527>] kthread+0xd7/0xf0
+[ 5123.118456] [<ffffffff810a4450>] ? kthread_worker_fn+0x160/0x160
+[ 5123.119108] [<ffffffff816d9cdf>] ret_from_fork+0x3f/0x70
+[ 5123.119723] [<ffffffff810a4450>] ? kthread_worker_fn+0x160/0x160
+[ 5123.120329] Code: 4c 8b 6a 58 74 17 eb 52 48 8d 55 a8 89 c6 4c 89 e7 e8 4a b5 ff ff 8b 45 b0 85 c0 74 1c 4c 89 f9 48 8b 55 90 48 8b 75 98 48 89 df <41> ff 55 00 3d e8 d8 ff ff 41 89 c6 74 cf 48 8b 4d c8 65 48 33
+[ 5123.121643] RIP [<ffffffffa03ed38b>] nfs4_proc_get_locations+0x9b/0x120 [nfsv4]
+[ 5123.122308] RSP <ffff88005877fdb8>
+[ 5123.122942] CR2: 0000000000000000
+
+Fixes: ec011fe847 ("NFS: Introduce a vector of migration recovery ops")
+Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/nfs4proc.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/fs/nfs/nfs4proc.c
++++ b/fs/nfs/nfs4proc.c
+@@ -8571,6 +8571,7 @@ static const struct nfs4_minor_version_o
+ .reboot_recovery_ops = &nfs41_reboot_recovery_ops,
+ .nograce_recovery_ops = &nfs41_nograce_recovery_ops,
+ .state_renewal_ops = &nfs41_state_renewal_ops,
++ .mig_recovery_ops = &nfs41_mig_recovery_ops,
+ };
+ #endif
+
--- /dev/null
+From e9ae58aeee8842a50f7e199d602a5ccb2e41a95f Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Mon, 17 Aug 2015 12:57:07 -0500
+Subject: NFS: nfs_set_pgio_error sometimes misses errors
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit e9ae58aeee8842a50f7e199d602a5ccb2e41a95f upstream.
+
+We should ensure that we always set the pgio_header's error field
+if a READ or WRITE RPC call returns an error. The current code depends
+on 'hdr->good_bytes' always being initialised to a large value, which
+is not always done correctly by callers.
+When this happens, applications may end up missing important errors.
+
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/pagelist.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/fs/nfs/pagelist.c
++++ b/fs/nfs/pagelist.c
+@@ -77,8 +77,8 @@ EXPORT_SYMBOL_GPL(nfs_pgheader_init);
+ void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos)
+ {
+ spin_lock(&hdr->lock);
+- if (pos < hdr->io_start + hdr->good_bytes) {
+- set_bit(NFS_IOHDR_ERROR, &hdr->flags);
++ if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags)
++ || pos < hdr->io_start + hdr->good_bytes) {
+ clear_bit(NFS_IOHDR_EOF, &hdr->flags);
+ hdr->good_bytes = pos - hdr->io_start;
+ hdr->error = error;
--- /dev/null
+From 69f230d907e8c1ca3f9bd528993eeb98f712b0dd Mon Sep 17 00:00:00 2001
+From: Peng Tao <tao.peng@primarydata.com>
+Date: Thu, 20 Aug 2015 01:52:59 +0800
+Subject: NFS41/flexfiles: update inode after write finishes
+
+From: Peng Tao <tao.peng@primarydata.com>
+
+commit 69f230d907e8c1ca3f9bd528993eeb98f712b0dd upstream.
+
+Otherwise we break fstest case tests/read_write/mctime.t
+
+Does files layout need the same fix as well?
+
+Cc: Anna Schumaker <anna.schumaker@netapp.com>
+Signed-off-by: Peng Tao <tao.peng@primarydata.com>
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/flexfilelayout/flexfilelayout.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/fs/nfs/flexfilelayout/flexfilelayout.c
++++ b/fs/nfs/flexfilelayout/flexfilelayout.c
+@@ -1039,6 +1039,9 @@ static int ff_layout_write_done_cb(struc
+ hdr->res.verf->committed == NFS_DATA_SYNC)
+ ff_layout_set_layoutcommit(hdr);
+
++ if (task->tk_status >= 0)
++ nfs_writeback_update_inode(hdr);
++
+ return 0;
+ }
+
--- /dev/null
+From 5420401079e152ff68a8024f6a375804b1c21505 Mon Sep 17 00:00:00 2001
+From: Peng Tao <tao.peng@primarydata.com>
+Date: Sat, 22 Aug 2015 06:40:00 +0800
+Subject: NFS41/flexfiles: zero out DS write wcc
+
+From: Peng Tao <tao.peng@primarydata.com>
+
+commit 5420401079e152ff68a8024f6a375804b1c21505 upstream.
+
+We do not want to update inode attributes with DS values.
+
+Signed-off-by: Peng Tao <tao.peng@primarydata.com>
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/flexfilelayout/flexfilelayout.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/fs/nfs/flexfilelayout/flexfilelayout.c
++++ b/fs/nfs/flexfilelayout/flexfilelayout.c
+@@ -1039,6 +1039,8 @@ static int ff_layout_write_done_cb(struc
+ hdr->res.verf->committed == NFS_DATA_SYNC)
+ ff_layout_set_layoutcommit(hdr);
+
++ /* zero out fattr since we don't care DS attr at all */
++ hdr->fattr.valid = 0;
+ if (task->tk_status >= 0)
+ nfs_writeback_update_inode(hdr);
+
--- /dev/null
+From aaae3f00d3f67f681a1f3cb7af999e976e8a24ce Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Thu, 20 Aug 2015 18:56:07 -0500
+Subject: NFSv4: Force a post-op attribute update when holding a delegation
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit aaae3f00d3f67f681a1f3cb7af999e976e8a24ce upstream.
+
+If the ctime or mtime or change attribute have changed because
+of an operation we initiated, we should make sure that we force
+an attribute update. However we do not want to mark the page cache
+for revalidation.
+
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/inode.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/fs/nfs/inode.c
++++ b/fs/nfs/inode.c
+@@ -1480,6 +1480,13 @@ static int nfs_post_op_update_inode_lock
+ {
+ unsigned long invalid = NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
+
++ /*
++ * Don't revalidate the pagecache if we hold a delegation, but do
++ * force an attribute update
++ */
++ if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
++ invalid = NFS_INO_INVALID_ATTR|NFS_INO_REVAL_FORCED;
++
+ if (S_ISDIR(inode->i_mode))
+ invalid |= NFS_INO_INVALID_DATA;
+ nfs_set_cache_invalid(inode, invalid);
--- /dev/null
+From 4a1e2feb9d246775dee0f78ed5b18826bae2b1c5 Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Sun, 30 Aug 2015 18:37:59 -0700
+Subject: NFSv4.1: Fix a protocol issue with CLOSE stateids
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit 4a1e2feb9d246775dee0f78ed5b18826bae2b1c5 upstream.
+
+According to RFC5661 Section 18.2.4, CLOSE is supposed to return
+the zero stateid. This means that nfs_clear_open_stateid_locked()
+cannot assume that the result stateid will always match the 'other'
+field of the existing open stateid when trying to determine a race
+with a parallel OPEN.
+
+Instead, we look at the argument, and check for matches.
+
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/nfs4proc.c | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+--- a/fs/nfs/nfs4proc.c
++++ b/fs/nfs/nfs4proc.c
+@@ -1216,6 +1216,7 @@ static void nfs_resync_open_stateid_lock
+ }
+
+ static void nfs_clear_open_stateid_locked(struct nfs4_state *state,
++ nfs4_stateid *arg_stateid,
+ nfs4_stateid *stateid, fmode_t fmode)
+ {
+ clear_bit(NFS_O_RDWR_STATE, &state->flags);
+@@ -1234,8 +1235,9 @@ static void nfs_clear_open_stateid_locke
+ if (stateid == NULL)
+ return;
+ /* Handle races with OPEN */
+- if (!nfs4_stateid_match_other(stateid, &state->open_stateid) ||
+- !nfs4_stateid_is_newer(stateid, &state->open_stateid)) {
++ if (!nfs4_stateid_match_other(arg_stateid, &state->open_stateid) ||
++ (nfs4_stateid_match_other(stateid, &state->open_stateid) &&
++ !nfs4_stateid_is_newer(stateid, &state->open_stateid))) {
+ nfs_resync_open_stateid_locked(state);
+ return;
+ }
+@@ -1244,10 +1246,12 @@ static void nfs_clear_open_stateid_locke
+ nfs4_stateid_copy(&state->open_stateid, stateid);
+ }
+
+-static void nfs_clear_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fmode)
++static void nfs_clear_open_stateid(struct nfs4_state *state,
++ nfs4_stateid *arg_stateid,
++ nfs4_stateid *stateid, fmode_t fmode)
+ {
+ write_seqlock(&state->seqlock);
+- nfs_clear_open_stateid_locked(state, stateid, fmode);
++ nfs_clear_open_stateid_locked(state, arg_stateid, stateid, fmode);
+ write_sequnlock(&state->seqlock);
+ if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags))
+ nfs4_schedule_state_manager(state->owner->so_server->nfs_client);
+@@ -2672,7 +2676,8 @@ static void nfs4_close_done(struct rpc_t
+ goto out_release;
+ }
+ }
+- nfs_clear_open_stateid(state, res_stateid, calldata->arg.fmode);
++ nfs_clear_open_stateid(state, &calldata->arg.stateid,
++ res_stateid, calldata->arg.fmode);
+ out_release:
+ nfs_release_seqid(calldata->arg.seqid);
+ nfs_refresh_inode(calldata->inode, calldata->res.fattr);
--- /dev/null
+From d13549074cf066d6d5bb29903d044beffea342d3 Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Thu, 27 Aug 2015 20:37:39 -0400
+Subject: NFSv4.1/flexfiles: Fix a protocol error in layoutreturn
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit d13549074cf066d6d5bb29903d044beffea342d3 upstream.
+
+According to the flexfiles protocol, the layoutreturn should specify an
+array of errors in the following format:
+
+struct ff_ioerr4 {
+ offset4 ffie_offset;
+ length4 ffie_length;
+ stateid4 ffie_stateid;
+ device_error4 ffie_errors<>;
+};
+
+This patch fixes up the code to ensure that our ffie_errors is indeed
+encoded as an array (albeit with only a single entry).
+
+Reported-by: Tom Haynes <thomas.haynes@primarydata.com>
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/flexfilelayout/flexfilelayoutdev.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
++++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+@@ -500,16 +500,19 @@ int ff_layout_encode_ds_ioerr(struct nfs
+ range->offset, range->length))
+ continue;
+ /* offset(8) + length(8) + stateid(NFS4_STATEID_SIZE)
+- * + deviceid(NFS4_DEVICEID4_SIZE) + status(4) + opnum(4)
++ * + array length + deviceid(NFS4_DEVICEID4_SIZE)
++ * + status(4) + opnum(4)
+ */
+ p = xdr_reserve_space(xdr,
+- 24 + NFS4_STATEID_SIZE + NFS4_DEVICEID4_SIZE);
++ 28 + NFS4_STATEID_SIZE + NFS4_DEVICEID4_SIZE);
+ if (unlikely(!p))
+ return -ENOBUFS;
+ p = xdr_encode_hyper(p, err->offset);
+ p = xdr_encode_hyper(p, err->length);
+ p = xdr_encode_opaque_fixed(p, &err->stateid,
+ NFS4_STATEID_SIZE);
++ /* Encode 1 error */
++ *p++ = cpu_to_be32(1);
+ p = xdr_encode_opaque_fixed(p, &err->deviceid,
+ NFS4_DEVICEID4_SIZE);
+ *p++ = cpu_to_be32(err->status);
--- /dev/null
+From 36319608e28701c07cad80ae3be8b0fdfb1ab40f Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Wed, 19 Aug 2015 00:14:20 -0500
+Subject: Revert "NFSv4: Remove incorrect check in can_open_delegated()"
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit 36319608e28701c07cad80ae3be8b0fdfb1ab40f upstream.
+
+This reverts commit 4e379d36c050b0117b5d10048be63a44f5036115.
+
+This commit opens up a race between the recovery code and the open code.
+
+Reported-by: Olga Kornievskaia <aglo@umich.edu>
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfs/nfs4proc.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/fs/nfs/nfs4proc.c
++++ b/fs/nfs/nfs4proc.c
+@@ -1152,6 +1152,8 @@ static int can_open_delegated(struct nfs
+ return 0;
+ if ((delegation->type & fmode) != fmode)
+ return 0;
++ if (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags))
++ return 0;
+ if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
+ return 0;
+ nfs_mark_delegation_referenced(delegation);
nfsv4-don-t-set-setattr-for-o_rdonly-o_excl.patch
nfs-don-t-let-the-ctime-override-attribute-barriers.patch
nfsv4.1-pnfs-fix-borken-function-_same_data_server_addrs_locked.patch
+nfs-fix-a-null-pointer-dereference-of-migration-recovery-ops-for-v4.2-client.patch
+nfs-nfs_set_pgio_error-sometimes-misses-errors.patch
+nfs41-flexfiles-update-inode-after-write-finishes.patch
+nfsv4-force-a-post-op-attribute-update-when-holding-a-delegation.patch
+nfs41-flexfiles-zero-out-ds-write-wcc.patch
+nfsv4.1-flexfiles-fix-a-protocol-error-in-layoutreturn.patch
+nfsv4.1-fix-a-protocol-issue-with-close-stateids.patch
+revert-nfsv4-remove-incorrect-check-in-can_open_delegated.patch
+net-sunrpc-fix-tracepoint-warning-unknown-op.patch
+sunrpc-fix-a-thinko-in-xs_connect.patch
+sunrpc-xs_reset_transport-must-mark-the-connection-as-disconnected.patch
--- /dev/null
+From 99b1a4c32ad22024ac6198a4337aaec5ea23168f Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Thu, 13 Aug 2015 15:33:51 -0400
+Subject: SUNRPC: Fix a thinko in xs_connect()
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit 99b1a4c32ad22024ac6198a4337aaec5ea23168f upstream.
+
+It is rather pointless to test the value of transport->inet after
+calling xs_reset_transport(), since it will always be zero, and
+so we will never see any exponential back off behaviour.
+Also don't force early connections for SOFTCONN tasks. If the server
+disconnects us, we should respect the exponential backoff.
+
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/sunrpc/xprtsock.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+--- a/net/sunrpc/xprtsock.c
++++ b/net/sunrpc/xprtsock.c
+@@ -2216,13 +2216,14 @@ static void xs_connect(struct rpc_xprt *
+
+ WARN_ON_ONCE(!xprt_lock_connect(xprt, task, transport));
+
+- /* Start by resetting any existing state */
+- xs_reset_transport(transport);
+-
+- if (transport->sock != NULL && !RPC_IS_SOFTCONN(task)) {
++ if (transport->sock != NULL) {
+ dprintk("RPC: xs_connect delayed xprt %p for %lu "
+ "seconds\n",
+ xprt, xprt->reestablish_timeout / HZ);
++
++ /* Start by resetting any existing state */
++ xs_reset_transport(transport);
++
+ queue_delayed_work(rpciod_workqueue,
+ &transport->connect_worker,
+ xprt->reestablish_timeout);
--- /dev/null
+From 0c78789e3a030615c6650fde89546cadf40ec2cc Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+Date: Sat, 29 Aug 2015 13:36:30 -0700
+Subject: SUNRPC: xs_reset_transport must mark the connection as disconnected
+
+From: Trond Myklebust <trond.myklebust@primarydata.com>
+
+commit 0c78789e3a030615c6650fde89546cadf40ec2cc upstream.
+
+In case the reconnection attempt fails.
+
+Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/sunrpc/xprtsock.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/net/sunrpc/xprtsock.c
++++ b/net/sunrpc/xprtsock.c
+@@ -834,6 +834,7 @@ static void xs_reset_transport(struct so
+ sk->sk_user_data = NULL;
+
+ xs_restore_old_callbacks(transport, sk);
++ xprt_clear_connected(xprt);
+ write_unlock_bh(&sk->sk_callback_lock);
+ xs_sock_reset_connection_flags(xprt);
+