Nishad Kamdar | 508578f | 2020-05-12 16:54:17 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 3 | * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc. |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 4 | * Copyright (c) 2013 Red Hat, Inc. |
Nathan Scott | aa82daa | 2005-11-02 10:33:33 +1100 | [diff] [blame] | 5 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #ifndef __XFS_ATTR_LEAF_H__ |
| 8 | #define __XFS_ATTR_LEAF_H__ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | struct attrlist; |
Christoph Hellwig | ad9b463 | 2008-06-23 13:23:48 +1000 | [diff] [blame] | 11 | struct xfs_attr_list_context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | struct xfs_da_args; |
| 13 | struct xfs_da_state; |
| 14 | struct xfs_da_state_blk; |
| 15 | struct xfs_inode; |
| 16 | struct xfs_trans; |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | /* |
Christoph Hellwig | a39f089a | 2019-11-08 14:52:06 -0800 | [diff] [blame] | 19 | * Incore version of the attribute leaf header. |
| 20 | */ |
| 21 | struct 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | /*======================================================================== |
| 42 | * Function prototypes for the kernel. |
| 43 | *========================================================================*/ |
| 44 | |
| 45 | /* |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 46 | * Internal routines when attribute fork size < XFS_LITINO(mp). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | */ |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 48 | void xfs_attr_shortform_create(struct xfs_da_args *args); |
| 49 | void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int xfs_attr_shortform_lookup(struct xfs_da_args *args); |
| 51 | int xfs_attr_shortform_getvalue(struct xfs_da_args *args); |
Darrick J. Wong | 6e643cd | 2017-12-07 19:07:02 -0800 | [diff] [blame] | 52 | int xfs_attr_shortform_to_leaf(struct xfs_da_args *args, |
| 53 | struct xfs_buf **leaf_bp); |
Allison Henderson | 816c8e3 | 2021-05-28 15:15:05 -0700 | [diff] [blame] | 54 | int xfs_attr_sf_removename(struct xfs_da_args *args); |
Allison Collins | 07120f1 | 2020-07-20 21:47:22 -0700 | [diff] [blame] | 55 | int xfs_attr_sf_findname(struct xfs_da_args *args, |
| 56 | struct xfs_attr_sf_entry **sfep, |
| 57 | unsigned int *basep); |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 58 | int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp); |
Darrick J. Wong | ae90b99 | 2016-11-08 11:56:20 +1100 | [diff] [blame] | 59 | int xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes); |
Darrick J. Wong | 1e1bbd8 | 2018-01-08 10:51:05 -0800 | [diff] [blame] | 60 | xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip); |
Dave Chinner | 6dfe5a0 | 2015-05-29 07:40:08 +1000 | [diff] [blame] | 61 | void xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 64 | * Internal routines when attribute fork size == XFS_LBSIZE(mp). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | */ |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 66 | int xfs_attr3_leaf_to_node(struct xfs_da_args *args); |
| 67 | int xfs_attr3_leaf_to_shortform(struct xfs_buf *bp, |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 68 | struct xfs_da_args *args, int forkoff); |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 69 | int xfs_attr3_leaf_clearflag(struct xfs_da_args *args); |
| 70 | int xfs_attr3_leaf_setflag(struct xfs_da_args *args); |
| 71 | int xfs_attr3_leaf_flipflags(struct xfs_da_args *args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | /* |
| 74 | * Routines used for growing the Btree. |
| 75 | */ |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 76 | int xfs_attr3_leaf_split(struct xfs_da_state *state, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | struct xfs_da_state_blk *oldblk, |
| 78 | struct xfs_da_state_blk *newblk); |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 79 | int xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | struct xfs_da_args *args); |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 81 | int xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args); |
| 82 | int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | struct xfs_da_args *args); |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 84 | int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | struct xfs_da_args *args); |
Darrick J. Wong | 16c6e92 | 2019-10-28 16:12:33 -0700 | [diff] [blame] | 86 | int xfs_attr3_leaf_list_int(struct xfs_buf *bp, |
| 87 | struct xfs_attr_list_context *context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | /* |
| 90 | * Routines used for shrinking the Btree. |
| 91 | */ |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 92 | int xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval); |
| 93 | void xfs_attr3_leaf_unbalance(struct xfs_da_state *state, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | struct xfs_da_state_blk *drop_blk, |
| 95 | struct xfs_da_state_blk *save_blk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | /* |
| 97 | * Utility routines. |
| 98 | */ |
Dave Chinner | 1d9025e | 2012-06-22 18:50:14 +1000 | [diff] [blame] | 99 | xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count); |
| 100 | int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp, |
| 101 | struct xfs_buf *leaf2_bp); |
Dave Chinner | c59f0ad | 2014-06-06 15:21:27 +1000 | [diff] [blame] | 102 | int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local); |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 103 | int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, |
Christoph Hellwig | dfb8759 | 2019-11-20 09:46:02 -0800 | [diff] [blame] | 104 | xfs_dablk_t bno, struct xfs_buf **bpp); |
Brian Foster | 2f66124 | 2015-04-13 11:26:02 +1000 | [diff] [blame] | 105 | void xfs_attr3_leaf_hdr_from_disk(struct xfs_da_geometry *geo, |
| 106 | struct xfs_attr3_icleaf_hdr *to, |
Dave Chinner | 517c222 | 2013-04-24 18:58:55 +1000 | [diff] [blame] | 107 | struct xfs_attr_leafblock *from); |
Brian Foster | 2f66124 | 2015-04-13 11:26:02 +1000 | [diff] [blame] | 108 | void xfs_attr3_leaf_hdr_to_disk(struct xfs_da_geometry *geo, |
| 109 | struct xfs_attr_leafblock *to, |
Dave Chinner | d386b32 | 2013-08-12 20:49:31 +1000 | [diff] [blame] | 110 | struct xfs_attr3_icleaf_hdr *from); |
Dave Chinner | 1813dd6 | 2012-11-14 17:54:40 +1100 | [diff] [blame] | 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #endif /* __XFS_ATTR_LEAF_H__ */ |