]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: load metadata directory root at mount time
authorDarrick J. Wong <djwong@kernel.org>
Thu, 21 Nov 2024 00:24:12 +0000 (16:24 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:25 +0000 (18:01 -0800)
Load the metadata directory root inode into memory at mount time and
release it at unmount time.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
include/xfs_mount.h
libxfs/init.c

index c7fada9e2a6d70aa6cb7a15ccdaa9179a4dd09c8..6daf3f01ffa9cf683dadbb0964369b9957177321 100644 (file)
@@ -91,6 +91,7 @@ typedef struct xfs_mount {
        uint8_t                 *m_rsum_cache;
        struct xfs_inode        *m_rbmip;       /* pointer to bitmap inode */
        struct xfs_inode        *m_rsumip;      /* pointer to summary inode */
+       struct xfs_inode        *m_metadirip;   /* ptr to metadata directory */
        struct xfs_buftarg      *m_ddev_targp;
        struct xfs_buftarg      *m_logdev_targp;
        struct xfs_buftarg      *m_rtdev_targp;
index beb58706629d23d819f7b98e08672bbae2c9865e..bf488c5d8533b1144186760bd0c3924a1d67ce63 100644 (file)
@@ -619,6 +619,27 @@ libxfs_compute_all_maxlevels(
 
 }
 
+/* Mount the metadata files under the metadata directory tree. */
+STATIC void
+libxfs_mount_setup_metadir(
+       struct xfs_mount        *mp)
+{
+       int                     error;
+
+       /* Ignore filesystems that are under construction. */
+       if (mp->m_sb.sb_inprogress)
+               return;
+
+       error = -libxfs_metafile_iget(mp, mp->m_sb.sb_metadirino,
+                       XFS_METAFILE_DIR, &mp->m_metadirip);
+       if (error) {
+               fprintf(stderr,
+ _("%s: Failed to load metadir root directory, error %d\n"),
+                                       progname, error);
+               return;
+       }
+}
+
 /*
  * precalculate the low space thresholds for dynamic speculative preallocation.
  */
@@ -800,6 +821,9 @@ libxfs_mount(
        }
        xfs_set_perag_data_loaded(mp);
 
+       if (xfs_has_metadir(mp))
+               libxfs_mount_setup_metadir(mp);
+
        return mp;
 out_da:
        xfs_da_unmount(mp);
@@ -918,6 +942,8 @@ libxfs_umount(
        int                     error;
 
        libxfs_rtmount_destroy(mp);
+       if (mp->m_metadirip)
+               libxfs_irele(mp->m_metadirip);
 
        /*
         * Purge the buffer cache to write all dirty buffers to disk and free