18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
48c2ecf20Sopenharmony_ci * Copyright (c) 2013 Red Hat, Inc.
58c2ecf20Sopenharmony_ci * All Rights Reserved.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef __XFS_ATTR_LEAF_H__
88c2ecf20Sopenharmony_ci#define	__XFS_ATTR_LEAF_H__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistruct attrlist;
118c2ecf20Sopenharmony_cistruct xfs_attr_list_context;
128c2ecf20Sopenharmony_cistruct xfs_da_args;
138c2ecf20Sopenharmony_cistruct xfs_da_state;
148c2ecf20Sopenharmony_cistruct xfs_da_state_blk;
158c2ecf20Sopenharmony_cistruct xfs_inode;
168c2ecf20Sopenharmony_cistruct xfs_trans;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/*
198c2ecf20Sopenharmony_ci * Incore version of the attribute leaf header.
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_cistruct xfs_attr3_icleaf_hdr {
228c2ecf20Sopenharmony_ci	uint32_t	forw;
238c2ecf20Sopenharmony_ci	uint32_t	back;
248c2ecf20Sopenharmony_ci	uint16_t	magic;
258c2ecf20Sopenharmony_ci	uint16_t	count;
268c2ecf20Sopenharmony_ci	uint16_t	usedbytes;
278c2ecf20Sopenharmony_ci	/*
288c2ecf20Sopenharmony_ci	 * Firstused is 32-bit here instead of 16-bit like the on-disk variant
298c2ecf20Sopenharmony_ci	 * to support maximum fsb size of 64k without overflow issues throughout
308c2ecf20Sopenharmony_ci	 * the attr code. Instead, the overflow condition is handled on
318c2ecf20Sopenharmony_ci	 * conversion to/from disk.
328c2ecf20Sopenharmony_ci	 */
338c2ecf20Sopenharmony_ci	uint32_t	firstused;
348c2ecf20Sopenharmony_ci	__u8		holes;
358c2ecf20Sopenharmony_ci	struct {
368c2ecf20Sopenharmony_ci		uint16_t	base;
378c2ecf20Sopenharmony_ci		uint16_t	size;
388c2ecf20Sopenharmony_ci	} freemap[XFS_ATTR_LEAF_MAPSIZE];
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/*========================================================================
428c2ecf20Sopenharmony_ci * Function prototypes for the kernel.
438c2ecf20Sopenharmony_ci *========================================================================*/
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/*
468c2ecf20Sopenharmony_ci * Internal routines when attribute fork size < XFS_LITINO(mp).
478c2ecf20Sopenharmony_ci */
488c2ecf20Sopenharmony_civoid	xfs_attr_shortform_create(struct xfs_da_args *args);
498c2ecf20Sopenharmony_civoid	xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
508c2ecf20Sopenharmony_ciint	xfs_attr_shortform_lookup(struct xfs_da_args *args);
518c2ecf20Sopenharmony_ciint	xfs_attr_shortform_getvalue(struct xfs_da_args *args);
528c2ecf20Sopenharmony_ciint	xfs_attr_shortform_to_leaf(struct xfs_da_args *args,
538c2ecf20Sopenharmony_ci			struct xfs_buf **leaf_bp);
548c2ecf20Sopenharmony_ciint	xfs_attr_shortform_remove(struct xfs_da_args *args);
558c2ecf20Sopenharmony_ciint	xfs_attr_sf_findname(struct xfs_da_args *args,
568c2ecf20Sopenharmony_ci			     struct xfs_attr_sf_entry **sfep,
578c2ecf20Sopenharmony_ci			     unsigned int *basep);
588c2ecf20Sopenharmony_ciint	xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
598c2ecf20Sopenharmony_ciint	xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
608c2ecf20Sopenharmony_cixfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip);
618c2ecf20Sopenharmony_civoid	xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/*
648c2ecf20Sopenharmony_ci * Internal routines when attribute fork size == XFS_LBSIZE(mp).
658c2ecf20Sopenharmony_ci */
668c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_to_node(struct xfs_da_args *args);
678c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_to_shortform(struct xfs_buf *bp,
688c2ecf20Sopenharmony_ci				   struct xfs_da_args *args, int forkoff);
698c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_clearflag(struct xfs_da_args *args);
708c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_setflag(struct xfs_da_args *args);
718c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_flipflags(struct xfs_da_args *args);
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/*
748c2ecf20Sopenharmony_ci * Routines used for growing the Btree.
758c2ecf20Sopenharmony_ci */
768c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_split(struct xfs_da_state *state,
778c2ecf20Sopenharmony_ci				   struct xfs_da_state_blk *oldblk,
788c2ecf20Sopenharmony_ci				   struct xfs_da_state_blk *newblk);
798c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf,
808c2ecf20Sopenharmony_ci					struct xfs_da_args *args);
818c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
828c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
838c2ecf20Sopenharmony_ci				 struct xfs_da_args *args);
848c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
858c2ecf20Sopenharmony_ci				    struct xfs_da_args *args);
868c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_list_int(struct xfs_buf *bp,
878c2ecf20Sopenharmony_ci				struct xfs_attr_list_context *context);
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/*
908c2ecf20Sopenharmony_ci * Routines used for shrinking the Btree.
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);
938c2ecf20Sopenharmony_civoid	xfs_attr3_leaf_unbalance(struct xfs_da_state *state,
948c2ecf20Sopenharmony_ci				       struct xfs_da_state_blk *drop_blk,
958c2ecf20Sopenharmony_ci				       struct xfs_da_state_blk *save_blk);
968c2ecf20Sopenharmony_ci/*
978c2ecf20Sopenharmony_ci * Utility routines.
988c2ecf20Sopenharmony_ci */
998c2ecf20Sopenharmony_cixfs_dahash_t	xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
1008c2ecf20Sopenharmony_ciint	xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
1018c2ecf20Sopenharmony_ci				   struct xfs_buf *leaf2_bp);
1028c2ecf20Sopenharmony_ciint	xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local);
1038c2ecf20Sopenharmony_ciint	xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
1048c2ecf20Sopenharmony_ci			xfs_dablk_t bno, struct xfs_buf **bpp);
1058c2ecf20Sopenharmony_civoid	xfs_attr3_leaf_hdr_from_disk(struct xfs_da_geometry *geo,
1068c2ecf20Sopenharmony_ci				     struct xfs_attr3_icleaf_hdr *to,
1078c2ecf20Sopenharmony_ci				     struct xfs_attr_leafblock *from);
1088c2ecf20Sopenharmony_civoid	xfs_attr3_leaf_hdr_to_disk(struct xfs_da_geometry *geo,
1098c2ecf20Sopenharmony_ci				   struct xfs_attr_leafblock *to,
1108c2ecf20Sopenharmony_ci				   struct xfs_attr3_icleaf_hdr *from);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#endif	/* __XFS_ATTR_LEAF_H__ */
113