Commit c555dd9b authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: load metadata directory root at mount time



Load the metadata directory root inode into memory at mount time and
release it at unmount time.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent dcf60691
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "xfs_trace.h"
#include "xfs_ag.h"
#include "xfs_rtbitmap.h"
#include "xfs_metafile.h"
#include "scrub/stats.h"

static DEFINE_MUTEX(xfs_uuid_table_mutex);
@@ -620,6 +621,22 @@ xfs_mount_setup_inode_geom(
	xfs_ialloc_setup_geometry(mp);
}

/* Mount the metadata directory tree root. */
STATIC int
xfs_mount_setup_metadir(
	struct xfs_mount	*mp)
{
	int			error;

	/* Load the metadata directory root inode into memory. */
	error = xfs_metafile_iget(mp, mp->m_sb.sb_metadirino, XFS_METAFILE_DIR,
			&mp->m_metadirip);
	if (error)
		xfs_warn(mp, "Failed to load metadir root directory, error %d",
				error);
	return error;
}

/* Compute maximum possible height for per-AG btree types for this fs. */
static inline void
xfs_agbtree_compute_maxlevels(
@@ -866,6 +883,12 @@ xfs_mountfs(
		mp->m_features |= XFS_FEAT_ATTR2;
	}

	if (xfs_has_metadir(mp)) {
		error = xfs_mount_setup_metadir(mp);
		if (error)
			goto out_free_metadir;
	}

	/*
	 * Get and sanity-check the root inode.
	 * Save the pointer to it in the mount structure.
@@ -876,7 +899,7 @@ xfs_mountfs(
		xfs_warn(mp,
			"Failed to read root inode 0x%llx, error %d",
			sbp->sb_rootino, -error);
		goto out_log_dealloc;
		goto out_free_metadir;
	}

	ASSERT(rip != NULL);
@@ -1018,6 +1041,9 @@ xfs_mountfs(
	xfs_irele(rip);
	/* Clean out dquots that might be in memory after quotacheck. */
	xfs_qm_unmount(mp);
 out_free_metadir:
	if (mp->m_metadirip)
		xfs_irele(mp->m_metadirip);

	/*
	 * Inactivate all inodes that might still be in memory after a log
@@ -1039,7 +1065,6 @@ xfs_mountfs(
	 * quota inodes.
	 */
	xfs_unmount_flush_inodes(mp);
 out_log_dealloc:
	xfs_log_mount_cancel(mp);
 out_inodegc_shrinker:
	shrinker_free(mp->m_inodegc_shrinker);
@@ -1091,6 +1116,8 @@ xfs_unmountfs(
	xfs_qm_unmount_quotas(mp);
	xfs_rtunmount_inodes(mp);
	xfs_irele(mp->m_rootip);
	if (mp->m_metadirip)
		xfs_irele(mp->m_metadirip);

	xfs_unmount_flush_inodes(mp);

+1 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ typedef struct xfs_mount {
	struct xfs_inode	*m_rbmip;	/* pointer to bitmap inode */
	struct xfs_inode	*m_rsumip;	/* pointer to summary inode */
	struct xfs_inode	*m_rootip;	/* pointer to root directory */
	struct xfs_inode	*m_metadirip;	/* ptr to metadata directory */
	struct xfs_quotainfo	*m_quotainfo;	/* disk quota information */
	struct xfs_buftarg	*m_ddev_targp;	/* data device */
	struct xfs_buftarg	*m_logdev_targp;/* log device */