18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2016 Oracle. All Rights Reserved. 48c2ecf20Sopenharmony_ci * Author: Darrick J. Wong <darrick.wong@oracle.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef __XFS_DEFER_H__ 78c2ecf20Sopenharmony_ci#define __XFS_DEFER_H__ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct xfs_btree_cur; 108c2ecf20Sopenharmony_cistruct xfs_defer_op_type; 118c2ecf20Sopenharmony_cistruct xfs_defer_capture; 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Header for deferred operation list. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_cienum xfs_defer_ops_type { 178c2ecf20Sopenharmony_ci XFS_DEFER_OPS_TYPE_BMAP, 188c2ecf20Sopenharmony_ci XFS_DEFER_OPS_TYPE_REFCOUNT, 198c2ecf20Sopenharmony_ci XFS_DEFER_OPS_TYPE_RMAP, 208c2ecf20Sopenharmony_ci XFS_DEFER_OPS_TYPE_FREE, 218c2ecf20Sopenharmony_ci XFS_DEFER_OPS_TYPE_AGFL_FREE, 228c2ecf20Sopenharmony_ci XFS_DEFER_OPS_TYPE_MAX, 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 268c2ecf20Sopenharmony_ci * Save a log intent item and a list of extents, so that we can replay 278c2ecf20Sopenharmony_ci * whatever action had to happen to the extent list and file the log done 288c2ecf20Sopenharmony_ci * item. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_cistruct xfs_defer_pending { 318c2ecf20Sopenharmony_ci struct list_head dfp_list; /* pending items */ 328c2ecf20Sopenharmony_ci struct list_head dfp_work; /* work items */ 338c2ecf20Sopenharmony_ci struct xfs_log_item *dfp_intent; /* log intent item */ 348c2ecf20Sopenharmony_ci struct xfs_log_item *dfp_done; /* log done item */ 358c2ecf20Sopenharmony_ci unsigned int dfp_count; /* # extent items */ 368c2ecf20Sopenharmony_ci enum xfs_defer_ops_type dfp_type; 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_civoid xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type, 408c2ecf20Sopenharmony_ci struct list_head *h); 418c2ecf20Sopenharmony_ciint xfs_defer_finish_noroll(struct xfs_trans **tp); 428c2ecf20Sopenharmony_ciint xfs_defer_finish(struct xfs_trans **tp); 438c2ecf20Sopenharmony_civoid xfs_defer_cancel(struct xfs_trans *); 448c2ecf20Sopenharmony_civoid xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp); 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* Description of a deferred type. */ 478c2ecf20Sopenharmony_cistruct xfs_defer_op_type { 488c2ecf20Sopenharmony_ci struct xfs_log_item *(*create_intent)(struct xfs_trans *tp, 498c2ecf20Sopenharmony_ci struct list_head *items, unsigned int count, bool sort); 508c2ecf20Sopenharmony_ci void (*abort_intent)(struct xfs_log_item *intent); 518c2ecf20Sopenharmony_ci struct xfs_log_item *(*create_done)(struct xfs_trans *tp, 528c2ecf20Sopenharmony_ci struct xfs_log_item *intent, unsigned int count); 538c2ecf20Sopenharmony_ci int (*finish_item)(struct xfs_trans *tp, struct xfs_log_item *done, 548c2ecf20Sopenharmony_ci struct list_head *item, struct xfs_btree_cur **state); 558c2ecf20Sopenharmony_ci void (*finish_cleanup)(struct xfs_trans *tp, 568c2ecf20Sopenharmony_ci struct xfs_btree_cur *state, int error); 578c2ecf20Sopenharmony_ci void (*cancel_item)(struct list_head *item); 588c2ecf20Sopenharmony_ci unsigned int max_items; 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciextern const struct xfs_defer_op_type xfs_bmap_update_defer_type; 628c2ecf20Sopenharmony_ciextern const struct xfs_defer_op_type xfs_refcount_update_defer_type; 638c2ecf20Sopenharmony_ciextern const struct xfs_defer_op_type xfs_rmap_update_defer_type; 648c2ecf20Sopenharmony_ciextern const struct xfs_defer_op_type xfs_extent_free_defer_type; 658c2ecf20Sopenharmony_ciextern const struct xfs_defer_op_type xfs_agfl_free_defer_type; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* 688c2ecf20Sopenharmony_ci * This structure enables a dfops user to detach the chain of deferred 698c2ecf20Sopenharmony_ci * operations from a transaction so that they can be continued later. 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_cistruct xfs_defer_capture { 728c2ecf20Sopenharmony_ci /* List of other capture structures. */ 738c2ecf20Sopenharmony_ci struct list_head dfc_list; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci /* Deferred ops state saved from the transaction. */ 768c2ecf20Sopenharmony_ci struct list_head dfc_dfops; 778c2ecf20Sopenharmony_ci unsigned int dfc_tpflags; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci /* Block reservations for the data and rt devices. */ 808c2ecf20Sopenharmony_ci unsigned int dfc_blkres; 818c2ecf20Sopenharmony_ci unsigned int dfc_rtxres; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci /* Log reservation saved from the transaction. */ 848c2ecf20Sopenharmony_ci unsigned int dfc_logres; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci /* 878c2ecf20Sopenharmony_ci * An inode reference that must be maintained to complete the deferred 888c2ecf20Sopenharmony_ci * work. 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci struct xfs_inode *dfc_capture_ip; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* 948c2ecf20Sopenharmony_ci * Functions to capture a chain of deferred operations and continue them later. 958c2ecf20Sopenharmony_ci * This doesn't normally happen except log recovery. 968c2ecf20Sopenharmony_ci */ 978c2ecf20Sopenharmony_ciint xfs_defer_ops_capture_and_commit(struct xfs_trans *tp, 988c2ecf20Sopenharmony_ci struct xfs_inode *capture_ip, struct list_head *capture_list); 998c2ecf20Sopenharmony_civoid xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp, 1008c2ecf20Sopenharmony_ci struct xfs_inode **captured_ipp); 1018c2ecf20Sopenharmony_civoid xfs_defer_ops_release(struct xfs_mount *mp, struct xfs_defer_capture *d); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#endif /* __XFS_DEFER_H__ */ 104