From: Andy Adamson <andros@xxxxxxxxxx> This is a rebase of Andy's patch (which is not yet in the pns-submit tree) onto my patches, yet taking into account some issues Benny noted which are best addressed by ensuring that nfs4_layoutreturn_release make no reference to call results, as there is no guarantee that a call was made. Add missing layoutreturn stateid update. This patch also enforces the following rfc 5661 requirement: section 12.5.3 "For LAYOUTRETURN results, the client MUST delete the range from its record of what ranges of the file's layout it had before using the seqid." Reported-by: P.B.Shelley <shelleypt@xxxxxxxxx> Signed-off-by: Andy Adamson <andros@xxxxxxxxxx> Signed-off-by: Benny Halevy <bhalevy@xxxxxxxxxxx> Signed-off-by: Fred Isaman <iisaman@xxxxxxxxxx> --- fs/nfs/nfs4proc.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 96bd822..4fba3f0 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5674,10 +5674,6 @@ static void nfs4_layoutreturn_release(void *calldata) if (lrp->args.return_type == RETURN_FILE) { struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout; - spin_lock(&lo->inode->i_lock); - if (!lrp->res.lrs_present) - pnfs_invalidate_layout_stateid(lo); - spin_unlock(&lo->inode->i_lock); pnfs_layoutreturn_release(lo, &lrp->args.range); } kfree(calldata); @@ -5720,6 +5716,16 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool issync) if (status != 0) goto out; status = task->tk_status; + if (status == 0 && lrp->args.return_type == RETURN_FILE) { + struct pnfs_layout_hdr *lo = NFS_I(ino)->layout; + + spin_lock(&lo->inode->i_lock); + if (!lrp->res.lrs_present) + pnfs_invalidate_layout_stateid(lo); + else + pnfs_set_layout_stateid(lo, &lrp->res.stateid); + spin_unlock(&lo->inode->i_lock); + } out: dprintk("<-- %s\n", __func__); rpc_put_task(task); -- 1.7.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html