[Bug 210316] panic after trying to r/w mount msdosfs on write protected media

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed May 16 12:38:45 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210316

--- Comment #10 from Andriy Gapon <avg at FreeBSD.org> ---
(In reply to Konstantin Belousov from comment #9)

Kostik,
I need to refresh my memory of this problem.

Meanwhile, I have a counter-question.
Is there a bwrite variant where a failure is a final failure with no side
effects?  I mean, if that bwriteX fails, then the buffer is just discarded.
Something with semantics similar to write(2).

My understanding of what happens now.
bufwrite calls this code:
        if ((oldflags & B_ASYNC) == 0) {
                int rtval = bufwait(bp);
                brelse(bp);
                return (rtval);

Then in brelse() the following block is executed:
        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.  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);

I think that it would be nice to have a way to instruct the buffer code to
never retry a specific synchronous write request.
If we had such a mechanism we could use it in filesystems's mount code to check
whether we can really write to the backing media.

Or should a caller of bwrite() explicitly manipulate b_flags (e.g. B_INVAL,
B_RELBUF) to get the desired effect?

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-fs mailing list