kernel - Fix endless nfs error 70 during shutdown
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 8 Dec 2011 04:08:03 +0000 (20:08 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 8 Dec 2011 04:08:03 +0000 (20:08 -0800)
* 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
sys/vfs/nfs/nfsm_subs.c

index b68bd89..4cad5ad 100644 (file)
@@ -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);
index 2db5709..2cdc5f3 100644 (file)
@@ -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);
        }