--- /dev/null
+From stable-bounces@linux.kernel.org Tue Jun 27 15:35:25 2006
+Date: Wed, 28 Jun 2006 08:34:44 +1000
+From: Nathan Scott <nathans@sgi.com>
+To: stable@kernel.org
+Cc:
+Subject: [stable] XFS corruption fix for next stable release
+
+From: Mandy Kirkconnell <alkirkco@sgi.com>
+
+Fix nused counter. It's currently getting set to -1 rather than getting
+decremented by 1. Since nused never reaches 0, the "if (!free->hdr.nused)"
+check in xfs_dir2_leafn_remove() fails every time and xfs_dir2_shrink_inode()
+doesn't get called when it should. This causes extra blocks to be left on
+an empty directory and the directory in unable to be converted back to
+inline extent mode.
+
+Signed-off-by: Mandy Kirkconnell <alkirkco@sgi.com>
+Signed-off-by: Nathan Scott <nathans@sgi.com>
+Signed-off-by: Chris Wright <chrisw@sous-sol.org>
+
+---
+ fs/xfs/xfs_dir2_node.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- linux-2.6.17.2.orig/fs/xfs/xfs_dir2_node.c
++++ linux-2.6.17.2/fs/xfs/xfs_dir2_node.c
+@@ -970,7 +970,7 @@ xfs_dir2_leafn_remove(
+ /*
+ * One less used entry in the free table.
+ */
+- free->hdr.nused = cpu_to_be32(-1);
++ be32_add(&free->hdr.nused, -1);
+ xfs_dir2_free_log_header(tp, fbp);
+ /*
+ * If this was the last entry in the table, we can