Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_DIR2_PRIV_H__ |
| 7 | #define __XFS_DIR2_PRIV_H__ |
| 8 | |
Dave Chinner | 0cb9776 | 2013-08-12 20:50:09 +1000 | [diff] [blame] | 9 | struct dir_context; |
| 10 | |
Christoph Hellwig | a39f089a | 2019-11-08 14:52:06 -0800 | [diff] [blame] | 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 | */ |
| 15 | struct 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 | |
| 23 | struct xfs_dir3_icfree_hdr { |
| 24 | uint32_t magic; |
| 25 | uint32_t firstdb; |
| 26 | uint32_t nvalid; |
| 27 | uint32_t nused; |
| 28 | }; |
| 29 | |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 30 | /* xfs_dir2.c */ |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 31 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, |
| 32 | xfs_dir2_db_t *dbp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 33 | extern int xfs_dir_cilookup_result(struct xfs_da_args *args, |
| 34 | const unsigned char *name, int len); |
| 35 | |
Dave Chinner | 0cb9776 | 2013-08-12 20:50:09 +1000 | [diff] [blame] | 36 | |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 37 | /* xfs_dir2_block.c */ |
Dave Chinner | 4a8af27 | 2013-08-12 20:49:36 +1000 | [diff] [blame] | 38 | extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 39 | struct xfs_buf **bpp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 40 | extern int xfs_dir2_block_addname(struct xfs_da_args *args); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 41 | extern int xfs_dir2_block_lookup(struct xfs_da_args *args); |
| 42 | extern int xfs_dir2_block_removename(struct xfs_da_args *args); |
| 43 | extern int xfs_dir2_block_replace(struct xfs_da_args *args); |
| 44 | extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 45 | struct xfs_buf *lbp, struct xfs_buf *dbp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 46 | |
| 47 | /* xfs_dir2_data.c */ |
| 48 | #ifdef DEBUG |
Darrick J. Wong | a6a781a | 2018-01-08 10:51:03 -0800 | [diff] [blame] | 49 | extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 50 | #else |
Dave Chinner | 33363fe | 2013-04-03 16:11:22 +1100 | [diff] [blame] | 51 | #define xfs_dir3_data_check(dp,bp) |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 52 | #endif |
Dave Chinner | 1813dd6 | 2012-11-14 17:54:40 +1100 | [diff] [blame] | 53 | |
Darrick J. Wong | a6a781a | 2018-01-08 10:51:03 -0800 | [diff] [blame] | 54 | extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp, |
| 55 | struct xfs_buf *bp); |
Dave Chinner | 33363fe | 2013-04-03 16:11:22 +1100 | [diff] [blame] | 56 | extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp, |
Dave Chinner | e481357 | 2012-11-12 22:54:14 +1100 | [diff] [blame] | 57 | xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp); |
Eric Sandeen | 9df2dd0 | 2014-04-14 19:01:59 +1000 | [diff] [blame] | 58 | extern int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno, |
| 59 | xfs_daddr_t mapped_bno); |
Dave Chinner | 82025d7 | 2012-11-12 22:54:12 +1100 | [diff] [blame] | 60 | |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 61 | extern struct xfs_dir2_data_free * |
| 62 | xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr, |
Dave Chinner | 2ca9877 | 2013-10-29 22:11:49 +1100 | [diff] [blame] | 63 | struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup, |
| 64 | int *loghead); |
Dave Chinner | f5f3d9b | 2013-04-03 16:11:20 +1100 | [diff] [blame] | 65 | extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 66 | struct xfs_buf **bpp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 67 | |
| 68 | /* xfs_dir2_leaf.c */ |
Christoph Hellwig | 5184255 | 2019-11-08 14:57:49 -0800 | [diff] [blame^] | 69 | void xfs_dir2_leaf_hdr_from_disk(struct xfs_mount *mp, |
| 70 | struct xfs_dir3_icleaf_hdr *to, struct xfs_dir2_leaf *from); |
Darrick J. Wong | 2678809 | 2017-06-16 11:00:07 -0700 | [diff] [blame] | 71 | extern int xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 72 | xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp); |
Dave Chinner | 24df33b | 2013-04-12 07:30:21 +1000 | [diff] [blame] | 73 | extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp, |
Dave Chinner | e6f7667 | 2012-11-12 22:54:15 +1100 | [diff] [blame] | 74 | xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 75 | extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 76 | struct xfs_buf *dbp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 77 | extern int xfs_dir2_leaf_addname(struct xfs_da_args *args); |
Dave Chinner | 24df33b | 2013-04-12 07:30:21 +1000 | [diff] [blame] | 78 | extern void xfs_dir3_leaf_compact(struct xfs_da_args *args, |
| 79 | struct xfs_dir3_icleaf_hdr *leafhdr, struct xfs_buf *bp); |
| 80 | extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr, |
| 81 | struct xfs_dir2_leaf_entry *ents, int *indexp, |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 82 | int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); |
Dave Chinner | 24df33b | 2013-04-12 07:30:21 +1000 | [diff] [blame] | 83 | extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 84 | struct xfs_buf **bpp, uint16_t magic); |
Dave Chinner | bc85178 | 2014-06-06 15:20:54 +1000 | [diff] [blame] | 85 | extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args, |
Dave Chinner | 4141956 | 2013-10-29 22:11:50 +1100 | [diff] [blame] | 86 | struct xfs_buf *bp, int first, int last); |
Dave Chinner | bc85178 | 2014-06-06 15:20:54 +1000 | [diff] [blame] | 87 | extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 88 | struct xfs_buf *bp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 89 | extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); |
| 90 | extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); |
| 91 | extern int xfs_dir2_leaf_replace(struct xfs_da_args *args); |
| 92 | extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 93 | struct xfs_buf *lbp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 94 | extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 95 | struct xfs_buf *lbp, xfs_dir2_db_t db); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 96 | extern struct xfs_dir2_leaf_entry * |
Dave Chinner | 24df33b | 2013-04-12 07:30:21 +1000 | [diff] [blame] | 97 | xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr, |
| 98 | struct xfs_dir2_leaf_entry *ents, int index, int compact, |
| 99 | int lowstale, int highstale, int *lfloglow, int *lfloghigh); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 100 | extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state); |
| 101 | |
Darrick J. Wong | a6a781a | 2018-01-08 10:51:03 -0800 | [diff] [blame] | 102 | extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp, |
| 103 | struct xfs_inode *dp, struct xfs_dir3_icleaf_hdr *hdr, |
| 104 | struct xfs_dir2_leaf *leaf); |
Dave Chinner | 24df33b | 2013-04-12 07:30:21 +1000 | [diff] [blame] | 105 | |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 106 | /* xfs_dir2_node.c */ |
| 107 | extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 108 | struct xfs_buf *lbp); |
Darrick J. Wong | 8e8877e | 2017-06-16 11:00:13 -0700 | [diff] [blame] | 109 | extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp, |
Dave Chinner | 4141956 | 2013-10-29 22:11:50 +1100 | [diff] [blame] | 110 | struct xfs_buf *bp, int *count); |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 111 | extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp, |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 112 | struct xfs_da_args *args, int *indexp, |
| 113 | struct xfs_da_state *state); |
Dave Chinner | 4141956 | 2013-10-29 22:11:50 +1100 | [diff] [blame] | 114 | extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp, |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 115 | struct xfs_buf *leaf2_bp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 116 | extern int xfs_dir2_leafn_split(struct xfs_da_state *state, |
| 117 | struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk); |
| 118 | extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action); |
| 119 | extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state, |
| 120 | struct xfs_da_state_blk *drop_blk, |
| 121 | struct xfs_da_state_blk *save_blk); |
| 122 | extern int xfs_dir2_node_addname(struct xfs_da_args *args); |
| 123 | extern int xfs_dir2_node_lookup(struct xfs_da_args *args); |
| 124 | extern int xfs_dir2_node_removename(struct xfs_da_args *args); |
| 125 | extern int xfs_dir2_node_replace(struct xfs_da_args *args); |
| 126 | extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo, |
| 127 | int *rvalp); |
Dave Chinner | 2025207 | 2012-11-12 22:54:13 +1100 | [diff] [blame] | 128 | extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp, |
| 129 | xfs_dablk_t fbno, struct xfs_buf **bpp); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 130 | |
| 131 | /* xfs_dir2_sf.c */ |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 132 | extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, |
| 133 | struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp); |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 134 | extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp, |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 135 | int size, xfs_dir2_sf_hdr_t *sfhp); |
| 136 | extern int xfs_dir2_sf_addname(struct xfs_da_args *args); |
| 137 | extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 138 | extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); |
| 139 | extern int xfs_dir2_sf_removename(struct xfs_da_args *args); |
| 140 | extern int xfs_dir2_sf_replace(struct xfs_da_args *args); |
Darrick J. Wong | dc042c2 | 2018-01-08 10:51:06 -0800 | [diff] [blame] | 141 | extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip); |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 142 | |
Dave Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 143 | /* xfs_dir2_readdir.c */ |
Darrick J. Wong | acb9553 | 2017-06-16 11:00:14 -0700 | [diff] [blame] | 144 | extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp, |
| 145 | struct dir_context *ctx, size_t bufsize); |
Dave Chinner | c24b5df | 2013-08-12 20:49:45 +1000 | [diff] [blame] | 146 | |
Christoph Hellwig | 5792664 | 2011-07-13 13:43:48 +0200 | [diff] [blame] | 147 | #endif /* __XFS_DIR2_PRIV_H__ */ |