Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_DIR2_PRIV_H__
0007 #define __XFS_DIR2_PRIV_H__
0008 
0009 struct dir_context;
0010 
0011 /*
0012  * In-core version of the leaf and free block headers to abstract the
0013  * differences in the v2 and v3 disk format of the headers.
0014  */
0015 struct xfs_dir3_icleaf_hdr {
0016     uint32_t        forw;
0017     uint32_t        back;
0018     uint16_t        magic;
0019     uint16_t        count;
0020     uint16_t        stale;
0021 
0022     /*
0023      * Pointer to the on-disk format entries, which are behind the
0024      * variable size (v4 vs v5) header in the on-disk block.
0025      */
0026     struct xfs_dir2_leaf_entry *ents;
0027 };
0028 
0029 struct xfs_dir3_icfree_hdr {
0030     uint32_t        magic;
0031     uint32_t        firstdb;
0032     uint32_t        nvalid;
0033     uint32_t        nused;
0034 
0035     /*
0036      * Pointer to the on-disk format entries, which are behind the
0037      * variable size (v4 vs v5) header in the on-disk block.
0038      */
0039     __be16          *bests;
0040 };
0041 
0042 /* xfs_dir2.c */
0043 xfs_dahash_t xfs_ascii_ci_hashname(const struct xfs_name *name);
0044 enum xfs_dacmp xfs_ascii_ci_compname(struct xfs_da_args *args,
0045         const unsigned char *name, int len);
0046 extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
0047                 xfs_dir2_db_t *dbp);
0048 extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
0049                 const unsigned char *name, int len);
0050 
0051 
0052 /* xfs_dir2_block.c */
0053 extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp,
0054                    struct xfs_buf **bpp);
0055 extern int xfs_dir2_block_addname(struct xfs_da_args *args);
0056 extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
0057 extern int xfs_dir2_block_removename(struct xfs_da_args *args);
0058 extern int xfs_dir2_block_replace(struct xfs_da_args *args);
0059 extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
0060         struct xfs_buf *lbp, struct xfs_buf *dbp);
0061 
0062 /* xfs_dir2_data.c */
0063 struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p(struct xfs_mount *mp,
0064         struct xfs_dir2_data_hdr *hdr);
0065 __be16 *xfs_dir2_data_entry_tag_p(struct xfs_mount *mp,
0066         struct xfs_dir2_data_entry *dep);
0067 uint8_t xfs_dir2_data_get_ftype(struct xfs_mount *mp,
0068         struct xfs_dir2_data_entry *dep);
0069 void xfs_dir2_data_put_ftype(struct xfs_mount *mp,
0070         struct xfs_dir2_data_entry *dep, uint8_t ftype);
0071 
0072 #ifdef DEBUG
0073 extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
0074 #else
0075 #define xfs_dir3_data_check(dp,bp)
0076 #endif
0077 
0078 extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
0079         struct xfs_buf *bp);
0080 int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
0081         xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp);
0082 int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
0083         unsigned int flags);
0084 
0085 extern struct xfs_dir2_data_free *
0086 xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
0087         struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup,
0088         int *loghead);
0089 extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
0090         struct xfs_buf **bpp);
0091 
0092 /* xfs_dir2_leaf.c */
0093 void xfs_dir2_leaf_hdr_from_disk(struct xfs_mount *mp,
0094         struct xfs_dir3_icleaf_hdr *to, struct xfs_dir2_leaf *from);
0095 void xfs_dir2_leaf_hdr_to_disk(struct xfs_mount *mp, struct xfs_dir2_leaf *to,
0096         struct xfs_dir3_icleaf_hdr *from);
0097 int xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
0098         xfs_dablk_t fbno, struct xfs_buf **bpp);
0099 int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp,
0100         xfs_dablk_t fbno, struct xfs_buf **bpp);
0101 extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
0102         struct xfs_buf *dbp);
0103 extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
0104 extern void xfs_dir3_leaf_compact(struct xfs_da_args *args,
0105         struct xfs_dir3_icleaf_hdr *leafhdr, struct xfs_buf *bp);
0106 extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,
0107         struct xfs_dir2_leaf_entry *ents, int *indexp,
0108         int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
0109 extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno,
0110         struct xfs_buf **bpp, uint16_t magic);
0111 extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args,
0112         struct xfs_dir3_icleaf_hdr *hdr, struct xfs_buf *bp, int first,
0113         int last);
0114 extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args,
0115         struct xfs_buf *bp);
0116 extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
0117 extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
0118 extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
0119 extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
0120         struct xfs_buf *lbp);
0121 extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
0122         struct xfs_buf *lbp, xfs_dir2_db_t db);
0123 extern struct xfs_dir2_leaf_entry *
0124 xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
0125         struct xfs_dir2_leaf_entry *ents, int index, int compact,
0126         int lowstale, int highstale, int *lfloglow, int *lfloghigh);
0127 extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
0128 
0129 extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp,
0130         struct xfs_dir3_icleaf_hdr *hdr, struct xfs_dir2_leaf *leaf,
0131         bool expensive_checks);
0132 
0133 /* xfs_dir2_node.c */
0134 void xfs_dir2_free_hdr_from_disk(struct xfs_mount *mp,
0135         struct xfs_dir3_icfree_hdr *to, struct xfs_dir2_free *from);
0136 extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
0137         struct xfs_buf *lbp);
0138 extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,
0139         struct xfs_buf *bp, int *count);
0140 extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
0141         struct xfs_da_args *args, int *indexp,
0142         struct xfs_da_state *state);
0143 extern int xfs_dir2_leafn_order(struct xfs_inode *dp, struct xfs_buf *leaf1_bp,
0144         struct xfs_buf *leaf2_bp);
0145 extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
0146     struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk);
0147 extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
0148 extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state,
0149         struct xfs_da_state_blk *drop_blk,
0150         struct xfs_da_state_blk *save_blk);
0151 extern int xfs_dir2_node_addname(struct xfs_da_args *args);
0152 extern int xfs_dir2_node_lookup(struct xfs_da_args *args);
0153 extern int xfs_dir2_node_removename(struct xfs_da_args *args);
0154 extern int xfs_dir2_node_replace(struct xfs_da_args *args);
0155 extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo,
0156         int *rvalp);
0157 extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,
0158         xfs_dablk_t fbno, struct xfs_buf **bpp);
0159 
0160 /* xfs_dir2_sf.c */
0161 xfs_ino_t xfs_dir2_sf_get_ino(struct xfs_mount *mp, struct xfs_dir2_sf_hdr *hdr,
0162         struct xfs_dir2_sf_entry *sfep);
0163 xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *hdr);
0164 void xfs_dir2_sf_put_parent_ino(struct xfs_dir2_sf_hdr *hdr, xfs_ino_t ino);
0165 uint8_t xfs_dir2_sf_get_ftype(struct xfs_mount *mp,
0166         struct xfs_dir2_sf_entry *sfep);
0167 struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry(struct xfs_mount *mp,
0168         struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_entry *sfep);
0169 extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
0170         struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
0171 extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
0172         int size, xfs_dir2_sf_hdr_t *sfhp);
0173 extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
0174 extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
0175 extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
0176 extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
0177 extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
0178 extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip);
0179 int xfs_dir2_sf_entsize(struct xfs_mount *mp,
0180         struct xfs_dir2_sf_hdr *hdr, int len);
0181 void xfs_dir2_sf_put_ino(struct xfs_mount *mp, struct xfs_dir2_sf_hdr *hdr,
0182         struct xfs_dir2_sf_entry *sfep, xfs_ino_t ino);
0183 void xfs_dir2_sf_put_ftype(struct xfs_mount *mp,
0184         struct xfs_dir2_sf_entry *sfep, uint8_t ftype);
0185 
0186 /* xfs_dir2_readdir.c */
0187 extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
0188                struct dir_context *ctx, size_t bufsize);
0189 
0190 static inline unsigned int
0191 xfs_dir2_data_entsize(
0192     struct xfs_mount    *mp,
0193     unsigned int        namelen)
0194 {
0195     unsigned int        len;
0196 
0197     len = offsetof(struct xfs_dir2_data_entry, name[0]) + namelen +
0198             sizeof(xfs_dir2_data_off_t) /* tag */;
0199     if (xfs_has_ftype(mp))
0200         len += sizeof(uint8_t);
0201     return round_up(len, XFS_DIR2_DATA_ALIGN);
0202 }
0203 
0204 xfs_dahash_t xfs_dir2_hashname(struct xfs_mount *mp,
0205         const struct xfs_name *name);
0206 enum xfs_dacmp xfs_dir2_compname(struct xfs_da_args *args,
0207         const unsigned char *name, int len);
0208 
0209 #endif /* __XFS_DIR2_PRIV_H__ */