]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Fix barrier fail detection in XFS
authorChristoph Hellwig <hch@lst.de>
Fri, 10 Oct 2008 06:28:29 +0000 (17:28 +1100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 18 Oct 2008 17:49:11 +0000 (10:49 -0700)
commit 73f6aa4d44ab6157badc456ddfa05b31e58de5f0 upstream.

Currently we disable barriers as soon as we get a buffer in xlog_iodone
that has the XBF_ORDERED flag cleared.  But this can be the case not only
for buffers where the barrier failed, but also the first buffer of a
split log write in case of a log wraparound.  Due to the disabled
barriers we can easily get directory corruption on unclean shutdowns.
So instead of using this check add a new buffer flag for failed barrier
writes.

This is a regression vs 2.6.26 caused by patch to use the right macro
to check for the ORDERED flag, as we previously got true returned for
every buffer.

Thanks to Toei Rei for reporting the bug.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: David Chinner <david@fromorbit.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/xfs/linux-2.6/xfs_buf.c
fs/xfs/linux-2.6/xfs_buf.h
fs/xfs/xfs_log.c

index 986061ae1b9b18f1e22220e04b0db715a79c3dd6..36d5fcd3f593d8694926e70181b1bade9a1df8b6 100644 (file)
@@ -1001,12 +1001,13 @@ xfs_buf_iodone_work(
         * We can get an EOPNOTSUPP to ordered writes.  Here we clear the
         * ordered flag and reissue them.  Because we can't tell the higher
         * layers directly that they should not issue ordered I/O anymore, they
-        * need to check if the ordered flag was cleared during I/O completion.
+        * need to check if the _XFS_BARRIER_FAILED flag was set during I/O completion.
         */
        if ((bp->b_error == EOPNOTSUPP) &&
            (bp->b_flags & (XBF_ORDERED|XBF_ASYNC)) == (XBF_ORDERED|XBF_ASYNC)) {
                XB_TRACE(bp, "ordered_retry", bp->b_iodone);
                bp->b_flags &= ~XBF_ORDERED;
+               bp->b_flags |= _XFS_BARRIER_FAILED;
                xfs_buf_iorequest(bp);
        } else if (bp->b_iodone)
                (*(bp->b_iodone))(bp);
index fe01099566564d0a3dc9cedc850c9874d41bdc6a..456519a088c7bfb5ba472f0a8125818a46a5ac5b 100644 (file)
@@ -85,6 +85,14 @@ typedef enum {
         * modifications being lost.
         */
        _XBF_PAGE_LOCKED = (1 << 22),
+
+       /*
+        * If we try a barrier write, but it fails we have to communicate
+        * this to the upper layers.  Unfortunately b_error gets overwritten
+        * when the buffer is re-issued so we have to add another flag to
+        * keep this information.
+        */
+       _XFS_BARRIER_FAILED = (1 << 23),
 } xfs_buf_flags_t;
 
 typedef enum {
index 503ea89e8b9a24ac1b3da0901191ad82673f50f5..0b02c6443551f78b24af282cad994c5b07a2523f 100644 (file)
@@ -1033,11 +1033,12 @@ xlog_iodone(xfs_buf_t *bp)
        l = iclog->ic_log;
 
        /*
-        * If the ordered flag has been removed by a lower
-        * layer, it means the underlyin device no longer supports
+        * If the _XFS_BARRIER_FAILED flag was set by a lower
+        * layer, it means the underlying device no longer supports
         * barrier I/O. Warn loudly and turn off barriers.
         */
-       if ((l->l_mp->m_flags & XFS_MOUNT_BARRIER) && !XFS_BUF_ISORDERED(bp)) {
+       if (bp->b_flags & _XFS_BARRIER_FAILED) {
+               bp->b_flags &= ~_XFS_BARRIER_FAILED;
                l->l_mp->m_flags &= ~XFS_MOUNT_BARRIER;
                xfs_fs_cmn_err(CE_WARN, l->l_mp,
                                "xlog_iodone: Barriers are no longer supported"