Make sure that we clear the layout segments in cases where we see a
fatal error, and also in the case where the layout is invalid.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
                fallthrough;
        default:
                task->tk_status = 0;
+               lrp->res.lrs_present = 0;
                fallthrough;
        case 0:
                break;
                task->tk_status = 0;
                break;
        case -NFS4ERR_DELAY:
-               if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN)
-                       break;
-               goto out_restart;
+               if (nfs4_async_handle_error(task, server, NULL, NULL) ==
+                   -EAGAIN)
+                       goto out_restart;
+               lrp->res.lrs_present = 0;
+               break;
        }
        return;
 out_restart:
 
        LIST_HEAD(freeme);
 
        spin_lock(&inode->i_lock);
-       if (!pnfs_layout_is_valid(lo) ||
-           !nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid))
+       if (!nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid))
                goto out_unlock;
-       if (stateid) {
+       if (stateid && pnfs_layout_is_valid(lo)) {
                u32 seq = be32_to_cpu(arg_stateid->seqid);
 
                pnfs_mark_matching_lsegs_invalid(lo, &freeme, range, seq);