NFSv4: Always clear the pNFS layout when handling ESTALE
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 30 May 2018 02:06:08 +0000 (22:06 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 31 May 2018 19:02:16 +0000 (15:02 -0400)
If we get an ESTALE error in response to an RPC call operating on the
file on the MDS, we should immediately cancel the layout for that file.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs42proc.c
fs/nfs/nfs4proc.c

index 4d4a3df28779ce286a464b9886f5348fc59b3033..5f59b6f65a421911fb35d196636dd7d0a7488053 100644 (file)
@@ -370,6 +370,10 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata)
        switch (task->tk_status) {
        case 0:
                break;
+       case -NFS4ERR_BADHANDLE:
+       case -ESTALE:
+               pnfs_destroy_layout(NFS_I(inode));
+               break;
        case -NFS4ERR_EXPIRED:
        case -NFS4ERR_ADMIN_REVOKED:
        case -NFS4ERR_DELEG_REVOKED:
index 36e36f176c75db3b6638a09cf9d6f49b31e7f64c..a0f16c8c5ebd80c688207baefb09405ae636a33f 100644 (file)
@@ -407,6 +407,11 @@ static int nfs4_do_handle_exception(struct nfs_server *server,
        switch(errorcode) {
                case 0:
                        return 0;
+               case -NFS4ERR_BADHANDLE:
+               case -ESTALE:
+                       if (inode != NULL && S_ISREG(inode->i_mode))
+                               pnfs_destroy_layout(NFS_I(inode));
+                       break;
                case -NFS4ERR_DELEG_REVOKED:
                case -NFS4ERR_ADMIN_REVOKED:
                case -NFS4ERR_EXPIRED: