xfs_ialloc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_IALLOC_H__
  7. #define __XFS_IALLOC_H__
  8. struct xfs_buf;
  9. struct xfs_dinode;
  10. struct xfs_imap;
  11. struct xfs_mount;
  12. struct xfs_trans;
  13. struct xfs_btree_cur;
  14. /* Move inodes in clusters of this size */
  15. #define XFS_INODE_BIG_CLUSTER_SIZE 8192
  16. struct xfs_icluster {
  17. bool deleted; /* record is deleted */
  18. xfs_ino_t first_ino; /* first inode number */
  19. uint64_t alloc; /* inode phys. allocation bitmap for
  20. * sparse chunks */
  21. };
  22. /*
  23. * Make an inode pointer out of the buffer/offset.
  24. */
  25. static inline struct xfs_dinode *
  26. xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
  27. {
  28. return xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog);
  29. }
  30. /*
  31. * Allocate an inode on disk. Mode is used to tell whether the new inode will
  32. * need space, and whether it is a directory.
  33. */
  34. int xfs_dialloc(struct xfs_trans **tpp, xfs_ino_t parent, umode_t mode,
  35. xfs_ino_t *new_ino);
  36. int xfs_difree(struct xfs_trans *tp, struct xfs_perag *pag,
  37. xfs_ino_t ino, struct xfs_icluster *ifree);
  38. /*
  39. * Return the location of the inode in imap, for mapping it into a buffer.
  40. */
  41. int
  42. xfs_imap(
  43. struct xfs_mount *mp, /* file system mount structure */
  44. struct xfs_trans *tp, /* transaction pointer */
  45. xfs_ino_t ino, /* inode to locate */
  46. struct xfs_imap *imap, /* location map structure */
  47. uint flags); /* flags for inode btree lookup */
  48. /*
  49. * Log specified fields for the ag hdr (inode section)
  50. */
  51. void
  52. xfs_ialloc_log_agi(
  53. struct xfs_trans *tp, /* transaction pointer */
  54. struct xfs_buf *bp, /* allocation group header buffer */
  55. uint32_t fields); /* bitmask of fields to log */
  56. int xfs_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
  57. struct xfs_buf **agibpp);
  58. int xfs_ialloc_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
  59. struct xfs_buf **agibpp);
  60. /*
  61. * Lookup a record by ino in the btree given by cur.
  62. */
  63. int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino,
  64. xfs_lookup_t dir, int *stat);
  65. /*
  66. * Get the data from the pointed-to record.
  67. */
  68. int xfs_inobt_get_rec(struct xfs_btree_cur *cur,
  69. xfs_inobt_rec_incore_t *rec, int *stat);
  70. /*
  71. * Inode chunk initialisation routine
  72. */
  73. int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
  74. struct list_head *buffer_list, int icount,
  75. xfs_agnumber_t agno, xfs_agblock_t agbno,
  76. xfs_agblock_t length, unsigned int gen);
  77. union xfs_btree_rec;
  78. void xfs_inobt_btrec_to_irec(struct xfs_mount *mp,
  79. const union xfs_btree_rec *rec,
  80. struct xfs_inobt_rec_incore *irec);
  81. int xfs_ialloc_has_inodes_at_extent(struct xfs_btree_cur *cur,
  82. xfs_agblock_t bno, xfs_extlen_t len, bool *exists);
  83. int xfs_ialloc_has_inode_record(struct xfs_btree_cur *cur, xfs_agino_t low,
  84. xfs_agino_t high, bool *exists);
  85. int xfs_ialloc_count_inodes(struct xfs_btree_cur *cur, xfs_agino_t *count,
  86. xfs_agino_t *freecount);
  87. int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask,
  88. uint8_t count, int32_t freecount, xfs_inofree_t free,
  89. int *stat);
  90. int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
  91. void xfs_ialloc_setup_geometry(struct xfs_mount *mp);
  92. xfs_ino_t xfs_ialloc_calc_rootino(struct xfs_mount *mp, int sunit);
  93. int xfs_ialloc_check_shrink(struct xfs_trans *tp, xfs_agnumber_t agno,
  94. struct xfs_buf *agibp, xfs_agblock_t new_length);
  95. #endif /* __XFS_IALLOC_H__ */