Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * Copyright (C) 2016 Oracle.  All Rights Reserved.
0004  * Author: Darrick J. Wong <darrick.wong@oracle.com>
0005  */
0006 #ifndef __XFS_DEFER_H__
0007 #define __XFS_DEFER_H__
0008 
0009 struct xfs_btree_cur;
0010 struct xfs_defer_op_type;
0011 struct xfs_defer_capture;
0012 
0013 /*
0014  * Header for deferred operation list.
0015  */
0016 enum xfs_defer_ops_type {
0017     XFS_DEFER_OPS_TYPE_BMAP,
0018     XFS_DEFER_OPS_TYPE_REFCOUNT,
0019     XFS_DEFER_OPS_TYPE_RMAP,
0020     XFS_DEFER_OPS_TYPE_FREE,
0021     XFS_DEFER_OPS_TYPE_AGFL_FREE,
0022     XFS_DEFER_OPS_TYPE_ATTR,
0023     XFS_DEFER_OPS_TYPE_MAX,
0024 };
0025 
0026 /*
0027  * Save a log intent item and a list of extents, so that we can replay
0028  * whatever action had to happen to the extent list and file the log done
0029  * item.
0030  */
0031 struct xfs_defer_pending {
0032     struct list_head        dfp_list;   /* pending items */
0033     struct list_head        dfp_work;   /* work items */
0034     struct xfs_log_item     *dfp_intent;    /* log intent item */
0035     struct xfs_log_item     *dfp_done;  /* log done item */
0036     unsigned int            dfp_count;  /* # extent items */
0037     enum xfs_defer_ops_type     dfp_type;
0038 };
0039 
0040 void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
0041         struct list_head *h);
0042 int xfs_defer_finish_noroll(struct xfs_trans **tp);
0043 int xfs_defer_finish(struct xfs_trans **tp);
0044 void xfs_defer_cancel(struct xfs_trans *);
0045 void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
0046 
0047 /* Description of a deferred type. */
0048 struct xfs_defer_op_type {
0049     struct xfs_log_item *(*create_intent)(struct xfs_trans *tp,
0050             struct list_head *items, unsigned int count, bool sort);
0051     void (*abort_intent)(struct xfs_log_item *intent);
0052     struct xfs_log_item *(*create_done)(struct xfs_trans *tp,
0053             struct xfs_log_item *intent, unsigned int count);
0054     int (*finish_item)(struct xfs_trans *tp, struct xfs_log_item *done,
0055             struct list_head *item, struct xfs_btree_cur **state);
0056     void (*finish_cleanup)(struct xfs_trans *tp,
0057             struct xfs_btree_cur *state, int error);
0058     void (*cancel_item)(struct list_head *item);
0059     unsigned int        max_items;
0060 };
0061 
0062 extern const struct xfs_defer_op_type xfs_bmap_update_defer_type;
0063 extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;
0064 extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;
0065 extern const struct xfs_defer_op_type xfs_extent_free_defer_type;
0066 extern const struct xfs_defer_op_type xfs_agfl_free_defer_type;
0067 extern const struct xfs_defer_op_type xfs_attr_defer_type;
0068 
0069 
0070 /*
0071  * Deferred operation item relogging limits.
0072  */
0073 #define XFS_DEFER_OPS_NR_INODES 2   /* join up to two inodes */
0074 #define XFS_DEFER_OPS_NR_BUFS   2   /* join up to two buffers */
0075 
0076 /* Resources that must be held across a transaction roll. */
0077 struct xfs_defer_resources {
0078     /* held buffers */
0079     struct xfs_buf      *dr_bp[XFS_DEFER_OPS_NR_BUFS];
0080 
0081     /* inodes with no unlock flags */
0082     struct xfs_inode    *dr_ip[XFS_DEFER_OPS_NR_INODES];
0083 
0084     /* number of held buffers */
0085     unsigned short      dr_bufs;
0086 
0087     /* bitmap of ordered buffers */
0088     unsigned short      dr_ordered;
0089 
0090     /* number of held inodes */
0091     unsigned short      dr_inos;
0092 };
0093 
0094 /*
0095  * This structure enables a dfops user to detach the chain of deferred
0096  * operations from a transaction so that they can be continued later.
0097  */
0098 struct xfs_defer_capture {
0099     /* List of other capture structures. */
0100     struct list_head    dfc_list;
0101 
0102     /* Deferred ops state saved from the transaction. */
0103     struct list_head    dfc_dfops;
0104     unsigned int        dfc_tpflags;
0105 
0106     /* Block reservations for the data and rt devices. */
0107     unsigned int        dfc_blkres;
0108     unsigned int        dfc_rtxres;
0109 
0110     /* Log reservation saved from the transaction. */
0111     unsigned int        dfc_logres;
0112 
0113     struct xfs_defer_resources dfc_held;
0114 };
0115 
0116 /*
0117  * Functions to capture a chain of deferred operations and continue them later.
0118  * This doesn't normally happen except log recovery.
0119  */
0120 int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp,
0121         struct list_head *capture_list);
0122 void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp,
0123         struct xfs_defer_resources *dres);
0124 void xfs_defer_ops_capture_free(struct xfs_mount *mp,
0125         struct xfs_defer_capture *d);
0126 void xfs_defer_resources_rele(struct xfs_defer_resources *dres);
0127 
0128 int __init xfs_defer_init_item_caches(void);
0129 void xfs_defer_destroy_item_caches(void);
0130 
0131 #endif /* __XFS_DEFER_H__ */