]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0 |
b626fb59 DC |
2 | /* |
3 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. | |
4 | * All Rights Reserved. | |
b626fb59 DC |
5 | */ |
6 | ||
7 | #ifndef __XFS_TRANS_H__ | |
8 | #define __XFS_TRANS_H__ | |
9 | ||
10 | struct xfs_mount; | |
11 | struct xfs_buftarg; | |
12 | struct xfs_buf; | |
13 | struct xfs_buf_map; | |
14 | ||
15 | /* | |
16 | * Userspace Transaction interface | |
17 | */ | |
18 | ||
19 | typedef struct xfs_log_item { | |
2fdd378a DC |
20 | struct list_head li_trans; /* transaction list */ |
21 | xfs_lsn_t li_lsn; /* last on-disk lsn */ | |
b626fb59 DC |
22 | struct xfs_mount *li_mountp; /* ptr to fs mount */ |
23 | uint li_type; /* item type */ | |
2fdd378a | 24 | unsigned long li_flags; /* misc flags */ |
b626fb59 DC |
25 | } xfs_log_item_t; |
26 | ||
2fdd378a DC |
27 | #define XFS_LI_DIRTY 3 /* log item dirty in transaction */ |
28 | ||
b626fb59 DC |
29 | typedef struct xfs_inode_log_item { |
30 | xfs_log_item_t ili_item; /* common portion */ | |
31 | struct xfs_inode *ili_inode; /* inode pointer */ | |
32 | unsigned short ili_flags; /* misc flags */ | |
c0860494 | 33 | unsigned short ili_lock_flags; /* lock flags */ |
b626fb59 DC |
34 | unsigned int ili_fields; /* fields to be logged */ |
35 | unsigned int ili_last_fields; /* fields when flushed*/ | |
b626fb59 DC |
36 | } xfs_inode_log_item_t; |
37 | ||
38 | typedef struct xfs_buf_log_item { | |
39 | xfs_log_item_t bli_item; /* common item structure */ | |
40 | struct xfs_buf *bli_buf; /* real buffer pointer */ | |
41 | unsigned int bli_flags; /* misc flags */ | |
42 | unsigned int bli_recur; /* recursion count */ | |
43 | xfs_buf_log_format_t bli_format; /* in-log header */ | |
44 | } xfs_buf_log_item_t; | |
45 | ||
46 | #define XFS_BLI_DIRTY (1<<0) | |
47 | #define XFS_BLI_HOLD (1<<1) | |
48 | #define XFS_BLI_STALE (1<<2) | |
49 | #define XFS_BLI_INODE_ALLOC_BUF (1<<3) | |
50 | ||
51 | typedef struct xfs_dq_logitem { | |
52 | xfs_log_item_t qli_item; /* common portion */ | |
53 | struct xfs_dquot *qli_dquot; /* dquot ptr */ | |
54 | xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ | |
55 | xfs_dq_logformat_t qli_format; /* logged structure */ | |
56 | } xfs_dq_logitem_t; | |
57 | ||
58 | typedef struct xfs_qoff_logitem { | |
59 | xfs_log_item_t qql_item; /* common portion */ | |
60 | struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */ | |
61 | xfs_qoff_logformat_t qql_format; /* logged structure */ | |
62 | } xfs_qoff_logitem_t; | |
63 | ||
f5f4497f BF |
64 | #define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ |
65 | #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ | |
66 | ||
b626fb59 DC |
67 | typedef struct xfs_trans { |
68 | unsigned int t_type; /* transaction type */ | |
69 | unsigned int t_log_res; /* amt of log space resvd */ | |
70 | unsigned int t_log_count; /* count for perm log res */ | |
0268fdc3 | 71 | unsigned int t_blk_res; /* # of blocks resvd */ |
255682d9 | 72 | xfs_fsblock_t t_firstblock; /* first block allocated */ |
b626fb59 | 73 | struct xfs_mount *t_mountp; /* ptr to fs mount struct */ |
41ab9202 | 74 | unsigned int t_blk_res_used; /* # of resvd blocks used */ |
b626fb59 DC |
75 | unsigned int t_flags; /* misc flags */ |
76 | long t_icount_delta; /* superblock icount change */ | |
77 | long t_ifree_delta; /* superblock ifree change */ | |
78 | long t_fdblocks_delta; /* superblock fdblocks chg */ | |
79 | long t_frextents_delta; /* superblock freextents chg */ | |
80 | struct list_head t_items; /* first log item desc chunk */ | |
92a8736e | 81 | struct list_head t_dfops; /* deferred operations */ |
b626fb59 DC |
82 | } xfs_trans_t; |
83 | ||
84 | void xfs_trans_init(struct xfs_mount *); | |
d67406c9 | 85 | int xfs_trans_roll(struct xfs_trans **); |
b626fb59 | 86 | |
9074815c CH |
87 | int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp, |
88 | uint blocks, uint rtextents, uint flags, | |
89 | struct xfs_trans **tpp); | |
225e4bb2 DW |
90 | int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks, |
91 | struct xfs_trans **tpp); | |
3680a764 | 92 | int libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp); |
de5a3f46 | 93 | int libxfs_trans_commit(struct xfs_trans *); |
3d7434fe | 94 | void libxfs_trans_cancel(struct xfs_trans *); |
ac0a2228 BF |
95 | |
96 | /* cancel dfops associated with a transaction */ | |
97 | void xfs_defer_cancel(struct xfs_trans *); | |
98 | ||
b626fb59 DC |
99 | struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *, struct xfs_mount *, int); |
100 | ||
b626fb59 DC |
101 | void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint); |
102 | void libxfs_trans_ijoin_ref(struct xfs_trans *, struct xfs_inode *, int); | |
103 | void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *, | |
104 | uint); | |
d67406c9 | 105 | int libxfs_trans_roll_inode (struct xfs_trans **, struct xfs_inode *); |
b626fb59 DC |
106 | |
107 | void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *); | |
108 | void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *); | |
109 | void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *); | |
110 | void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *); | |
59630067 | 111 | void libxfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); |
b626fb59 DC |
112 | void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, |
113 | uint, uint); | |
38fa71a7 | 114 | bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); |
b626fb59 DC |
115 | |
116 | struct xfs_buf *libxfs_trans_get_buf_map(struct xfs_trans *tp, | |
117 | struct xfs_buftarg *btp, | |
118 | struct xfs_buf_map *map, int nmaps, | |
119 | uint flags); | |
120 | ||
121 | int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp, | |
122 | struct xfs_buftarg *btp, | |
123 | struct xfs_buf_map *map, int nmaps, | |
124 | uint flags, struct xfs_buf **bpp, | |
125 | const struct xfs_buf_ops *ops); | |
126 | static inline struct xfs_buf * | |
127 | libxfs_trans_get_buf( | |
128 | struct xfs_trans *tp, | |
129 | struct xfs_buftarg *btp, | |
130 | xfs_daddr_t blkno, | |
131 | int numblks, | |
132 | uint flags) | |
133 | { | |
134 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
135 | return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags); | |
136 | } | |
137 | ||
138 | static inline int | |
139 | libxfs_trans_read_buf( | |
140 | struct xfs_mount *mp, | |
141 | struct xfs_trans *tp, | |
142 | struct xfs_buftarg *btp, | |
143 | xfs_daddr_t blkno, | |
144 | int numblks, | |
145 | uint flags, | |
146 | struct xfs_buf **bpp, | |
147 | const struct xfs_buf_ops *ops) | |
148 | { | |
149 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
150 | return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops); | |
151 | } | |
152 | ||
153 | #endif /* __XFS_TRANS_H__ */ |