blob: 2c3370a3c010a9afdec10e7ba56ef181d75db59d [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;
34};
35
Christoph Hellwig57926642011-07-13 13:43:48 +020036/* xfs_dir2.c */
Christoph Hellwig57926642011-07-13 13:43:48 +020037extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
38 xfs_dir2_db_t *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020039extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
40 const unsigned char *name, int len);
41
Dave Chinner0cb97762013-08-12 20:50:09 +100042
Christoph Hellwig57926642011-07-13 13:43:48 +020043/* xfs_dir2_block.c */
Dave Chinner4a8af272013-08-12 20:49:36 +100044extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp,
45 struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020046extern int xfs_dir2_block_addname(struct xfs_da_args *args);
Christoph Hellwig57926642011-07-13 13:43:48 +020047extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
48extern int xfs_dir2_block_removename(struct xfs_da_args *args);
49extern int xfs_dir2_block_replace(struct xfs_da_args *args);
50extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100051 struct xfs_buf *lbp, struct xfs_buf *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020052
53/* xfs_dir2_data.c */
54#ifdef DEBUG
Darrick J. Wonga6a781a2018-01-08 10:51:03 -080055extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
Christoph Hellwig57926642011-07-13 13:43:48 +020056#else
Dave Chinner33363fe2013-04-03 16:11:22 +110057#define xfs_dir3_data_check(dp,bp)
Christoph Hellwig57926642011-07-13 13:43:48 +020058#endif
Dave Chinner1813dd62012-11-14 17:54:40 +110059
Darrick J. Wonga6a781a2018-01-08 10:51:03 -080060extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
61 struct xfs_buf *bp);
Dave Chinner33363fe2013-04-03 16:11:22 +110062extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
Dave Chinnere4813572012-11-12 22:54:14 +110063 xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
Eric Sandeen9df2dd02014-04-14 19:01:59 +100064extern int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
65 xfs_daddr_t mapped_bno);
Dave Chinner82025d72012-11-12 22:54:12 +110066
Christoph Hellwig57926642011-07-13 13:43:48 +020067extern struct xfs_dir2_data_free *
68xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
Dave Chinner2ca98772013-10-29 22:11:49 +110069 struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup,
70 int *loghead);
Dave Chinnerf5f3d9b2013-04-03 16:11:20 +110071extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
Dave Chinner1d9025e2012-06-22 18:50:14 +100072 struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020073
74/* xfs_dir2_leaf.c */
Christoph Hellwig51842552019-11-08 14:57:49 -080075void xfs_dir2_leaf_hdr_from_disk(struct xfs_mount *mp,
76 struct xfs_dir3_icleaf_hdr *to, struct xfs_dir2_leaf *from);
Christoph Hellwig163fbbb2019-11-08 14:57:50 -080077void xfs_dir2_leaf_hdr_to_disk(struct xfs_mount *mp, struct xfs_dir2_leaf *to,
78 struct xfs_dir3_icleaf_hdr *from);
Darrick J. Wong26788092017-06-16 11:00:07 -070079extern int xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
80 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
Dave Chinner24df33b2013-04-12 07:30:21 +100081extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
Dave Chinnere6f76672012-11-12 22:54:15 +110082 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +020083extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100084 struct xfs_buf *dbp);
Christoph Hellwig57926642011-07-13 13:43:48 +020085extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
Dave Chinner24df33b2013-04-12 07:30:21 +100086extern void xfs_dir3_leaf_compact(struct xfs_da_args *args,
87 struct xfs_dir3_icleaf_hdr *leafhdr, struct xfs_buf *bp);
88extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,
89 struct xfs_dir2_leaf_entry *ents, int *indexp,
Christoph Hellwig57926642011-07-13 13:43:48 +020090 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
Dave Chinner24df33b2013-04-12 07:30:21 +100091extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno,
Darrick J. Wongc8ce5402017-06-16 11:00:05 -070092 struct xfs_buf **bpp, uint16_t magic);
Dave Chinnerbc851782014-06-06 15:20:54 +100093extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args,
Christoph Hellwig787b0892019-11-08 14:57:50 -080094 struct xfs_dir3_icleaf_hdr *hdr, struct xfs_buf *bp, int first,
95 int last);
Dave Chinnerbc851782014-06-06 15:20:54 +100096extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +100097 struct xfs_buf *bp);
Christoph Hellwig57926642011-07-13 13:43:48 +020098extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
99extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
100extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
101extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000102 struct xfs_buf *lbp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200103extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000104 struct xfs_buf *lbp, xfs_dir2_db_t db);
Christoph Hellwig57926642011-07-13 13:43:48 +0200105extern struct xfs_dir2_leaf_entry *
Dave Chinner24df33b2013-04-12 07:30:21 +1000106xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
107 struct xfs_dir2_leaf_entry *ents, int index, int compact,
108 int lowstale, int highstale, int *lfloglow, int *lfloghigh);
Christoph Hellwig57926642011-07-13 13:43:48 +0200109extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
110
Darrick J. Wonga6a781a2018-01-08 10:51:03 -0800111extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp,
Christoph Hellwig5ba30912019-11-08 14:57:52 -0800112 struct xfs_dir3_icleaf_hdr *hdr, struct xfs_dir2_leaf *leaf);
Dave Chinner24df33b2013-04-12 07:30:21 +1000113
Christoph Hellwig57926642011-07-13 13:43:48 +0200114/* xfs_dir2_node.c */
Christoph Hellwig5ba30912019-11-08 14:57:52 -0800115void xfs_dir2_free_hdr_from_disk(struct xfs_mount *mp,
116 struct xfs_dir3_icfree_hdr *to, struct xfs_dir2_free *from);
Christoph Hellwig57926642011-07-13 13:43:48 +0200117extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000118 struct xfs_buf *lbp);
Darrick J. Wong8e8877e2017-06-16 11:00:13 -0700119extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,
Dave Chinner41419562013-10-29 22:11:50 +1100120 struct xfs_buf *bp, int *count);
Dave Chinner1d9025e2012-06-22 18:50:14 +1000121extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
Christoph Hellwig57926642011-07-13 13:43:48 +0200122 struct xfs_da_args *args, int *indexp,
123 struct xfs_da_state *state);
Dave Chinner41419562013-10-29 22:11:50 +1100124extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp,
Dave Chinner1d9025e2012-06-22 18:50:14 +1000125 struct xfs_buf *leaf2_bp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200126extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
127 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk);
128extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
129extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state,
130 struct xfs_da_state_blk *drop_blk,
131 struct xfs_da_state_blk *save_blk);
132extern int xfs_dir2_node_addname(struct xfs_da_args *args);
133extern int xfs_dir2_node_lookup(struct xfs_da_args *args);
134extern int xfs_dir2_node_removename(struct xfs_da_args *args);
135extern int xfs_dir2_node_replace(struct xfs_da_args *args);
136extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo,
137 int *rvalp);
Dave Chinner20252072012-11-12 22:54:13 +1100138extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,
139 xfs_dablk_t fbno, struct xfs_buf **bpp);
Christoph Hellwig57926642011-07-13 13:43:48 +0200140
141/* xfs_dir2_sf.c */
Christoph Hellwig57926642011-07-13 13:43:48 +0200142extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
143 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
Dave Chinner1d9025e2012-06-22 18:50:14 +1000144extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
Christoph Hellwig57926642011-07-13 13:43:48 +0200145 int size, xfs_dir2_sf_hdr_t *sfhp);
146extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
147extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
Christoph Hellwig57926642011-07-13 13:43:48 +0200148extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
149extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
150extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
Darrick J. Wongdc042c22018-01-08 10:51:06 -0800151extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip);
Christoph Hellwig57926642011-07-13 13:43:48 +0200152
Dave Chinnerc24b5df2013-08-12 20:49:45 +1000153/* xfs_dir2_readdir.c */
Darrick J. Wongacb95532017-06-16 11:00:14 -0700154extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
155 struct dir_context *ctx, size_t bufsize);
Dave Chinnerc24b5df2013-08-12 20:49:45 +1000156
Christoph Hellwig57926642011-07-13 13:43:48 +0200157#endif /* __XFS_DIR2_PRIV_H__ */