]>
Commit | Line | Data |
---|---|---|
b626fb59 DC |
1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it would be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
19 | #ifndef __XFS_TRANS_H__ | |
20 | #define __XFS_TRANS_H__ | |
21 | ||
22 | struct xfs_mount; | |
23 | struct xfs_buftarg; | |
24 | struct xfs_buf; | |
25 | struct xfs_buf_map; | |
26 | ||
27 | /* | |
28 | * Userspace Transaction interface | |
29 | */ | |
30 | ||
31 | typedef struct xfs_log_item { | |
32 | struct xfs_log_item_desc *li_desc; /* ptr to current desc*/ | |
33 | struct xfs_mount *li_mountp; /* ptr to fs mount */ | |
34 | uint li_type; /* item type */ | |
35 | xfs_lsn_t li_lsn; | |
36 | } xfs_log_item_t; | |
37 | ||
38 | typedef struct xfs_inode_log_item { | |
39 | xfs_log_item_t ili_item; /* common portion */ | |
40 | struct xfs_inode *ili_inode; /* inode pointer */ | |
41 | unsigned short ili_flags; /* misc flags */ | |
42 | unsigned int ili_fields; /* fields to be logged */ | |
43 | unsigned int ili_last_fields; /* fields when flushed*/ | |
44 | xfs_inode_log_format_t ili_format; /* logged structure */ | |
45 | } xfs_inode_log_item_t; | |
46 | ||
47 | typedef struct xfs_buf_log_item { | |
48 | xfs_log_item_t bli_item; /* common item structure */ | |
49 | struct xfs_buf *bli_buf; /* real buffer pointer */ | |
50 | unsigned int bli_flags; /* misc flags */ | |
51 | unsigned int bli_recur; /* recursion count */ | |
52 | xfs_buf_log_format_t bli_format; /* in-log header */ | |
53 | } xfs_buf_log_item_t; | |
54 | ||
55 | #define XFS_BLI_DIRTY (1<<0) | |
56 | #define XFS_BLI_HOLD (1<<1) | |
57 | #define XFS_BLI_STALE (1<<2) | |
58 | #define XFS_BLI_INODE_ALLOC_BUF (1<<3) | |
59 | ||
60 | typedef struct xfs_dq_logitem { | |
61 | xfs_log_item_t qli_item; /* common portion */ | |
62 | struct xfs_dquot *qli_dquot; /* dquot ptr */ | |
63 | xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ | |
64 | xfs_dq_logformat_t qli_format; /* logged structure */ | |
65 | } xfs_dq_logitem_t; | |
66 | ||
67 | typedef struct xfs_qoff_logitem { | |
68 | xfs_log_item_t qql_item; /* common portion */ | |
69 | struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */ | |
70 | xfs_qoff_logformat_t qql_format; /* logged structure */ | |
71 | } xfs_qoff_logitem_t; | |
72 | ||
73 | typedef struct xfs_trans { | |
74 | unsigned int t_type; /* transaction type */ | |
75 | unsigned int t_log_res; /* amt of log space resvd */ | |
76 | unsigned int t_log_count; /* count for perm log res */ | |
0268fdc3 | 77 | unsigned int t_blk_res; /* # of blocks resvd */ |
b626fb59 DC |
78 | struct xfs_mount *t_mountp; /* ptr to fs mount struct */ |
79 | unsigned int t_flags; /* misc flags */ | |
80 | long t_icount_delta; /* superblock icount change */ | |
81 | long t_ifree_delta; /* superblock ifree change */ | |
82 | long t_fdblocks_delta; /* superblock fdblocks chg */ | |
83 | long t_frextents_delta; /* superblock freextents chg */ | |
84 | struct list_head t_items; /* first log item desc chunk */ | |
85 | } xfs_trans_t; | |
86 | ||
87 | void xfs_trans_init(struct xfs_mount *); | |
88 | int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *); | |
89 | ||
90 | xfs_trans_t *libxfs_trans_alloc(struct xfs_mount *, int); | |
b626fb59 DC |
91 | int libxfs_trans_reserve(struct xfs_trans *, struct xfs_trans_res *, |
92 | uint, uint); | |
de5a3f46 | 93 | int libxfs_trans_commit(struct xfs_trans *); |
3d7434fe | 94 | void libxfs_trans_cancel(struct xfs_trans *); |
b626fb59 DC |
95 | struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *, struct xfs_mount *, int); |
96 | ||
97 | int libxfs_trans_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, | |
98 | uint, uint, struct xfs_inode **); | |
99 | void libxfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint); | |
100 | void libxfs_trans_ijoin_ref(struct xfs_trans *, struct xfs_inode *, int); | |
101 | void libxfs_trans_log_inode (struct xfs_trans *, struct xfs_inode *, | |
102 | uint); | |
103 | ||
104 | void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *); | |
105 | void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *); | |
106 | void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *); | |
107 | void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *); | |
108 | void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, | |
109 | uint, uint); | |
110 | ||
111 | struct xfs_buf *libxfs_trans_get_buf_map(struct xfs_trans *tp, | |
112 | struct xfs_buftarg *btp, | |
113 | struct xfs_buf_map *map, int nmaps, | |
114 | uint flags); | |
115 | ||
116 | int libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp, | |
117 | struct xfs_buftarg *btp, | |
118 | struct xfs_buf_map *map, int nmaps, | |
119 | uint flags, struct xfs_buf **bpp, | |
120 | const struct xfs_buf_ops *ops); | |
121 | static inline struct xfs_buf * | |
122 | libxfs_trans_get_buf( | |
123 | struct xfs_trans *tp, | |
124 | struct xfs_buftarg *btp, | |
125 | xfs_daddr_t blkno, | |
126 | int numblks, | |
127 | uint flags) | |
128 | { | |
129 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
130 | return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags); | |
131 | } | |
132 | ||
133 | static inline int | |
134 | libxfs_trans_read_buf( | |
135 | struct xfs_mount *mp, | |
136 | struct xfs_trans *tp, | |
137 | struct xfs_buftarg *btp, | |
138 | xfs_daddr_t blkno, | |
139 | int numblks, | |
140 | uint flags, | |
141 | struct xfs_buf **bpp, | |
142 | const struct xfs_buf_ops *ops) | |
143 | { | |
144 | DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); | |
145 | return libxfs_trans_read_buf_map(mp, tp, btp, &map, 1, flags, bpp, ops); | |
146 | } | |
147 | ||
148 | #endif /* __XFS_TRANS_H__ */ |