]>
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 */ |
255682d9 | 67 | xfs_fsblock_t t_firstblock; /* first block allocated */ |
b626fb59 | 68 | struct xfs_mount *t_mountp; /* ptr to fs mount struct */ |
41ab9202 | 69 | unsigned int t_blk_res_used; /* # of resvd blocks used */ |
b626fb59 DC |
70 | unsigned int t_flags; /* misc flags */ |
71 | long t_icount_delta; /* superblock icount change */ | |
72 | long t_ifree_delta; /* superblock ifree change */ | |
73 | long t_fdblocks_delta; /* superblock fdblocks chg */ | |
74 | long t_frextents_delta; /* superblock freextents chg */ | |
75 | struct list_head t_items; /* first log item desc chunk */ | |
92a8736e | 76 | struct list_head t_dfops; /* deferred operations */ |
b626fb59 DC |
77 | } xfs_trans_t; |
78 | ||
79 | void xfs_trans_init(struct xfs_mount *); | |
d67406c9 | 80 | int xfs_trans_roll(struct xfs_trans **); |
b626fb59 | 81 | |
9074815c CH |
82 | int libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp, |
83 | uint blocks, uint rtextents, uint flags, | |
84 | struct xfs_trans **tpp); | |
225e4bb2 DW |
85 | int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks, |
86 | struct xfs_trans **tpp); | |
3680a764 | 87 | int libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp); |
de5a3f46 | 88 | int libxfs_trans_commit(struct xfs_trans *); |
3d7434fe | 89 | void libxfs_trans_cancel(struct xfs_trans *); |
ac0a2228 BF |
90 | |
91 | /* cancel dfops associated with a transaction */ | |
92 | void xfs_defer_cancel(struct xfs_trans *); | |
93 | ||
37e6f885 | 94 | struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *); |
b626fb59 | 95 | |
b626fb59 | 96 | void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint); |
b626fb59 DC |
97 | void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *, |
98 | uint); | |
d67406c9 | 99 | int libxfs_trans_roll_inode (struct xfs_trans **, struct xfs_inode *); |
b626fb59 DC |
100 | |
101 | void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *); | |
102 | void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *); | |
103 | void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *); | |
104 | void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *); | |
9833c1a4 | 105 | void libxfs_trans_bhold_release(struct xfs_trans *, struct xfs_buf *); |
59630067 | 106 | void libxfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); |
b626fb59 DC |
107 | void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, |
108 | uint, uint); | |
38fa71a7 | 109 | bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); |
b626fb59 | 110 | |
51409fcc DW |
111 | int libxfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *btp, |
112 | struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags, | |
113 | struct xfs_buf **bpp); | |
b626fb59 DC |
114 | |
115 | int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp, | |
116 | struct xfs_buftarg *btp, | |
117 | struct xfs_buf_map *map, int nmaps, | |
3a3f5b14 | 118 | xfs_buf_flags_t flags, struct xfs_buf **bpp, |
b626fb59 | 119 | const struct xfs_buf_ops *ops); |
7f15a547 | 120 | static inline int |
b626fb59 DC |
121 | libxfs_trans_get_buf( |
122 | struct xfs_trans *tp, | |
123 | struct xfs_buftarg *btp, | |
124 | xfs_daddr_t blkno, | |
125 | int numblks, | |
7f15a547 DW |
126 | uint flags, |
127 | struct xfs_buf **bpp) | |
b626fb59 DC |
128 | { |
129 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
51409fcc | 130 | |
7f15a547 | 131 | return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, bpp); |
b626fb59 DC |
132 | } |
133 | ||
134 | static inline int | |
135 | libxfs_trans_read_buf( | |
136 | struct xfs_mount *mp, | |
137 | struct xfs_trans *tp, | |
138 | struct xfs_buftarg *btp, | |
139 | xfs_daddr_t blkno, | |
140 | int numblks, | |
3a3f5b14 | 141 | xfs_buf_flags_t flags, |
b626fb59 DC |
142 | struct xfs_buf **bpp, |
143 | const struct xfs_buf_ops *ops) | |
144 | { | |
145 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
146 | return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops); | |
147 | } | |
148 | ||
149 | #endif /* __XFS_TRANS_H__ */ |