xfs_defer.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <darrick.wong@oracle.com>
  5. */
  6. #ifndef __XFS_DEFER_H__
  7. #define __XFS_DEFER_H__
  8. struct xfs_defer_op_type;
  9. /*
  10. * Save a log intent item and a list of extents, so that we can replay
  11. * whatever action had to happen to the extent list and file the log done
  12. * item.
  13. */
  14. struct xfs_defer_pending {
  15. const struct xfs_defer_op_type *dfp_type; /* function pointers */
  16. struct list_head dfp_list; /* pending items */
  17. void *dfp_intent; /* log intent item */
  18. void *dfp_done; /* log done item */
  19. struct list_head dfp_work; /* work items */
  20. unsigned int dfp_count; /* # extent items */
  21. };
  22. /*
  23. * Header for deferred operation list.
  24. */
  25. enum xfs_defer_ops_type {
  26. XFS_DEFER_OPS_TYPE_BMAP,
  27. XFS_DEFER_OPS_TYPE_REFCOUNT,
  28. XFS_DEFER_OPS_TYPE_RMAP,
  29. XFS_DEFER_OPS_TYPE_FREE,
  30. XFS_DEFER_OPS_TYPE_AGFL_FREE,
  31. XFS_DEFER_OPS_TYPE_MAX,
  32. };
  33. void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
  34. struct list_head *h);
  35. int xfs_defer_finish_noroll(struct xfs_trans **tp);
  36. int xfs_defer_finish(struct xfs_trans **tp);
  37. void xfs_defer_cancel(struct xfs_trans *);
  38. void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
  39. /* Description of a deferred type. */
  40. struct xfs_defer_op_type {
  41. enum xfs_defer_ops_type type;
  42. unsigned int max_items;
  43. void (*abort_intent)(void *);
  44. void *(*create_done)(struct xfs_trans *, void *, unsigned int);
  45. int (*finish_item)(struct xfs_trans *, struct list_head *, void *,
  46. void **);
  47. void (*finish_cleanup)(struct xfs_trans *, void *, int);
  48. void (*cancel_item)(struct list_head *);
  49. int (*diff_items)(void *, struct list_head *, struct list_head *);
  50. void *(*create_intent)(struct xfs_trans *, uint);
  51. void (*log_item)(struct xfs_trans *, void *, struct list_head *);
  52. };
  53. void xfs_defer_init_op_type(const struct xfs_defer_op_type *type);
  54. #endif /* __XFS_DEFER_H__ */