Skip to contentSkip to conversation

xfs: more shutdown-related fixes

PATCH In review Dave Chinner 5 participants 9 messages Sep 3, 2013 – Oct 18, 2013 XFS filesystem

lore
Share & tools
lore
#0 lore raw

cover xfs: more shutdown-related fixes

Hi folks,

More fixes as a result of forced shutdown testing. The first is fixing yet another hole in the buf log item freein logic when a transaction is aborted, and the other removes the asserts from the inode buffer checking so that verifiers return errors rather than crashing the system.

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

PATCH 1/2 xfs: aborted buf items can be in the AIL.

From: Dave Chinner <[email protected]>

Saw this on generic/270 after a DQALLOC transaction overrun shutdown:

XFS: Assertion failed: !(bip->bli_item.li_flags & XFS_LI_IN_AIL), file: fs/xfs/xfs_buf_item.c, line: 952
.....

 xfs_buf_item_relse+0x4f/0xd0
 xfs_buf_item_unlock+0x1b4/0x1e0
 xfs_trans_free_items+0x7d/0xb0
 xfs_trans_cancel+0x13c/0x1b0
 xfs_symlink+0x37e/0xa60

....

When a transaction abort occured.

If we are aborting a transaction and trigger this code path, then the item may be dirty. If the item is dirty, then it may be in the AIL. Hence if we are aborting, we need to check if the item is in the AIL and remove it before freeing it.

---
 fs/xfs/xfs_buf_item.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
fs/xfs/xfs_buf_item.c +19 -5
index 3a944b1..88c5ea7 100644
@@ -613,13 +613,27 @@ xfs_buf_item_unlock(
 			}
 		}
 	}
-	if (clean || aborted) {
-		if (atomic_dec_and_test(&bip->bli_refcount)) {
-			ASSERT(!aborted || XFS_FORCED_SHUTDOWN(lip->li_mountp));
+
+	/*
+	 * Clean buffers, by definition, cannot be in the AIL. However, aborted
+	 * buffers may be dirty and hence in the AIL. Therefore if we are
+	 * aborting a buffer and we've just taken the last refernce away, we
+	 * have to check if it is in the AIL before freeing it. We need to free
+	 * it in this case, because an aborted transaction has already shut the
+	 * filesystem down and this is the last chance we will have to do so.
+	 */
+	if (atomic_dec_and_test(&bip->bli_refcount)) {
+		if (clean)
+			xfs_buf_item_relse(bp);
+		else if (aborted) {
+			ASSERT(XFS_FORCED_SHUTDOWN(lip->li_mountp));
+			if (lip->li_flags & XFS_LI_IN_AIL) {
+				xfs_trans_ail_delete(lip->li_ailp, lip,
+						     SHUTDOWN_LOG_IO_ERROR);
+			}
 			xfs_buf_item_relse(bp);
 		}
-	} else
-		atomic_dec(&bip->bli_refcount);
+	}
 
 	if (!(flags & XFS_BLI_HOLD))
 		xfs_buf_relse(bp);
Signature · 6 lines
1.8.3.2

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] xfs: aborted buf items can be in the AIL.

Quoted 16 lines · Dave Chinner

From: Dave Chinner<[email protected]>

Saw this on generic/270 after a DQALLOC transaction overrun shutdown:

XFS: Assertion failed: !(bip->bli_item.li_flags& XFS_LI_IN_AIL), file: fs/xfs/xfs_buf_item.c, line: 952
.....

  xfs_buf_item_relse+0x4f/0xd0
  xfs_buf_item_unlock+0x1b4/0x1e0
  xfs_trans_free_items+0x7d/0xb0
  xfs_trans_cancel+0x13c/0x1b0
  xfs_symlink+0x37e/0xa60

....

When a transaction abort occured.

Quoted 7 lines

If we are aborting a transaction and trigger this code path, then the item may be dirty. If the item is dirty, then it may be in the AIL. Hence if we are aborting, we need to check if the item is in the AIL and remove it before freeing it.

---

This is fine for Linux 3.12. Christoph's reference counting reorg sounds interesting.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw

PATCH 2/2 xfs: don't assert fail on bad inode numbers

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

Let the inode verifier do it's work by returning an error when we fail to find correct magic numbers in an inode buffer.

---
 fs/xfs/xfs_inode_buf.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/xfs/xfs_inode_buf.c +3 -5
index 3d25c9a..63382d3 100644
@@ -53,9 +53,8 @@ xfs_inobp_check(
 					i * mp->m_sb.sb_inodesize);
 		if (!dip->di_next_unlinked)  {
 			xfs_alert(mp,
-	"Detected bogus zero next_unlinked field in incore inode buffer 0x%p.",
-				bp);
-			ASSERT(dip->di_next_unlinked);
+	"Detected bogus zero next_unlinked field in inode %d buffer 0x%llx.",
+				i, (long long)bp->b_bn);
 		}
 	}
 }
@@ -106,11 +105,10 @@ xfs_inode_buf_verify(
 			XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_HIGH,
 					     mp, dip);
 #ifdef DEBUG
-			xfs_emerg(mp,
+			xfs_alert(mp,
 				"bad inode magic/vsn daddr %lld #%d (magic=%x)",
 				(unsigned long long)bp->b_bn, i,
 				be16_to_cpu(dip->di_magic));
-			ASSERT(0);
 #endif
 		}
 	}
Signature · 6 lines
1.8.3.2

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] xfs: don't assert fail on bad inode numbers

Quoted 7 lines · Dave Chinner

From: Dave Chinner<[email protected]>

Let the inode verifier do it's work by returning an error when we fail to find correct magic numbers in an inode buffer.

---

Looks okay - the xfs_buf_ioerror() sets the error code for the caller to detect.

We talked about this in June:
http://oss.sgi.com/archives/xfs/2013-06/msg00712.html

Looks good.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw
In reply to Dave Chinner
Quoted 7 lines · Dave Chinner

Hi folks,

More fixes as a result of forced shutdown testing. The first is fixing yet another hole in the buf log item freein logic when a transaction is aborted, and the other removes the asserts from the inode buffer checking so that verifiers return errors rather than crashing the system.

Btw, I've been wondering for a while if we need a major change to how the buf item refcounting works. All these little special cases in there are utterly non-intuitive. I've not looked very deep yet, but a normal scheme where every reference to it increments the refcount, and we simply free it when that hits zero should work here as well. We'd still need flags for the abort and clean conditions, but it would still be way simpler than what we have now.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#7 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 7 lines · Dave Chinner

Hi folks,

More fixes as a result of forced shutdown testing. The first is fixing yet another hole in the buf log item freein logic when a transaction is aborted, and the other removes the asserts from the inode buffer checking so that verifiers return errors rather than crashing the system.

Quoted 7 lines

Btw, I've been wondering for a while if we need a major change to how the buf item refcounting works. All these little special cases in there are utterly non-intuitive. I've not looked very deep yet, but a normal scheme where every reference to it increments the refcount, and we simply free it when that hits zero should work here as well. We'd still need flags for the abort and clean conditions, but it would still be way simpler than what we have now.

Yes, it makes sense to do, but I haven't considered it yet as I have other things to worry about right now. We'd still need the AIL removal on abort, though, as that is still the last place we'll see it on a shutdown...

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#8 lore raw
In reply to Dave Chinner
Quoted 7 lines · Dave Chinner

Hi folks,

More fixes as a result of forced shutdown testing. The first is fixing yet another hole in the buf log item freein logic when a transaction is aborted, and the other removes the asserts from the inode buffer checking so that verifiers return errors rather than crashing the system.

Applied these 2.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs