Date: Fri, 14 Apr 2017 20:15:34 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316941 - head/sys/kern Message-ID: <201704142015.v3EKFYWA017623@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Fri Apr 14 20:15:34 2017 New Revision: 316941 URL: https://svnweb.freebsd.org/changeset/base/316941 Log: Don't try to write out bufs that have already failed with ENXIO. This fixes some panics after disconnecting mounted disks. Submitted by: imp (slightly different version, which I've then lost) Reviewed by: kib, imp, mckusick MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9674 Modified: head/sys/kern/vfs_bio.c Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Fri Apr 14 20:15:17 2017 (r316940) +++ head/sys/kern/vfs_bio.c Fri Apr 14 20:15:34 2017 (r316941) @@ -2290,18 +2290,28 @@ brelse(struct buf *bp) bdirty(bp); } if (bp->b_iocmd == BIO_WRITE && (bp->b_ioflags & BIO_ERROR) && + (bp->b_error != ENXIO || !LIST_EMPTY(&bp->b_dep)) && !(bp->b_flags & B_INVAL)) { /* - * Failed write, redirty. Must clear BIO_ERROR to prevent - * pages from being scrapped. + * Failed write, redirty. All errors except ENXIO (which + * means the device is gone) are expected to be potentially + * transient - underlying media might work if tried again + * after EIO, and memory might be available after an ENOMEM. + * + * Do this also for buffers that failed with ENXIO, but have + * non-empty dependencies - the soft updates code might need + * to access the buffer to untangle them. + * + * Must clear BIO_ERROR to prevent pages from being scrapped. */ bp->b_ioflags &= ~BIO_ERROR; bdirty(bp); } else if ((bp->b_flags & (B_NOCACHE | B_INVAL)) || (bp->b_ioflags & BIO_ERROR) || (bp->b_bufsize <= 0)) { /* - * Either a failed read I/O or we were asked to free or not - * cache the buffer. + * Either a failed read I/O, or we were asked to free or not + * cache the buffer, or we failed to write to a device that's + * no longer present. */ bp->b_flags |= B_INVAL; if (!LIST_EMPTY(&bp->b_dep))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704142015.v3EKFYWA017623>