]>
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 */ |
2b8ea826 | 25 | struct xfs_buf *li_buf; /* real buffer pointer */ |
2efa10f3 | 26 | struct list_head li_bio_list; /* buffer item list */ |
b626fb59 DC |
27 | } xfs_log_item_t; |
28 | ||
2fdd378a DC |
29 | #define XFS_LI_DIRTY 3 /* log item dirty in transaction */ |
30 | ||
ed8d09e1 | 31 | struct xfs_inode_log_item { |
b626fb59 DC |
32 | xfs_log_item_t ili_item; /* common portion */ |
33 | struct xfs_inode *ili_inode; /* inode pointer */ | |
c0860494 | 34 | unsigned short ili_lock_flags; /* lock flags */ |
b626fb59 | 35 | unsigned int ili_last_fields; /* fields when flushed*/ |
5539639c ES |
36 | unsigned int ili_fields; /* fields to be logged */ |
37 | unsigned int ili_fsync_fields; /* ignored by userspace */ | |
ed8d09e1 | 38 | }; |
b626fb59 DC |
39 | |
40 | typedef struct xfs_buf_log_item { | |
41 | xfs_log_item_t bli_item; /* common item structure */ | |
42 | struct xfs_buf *bli_buf; /* real buffer pointer */ | |
43 | unsigned int bli_flags; /* misc flags */ | |
44 | unsigned int bli_recur; /* recursion count */ | |
cebe02e2 | 45 | xfs_buf_log_format_t __bli_format; /* in-log header */ |
b626fb59 DC |
46 | } xfs_buf_log_item_t; |
47 | ||
48 | #define XFS_BLI_DIRTY (1<<0) | |
49 | #define XFS_BLI_HOLD (1<<1) | |
50 | #define XFS_BLI_STALE (1<<2) | |
51 | #define XFS_BLI_INODE_ALLOC_BUF (1<<3) | |
e30de1a1 | 52 | #define XFS_BLI_ORDERED (1<<4) |
b626fb59 | 53 | |
b626fb59 DC |
54 | typedef struct xfs_qoff_logitem { |
55 | xfs_log_item_t qql_item; /* common portion */ | |
56 | struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */ | |
57 | xfs_qoff_logformat_t qql_format; /* logged structure */ | |
58 | } xfs_qoff_logitem_t; | |
59 | ||
f5f4497f BF |
60 | #define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ |
61 | #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ | |
62 | ||
b626fb59 | 63 | typedef struct xfs_trans { |
b626fb59 DC |
64 | unsigned int t_log_res; /* amt of log space resvd */ |
65 | unsigned int t_log_count; /* count for perm log res */ | |
0268fdc3 | 66 | unsigned int t_blk_res; /* # of blocks resvd */ |
41ab9202 | 67 | unsigned int t_blk_res_used; /* # of resvd blocks used */ |
75d8bf7e DW |
68 | unsigned int t_rtx_res; /* # of rt extents resvd */ |
69 | unsigned int t_rtx_res_used; /* # of resvd rt extents used */ | |
b626fb59 | 70 | unsigned int t_flags; /* misc flags */ |
75d8bf7e DW |
71 | xfs_fsblock_t t_firstblock; /* first block allocated */ |
72 | struct xfs_mount *t_mountp; /* ptr to fs mount struct */ | |
b626fb59 DC |
73 | long t_icount_delta; /* superblock icount change */ |
74 | long t_ifree_delta; /* superblock ifree change */ | |
75 | long t_fdblocks_delta; /* superblock fdblocks chg */ | |
76 | long t_frextents_delta; /* superblock freextents chg */ | |
77 | struct list_head t_items; /* first log item desc chunk */ | |
92a8736e | 78 | struct list_head t_dfops; /* deferred operations */ |
b626fb59 DC |
79 | } xfs_trans_t; |
80 | ||
81 | void xfs_trans_init(struct xfs_mount *); | |
d67406c9 | 82 | int xfs_trans_roll(struct xfs_trans **); |
b626fb59 | 83 | |
9074815c CH |
84 | int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp, |
85 | uint blocks, uint rtextents, uint flags, | |
86 | struct xfs_trans **tpp); | |
225e4bb2 DW |
87 | int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks, |
88 | struct xfs_trans **tpp); | |
3680a764 | 89 | int libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp); |
de5a3f46 | 90 | int libxfs_trans_commit(struct xfs_trans *); |
3d7434fe | 91 | void libxfs_trans_cancel(struct xfs_trans *); |
ac0a2228 BF |
92 | |
93 | /* cancel dfops associated with a transaction */ | |
94 | void xfs_defer_cancel(struct xfs_trans *); | |
95 | ||
37e6f885 | 96 | struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *); |
b626fb59 | 97 | |
b626fb59 | 98 | void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint); |
b626fb59 DC |
99 | void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *, |
100 | uint); | |
d67406c9 | 101 | int libxfs_trans_roll_inode (struct xfs_trans **, struct xfs_inode *); |
b626fb59 DC |
102 | |
103 | void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *); | |
104 | void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *); | |
105 | void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *); | |
106 | void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *); | |
9833c1a4 | 107 | void libxfs_trans_bhold_release(struct xfs_trans *, struct xfs_buf *); |
59630067 | 108 | void libxfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); |
b626fb59 DC |
109 | void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, |
110 | uint, uint); | |
38fa71a7 | 111 | bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); |
b626fb59 | 112 | |
51409fcc DW |
113 | int libxfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *btp, |
114 | struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags, | |
115 | struct xfs_buf **bpp); | |
b626fb59 DC |
116 | |
117 | int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp, | |
118 | struct xfs_buftarg *btp, | |
119 | struct xfs_buf_map *map, int nmaps, | |
3a3f5b14 | 120 | xfs_buf_flags_t flags, struct xfs_buf **bpp, |
b626fb59 | 121 | const struct xfs_buf_ops *ops); |
7f15a547 | 122 | static inline int |
b626fb59 DC |
123 | libxfs_trans_get_buf( |
124 | struct xfs_trans *tp, | |
125 | struct xfs_buftarg *btp, | |
126 | xfs_daddr_t blkno, | |
127 | int numblks, | |
7f15a547 DW |
128 | uint flags, |
129 | struct xfs_buf **bpp) | |
b626fb59 DC |
130 | { |
131 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
51409fcc | 132 | |
7f15a547 | 133 | return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, bpp); |
b626fb59 DC |
134 | } |
135 | ||
136 | static inline int | |
137 | libxfs_trans_read_buf( | |
138 | struct xfs_mount *mp, | |
139 | struct xfs_trans *tp, | |
140 | struct xfs_buftarg *btp, | |
141 | xfs_daddr_t blkno, | |
142 | int numblks, | |
3a3f5b14 | 143 | xfs_buf_flags_t flags, |
b626fb59 DC |
144 | struct xfs_buf **bpp, |
145 | const struct xfs_buf_ops *ops) | |
146 | { | |
147 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
148 | return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops); | |
149 | } | |
150 | ||
1826a6b0 DW |
151 | #define xfs_log_item_in_current_chkpt(lip) (false) |
152 | #define xfs_trans_item_relog(lip, tp) (NULL) | |
153 | ||
e49ec9ed DW |
154 | /* Contorted mess to make gcc shut up about unused vars. */ |
155 | #define xlog_grant_push_threshold(log, need) \ | |
156 | ((log) == (log) ? NULLCOMMITLSN : NULLCOMMITLSN) | |
157 | ||
158 | /* from xfs_log.h */ | |
159 | /* | |
160 | * By comparing each component, we don't have to worry about extra | |
161 | * endian issues in treating two 32 bit numbers as one 64 bit number | |
162 | */ | |
163 | static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) | |
164 | { | |
165 | if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2)) | |
166 | return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999; | |
167 | ||
168 | if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2)) | |
169 | return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999; | |
170 | ||
171 | return 0; | |
172 | } | |
173 | ||
174 | #define XFS_LSN_CMP(a, b) _lsn_cmp(a, b) | |
175 | ||
b626fb59 | 176 | #endif /* __XFS_TRANS_H__ */ |