1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2022 Oracle. All Rights Reserved.
* Author: Darrick J. Wong <djwong@kernel.org>
*/
#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_ftype = XFS_DIR3_FT_REG_FILE, \
.im_depth = ARRAY_SIZE(path), \
.im_dynamicmask = 0, \
}
/* Key for looking up metadata inodes. */
struct xfs_imeta_path {
/* Array of string pointers. */
const char **im_path;
/* Number of strings in path. */
unsigned int im_depth;
/* Expected file type. */
unsigned int im_ftype;
/* Each bit corresponds to an element of im_path needing to be freed */
unsigned long long im_dynamicmask;
};
/* Cleanup widget for metadata inode creation and deletion. */
struct xfs_imeta_update {
/* Parent directory */
struct xfs_inode *dp;
/* Parent directory lock mode */
unsigned int lock_mode;
};
/* Lookup keys for static metadata inodes. */
extern const struct xfs_imeta_path XFS_IMETA_RTBITMAP;
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_mount *mp, const struct xfs_imeta_path *path,
xfs_ino_t *ino);
int xfs_imeta_lookup_update(struct xfs_mount *mp,
const struct xfs_imeta_path *path,
struct xfs_imeta_update *upd, xfs_ino_t *inop);
int xfs_imeta_create_file_path(struct xfs_mount *mp,
unsigned int nr_components, struct xfs_imeta_path **pathp);
void xfs_imeta_free_path(struct xfs_imeta_path *path);
void xfs_imeta_set_metaflag(struct xfs_trans *tp, struct xfs_inode *ip);
/* Don't allocate quota for this file. */
#define XFS_IMETA_CREATE_NOQUOTA (1 << 0)
int xfs_imeta_create(struct xfs_trans **tpp, const struct xfs_imeta_path *path,
umode_t mode, unsigned int flags, struct xfs_inode **ipp,
struct xfs_imeta_update *upd);
int xfs_imeta_unlink(struct xfs_trans **tpp, const struct xfs_imeta_path *path,
struct xfs_inode *ip, struct xfs_imeta_update *upd);
int xfs_imeta_link(struct xfs_trans *tp, const struct xfs_imeta_path *path,
struct xfs_inode *ip, struct xfs_imeta_update *upd);
void xfs_imeta_end_update(struct xfs_mount *mp, struct xfs_imeta_update *upd,
int error);
int xfs_imeta_start_update(struct xfs_mount *mp,
const struct xfs_imeta_path *path,
struct xfs_imeta_update *upd);
bool xfs_is_static_meta_ino(struct xfs_mount *mp, xfs_ino_t ino);
int xfs_imeta_mount(struct xfs_mount *mp);
void xfs_imeta_droplink(struct xfs_inode *ip);
unsigned int xfs_imeta_create_space_res(struct xfs_mount *mp);
unsigned int xfs_imeta_unlink_space_res(struct xfs_mount *mp);
/* Must be implemented by the libxfs client */
int xfs_imeta_iget(struct xfs_mount *mp, xfs_ino_t ino, unsigned char ftype,
struct xfs_inode **ipp);
void xfs_imeta_irele(struct xfs_inode *ip);
int xfs_imeta_ensure_dirpath(struct xfs_mount *mp,
const struct xfs_imeta_path *path);
#endif /* __XFS_IMETA_H__ */
|