blob: 5f42f2c81869e66375eec3db1bdaf77cdd672a2e [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;
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
Christoph Hellwig57926642011-07-13 13:43:48 +020030/* xfs_dir2.c */
Christoph Hellwig57926642011-07-13 13:43:48 +020031extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
32 xfs_dir2_db_t *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020033extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
34 const unsigned char *name, int len);
35
Dave Chinner0cb97762013-08-12 20:50:09 +100036
Christoph Hellwig57926642011-07-13 13:43:48 +020037/* xfs_dir2_block.c */
Dave Chinner4a8af272013-08-12 20:49:36 +100038extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp,
39 struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020040extern int xfs_dir2_block_addname(struct xfs_da_args *args);
Christoph Hellwig57926642011-07-13 13:43:48 +020041extern 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,
Dave Chinner1d9025e2012-06-22 18:50:14 +100045 struct xfs_buf *lbp, struct xfs_buf *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020046
47/* xfs_dir2_data.c */
48#ifdef DEBUG
Darrick J. Wonga6a781a2018-01-08 10:51:03 -080049extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
Christoph Hellwig57926642011-07-13 13:43:48 +020050#else
Dave Chinner33363fe2013-04-03 16:11:22 +110051#define xfs_dir3_data_check(dp,bp)
Christoph Hellwig57926642011-07-13 13:43:48 +020052#endif
Dave Chinner1813dd62012-11-14 17:54:40 +110053
Darrick J. Wonga6a781a2018-01-08 10:51:03 -080054extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
55 struct xfs_buf *bp);
Dave Chinner33363fe2013-04-03 16:11:22 +110056extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
Dave Chinnere4813572012-11-12 22:54:14 +110057 xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
Eric Sandeen9df2dd02014-04-14 19:01:59 +100058extern int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
59 xfs_daddr_t mapped_bno);
Dave Chinner82025d72012-11-12 22:54:12 +110060
Christoph Hellwig57926642011-07-13 13:43:48 +020061extern struct xfs_dir2_data_free *
62xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
Dave Chinner2ca98772013-10-29 22:11:49 +110063 struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup,
64 int *loghead);
Dave Chinnerf5f3d9b2013-04-03 16:11:20 +110065extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
Dave Chinner1d9025e2012-06-22 18:50:14 +100066 struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020067
68/* xfs_dir2_leaf.c */
Christoph Hellwig51842552019-11-08 14:57:49 -080069void xfs_dir2_leaf_hdr_from_disk(struct xfs_mount *mp,
70 struct xfs_dir3_icleaf_hdr *to, struct xfs_dir2_leaf *from);
Darrick J. Wong26788092017-06-16 11:00:07 -070071extern 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 Chinner24df33b2013-04-12 07:30:21 +100073extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
Dave Chinnere6f76672012-11-12 22:54:15 +110074 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020075extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100076 struct xfs_buf *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020077extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
Dave Chinner24df33b2013-04-12 07:30:21 +100078extern void xfs_dir3_leaf_compact(struct xfs_da_args *args,
79 struct xfs_dir3_icleaf_hdr *leafhdr, struct xfs_buf *bp);
80extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,
81 struct xfs_dir2_leaf_entry *ents, int *indexp,
Christoph Hellwig57926642011-07-13 13:43:48 +020082 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
Dave Chinner24df33b2013-04-12 07:30:21 +100083extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno,
Darrick J. Wongc8ce5402017-06-16 11:00:05 -070084 struct xfs_buf **bpp, uint16_t magic);
Dave Chinnerbc851782014-06-06 15:20:54 +100085extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args,
Dave Chinner41419562013-10-29 22:11:50 +110086 struct xfs_buf *bp, int first, int last);
Dave Chinnerbc851782014-06-06 15:20:54 +100087extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100088 struct xfs_buf *bp);
Christoph Hellwig57926642011-07-13 13:43:48 +020089extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
90extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
91extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
92extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100093 struct xfs_buf *lbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020094extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100095 struct xfs_buf *lbp, xfs_dir2_db_t db);
Christoph Hellwig57926642011-07-13 13:43:48 +020096extern struct xfs_dir2_leaf_entry *
Dave Chinner24df33b2013-04-12 07:30:21 +100097xfs_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 Hellwig57926642011-07-13 13:43:48 +0200100extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
101
Darrick J. Wonga6a781a2018-01-08 10:51:03 -0800102extern 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 Chinner24df33b2013-04-12 07:30:21 +1000105
Christoph Hellwig57926642011-07-13 13:43:48 +0200106/* xfs_dir2_node.c */
107extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000108 struct xfs_buf *lbp);
Darrick J. Wong8e8877e2017-06-16 11:00:13 -0700109extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,
Dave Chinner41419562013-10-29 22:11:50 +1100110 struct xfs_buf *bp, int *count);
Dave Chinner1d9025e2012-06-22 18:50:14 +1000111extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
Christoph Hellwig57926642011-07-13 13:43:48 +0200112 struct xfs_da_args *args, int *indexp,
113 struct xfs_da_state *state);
Dave Chinner41419562013-10-29 22:11:50 +1100114extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000115 struct xfs_buf *leaf2_bp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200116extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
117 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk);
118extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
119extern 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);
122extern int xfs_dir2_node_addname(struct xfs_da_args *args);
123extern int xfs_dir2_node_lookup(struct xfs_da_args *args);
124extern int xfs_dir2_node_removename(struct xfs_da_args *args);
125extern int xfs_dir2_node_replace(struct xfs_da_args *args);
126extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo,
127 int *rvalp);
Dave Chinner20252072012-11-12 22:54:13 +1100128extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,
129 xfs_dablk_t fbno, struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200130
131/* xfs_dir2_sf.c */
Christoph Hellwig57926642011-07-13 13:43:48 +0200132extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
133 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
Dave Chinner1d9025e2012-06-22 18:50:14 +1000134extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
Christoph Hellwig57926642011-07-13 13:43:48 +0200135 int size, xfs_dir2_sf_hdr_t *sfhp);
136extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
137extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
Christoph Hellwig57926642011-07-13 13:43:48 +0200138extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
139extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
140extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
Darrick J. Wongdc042c22018-01-08 10:51:06 -0800141extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip);
Christoph Hellwig57926642011-07-13 13:43:48 +0200142
Dave Chinnerc24b5df2013-08-12 20:49:45 +1000143/* xfs_dir2_readdir.c */
Darrick J. Wongacb95532017-06-16 11:00:14 -0700144extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
145 struct dir_context *ctx, size_t bufsize);
Dave Chinnerc24b5df2013-08-12 20:49:45 +1000146
Christoph Hellwig57926642011-07-13 13:43:48 +0200147#endif /* __XFS_DIR2_PRIV_H__ */