xfs_icache.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef XFS_SYNC_H
  7. #define XFS_SYNC_H 1
  8. struct xfs_mount;
  9. struct xfs_perag;
  10. struct xfs_eofblocks {
  11. __u32 eof_flags;
  12. kuid_t eof_uid;
  13. kgid_t eof_gid;
  14. prid_t eof_prid;
  15. __u64 eof_min_file_size;
  16. };
  17. #define SYNC_WAIT 0x0001 /* wait for i/o to complete */
  18. #define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */
  19. /*
  20. * tags for inode radix tree
  21. */
  22. #define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup
  23. in xfs_inode_ag_iterator */
  24. #define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */
  25. #define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */
  26. #define XFS_ICI_COWBLOCKS_TAG 2 /* inode can have cow blocks to gc */
  27. /*
  28. * Flags for xfs_iget()
  29. */
  30. #define XFS_IGET_CREATE 0x1
  31. #define XFS_IGET_UNTRUSTED 0x2
  32. #define XFS_IGET_DONTCACHE 0x4
  33. #define XFS_IGET_INCORE 0x8 /* don't read from disk or reinit */
  34. /*
  35. * flags for AG inode iterator
  36. */
  37. #define XFS_AGITER_INEW_WAIT 0x1 /* wait on new inodes */
  38. int xfs_iget(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t ino,
  39. uint flags, uint lock_flags, xfs_inode_t **ipp);
  40. /* recovery needs direct inode allocation capability */
  41. struct xfs_inode * xfs_inode_alloc(struct xfs_mount *mp, xfs_ino_t ino);
  42. void xfs_inode_free(struct xfs_inode *ip);
  43. void xfs_reclaim_worker(struct work_struct *work);
  44. int xfs_reclaim_inodes(struct xfs_mount *mp, int mode);
  45. int xfs_reclaim_inodes_count(struct xfs_mount *mp);
  46. long xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan);
  47. void xfs_inode_set_reclaim_tag(struct xfs_inode *ip);
  48. void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip);
  49. void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip);
  50. int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *);
  51. int xfs_inode_free_quota_eofblocks(struct xfs_inode *ip);
  52. void xfs_eofblocks_worker(struct work_struct *);
  53. void xfs_queue_eofblocks(struct xfs_mount *);
  54. void xfs_inode_set_cowblocks_tag(struct xfs_inode *ip);
  55. void xfs_inode_clear_cowblocks_tag(struct xfs_inode *ip);
  56. int xfs_icache_free_cowblocks(struct xfs_mount *, struct xfs_eofblocks *);
  57. int xfs_inode_free_quota_cowblocks(struct xfs_inode *ip);
  58. void xfs_cowblocks_worker(struct work_struct *);
  59. void xfs_queue_cowblocks(struct xfs_mount *);
  60. int xfs_inode_ag_iterator(struct xfs_mount *mp,
  61. int (*execute)(struct xfs_inode *ip, int flags, void *args),
  62. int flags, void *args);
  63. int xfs_inode_ag_iterator_flags(struct xfs_mount *mp,
  64. int (*execute)(struct xfs_inode *ip, int flags, void *args),
  65. int flags, void *args, int iter_flags);
  66. int xfs_inode_ag_iterator_tag(struct xfs_mount *mp,
  67. int (*execute)(struct xfs_inode *ip, int flags, void *args),
  68. int flags, void *args, int tag);
  69. static inline int
  70. xfs_fs_eofblocks_from_user(
  71. struct xfs_fs_eofblocks *src,
  72. struct xfs_eofblocks *dst)
  73. {
  74. if (src->eof_version != XFS_EOFBLOCKS_VERSION)
  75. return -EINVAL;
  76. if (src->eof_flags & ~XFS_EOF_FLAGS_VALID)
  77. return -EINVAL;
  78. if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) ||
  79. memchr_inv(src->pad64, 0, sizeof(src->pad64)))
  80. return -EINVAL;
  81. dst->eof_flags = src->eof_flags;
  82. dst->eof_prid = src->eof_prid;
  83. dst->eof_min_file_size = src->eof_min_file_size;
  84. dst->eof_uid = INVALID_UID;
  85. if (src->eof_flags & XFS_EOF_FLAGS_UID) {
  86. dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid);
  87. if (!uid_valid(dst->eof_uid))
  88. return -EINVAL;
  89. }
  90. dst->eof_gid = INVALID_GID;
  91. if (src->eof_flags & XFS_EOF_FLAGS_GID) {
  92. dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid);
  93. if (!gid_valid(dst->eof_gid))
  94. return -EINVAL;
  95. }
  96. return 0;
  97. }
  98. int xfs_icache_inode_is_allocated(struct xfs_mount *mp, struct xfs_trans *tp,
  99. xfs_ino_t ino, bool *inuse);
  100. void xfs_icache_disable_reclaim(struct xfs_mount *mp);
  101. void xfs_icache_enable_reclaim(struct xfs_mount *mp);
  102. #endif