public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfsprogs: fix inode crash in xfs_repair
@ 2013-08-13 22:13 Mark Tinguely
  2013-08-14  6:40 ` Dave Chinner
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Tinguely @ 2013-08-13 22:13 UTC (permalink / raw)
  To: xfs

[-- Attachment #1: xfs_progs-fix-repair-crash-new-ichunk.patch --]
[-- Type: text/plain, Size: 1702 bytes --]

Adding the lost+found in phase 6 could allocate an inode from
a new inode chunk. That newly created chunk was not around in
the scan phase, and is not in the avl tree which will result
in a NULL dereference.

This patch adds the newly created inode chunk and inodes as if
found in the scan phase.

Metadata dump available for future tests.

Signed-off-by: Mark Tinguely <tinguely@sgi.com>
---
 repair/incore_ino.c |    2 +-
 repair/phase6.c     |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

Index: b/repair/incore_ino.c
===================================================================
--- a/repair/incore_ino.c
+++ b/repair/incore_ino.c
@@ -700,7 +700,7 @@ get_inode_parent(ino_tree_node_t *irec,
 	return(0LL);
 }
 
-static void
+void
 alloc_ex_data(ino_tree_node_t *irec)
 {
 	parent_list_t 	*ptbl;
Index: b/repair/phase6.c
===================================================================
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -930,6 +930,21 @@ mk_orphanage(xfs_mount_t *mp)
 	irec = find_inode_rec(mp,
 			XFS_INO_TO_AGNO(mp, ino),
 			XFS_INO_TO_AGINO(mp, ino));
+
+	if (irec == NULL && XFS_INO_TO_AGNO(mp, ino) < mp->m_sb.sb_agcount &&
+	    ip != NULL && ip->i_d.di_magic == XFS_DINODE_MAGIC) {
+
+		/*
+		 * add the newly allocated inode chunk to the avl tree.
+		 */
+		irec = set_inode_free_alloc(mp, XFS_INO_TO_AGNO(mp, ino),
+					    XFS_INO_TO_AGINO(mp, ino));
+		alloc_ex_data(irec);
+
+		for (i = 0; i < XFS_INODES_PER_CHUNK; i++)
+			set_inode_free(irec, i);
+	}
+
 	ino_offset = get_inode_offset(mp, ino, irec);
 
 	/*


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-15 21:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-13 22:13 [PATCH] xfsprogs: fix inode crash in xfs_repair Mark Tinguely
2013-08-14  6:40 ` Dave Chinner
2013-08-14 13:33   ` Mark Tinguely
2013-08-15  0:33     ` Dave Chinner
2013-08-15 14:07       ` Mark Tinguely
2013-08-15 21:47         ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox