blob: efa757f1e912c7ac8ba642c6a9586c02479d1064 [file] [log] [blame]
Nishad Kamdar508578f2020-05-12 16:54:17 -07001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
Dave Chinner517c2222013-04-24 18:58:55 +10004 * Copyright (c) 2013 Red Hat, Inc.
Nathan Scottaa82daa2005-11-02 10:33:33 +11005 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7#ifndef __XFS_ATTR_LEAF_H__
8#define __XFS_ATTR_LEAF_H__
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010struct attrlist;
Christoph Hellwigad9b4632008-06-23 13:23:48 +100011struct xfs_attr_list_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012struct xfs_da_args;
13struct xfs_da_state;
14struct xfs_da_state_blk;
15struct xfs_inode;
16struct xfs_trans;
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018/*
Christoph Hellwiga39f089a2019-11-08 14:52:06 -080019 * Incore version of the attribute leaf header.
20 */
21struct xfs_attr3_icleaf_hdr {
22 uint32_t forw;
23 uint32_t back;
24 uint16_t magic;
25 uint16_t count;
26 uint16_t usedbytes;
27 /*
28 * Firstused is 32-bit here instead of 16-bit like the on-disk variant
29 * to support maximum fsb size of 64k without overflow issues throughout
30 * the attr code. Instead, the overflow condition is handled on
31 * conversion to/from disk.
32 */
33 uint32_t firstused;
34 __u8 holes;
35 struct {
36 uint16_t base;
37 uint16_t size;
38 } freemap[XFS_ATTR_LEAF_MAPSIZE];
39};
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/*========================================================================
42 * Function prototypes for the kernel.
43 *========================================================================*/
44
45/*
Nathan Scottd8cc8902005-11-02 10:34:53 +110046 * Internal routines when attribute fork size < XFS_LITINO(mp).
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 */
Nathan Scottd8cc8902005-11-02 10:34:53 +110048void xfs_attr_shortform_create(struct xfs_da_args *args);
49void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050int xfs_attr_shortform_lookup(struct xfs_da_args *args);
51int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
Darrick J. Wong6e643cd2017-12-07 19:07:02 -080052int xfs_attr_shortform_to_leaf(struct xfs_da_args *args,
53 struct xfs_buf **leaf_bp);
Allison Henderson816c8e32021-05-28 15:15:05 -070054int xfs_attr_sf_removename(struct xfs_da_args *args);
Allison Collins07120f12020-07-20 21:47:22 -070055int xfs_attr_sf_findname(struct xfs_da_args *args,
56 struct xfs_attr_sf_entry **sfep,
57 unsigned int *basep);
Dave Chinner1d9025e2012-06-22 18:50:14 +100058int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
Darrick J. Wongae90b992016-11-08 11:56:20 +110059int xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
Darrick J. Wong1e1bbd82018-01-08 10:51:05 -080060xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip);
Dave Chinner6dfe5a02015-05-29 07:40:08 +100061void xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63/*
Nathan Scottd8cc8902005-11-02 10:34:53 +110064 * Internal routines when attribute fork size == XFS_LBSIZE(mp).
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 */
Dave Chinner517c2222013-04-24 18:58:55 +100066int xfs_attr3_leaf_to_node(struct xfs_da_args *args);
67int xfs_attr3_leaf_to_shortform(struct xfs_buf *bp,
Nathan Scottd8cc8902005-11-02 10:34:53 +110068 struct xfs_da_args *args, int forkoff);
Dave Chinner517c2222013-04-24 18:58:55 +100069int xfs_attr3_leaf_clearflag(struct xfs_da_args *args);
70int xfs_attr3_leaf_setflag(struct xfs_da_args *args);
71int xfs_attr3_leaf_flipflags(struct xfs_da_args *args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73/*
74 * Routines used for growing the Btree.
75 */
Dave Chinner517c2222013-04-24 18:58:55 +100076int xfs_attr3_leaf_split(struct xfs_da_state *state,
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 struct xfs_da_state_blk *oldblk,
78 struct xfs_da_state_blk *newblk);
Dave Chinner517c2222013-04-24 18:58:55 +100079int xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf,
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 struct xfs_da_args *args);
Dave Chinner517c2222013-04-24 18:58:55 +100081int xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
82int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 struct xfs_da_args *args);
Dave Chinner517c2222013-04-24 18:58:55 +100084int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 struct xfs_da_args *args);
Darrick J. Wong16c6e922019-10-28 16:12:33 -070086int xfs_attr3_leaf_list_int(struct xfs_buf *bp,
87 struct xfs_attr_list_context *context);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89/*
90 * Routines used for shrinking the Btree.
91 */
Dave Chinner517c2222013-04-24 18:58:55 +100092int xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);
93void xfs_attr3_leaf_unbalance(struct xfs_da_state *state,
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 struct xfs_da_state_blk *drop_blk,
95 struct xfs_da_state_blk *save_blk);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096/*
97 * Utility routines.
98 */
Dave Chinner1d9025e2012-06-22 18:50:14 +100099xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
100int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
101 struct xfs_buf *leaf2_bp);
Dave Chinnerc59f0ad2014-06-06 15:21:27 +1000102int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local);
Dave Chinner517c2222013-04-24 18:58:55 +1000103int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
Christoph Hellwigdfb87592019-11-20 09:46:02 -0800104 xfs_dablk_t bno, struct xfs_buf **bpp);
Brian Foster2f661242015-04-13 11:26:02 +1000105void xfs_attr3_leaf_hdr_from_disk(struct xfs_da_geometry *geo,
106 struct xfs_attr3_icleaf_hdr *to,
Dave Chinner517c2222013-04-24 18:58:55 +1000107 struct xfs_attr_leafblock *from);
Brian Foster2f661242015-04-13 11:26:02 +1000108void xfs_attr3_leaf_hdr_to_disk(struct xfs_da_geometry *geo,
109 struct xfs_attr_leafblock *to,
Dave Chinnerd386b322013-08-12 20:49:31 +1000110 struct xfs_attr3_icleaf_hdr *from);
Dave Chinner1813dd62012-11-14 17:54:40 +1100111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#endif /* __XFS_ATTR_LEAF_H__ */