From 889ecf29edfa4102eec38fcb3d6fd6be9e41f8fc Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 5 Jan 2021 17:45:33 -0800 Subject: xfs: convert metadata inode lookup keys to use paths Convert the magic metadata inode lookup keys to use actual strings for paths. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_imeta.c | 48 +++++++++++++++++++++++++---------------------- fs/xfs/libxfs/xfs_imeta.h | 17 +++++++++++++++-- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c index 2d838a66a1bb..c091f564a276 100644 --- a/fs/xfs/libxfs/xfs_imeta.c +++ b/fs/xfs/libxfs/xfs_imeta.c @@ -48,26 +48,17 @@ */ /* Static metadata inode paths */ - -const struct xfs_imeta_path XFS_IMETA_RTBITMAP = { - .bogus = 0, -}; - -const struct xfs_imeta_path XFS_IMETA_RTSUMMARY = { - .bogus = 1, -}; - -const struct xfs_imeta_path XFS_IMETA_USRQUOTA = { - .bogus = 2, -}; - -const struct xfs_imeta_path XFS_IMETA_GRPQUOTA = { - .bogus = 3, -}; - -const struct xfs_imeta_path XFS_IMETA_PRJQUOTA = { - .bogus = 4, -}; +static const char *rtbitmap_path[] = {"realtime", "0.bitmap"}; +static const char *rtsummary_path[] = {"realtime", "0.summary"}; +static const char *usrquota_path[] = {"quota", "user"}; +static const char *grpquota_path[] = {"quota", "group"}; +static const char *prjquota_path[] = {"quota", "project"}; + +XFS_IMETA_DEFINE_PATH(XFS_IMETA_RTBITMAP, rtbitmap_path); +XFS_IMETA_DEFINE_PATH(XFS_IMETA_RTSUMMARY, rtsummary_path); +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); /* Are these two paths equal? */ STATIC bool @@ -75,7 +66,20 @@ xfs_imeta_path_compare( const struct xfs_imeta_path *a, const struct xfs_imeta_path *b) { - return a == 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? */ @@ -83,7 +87,7 @@ static inline bool xfs_imeta_path_check( const struct xfs_imeta_path *path) { - return true; + return path->im_depth <= XFS_IMETA_MAX_DEPTH; } /* Functions for storing and retrieving superblock inode values. */ diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h index 78a5ade91f04..8f2f56c15db7 100644 --- a/fs/xfs/libxfs/xfs_imeta.h +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -6,10 +6,23 @@ #ifndef __XFS_IMETA_H__ #define __XFS_IMETA_H__ +/* How deep can we nest metadata dirs? */ +#define XFS_IMETA_MAX_DEPTH 64 + +/* Form an imeta path from a simple array of strings. */ +#define XFS_IMETA_DEFINE_PATH(name, path) \ +const struct xfs_imeta_path name = { \ + .im_path = (path), \ + .im_depth = ARRAY_SIZE(path), \ +} + /* Key for looking up metadata inodes. */ struct xfs_imeta_path { - /* Temporary: integer to keep the static imeta definitions unique */ - int bogus; + /* Array of string pointers. */ + const char **im_path; + + /* Number of strings in path. */ + unsigned int im_depth; }; /* Cleanup widget for metadata inode creation and deletion. */ -- cgit v1.2.3