[PATCH 22/22] xfs: create library function to reset root inodes

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

 



From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

Create a library function to reset a root inode, which xfs_repair will
take advantage of in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
---
 fs/xfs/libxfs/xfs_inode_util.c |   24 ++++++++++++++++++++++++
 fs/xfs/libxfs/xfs_inode_util.h |    1 +
 2 files changed, 25 insertions(+)


diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c
index 01a320747ddf..00cda9046c8e 100644
--- a/fs/xfs/libxfs/xfs_inode_util.c
+++ b/fs/xfs/libxfs/xfs_inode_util.c
@@ -416,6 +416,30 @@ xfs_ialloc(
 	return 0;
 }
 
+/*
+ * Forcibly reinitialize a fixed-location inode, such as a filesystem root
+ * directory or the realtime metadata inodes.  The inode must not otherwise be
+ * in use, and the inode's forks must already be empty.
+ */
+int
+xfs_fixed_inode_reset(
+	struct xfs_trans		*tp,
+	umode_t				mode,
+	struct xfs_inode		*ip)
+{
+	struct xfs_ialloc_args	args = {
+		.ops			= &xfs_default_ialloc_ops,
+		.nlink			= S_ISDIR(mode) ? 2 : 1,
+		.mode			= mode,
+	};
+	struct xfs_mount		*mp = tp->t_mountp;
+
+	ip->i_d.di_version = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
+
+	xfs_inode_init(tp, &args, ip);
+	return 0;
+}
+
 /*
  * Allocates a new inode from disk and return a pointer to the
  * incore copy. This routine will internally commit the current
diff --git a/fs/xfs/libxfs/xfs_inode_util.h b/fs/xfs/libxfs/xfs_inode_util.h
index 4918379b682e..5a6f1a348a47 100644
--- a/fs/xfs/libxfs/xfs_inode_util.h
+++ b/fs/xfs/libxfs/xfs_inode_util.h
@@ -97,6 +97,7 @@ extern const struct xfs_ialloc_ops xfs_default_ialloc_ops;
 
 int xfs_dir_ialloc(struct xfs_trans **tpp, const struct xfs_ialloc_args *args,
 		   struct xfs_inode **ipp);
+int xfs_fixed_inode_reset(struct xfs_trans *tp, umode_t mode, struct xfs_inode *ip);
 
 int xfs_iunlink(struct xfs_trans *tp, struct xfs_inode *ip);
 int xfs_iunlink_remove(struct xfs_trans *tp, struct xfs_inode *ip);




[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