]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: stop recording metadir inode numbers in the in-core superblock
authorChristoph Hellwig <hch@lst.de>
Sat, 13 Apr 2024 06:28:48 +0000 (08:28 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 15 Apr 2024 17:08:49 +0000 (19:08 +0200)
Source kernel commit: fe8cf66f7fadcd5f64de623d9e4dd30194c5108e

Both the RT and quota code now natively support metadir.

Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_imeta.c
libxfs/xfs_imeta.h

index 8fdc9fcfc1fcfbd60955dd2273e8a0e92a69d703..83e3c3b407d4a646ad2a5f33b106cb06b3c47fe7 100644 (file)
@@ -74,33 +74,6 @@ XFS_IMETA_DEFINE_PATH(XFS_IMETA_USRQUOTA,    usrquota_path);
 XFS_IMETA_DEFINE_PATH(XFS_IMETA_GRPQUOTA,      grpquota_path);
 XFS_IMETA_DEFINE_PATH(XFS_IMETA_PRJQUOTA,      prjquota_path);
 
-const struct xfs_imeta_path XFS_IMETA_METADIR = {
-       .im_depth = 0,
-       .im_ftype = XFS_DIR3_FT_DIR,
-};
-
-/* Are these two paths equal? */
-STATIC bool
-xfs_imeta_path_compare(
-       const struct xfs_imeta_path     *a,
-       const struct xfs_imeta_path     *b)
-{
-       unsigned int                    i;
-
-       if (a == b)
-               return true;
-
-       if (a->im_depth != b->im_depth)
-               return false;
-
-       for (i = 0; i < a->im_depth; i++)
-               if (a->im_path[i] != b->im_path[i] &&
-                   strcmp(a->im_path[i], b->im_path[i]))
-                       return false;
-
-       return true;
-}
-
 /* Is this path ok? */
 static inline bool
 xfs_imeta_path_check(
@@ -109,64 +82,6 @@ xfs_imeta_path_check(
        return path->im_depth <= XFS_IMETA_MAX_DEPTH;
 }
 
-/* Functions for storing and retrieving superblock inode values. */
-
-/* Mapping of metadata inode paths to in-core superblock values. */
-static const struct xfs_imeta_sbmap {
-       const struct xfs_imeta_path     *path;
-       unsigned int                    offset;
-} xfs_imeta_sbmaps[] = {
-       {
-               .path   = &XFS_IMETA_RTBITMAP,
-               .offset = offsetof(struct xfs_sb, sb_rbmino),
-       },
-       {
-               .path   = &XFS_IMETA_RTSUMMARY,
-               .offset = offsetof(struct xfs_sb, sb_rsumino),
-       },
-       {
-               .path   = &XFS_IMETA_USRQUOTA,
-               .offset = offsetof(struct xfs_sb, sb_uquotino),
-       },
-       {
-               .path   = &XFS_IMETA_GRPQUOTA,
-               .offset = offsetof(struct xfs_sb, sb_gquotino),
-       },
-       {
-               .path   = &XFS_IMETA_PRJQUOTA,
-               .offset = offsetof(struct xfs_sb, sb_pquotino),
-       },
-       {
-               .path   = &XFS_IMETA_METADIR,
-               .offset = offsetof(struct xfs_sb, sb_metadirino),
-       },
-       { NULL, 0 },
-};
-
-/* Return a pointer to the in-core superblock inode value. */
-static inline xfs_ino_t *
-xfs_imeta_sbmap_to_inop(
-       struct xfs_mount                *mp,
-       const struct xfs_imeta_sbmap    *map)
-{
-       return (xfs_ino_t *)(((char *)&mp->m_sb) + map->offset);
-}
-
-/* Compute location of metadata inode pointer in the in-core superblock */
-static inline xfs_ino_t *
-xfs_imeta_path_to_sb_inop(
-       struct xfs_mount                *mp,
-       const struct xfs_imeta_path     *path)
-{
-       const struct xfs_imeta_sbmap    *p;
-
-       for (p = xfs_imeta_sbmaps; p->path; p++)
-               if (xfs_imeta_path_compare(p->path, path))
-                       return xfs_imeta_sbmap_to_inop(mp, p);
-
-       return NULL;
-}
-
 /* Functions for storing and retrieving metadata directory inode values. */
 
 static inline void
@@ -373,11 +288,9 @@ xfs_imeta_dir_lookup_int(
        int                             error;
 
        /* metadir ino is recorded in superblock */
-       if (xfs_imeta_path_compare(path, &XFS_IMETA_METADIR))
+       if (path->im_depth == 0)
                return tp->t_mountp->m_sb.sb_metadirino;
 
-       ASSERT(path->im_depth > 0);
-
        /* Find the parent of the last path component. */
        error = xfs_imeta_dir_parent(tp, path, &dp);
        if (error)
@@ -403,36 +316,6 @@ xfs_imeta_dir_lookup_int(
        return error;
 }
 
-/*
- * Load all the metadata inode pointers that are cached in the in-core
- * superblock but live somewhere in the metadata directory tree.
- */
-STATIC int
-xfs_imeta_dir_mount(
-       struct xfs_trans                *tp)
-{
-       struct xfs_mount                *mp = tp->t_mountp;
-       const struct xfs_imeta_sbmap    *p;
-       xfs_ino_t                       *sb_inop;
-       int                             err2;
-       int                             error = 0;
-
-       for (p = xfs_imeta_sbmaps; p->path && p->path->im_depth > 0; p++) {
-               if (p->path == &XFS_IMETA_METADIR)
-                       continue;
-               sb_inop = xfs_imeta_sbmap_to_inop(mp, p);
-               err2 = xfs_imeta_dir_lookup_int(tp, p->path, sb_inop);
-               if (err2 == -ENOENT) {
-                       *sb_inop = NULLFSINO;
-                       continue;
-               }
-               if (!error && err2)
-                       error = err2;
-       }
-
-       return error;
-}
-
 /* Set up an inode to be recognized as a metadata directory inode. */
 void
 xfs_imeta_set_iflag(
@@ -487,7 +370,6 @@ xfs_imeta_dir_create(
                .ppargs                 = upd->ppargs,
        };
        struct xfs_mount                *mp = upd->mp;
-       xfs_ino_t                       *sb_inop;
        xfs_ino_t                       ino;
        unsigned int                    resblks;
        int                             error;
@@ -548,11 +430,6 @@ xfs_imeta_dir_create(
        /* Metadir files are not accounted to quota. */
 
        trace_xfs_imeta_dir_create(upd);
-
-       /* Update the in-core superblock value if there is one. */
-       sb_inop = xfs_imeta_path_to_sb_inop(mp, upd->path);
-       if (sb_inop)
-               *sb_inop = ino;
        return 0;
 }
 
@@ -569,7 +446,6 @@ xfs_imeta_dir_link(
                .ppargs                 = upd->ppargs,
        };
        struct xfs_mount                *mp = upd->mp;
-       xfs_ino_t                       *sb_inop;
        xfs_ino_t                       ino;
        unsigned int                    resblks;
        int                             error;
@@ -578,12 +454,6 @@ xfs_imeta_dir_link(
        xfs_assert_ilocked(upd->ip, XFS_ILOCK_EXCL);
 
        /* Metadata directory root cannot be linked. */
-       if (xfs_imeta_path_compare(upd->path, &XFS_IMETA_METADIR)) {
-               ASSERT(0);
-               xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
-               return -EFSCORRUPTED;
-       }
-
        ASSERT(upd->path->im_depth > 0);
 
        /* Look up the name in the current directory. */
@@ -606,11 +476,6 @@ xfs_imeta_dir_link(
                return error;
 
        trace_xfs_imeta_dir_link(upd);
-
-       /* Update the in-core superblock value if there is one. */
-       sb_inop = xfs_imeta_path_to_sb_inop(mp, upd->path);
-       if (sb_inop)
-               *sb_inop = upd->ip->i_ino;
        return 0;
 }
 
@@ -697,21 +562,6 @@ xfs_imeta_link(
        return xfs_imeta_dir_link(upd);
 }
 
-/*
- * Ensure that the in-core superblock has all the values that it should.
- * Caller should pass in an empty transaction to avoid livelocking on btree
- * cycles.
- */
-int
-xfs_imeta_mount(
-       struct xfs_trans        *tp)
-{
-       if (xfs_has_metadir(tp->t_mountp))
-               return xfs_imeta_dir_mount(tp);
-
-       return 0;
-}
-
 /* Create a path to a file within the metadata directory tree. */
 int
 xfs_imeta_create_file_path(
index d99fc17ac5ce6f2231f67f35f6eb8b1606220d5d..2d5572270717b7795d4403ea1669a3c32b60e852 100644 (file)
@@ -76,7 +76,6 @@ extern const struct xfs_imeta_path XFS_IMETA_RTSUMMARY;
 extern const struct xfs_imeta_path XFS_IMETA_USRQUOTA;
 extern const struct xfs_imeta_path XFS_IMETA_GRPQUOTA;
 extern const struct xfs_imeta_path XFS_IMETA_PRJQUOTA;
-extern const struct xfs_imeta_path XFS_IMETA_METADIR;
 
 int xfs_imeta_lookup(struct xfs_trans *tp, const struct xfs_imeta_path *path,
                xfs_ino_t *ino);
@@ -94,8 +93,6 @@ int xfs_imeta_create(struct xfs_imeta_update *upd, umode_t mode,
                struct xfs_inode **ipp);
 int xfs_imeta_link(struct xfs_imeta_update *upd);
 
-int xfs_imeta_mount(struct xfs_trans *tp);
-
 unsigned int xfs_imeta_create_space_res(struct xfs_mount *mp);
 unsigned int xfs_imeta_link_space_res(struct xfs_mount *mp);