1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _LINUX_EXT3_JBD_H
16#define _LINUX_EXT3_JBD_H
17
18#include <linux/fs.h>
19#include <linux/jbd.h>
20#include <linux/ext3_fs.h>
21
22#define EXT3_JOURNAL(inode) (EXT3_SB((inode)->i_sb)->s_journal)
23
24
25
26
27
28
29
30
31#define EXT3_SINGLEDATA_TRANS_BLOCKS 8U
32
33
34
35
36
37#define EXT3_XATTR_TRANS_BLOCKS 6U
38
39
40
41
42
43
44
45#define EXT3_DATA_TRANS_BLOCKS(sb) (EXT3_SINGLEDATA_TRANS_BLOCKS + \
46 EXT3_XATTR_TRANS_BLOCKS - 2 + \
47 EXT3_MAXQUOTAS_TRANS_BLOCKS(sb))
48
49
50
51
52
53#define EXT3_DELETE_TRANS_BLOCKS(sb) (EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) + 64)
54
55
56
57
58
59
60
61#define EXT3_MAX_TRANS_DATA 64U
62
63
64
65
66
67
68
69
70#define EXT3_RESERVE_TRANS_BLOCKS 12U
71
72#define EXT3_INDEX_EXTRA_TRANS_BLOCKS 8
73
74#ifdef CONFIG_QUOTA
75
76
77#define EXT3_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0)
78
79
80#define EXT3_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
81 (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_INIT_REWRITE) : 0)
82#define EXT3_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
83 (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_DEL_REWRITE) : 0)
84#else
85#define EXT3_QUOTA_TRANS_BLOCKS(sb) 0
86#define EXT3_QUOTA_INIT_BLOCKS(sb) 0
87#define EXT3_QUOTA_DEL_BLOCKS(sb) 0
88#endif
89#define EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_TRANS_BLOCKS(sb))
90#define EXT3_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_INIT_BLOCKS(sb))
91#define EXT3_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_DEL_BLOCKS(sb))
92
93int
94ext3_mark_iloc_dirty(handle_t *handle,
95 struct inode *inode,
96 struct ext3_iloc *iloc);
97
98
99
100
101
102
103int ext3_reserve_inode_write(handle_t *handle, struct inode *inode,
104 struct ext3_iloc *iloc);
105
106int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
107
108
109
110
111
112
113
114
115static inline void ext3_journal_release_buffer(handle_t *handle,
116 struct buffer_head *bh)
117{
118 journal_release_buffer(handle, bh);
119}
120
121void ext3_journal_abort_handle(const char *caller, const char *err_fn,
122 struct buffer_head *bh, handle_t *handle, int err);
123
124int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
125 struct buffer_head *bh);
126
127int __ext3_journal_get_write_access(const char *where, handle_t *handle,
128 struct buffer_head *bh);
129
130int __ext3_journal_forget(const char *where, handle_t *handle,
131 struct buffer_head *bh);
132
133int __ext3_journal_revoke(const char *where, handle_t *handle,
134 unsigned long blocknr, struct buffer_head *bh);
135
136int __ext3_journal_get_create_access(const char *where,
137 handle_t *handle, struct buffer_head *bh);
138
139int __ext3_journal_dirty_metadata(const char *where,
140 handle_t *handle, struct buffer_head *bh);
141
142#define ext3_journal_get_undo_access(handle, bh) \
143 __ext3_journal_get_undo_access(__func__, (handle), (bh))
144#define ext3_journal_get_write_access(handle, bh) \
145 __ext3_journal_get_write_access(__func__, (handle), (bh))
146#define ext3_journal_revoke(handle, blocknr, bh) \
147 __ext3_journal_revoke(__func__, (handle), (blocknr), (bh))
148#define ext3_journal_get_create_access(handle, bh) \
149 __ext3_journal_get_create_access(__func__, (handle), (bh))
150#define ext3_journal_dirty_metadata(handle, bh) \
151 __ext3_journal_dirty_metadata(__func__, (handle), (bh))
152#define ext3_journal_forget(handle, bh) \
153 __ext3_journal_forget(__func__, (handle), (bh))
154
155int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
156
157handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks);
158int __ext3_journal_stop(const char *where, handle_t *handle);
159
160static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
161{
162 return ext3_journal_start_sb(inode->i_sb, nblocks);
163}
164
165#define ext3_journal_stop(handle) \
166 __ext3_journal_stop(__func__, (handle))
167
168static inline handle_t *ext3_journal_current_handle(void)
169{
170 return journal_current_handle();
171}
172
173static inline int ext3_journal_extend(handle_t *handle, int nblocks)
174{
175 return journal_extend(handle, nblocks);
176}
177
178static inline int ext3_journal_restart(handle_t *handle, int nblocks)
179{
180 return journal_restart(handle, nblocks);
181}
182
183static inline int ext3_journal_blocks_per_page(struct inode *inode)
184{
185 return journal_blocks_per_page(inode);
186}
187
188static inline int ext3_journal_force_commit(journal_t *journal)
189{
190 return journal_force_commit(journal);
191}
192
193
194int ext3_force_commit(struct super_block *sb);
195
196static inline int ext3_should_journal_data(struct inode *inode)
197{
198 if (!S_ISREG(inode->i_mode))
199 return 1;
200 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
201 return 1;
202 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
203 return 1;
204 return 0;
205}
206
207static inline int ext3_should_order_data(struct inode *inode)
208{
209 if (!S_ISREG(inode->i_mode))
210 return 0;
211 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
212 return 0;
213 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
214 return 1;
215 return 0;
216}
217
218static inline int ext3_should_writeback_data(struct inode *inode)
219{
220 if (!S_ISREG(inode->i_mode))
221 return 0;
222 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
223 return 0;
224 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
225 return 1;
226 return 0;
227}
228
229#endif
230