From 83a03e7ba91ea3de4a2af957d333f8b0ada36c56 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 7 Dec 2011 20:08:03 -0800 Subject: [PATCH] kernel - Fix endless nfs error 70 during shutdown * When shutting down NFS rw mounts left over buffers may not be able to flush during a forced unmount. * When unable to flush during a forced unmount mark the bp EIO instead of ESTALE and also mark it B_INVAL to remove the buffer from the the vnode. --- sys/vfs/nfs/nfs_socket.c | 2 +- sys/vfs/nfs/nfsm_subs.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/vfs/nfs/nfs_socket.c b/sys/vfs/nfs/nfs_socket.c index b68bd89..4cad5ad 100644 --- a/sys/vfs/nfs/nfs_socket.c +++ b/sys/vfs/nfs/nfs_socket.c @@ -1138,7 +1138,7 @@ nfs_request_setup(nfsm_info_t info) if (info->vp->v_mount->mnt_kern_flag & MNTK_UNMOUNTF) { m_freem(info->mreq); info->mreq = NULL; - return (ESTALE); + return (EIO); } nmp = VFSTONFS(info->vp->v_mount); req = kmalloc(sizeof(struct nfsreq), M_NFSREQ, M_WAITOK); diff --git a/sys/vfs/nfs/nfsm_subs.c b/sys/vfs/nfs/nfsm_subs.c index 2db5709..2cdc5f3 100644 --- a/sys/vfs/nfs/nfsm_subs.c +++ b/sys/vfs/nfs/nfsm_subs.c @@ -817,8 +817,18 @@ nfsm_request_bio(nfsm_info_t info, struct vnode *vp, int procnum, if (error != EINPROGRESS) { kprintf("nfsm_request_bio: early abort %d\n", error); bp = info->bio->bio_buf; - if (error) + if (error) { bp->b_flags |= B_ERROR; + if (error == EIO) /* unrecoverable */ + bp->b_flags |= B_INVAL; + } + + /* + * This can retry endlessly during a shutdown, change ESTALE + * to EIO in this case. + */ + if (shutdown_inprog && error == ESTALE) + error = EIO; bp->b_error = error; biodone(info->bio); } -- 1.7.7.2