[PATCH 36/46] xfs_repair: update incore metadata state whenever we create new files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Make sure that we update our incore metadata inode bookkeepping whenever
we create new metadata files.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 repair/phase6.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)


diff --git a/repair/phase6.c b/repair/phase6.c
index 3e740079235..b3ad4074ff8 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -514,6 +514,24 @@ mark_ino_inuse(
 		set_inode_isadir(irec, ino_offset);
 }
 
+/*
+ * Mark a newly allocated inode as metadata in the incore bitmap.  Callers
+ * must have already called mark_ino_inuse to ensure there is an incore record.
+ */
+static void
+mark_ino_metadata(
+	struct xfs_mount	*mp,
+	xfs_ino_t		ino)
+{
+	struct ino_tree_node	*irec;
+	int			ino_offset;
+
+	irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, ino),
+			XFS_INO_TO_AGINO(mp, ino));
+	ino_offset = get_inode_offset(mp, ino, irec);
+	set_inode_is_meta(irec, ino_offset);
+}
+
 /* Make sure this metadata directory path exists. */
 static int
 ensure_imeta_dirpath(
@@ -547,6 +565,7 @@ ensure_imeta_dirpath(
 		if (ino == NULLFSINO)
 			return ENOENT;
 		mark_ino_inuse(mp, ino, S_IFDIR, parent);
+		mark_ino_metadata(mp, ino);
 		parent = ino;
 	}
 
@@ -663,6 +682,7 @@ _("couldn't create new metadata inode, error %d\n"), error);
 
 	mark_ino_inuse(mp, (*ipp)->i_ino, S_IFREG,
 			lookup_imeta_path_dirname(mp, path));
+	mark_ino_metadata(mp, (*ipp)->i_ino);
 	return 0;
 }
 
@@ -1065,6 +1085,7 @@ mk_metadir(
 
 	libxfs_trans_ijoin(tp, mp->m_metadirip, 0);
 	libxfs_imeta_set_metaflag(tp, mp->m_metadirip);
+	mark_ino_metadata(mp, mp->m_metadirip->i_ino);
 
 	error = -libxfs_trans_commit(tp);
 	if (error)




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux