xref: /linux/fs/xfs/libxfs/xfs_attr_leaf.h (revision 856e7c4b619af622d56b3b454f7bec32a170ac99)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
4  * Copyright (c) 2013 Red Hat, Inc.
5  * All Rights Reserved.
6  */
7 #ifndef __XFS_ATTR_LEAF_H__
8 #define	__XFS_ATTR_LEAF_H__
9 
10 struct attrlist;
11 struct attrlist_cursor_kern;
12 struct xfs_attr_list_context;
13 struct xfs_da_args;
14 struct xfs_da_state;
15 struct xfs_da_state_blk;
16 struct xfs_inode;
17 struct xfs_trans;
18 
19 /*
20  * Used to keep a list of "remote value" extents when unlinking an inode.
21  */
22 typedef struct xfs_attr_inactive_list {
23 	xfs_dablk_t	valueblk;	/* block number of value bytes */
24 	int		valuelen;	/* number of bytes in value */
25 } xfs_attr_inactive_list_t;
26 
27 
28 /*========================================================================
29  * Function prototypes for the kernel.
30  *========================================================================*/
31 
32 /*
33  * Internal routines when attribute fork size < XFS_LITINO(mp).
34  */
35 void	xfs_attr_shortform_create(struct xfs_da_args *args);
36 void	xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
37 int	xfs_attr_shortform_lookup(struct xfs_da_args *args);
38 int	xfs_attr_shortform_getvalue(struct xfs_da_args *args);
39 int	xfs_attr_shortform_to_leaf(struct xfs_da_args *args,
40 			struct xfs_buf **leaf_bp);
41 int	xfs_attr_shortform_remove(struct xfs_da_args *args);
42 int	xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
43 int	xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
44 xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip);
45 void	xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
46 
47 /*
48  * Internal routines when attribute fork size == XFS_LBSIZE(mp).
49  */
50 int	xfs_attr3_leaf_to_node(struct xfs_da_args *args);
51 int	xfs_attr3_leaf_to_shortform(struct xfs_buf *bp,
52 				   struct xfs_da_args *args, int forkoff);
53 int	xfs_attr3_leaf_clearflag(struct xfs_da_args *args);
54 int	xfs_attr3_leaf_setflag(struct xfs_da_args *args);
55 int	xfs_attr3_leaf_flipflags(struct xfs_da_args *args);
56 
57 /*
58  * Routines used for growing the Btree.
59  */
60 int	xfs_attr3_leaf_split(struct xfs_da_state *state,
61 				   struct xfs_da_state_blk *oldblk,
62 				   struct xfs_da_state_blk *newblk);
63 int	xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf,
64 					struct xfs_da_args *args);
65 int	xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
66 int	xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
67 				 struct xfs_da_args *args);
68 int	xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
69 				    struct xfs_da_args *args);
70 void	xfs_attr3_leaf_list_int(struct xfs_buf *bp,
71 				      struct xfs_attr_list_context *context);
72 
73 /*
74  * Routines used for shrinking the Btree.
75  */
76 int	xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);
77 void	xfs_attr3_leaf_unbalance(struct xfs_da_state *state,
78 				       struct xfs_da_state_blk *drop_blk,
79 				       struct xfs_da_state_blk *save_blk);
80 /*
81  * Utility routines.
82  */
83 xfs_dahash_t	xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
84 int	xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
85 				   struct xfs_buf *leaf2_bp);
86 int	xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local);
87 int	xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
88 			xfs_dablk_t bno, xfs_daddr_t mappedbno,
89 			struct xfs_buf **bpp);
90 void	xfs_attr3_leaf_hdr_from_disk(struct xfs_da_geometry *geo,
91 				     struct xfs_attr3_icleaf_hdr *to,
92 				     struct xfs_attr_leafblock *from);
93 void	xfs_attr3_leaf_hdr_to_disk(struct xfs_da_geometry *geo,
94 				   struct xfs_attr_leafblock *to,
95 				   struct xfs_attr3_icleaf_hdr *from);
96 
97 #endif	/* __XFS_ATTR_LEAF_H__ */
98