Blame view
fs/xfs/xfs_trans.h
9.17 KB
0b61f8a40
|
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c
|
2 |
/* |
7b7187698
|
3 4 |
* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. * All Rights Reserved. |
1da177e4c
|
5 6 7 |
*/ #ifndef __XFS_TRANS_H__ #define __XFS_TRANS_H__ |
7fd36c441
|
8 |
/* kernel only transaction subsystem defines */ |
847fff5ca
|
9 10 11 12 13 14 15 16 |
struct xfs_buf; struct xfs_buftarg; struct xfs_efd_log_item; struct xfs_efi_log_item; struct xfs_inode; struct xfs_item_ops; struct xfs_log_iovec; |
847fff5ca
|
17 18 |
struct xfs_mount; struct xfs_trans; |
3d3c8b522
|
19 |
struct xfs_trans_res; |
847fff5ca
|
20 |
struct xfs_dquot_acct; |
f8dbebef9
|
21 22 |
struct xfs_rud_log_item; struct xfs_rui_log_item; |
9c1946446
|
23 |
struct xfs_btree_cur; |
f997ee213
|
24 |
struct xfs_cui_log_item; |
33ba61292
|
25 |
struct xfs_cud_log_item; |
77d61fe45
|
26 |
struct xfs_bui_log_item; |
9f3afb57d
|
27 |
struct xfs_bud_log_item; |
847fff5ca
|
28 |
|
efe2330fd
|
29 |
struct xfs_log_item { |
847fff5ca
|
30 |
struct list_head li_ail; /* AIL pointers */ |
e6631f855
|
31 |
struct list_head li_trans; /* transaction list */ |
847fff5ca
|
32 |
xfs_lsn_t li_lsn; /* last on-disk lsn */ |
847fff5ca
|
33 |
struct xfs_mount *li_mountp; /* ptr to fs mount */ |
fc1829f34
|
34 |
struct xfs_ail *li_ailp; /* ptr to AIL */ |
847fff5ca
|
35 |
uint li_type; /* item type */ |
22525c17e
|
36 |
unsigned long li_flags; /* misc flags */ |
d3a304b62
|
37 |
struct xfs_buf *li_buf; /* real buffer pointer */ |
643c8c05e
|
38 |
struct list_head li_bio_list; /* buffer item list */ |
272e42b21
|
39 |
const struct xfs_item_ops *li_ops; /* function list */ |
71e330b59
|
40 41 42 43 |
/* delayed logging */ struct list_head li_cil; /* CIL pointers */ struct xfs_log_vec *li_lv; /* active log vector */ |
b1c5ebb21
|
44 |
struct xfs_log_vec *li_lv_shadow; /* standby vector */ |
ccf7c23fc
|
45 |
xfs_lsn_t li_seq; /* CIL commit seq */ |
efe2330fd
|
46 |
}; |
847fff5ca
|
47 |
|
22525c17e
|
48 49 50 51 52 53 54 55 |
/* * li_flags use the (set/test/clear)_bit atomic interfaces because updates can * race with each other and we don't want to have to use the AIL lock to * serialise all updates. */ #define XFS_LI_IN_AIL 0 #define XFS_LI_ABORTED 1 #define XFS_LI_FAILED 2 |
e6631f855
|
56 |
#define XFS_LI_DIRTY 3 /* log item dirty in transaction */ |
847fff5ca
|
57 |
|
0b1b213fc
|
58 |
#define XFS_LI_FLAGS \ |
22525c17e
|
59 60 |
{ (1 << XFS_LI_IN_AIL), "IN_AIL" }, \ { (1 << XFS_LI_ABORTED), "ABORTED" }, \ |
e6631f855
|
61 |
{ (1 << XFS_LI_FAILED), "FAILED" }, \ |
901219bb2
|
62 |
{ (1 << XFS_LI_DIRTY), "DIRTY" } |
0b1b213fc
|
63 |
|
272e42b21
|
64 |
struct xfs_item_ops { |
9ce632a28
|
65 |
unsigned flags; |
efe2330fd
|
66 67 68 69 |
void (*iop_size)(struct xfs_log_item *, int *, int *); void (*iop_format)(struct xfs_log_item *, struct xfs_log_vec *); void (*iop_pin)(struct xfs_log_item *); void (*iop_unpin)(struct xfs_log_item *, int remove); |
43ff2122e
|
70 |
uint (*iop_push)(struct xfs_log_item *, struct list_head *); |
ddf92053e
|
71 72 |
void (*iop_committing)(struct xfs_log_item *, xfs_lsn_t commit_lsn); void (*iop_release)(struct xfs_log_item *); |
efe2330fd
|
73 |
xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t); |
e6fff81e4
|
74 75 |
int (*iop_recover)(struct xfs_log_item *lip, struct list_head *capture_list); |
154c733a3
|
76 |
bool (*iop_match)(struct xfs_log_item *item, uint64_t id); |
4e919af78
|
77 78 |
struct xfs_log_item *(*iop_relog)(struct xfs_log_item *intent, struct xfs_trans *tp); |
272e42b21
|
79 |
}; |
847fff5ca
|
80 |
|
d6b8fc6c7
|
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
/* Is this log item a deferred action intent? */ static inline bool xlog_item_is_intent(struct xfs_log_item *lip) { return lip->li_ops->iop_recover != NULL && lip->li_ops->iop_match != NULL; } /* Is this a log intent-done item? */ static inline bool xlog_item_is_intent_done(struct xfs_log_item *lip) { return lip->li_ops->iop_unpin == NULL && lip->li_ops->iop_push == NULL; } |
9ce632a28
|
96 97 98 99 100 |
/* * Release the log item as soon as committed. This is for items just logging * intents that never need to be written back in place. */ #define XFS_ITEM_RELEASE_WHEN_COMMITTED (1 << 0) |
239880ef6
|
101 102 |
void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item, int type, const struct xfs_item_ops *ops); |
847fff5ca
|
103 |
/* |
904c17e68
|
104 |
* Return values for the iop_push() routines. |
847fff5ca
|
105 |
*/ |
43ff2122e
|
106 107 108 109 |
#define XFS_ITEM_SUCCESS 0 #define XFS_ITEM_PINNED 1 #define XFS_ITEM_LOCKED 2 #define XFS_ITEM_FLUSHING 3 |
847fff5ca
|
110 |
|
e021a2e5f
|
111 |
/* |
9d9e62338
|
112 |
* Deferred operation item relogging limits. |
e021a2e5f
|
113 114 115 |
*/ #define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ |
239880ef6
|
116 |
|
847fff5ca
|
117 |
/* |
847fff5ca
|
118 119 120 121 |
* This is the structure maintained for every active transaction. */ typedef struct xfs_trans { unsigned int t_magic; /* magic number */ |
847fff5ca
|
122 123 124 125 126 127 |
unsigned int t_log_res; /* amt of log space resvd */ unsigned int t_log_count; /* count for perm log res */ unsigned int t_blk_res; /* # of blocks resvd */ unsigned int t_blk_res_used; /* # of resvd blocks used */ unsigned int t_rtx_res; /* # of rt extents resvd */ unsigned int t_rtx_res_used; /* # of resvd rt extents used */ |
44fd29468
|
128 |
unsigned int t_flags; /* misc flags */ |
bba59c5e4
|
129 |
xfs_fsblock_t t_firstblock; /* first block allocated */ |
35a8a72f0
|
130 |
struct xlog_ticket *t_ticket; /* log mgr ticket */ |
847fff5ca
|
131 132 |
struct xfs_mount *t_mountp; /* ptr to fs mount struct */ struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */ |
847fff5ca
|
133 134 135 136 137 138 |
int64_t t_icount_delta; /* superblock icount change */ int64_t t_ifree_delta; /* superblock ifree change */ int64_t t_fdblocks_delta; /* superblock fdblocks chg */ int64_t t_res_fdblocks_delta; /* on-disk only chg */ int64_t t_frextents_delta;/* superblock freextents chg*/ int64_t t_res_frextents_delta; /* on-disk only chg */ |
742ae1e35
|
139 |
#if defined(DEBUG) || defined(XFS_WARN) |
847fff5ca
|
140 141 142 143 144 145 146 147 148 149 150 151 |
int64_t t_ag_freeblks_delta; /* debugging counter */ int64_t t_ag_flist_delta; /* debugging counter */ int64_t t_ag_btree_delta; /* debugging counter */ #endif int64_t t_dblocks_delta;/* superblock dblocks change */ int64_t t_agcount_delta;/* superblock agcount change */ int64_t t_imaxpct_delta;/* superblock imaxpct change */ int64_t t_rextsize_delta;/* superblock rextsize chg */ int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */ int64_t t_rblocks_delta;/* superblock rblocks change */ int64_t t_rextents_delta;/* superblocks rextents chg */ int64_t t_rextslog_delta;/* superblocks rextslog chg */ |
e98c414f9
|
152 |
struct list_head t_items; /* log item descriptors */ |
ed3b4d6cd
|
153 |
struct list_head t_busy; /* list of busy extents */ |
9d9e62338
|
154 |
struct list_head t_dfops; /* deferred operations */ |
847fff5ca
|
155 156 |
unsigned long t_pflags; /* saved process flags state */ } xfs_trans_t; |
1da177e4c
|
157 158 159 160 |
/* * XFS transaction mechanism exported interfaces that are * actually macros. */ |
1da177e4c
|
161 |
#define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC) |
742ae1e35
|
162 |
#if defined(DEBUG) || defined(XFS_WARN) |
20f4ebf2b
|
163 164 165 |
#define xfs_trans_agblocks_delta(tp, d) ((tp)->t_ag_freeblks_delta += (int64_t)d) #define xfs_trans_agflist_delta(tp, d) ((tp)->t_ag_flist_delta += (int64_t)d) #define xfs_trans_agbtree_delta(tp, d) ((tp)->t_ag_btree_delta += (int64_t)d) |
1da177e4c
|
166 167 168 169 170 171 172 173 174 |
#else #define xfs_trans_agblocks_delta(tp, d) #define xfs_trans_agflist_delta(tp, d) #define xfs_trans_agbtree_delta(tp, d) #endif /* * XFS transaction mechanism exported interfaces. */ |
253f4911f
|
175 176 177 |
int xfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp, uint blocks, uint rtextents, uint flags, struct xfs_trans **tpp); |
e89c04133
|
178 179 |
int xfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp); |
20f4ebf2b
|
180 |
void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t); |
de2a4f591
|
181 |
|
9676b54e6
|
182 183 184 |
int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target, struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags, struct xfs_buf **bpp); |
de2a4f591
|
185 |
|
ce92464c1
|
186 |
static inline int |
de2a4f591
|
187 188 189 190 191 |
xfs_trans_get_buf( struct xfs_trans *tp, struct xfs_buftarg *target, xfs_daddr_t blkno, int numblks, |
ce92464c1
|
192 193 |
uint flags, struct xfs_buf **bpp) |
de2a4f591
|
194 |
{ |
c3f8fc73a
|
195 |
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); |
ce92464c1
|
196 |
return xfs_trans_get_buf_map(tp, target, &map, 1, flags, bpp); |
de2a4f591
|
197 198 199 200 201 202 203 |
} int xfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buftarg *target, struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags, |
c3f8fc73a
|
204 |
struct xfs_buf **bpp, |
1813dd640
|
205 |
const struct xfs_buf_ops *ops); |
de2a4f591
|
206 207 208 209 210 211 212 213 214 |
static inline int xfs_trans_read_buf( struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buftarg *target, xfs_daddr_t blkno, int numblks, xfs_buf_flags_t flags, |
c3f8fc73a
|
215 |
struct xfs_buf **bpp, |
1813dd640
|
216 |
const struct xfs_buf_ops *ops) |
de2a4f591
|
217 |
{ |
c3f8fc73a
|
218 219 |
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); return xfs_trans_read_buf_map(mp, tp, target, &map, 1, |
1813dd640
|
220 |
flags, bpp, ops); |
de2a4f591
|
221 |
} |
cead0b10f
|
222 |
struct xfs_buf *xfs_trans_getsb(struct xfs_trans *); |
1da177e4c
|
223 224 225 226 |
void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *); void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *); void xfs_trans_bhold(xfs_trans_t *, struct xfs_buf *); |
efa092f3d
|
227 |
void xfs_trans_bhold_release(xfs_trans_t *, struct xfs_buf *); |
1da177e4c
|
228 229 |
void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *); void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *); |
1da177e4c
|
230 |
void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *); |
a5814bcee
|
231 |
bool xfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); |
1da177e4c
|
232 233 |
void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint); void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *); |
dcd79a142
|
234 |
void xfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); |
ddc3415ab
|
235 |
void xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint); |
9684010d3
|
236 237 238 |
void xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint, uint); void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); |
38b6238eb
|
239 |
bool xfs_trans_buf_is_dirty(struct xfs_buf *bp); |
1da177e4c
|
240 |
void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint); |
9749fee83
|
241 |
|
70393313d
|
242 |
int xfs_trans_commit(struct xfs_trans *); |
411350df1
|
243 244 |
int xfs_trans_roll(struct xfs_trans **); int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *); |
4906e2154
|
245 |
void xfs_trans_cancel(xfs_trans_t *); |
249a8c112
|
246 247 |
int xfs_trans_ail_init(struct xfs_mount *); void xfs_trans_ail_destroy(struct xfs_mount *); |
1da177e4c
|
248 |
|
a4fbe6ab1
|
249 250 251 252 |
void xfs_trans_buf_set_type(struct xfs_trans *, struct xfs_buf *, enum xfs_blft); void xfs_trans_buf_copy_type(struct xfs_buf *dst_bp, struct xfs_buf *src_bp); |
a8272ce0c
|
253 |
extern kmem_zone_t *xfs_trans_zone; |
4e919af78
|
254 255 256 257 258 259 260 |
static inline struct xfs_log_item * xfs_trans_item_relog( struct xfs_log_item *lip, struct xfs_trans *tp) { return lip->li_ops->iop_relog(lip, tp); } |
1da177e4c
|
261 |
#endif /* __XFS_TRANS_H__ */ |