* [PATCH] fix barrier fail detection in XFS
@ 2008-10-10 6:28 Timothy Shimmin
2008-10-10 18:04 ` Linus Torvalds
2008-10-10 18:07 ` Linus Torvalds
0 siblings, 2 replies; 3+ messages in thread
From: Timothy Shimmin @ 2008-10-10 6:28 UTC (permalink / raw)
To: Linus Torvalds; +Cc: lkml, xfs-oss, Andrew Morton, stable, toei.rei
Hi Linus,
Please include the following patch.
This is an important fix posted by Christoph Hellwig today.
Without this fix, XFS can turn off barriers when we wrap our ondisk log.
Which could lead to corruption after unclean unmounts/shutdowns
on machines without a persistent write cache etc.
--Tim
---------------
Fix barrier fail detection in XFS
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>
Index: 2.6.x-xfs-quilt/fs/xfs/linux-2.6/xfs_buf.c
===================================================================
--- 2.6.x-xfs-quilt.orig/fs/xfs/linux-2.6/xfs_buf.c 2008-09-19 13:47:36.000000000 +1000
+++ 2.6.x-xfs-quilt/fs/xfs/linux-2.6/xfs_buf.c 2008-10-10 15:07:51.316145158 +1100
@@ -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: 2.6.x-xfs-quilt/fs/xfs/linux-2.6/xfs_buf.h
===================================================================
--- 2.6.x-xfs-quilt.orig/fs/xfs/linux-2.6/xfs_buf.h 2008-09-19 13:47:36.000000000 +1000
+++ 2.6.x-xfs-quilt/fs/xfs/linux-2.6/xfs_buf.h 2008-10-10 11:54:23.269373217 +1100
@@ -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: 2.6.x-xfs-quilt/fs/xfs/xfs_log.c
===================================================================
--- 2.6.x-xfs-quilt.orig/fs/xfs/xfs_log.c 2008-09-22 11:54:19.000000000 +1000
+++ 2.6.x-xfs-quilt/fs/xfs/xfs_log.c 2008-10-10 15:09:56.967725107 +1100
@@ -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"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix barrier fail detection in XFS
2008-10-10 6:28 [PATCH] fix barrier fail detection in XFS Timothy Shimmin
@ 2008-10-10 18:04 ` Linus Torvalds
2008-10-10 18:07 ` Linus Torvalds
1 sibling, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2008-10-10 18:04 UTC (permalink / raw)
To: Timothy Shimmin; +Cc: lkml, xfs-oss, Andrew Morton, stable, toei.rei
On Fri, 10 Oct 2008, Timothy Shimmin wrote:
>
> This is an important fix posted by Christoph Hellwig today.
> Without this fix, XFS can turn off barriers when we wrap our ondisk log.
> Which could lead to corruption after unclean unmounts/shutdowns
> on machines without a persistent write cache etc.
Ok, it clearly didn't make it into 2.6.27. I assume it it should be marked
for stable?
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix barrier fail detection in XFS
2008-10-10 6:28 [PATCH] fix barrier fail detection in XFS Timothy Shimmin
2008-10-10 18:04 ` Linus Torvalds
@ 2008-10-10 18:07 ` Linus Torvalds
1 sibling, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2008-10-10 18:07 UTC (permalink / raw)
To: Timothy Shimmin; +Cc: lkml, xfs-oss, Andrew Morton, stable, toei.rei
On Fri, 10 Oct 2008, Timothy Shimmin wrote:
>
> This is an important fix posted by Christoph Hellwig today.
Oh, btw, when doing this, please add the
From: Christoph Hellwig <hch@lst.de>
at the top of the email (and if you re-post the one-liner summary
description, prepend it with "Subject: ", so that when I apply it as an
email, the "Fix barrier fail detection in XFS" doesn't end up being
repeated twice - once from the real email subject line, and once as the
first normal line of the email).
I did it by hand, so you don't need to re-send, but just for future
reference, for when I don't happen to notice (and so that I don't have to
do it myself when I _do_ notice)
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-10 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-10 6:28 [PATCH] fix barrier fail detection in XFS Timothy Shimmin
2008-10-10 18:04 ` Linus Torvalds
2008-10-10 18:07 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox