attr.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2019 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <[email protected]>
  5. */
  6. #ifndef __XFS_SCRUB_ATTR_H__
  7. #define __XFS_SCRUB_ATTR_H__
  8. /*
  9. * Temporary storage for online scrub and repair of extended attributes.
  10. */
  11. struct xchk_xattr_buf {
  12. /* Size of @buf, in bytes. */
  13. size_t sz;
  14. /*
  15. * Memory buffer -- either used for extracting attr values while
  16. * walking the attributes; or for computing attr block bitmaps when
  17. * checking the attribute tree.
  18. *
  19. * Each bitmap contains enough bits to track every byte in an attr
  20. * block (rounded up to the size of an unsigned long). The attr block
  21. * used space bitmap starts at the beginning of the buffer; the free
  22. * space bitmap follows immediately after; and we have a third buffer
  23. * for storing intermediate bitmap results.
  24. */
  25. uint8_t buf[];
  26. };
  27. /* A place to store attribute values. */
  28. static inline uint8_t *
  29. xchk_xattr_valuebuf(
  30. struct xfs_scrub *sc)
  31. {
  32. struct xchk_xattr_buf *ab = sc->buf;
  33. return ab->buf;
  34. }
  35. /* A bitmap of space usage computed by walking an attr leaf block. */
  36. static inline unsigned long *
  37. xchk_xattr_usedmap(
  38. struct xfs_scrub *sc)
  39. {
  40. struct xchk_xattr_buf *ab = sc->buf;
  41. return (unsigned long *)ab->buf;
  42. }
  43. /* A bitmap of free space computed by walking attr leaf block free info. */
  44. static inline unsigned long *
  45. xchk_xattr_freemap(
  46. struct xfs_scrub *sc)
  47. {
  48. return xchk_xattr_usedmap(sc) +
  49. BITS_TO_LONGS(sc->mp->m_attr_geo->blksize);
  50. }
  51. /* A bitmap used to hold temporary results. */
  52. static inline unsigned long *
  53. xchk_xattr_dstmap(
  54. struct xfs_scrub *sc)
  55. {
  56. return xchk_xattr_freemap(sc) +
  57. BITS_TO_LONGS(sc->mp->m_attr_geo->blksize);
  58. }
  59. #endif /* __XFS_SCRUB_ATTR_H__ */