summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-02-19 17:02:43 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2020-03-03 18:47:51 -0800
commit34465289e9ae43f992403e4e04cf40c58703c020 (patch)
treeb02420dab5888ea2efd578c3e4b43037c244cea6 /fs
parentbc807a11b66b11f39c0eed7dde41fe68c3ed2d7f (diff)
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 <darrick.wong@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_imeta.c48
-rw-r--r--fs/xfs/libxfs/xfs_imeta.h17
2 files changed, 41 insertions, 24 deletions
diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c
index 71b5cf4872cf..9d7cf5dfb337 100644
--- a/fs/xfs/libxfs/xfs_imeta.c
+++ b/fs/xfs/libxfs/xfs_imeta.c
@@ -47,26 +47,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
@@ -74,7 +65,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? */
@@ -82,7 +86,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 f180664537b6..1eb1b10fedde 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. */