xfs_attr_leaf.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. struct attrlist;
  10. struct xfs_attr_list_context;
  11. struct xfs_da_args;
  12. struct xfs_da_state;
  13. struct xfs_da_state_blk;
  14. struct xfs_inode;
  15. struct xfs_trans;
  16. /*
  17. * Incore version of the attribute leaf header.
  18. */
  19. struct xfs_attr3_icleaf_hdr {
  20. uint32_t forw;
  21. uint32_t back;
  22. uint16_t magic;
  23. uint16_t count;
  24. uint16_t usedbytes;
  25. /*
  26. * Firstused is 32-bit here instead of 16-bit like the on-disk variant
  27. * to support maximum fsb size of 64k without overflow issues throughout
  28. * the attr code. Instead, the overflow condition is handled on
  29. * conversion to/from disk.
  30. */
  31. uint32_t firstused;
  32. __u8 holes;
  33. struct {
  34. uint16_t base;
  35. uint16_t size;
  36. } freemap[XFS_ATTR_LEAF_MAPSIZE];
  37. };
  38. /*========================================================================
  39. * Function prototypes for the kernel.
  40. *========================================================================*/
  41. /*
  42. * Internal routines when attribute fork size < XFS_LITINO(mp).
  43. */
  44. void xfs_attr_shortform_create(struct xfs_da_args *args);
  45. void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
  46. int xfs_attr_shortform_lookup(struct xfs_da_args *args);
  47. int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
  48. int xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
  49. int xfs_attr_sf_removename(struct xfs_da_args *args);
  50. int xfs_attr_sf_findname(struct xfs_da_args *args,
  51. struct xfs_attr_sf_entry **sfep,
  52. unsigned int *basep);
  53. int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
  54. int xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
  55. xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip);
  56. void xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
  57. /*
  58. * Internal routines when attribute fork size == XFS_LBSIZE(mp).
  59. */
  60. int xfs_attr3_leaf_to_node(struct xfs_da_args *args);
  61. int xfs_attr3_leaf_to_shortform(struct xfs_buf *bp,
  62. struct xfs_da_args *args, int forkoff);
  63. int xfs_attr3_leaf_clearflag(struct xfs_da_args *args);
  64. int xfs_attr3_leaf_setflag(struct xfs_da_args *args);
  65. int xfs_attr3_leaf_flipflags(struct xfs_da_args *args);
  66. /*
  67. * Routines used for growing the Btree.
  68. */
  69. int xfs_attr3_leaf_split(struct xfs_da_state *state,
  70. struct xfs_da_state_blk *oldblk,
  71. struct xfs_da_state_blk *newblk);
  72. int xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf,
  73. struct xfs_da_args *args);
  74. int xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
  75. int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
  76. struct xfs_da_args *args);
  77. int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
  78. struct xfs_da_args *args);
  79. int xfs_attr3_leaf_list_int(struct xfs_buf *bp,
  80. struct xfs_attr_list_context *context);
  81. /*
  82. * Routines used for shrinking the Btree.
  83. */
  84. int xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);
  85. void xfs_attr3_leaf_unbalance(struct xfs_da_state *state,
  86. struct xfs_da_state_blk *drop_blk,
  87. struct xfs_da_state_blk *save_blk);
  88. /*
  89. * Utility routines.
  90. */
  91. xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
  92. int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
  93. struct xfs_buf *leaf2_bp);
  94. int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local);
  95. int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
  96. xfs_dablk_t bno, struct xfs_buf **bpp);
  97. void xfs_attr3_leaf_hdr_from_disk(struct xfs_da_geometry *geo,
  98. struct xfs_attr3_icleaf_hdr *to,
  99. struct xfs_attr_leafblock *from);
  100. void xfs_attr3_leaf_hdr_to_disk(struct xfs_da_geometry *geo,
  101. struct xfs_attr_leafblock *to,
  102. struct xfs_attr3_icleaf_hdr *from);
  103. #endif /* __XFS_ATTR_LEAF_H__ */