blob: d2eaea663e7f205b69e785c262c8bf7a2ea992c0 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#ifndef __XFS_DIR2_PRIV_H__
7#define __XFS_DIR2_PRIV_H__
8
9struct dir_context;
10
11/*
12 * In-core version of the leaf and free block headers to abstract the
13 * differences in the v2 and v3 disk format of the headers.
14 */
15struct xfs_dir3_icleaf_hdr {
16 uint32_t forw;
17 uint32_t back;
18 uint16_t magic;
19 uint16_t count;
20 uint16_t stale;
21};
22
23struct xfs_dir3_icfree_hdr {
24 uint32_t magic;
25 uint32_t firstdb;
26 uint32_t nvalid;
27 uint32_t nused;
28};
29
30/* xfs_dir2.c */
31extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
32 xfs_dir2_db_t *dbp);
33extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
34 const unsigned char *name, int len);
35
36
37/* xfs_dir2_block.c */
38extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp,
39 struct xfs_buf **bpp);
40extern int xfs_dir2_block_addname(struct xfs_da_args *args);
41extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
42extern int xfs_dir2_block_removename(struct xfs_da_args *args);
43extern int xfs_dir2_block_replace(struct xfs_da_args *args);
44extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
45 struct xfs_buf *lbp, struct xfs_buf *dbp);
46
47/* xfs_dir2_data.c */
48#ifdef DEBUG
49extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
50#else
51#define xfs_dir3_data_check(dp,bp)
52#endif
53
54extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
55 struct xfs_buf *bp);
56extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
57 xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
58extern int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
59 xfs_daddr_t mapped_bno);
60
61extern struct xfs_dir2_data_free *
62xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
63 struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup,
64 int *loghead);
65extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
66 struct xfs_buf **bpp);
67
68/* xfs_dir2_leaf.c */
69extern int xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
70 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
71extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
72 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
73extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
74 struct xfs_buf *dbp);
75extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
76extern void xfs_dir3_leaf_compact(struct xfs_da_args *args,
77 struct xfs_dir3_icleaf_hdr *leafhdr, struct xfs_buf *bp);
78extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,
79 struct xfs_dir2_leaf_entry *ents, int *indexp,
80 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
81extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno,
82 struct xfs_buf **bpp, uint16_t magic);
83extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args,
84 struct xfs_buf *bp, int first, int last);
85extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args,
86 struct xfs_buf *bp);
87extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
88extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
89extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
90extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
91 struct xfs_buf *lbp);
92extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
93 struct xfs_buf *lbp, xfs_dir2_db_t db);
94extern struct xfs_dir2_leaf_entry *
95xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
96 struct xfs_dir2_leaf_entry *ents, int index, int compact,
97 int lowstale, int highstale, int *lfloglow, int *lfloghigh);
98extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
99
100extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp,
101 struct xfs_inode *dp, struct xfs_dir3_icleaf_hdr *hdr,
102 struct xfs_dir2_leaf *leaf);
103
104/* xfs_dir2_node.c */
105extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
106 struct xfs_buf *lbp);
107extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,
108 struct xfs_buf *bp, int *count);
109extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
110 struct xfs_da_args *args, int *indexp,
111 struct xfs_da_state *state);
112extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp,
113 struct xfs_buf *leaf2_bp);
114extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
115 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk);
116extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
117extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state,
118 struct xfs_da_state_blk *drop_blk,
119 struct xfs_da_state_blk *save_blk);
120extern int xfs_dir2_node_addname(struct xfs_da_args *args);
121extern int xfs_dir2_node_lookup(struct xfs_da_args *args);
122extern int xfs_dir2_node_removename(struct xfs_da_args *args);
123extern int xfs_dir2_node_replace(struct xfs_da_args *args);
124extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo,
125 int *rvalp);
126extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,
127 xfs_dablk_t fbno, struct xfs_buf **bpp);
128
129/* xfs_dir2_sf.c */
130extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
131 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
132extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
133 int size, xfs_dir2_sf_hdr_t *sfhp);
134extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
135extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
136extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
137extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
138extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
139extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip);
140
141/* xfs_dir2_readdir.c */
142extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
143 struct dir_context *ctx, size_t bufsize);
144
145#endif /* __XFS_DIR2_PRIV_H__ */