blob: 2584a5b95b0d1aa31fa3facc59cf05bbb0c18cca [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// 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
9struct xfs_defer_op_type;
10
11/*
12 * Save a log intent item and a list of extents, so that we can replay
13 * whatever action had to happen to the extent list and file the log done
14 * item.
15 */
16struct xfs_defer_pending {
17 const struct xfs_defer_op_type *dfp_type; /* function pointers */
18 struct list_head dfp_list; /* pending items */
19 void *dfp_intent; /* log intent item */
20 void *dfp_done; /* log done item */
21 struct list_head dfp_work; /* work items */
22 unsigned int dfp_count; /* # extent items */
23};
24
25/*
26 * Header for deferred operation list.
27 */
28enum xfs_defer_ops_type {
29 XFS_DEFER_OPS_TYPE_BMAP,
30 XFS_DEFER_OPS_TYPE_REFCOUNT,
31 XFS_DEFER_OPS_TYPE_RMAP,
32 XFS_DEFER_OPS_TYPE_FREE,
33 XFS_DEFER_OPS_TYPE_AGFL_FREE,
34 XFS_DEFER_OPS_TYPE_MAX,
35};
36
37void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
38 struct list_head *h);
39int xfs_defer_finish_noroll(struct xfs_trans **tp);
40int xfs_defer_finish(struct xfs_trans **tp);
41void xfs_defer_cancel(struct xfs_trans *);
42void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
43
44/* Description of a deferred type. */
45struct xfs_defer_op_type {
46 enum xfs_defer_ops_type type;
47 unsigned int max_items;
48 void (*abort_intent)(void *);
49 void *(*create_done)(struct xfs_trans *, void *, unsigned int);
50 int (*finish_item)(struct xfs_trans *, struct list_head *, void *,
51 void **);
52 void (*finish_cleanup)(struct xfs_trans *, void *, int);
53 void (*cancel_item)(struct list_head *);
54 int (*diff_items)(void *, struct list_head *, struct list_head *);
55 void *(*create_intent)(struct xfs_trans *, uint);
56 void (*log_item)(struct xfs_trans *, void *, struct list_head *);
57};
58
59void xfs_defer_init_op_type(const struct xfs_defer_op_type *type);
60
61#endif /* __XFS_DEFER_H__ */