blob: bb50853d09880b1d547fe438feaf093240923d16 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Christoph Hellwig57926642011-07-13 13:43:48 +02002/*
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Christoph Hellwig57926642011-07-13 13:43:48 +02005 */
6#ifndef __XFS_DIR2_PRIV_H__
7#define __XFS_DIR2_PRIV_H__
8
Dave Chinner0cb97762013-08-12 20:50:09 +10009struct dir_context;
10
Christoph Hellwiga39f089a2019-11-08 14:52:06 -080011/*
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;
Christoph Hellwig787b0892019-11-08 14:57:50 -080021
22 /*
23 * Pointer to the on-disk format entries, which are behind the
24 * variable size (v4 vs v5) header in the on-disk block.
25 */
26 struct xfs_dir2_leaf_entry *ents;
Christoph Hellwiga39f089a2019-11-08 14:52:06 -080027};
28
29struct xfs_dir3_icfree_hdr {
30 uint32_t magic;
31 uint32_t firstdb;
32 uint32_t nvalid;
33 uint32_t nused;
Christoph Hellwiga84f3d52019-11-08 14:58:05 -080034
35 /*
36 * Pointer to the on-disk format entries, which are behind the
37 * variable size (v4 vs v5) header in the on-disk block.
38 */
39 __be16 *bests;
Christoph Hellwiga39f089a2019-11-08 14:52:06 -080040};
41
Christoph Hellwig57926642011-07-13 13:43:48 +020042/* xfs_dir2.c */
Christoph Hellwig57926642011-07-13 13:43:48 +020043extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
44 xfs_dir2_db_t *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020045extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
46 const unsigned char *name, int len);
47
Dave Chinner0cb97762013-08-12 20:50:09 +100048
Christoph Hellwig57926642011-07-13 13:43:48 +020049/* xfs_dir2_block.c */
Dave Chinner4a8af272013-08-12 20:49:36 +100050extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp,
51 struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020052extern int xfs_dir2_block_addname(struct xfs_da_args *args);
Christoph Hellwig57926642011-07-13 13:43:48 +020053extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
54extern int xfs_dir2_block_removename(struct xfs_da_args *args);
55extern int xfs_dir2_block_replace(struct xfs_da_args *args);
56extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100057 struct xfs_buf *lbp, struct xfs_buf *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020058
59/* xfs_dir2_data.c */
60#ifdef DEBUG
Darrick J. Wonga6a781a2018-01-08 10:51:03 -080061extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
Christoph Hellwig57926642011-07-13 13:43:48 +020062#else
Dave Chinner33363fe2013-04-03 16:11:22 +110063#define xfs_dir3_data_check(dp,bp)
Christoph Hellwig57926642011-07-13 13:43:48 +020064#endif
Dave Chinner1813dd62012-11-14 17:54:40 +110065
Darrick J. Wonga6a781a2018-01-08 10:51:03 -080066extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
67 struct xfs_buf *bp);
Dave Chinner33363fe2013-04-03 16:11:22 +110068extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
Dave Chinnere4813572012-11-12 22:54:14 +110069 xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
Eric Sandeen9df2dd02014-04-14 19:01:59 +100070extern int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
71 xfs_daddr_t mapped_bno);
Dave Chinner82025d72012-11-12 22:54:12 +110072
Christoph Hellwig57926642011-07-13 13:43:48 +020073extern struct xfs_dir2_data_free *
74xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
Dave Chinner2ca98772013-10-29 22:11:49 +110075 struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup,
76 int *loghead);
Dave Chinnerf5f3d9b2013-04-03 16:11:20 +110077extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
Dave Chinner1d9025e2012-06-22 18:50:14 +100078 struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020079
80/* xfs_dir2_leaf.c */
Christoph Hellwig51842552019-11-08 14:57:49 -080081void xfs_dir2_leaf_hdr_from_disk(struct xfs_mount *mp,
82 struct xfs_dir3_icleaf_hdr *to, struct xfs_dir2_leaf *from);
Christoph Hellwig163fbbb2019-11-08 14:57:50 -080083void xfs_dir2_leaf_hdr_to_disk(struct xfs_mount *mp, struct xfs_dir2_leaf *to,
84 struct xfs_dir3_icleaf_hdr *from);
Darrick J. Wong26788092017-06-16 11:00:07 -070085extern int xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
86 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
Dave Chinner24df33b2013-04-12 07:30:21 +100087extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
Dave Chinnere6f76672012-11-12 22:54:15 +110088 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020089extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100090 struct xfs_buf *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020091extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
Dave Chinner24df33b2013-04-12 07:30:21 +100092extern void xfs_dir3_leaf_compact(struct xfs_da_args *args,
93 struct xfs_dir3_icleaf_hdr *leafhdr, struct xfs_buf *bp);
94extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,
95 struct xfs_dir2_leaf_entry *ents, int *indexp,
Christoph Hellwig57926642011-07-13 13:43:48 +020096 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
Dave Chinner24df33b2013-04-12 07:30:21 +100097extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno,
Darrick J. Wongc8ce5402017-06-16 11:00:05 -070098 struct xfs_buf **bpp, uint16_t magic);
Dave Chinnerbc851782014-06-06 15:20:54 +100099extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args,
Christoph Hellwig787b0892019-11-08 14:57:50 -0800100 struct xfs_dir3_icleaf_hdr *hdr, struct xfs_buf *bp, int first,
101 int last);
Dave Chinnerbc851782014-06-06 15:20:54 +1000102extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000103 struct xfs_buf *bp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200104extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
105extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
106extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
107extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000108 struct xfs_buf *lbp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200109extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000110 struct xfs_buf *lbp, xfs_dir2_db_t db);
Christoph Hellwig57926642011-07-13 13:43:48 +0200111extern struct xfs_dir2_leaf_entry *
Dave Chinner24df33b2013-04-12 07:30:21 +1000112xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
113 struct xfs_dir2_leaf_entry *ents, int index, int compact,
114 int lowstale, int highstale, int *lfloglow, int *lfloghigh);
Christoph Hellwig57926642011-07-13 13:43:48 +0200115extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
116
Darrick J. Wonga6a781a2018-01-08 10:51:03 -0800117extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp,
Christoph Hellwig5ba30912019-11-08 14:57:52 -0800118 struct xfs_dir3_icleaf_hdr *hdr, struct xfs_dir2_leaf *leaf);
Dave Chinner24df33b2013-04-12 07:30:21 +1000119
Christoph Hellwig57926642011-07-13 13:43:48 +0200120/* xfs_dir2_node.c */
Christoph Hellwig5ba30912019-11-08 14:57:52 -0800121void xfs_dir2_free_hdr_from_disk(struct xfs_mount *mp,
122 struct xfs_dir3_icfree_hdr *to, struct xfs_dir2_free *from);
Christoph Hellwig57926642011-07-13 13:43:48 +0200123extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000124 struct xfs_buf *lbp);
Darrick J. Wong8e8877e2017-06-16 11:00:13 -0700125extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,
Dave Chinner41419562013-10-29 22:11:50 +1100126 struct xfs_buf *bp, int *count);
Dave Chinner1d9025e2012-06-22 18:50:14 +1000127extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
Christoph Hellwig57926642011-07-13 13:43:48 +0200128 struct xfs_da_args *args, int *indexp,
129 struct xfs_da_state *state);
Dave Chinner41419562013-10-29 22:11:50 +1100130extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000131 struct xfs_buf *leaf2_bp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200132extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
133 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk);
134extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
135extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state,
136 struct xfs_da_state_blk *drop_blk,
137 struct xfs_da_state_blk *save_blk);
138extern int xfs_dir2_node_addname(struct xfs_da_args *args);
139extern int xfs_dir2_node_lookup(struct xfs_da_args *args);
140extern int xfs_dir2_node_removename(struct xfs_da_args *args);
141extern int xfs_dir2_node_replace(struct xfs_da_args *args);
142extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo,
143 int *rvalp);
Dave Chinner20252072012-11-12 22:54:13 +1100144extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,
145 xfs_dablk_t fbno, struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200146
147/* xfs_dir2_sf.c */
Christoph Hellwig84915e12019-11-08 15:02:31 -0800148xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *hdr);
149void xfs_dir2_sf_put_parent_ino(struct xfs_dir2_sf_hdr *hdr, xfs_ino_t ino);
Christoph Hellwig57926642011-07-13 13:43:48 +0200150extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
151 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
Dave Chinner1d9025e2012-06-22 18:50:14 +1000152extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
Christoph Hellwig57926642011-07-13 13:43:48 +0200153 int size, xfs_dir2_sf_hdr_t *sfhp);
154extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
155extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
Christoph Hellwig57926642011-07-13 13:43:48 +0200156extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
157extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
158extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
Darrick J. Wongdc042c22018-01-08 10:51:06 -0800159extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip);
Christoph Hellwig57926642011-07-13 13:43:48 +0200160
Dave Chinnerc24b5df2013-08-12 20:49:45 +1000161/* xfs_dir2_readdir.c */
Darrick J. Wongacb95532017-06-16 11:00:14 -0700162extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
163 struct dir_context *ctx, size_t bufsize);
Dave Chinnerc24b5df2013-08-12 20:49:45 +1000164
Christoph Hellwig57926642011-07-13 13:43:48 +0200165#endif /* __XFS_DIR2_PRIV_H__ */