aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ext3_jbd.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/ext3_jbd.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/ext3_jbd.h')
-rw-r--r--include/linux/ext3_jbd.h265
1 files changed, 265 insertions, 0 deletions
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
new file mode 100644
index 000000000000..e8292af9033b
--- /dev/null
+++ b/include/linux/ext3_jbd.h
@@ -0,0 +1,265 @@
1/*
2 * linux/include/linux/ext3_jbd.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 *
6 * Copyright 1998--1999 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Ext3-specific journaling extensions.
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/* Define the number of blocks we need to account to a transaction to
25 * modify one block of data.
26 *
27 * We may have to touch one inode, one bitmap buffer, up to three
28 * indirection blocks, the group and superblock summaries, and the data
29 * block to complete the transaction. */
30
31#define EXT3_SINGLEDATA_TRANS_BLOCKS 8U
32
33/* Extended attribute operations touch at most two data buffers,
34 * two bitmap buffers, and two group summaries, in addition to the inode
35 * and the superblock, which are already accounted for. */
36
37#define EXT3_XATTR_TRANS_BLOCKS 6U
38
39/* Define the minimum size for a transaction which modifies data. This
40 * needs to take into account the fact that we may end up modifying two
41 * quota files too (one for the group, one for the user quota). The
42 * superblock only gets updated once, of course, so don't bother
43 * counting that again for the quota updates. */
44
45#define EXT3_DATA_TRANS_BLOCKS (EXT3_SINGLEDATA_TRANS_BLOCKS + \
46 EXT3_XATTR_TRANS_BLOCKS - 2 + \
47 2*EXT3_QUOTA_TRANS_BLOCKS)
48
49/* Delete operations potentially hit one directory's namespace plus an
50 * entire inode, plus arbitrary amounts of bitmap/indirection data. Be
51 * generous. We can grow the delete transaction later if necessary. */
52
53#define EXT3_DELETE_TRANS_BLOCKS (2 * EXT3_DATA_TRANS_BLOCKS + 64)
54
55/* Define an arbitrary limit for the amount of data we will anticipate
56 * writing to any given transaction. For unbounded transactions such as
57 * write(2) and truncate(2) we can write more than this, but we always
58 * start off at the maximum transaction size and grow the transaction
59 * optimistically as we go. */
60
61#define EXT3_MAX_TRANS_DATA 64U
62
63/* We break up a large truncate or write transaction once the handle's
64 * buffer credits gets this low, we need either to extend the
65 * transaction or to start a new one. Reserve enough space here for
66 * inode, bitmap, superblock, group and indirection updates for at least
67 * one block, plus two quota updates. Quota allocations are not
68 * needed. */
69
70#define EXT3_RESERVE_TRANS_BLOCKS 12U
71
72#define EXT3_INDEX_EXTRA_TRANS_BLOCKS 8
73
74#ifdef CONFIG_QUOTA
75/* Amount of blocks needed for quota update - we know that the structure was
76 * allocated so we need to update only inode+data */
77#define EXT3_QUOTA_TRANS_BLOCKS 2
78/* Amount of blocks needed for quota insert/delete - we do some block writes
79 * but inode, sb and group updates are done only once */
80#define EXT3_QUOTA_INIT_BLOCKS (DQUOT_MAX_WRITES*\
81 (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3)
82#else
83#define EXT3_QUOTA_TRANS_BLOCKS 0
84#define EXT3_QUOTA_INIT_BLOCKS 0
85#endif
86
87int
88ext3_mark_iloc_dirty(handle_t *handle,
89 struct inode *inode,
90 struct ext3_iloc *iloc);
91
92/*
93 * On success, We end up with an outstanding reference count against
94 * iloc->bh. This _must_ be cleaned up later.
95 */
96
97int ext3_reserve_inode_write(handle_t *handle, struct inode *inode,
98 struct ext3_iloc *iloc);
99
100int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
101
102/*
103 * Wrapper functions with which ext3 calls into JBD. The intent here is
104 * to allow these to be turned into appropriate stubs so ext3 can control
105 * ext2 filesystems, so ext2+ext3 systems only nee one fs. This work hasn't
106 * been done yet.
107 */
108
109void ext3_journal_abort_handle(const char *caller, const char *err_fn,
110 struct buffer_head *bh, handle_t *handle, int err);
111
112static inline int
113__ext3_journal_get_undo_access(const char *where, handle_t *handle,
114 struct buffer_head *bh)
115{
116 int err = journal_get_undo_access(handle, bh);
117 if (err)
118 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
119 return err;
120}
121
122static inline int
123__ext3_journal_get_write_access(const char *where, handle_t *handle,
124 struct buffer_head *bh)
125{
126 int err = journal_get_write_access(handle, bh);
127 if (err)
128 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
129 return err;
130}
131
132static inline void
133ext3_journal_release_buffer(handle_t *handle, struct buffer_head *bh)
134{
135 journal_release_buffer(handle, bh);
136}
137
138static inline int
139__ext3_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh)
140{
141 int err = journal_forget(handle, bh);
142 if (err)
143 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
144 return err;
145}
146
147static inline int
148__ext3_journal_revoke(const char *where, handle_t *handle,
149 unsigned long blocknr, struct buffer_head *bh)
150{
151 int err = journal_revoke(handle, blocknr, bh);
152 if (err)
153 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
154 return err;
155}
156
157static inline int
158__ext3_journal_get_create_access(const char *where,
159 handle_t *handle, struct buffer_head *bh)
160{
161 int err = journal_get_create_access(handle, bh);
162 if (err)
163 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
164 return err;
165}
166
167static inline int
168__ext3_journal_dirty_metadata(const char *where,
169 handle_t *handle, struct buffer_head *bh)
170{
171 int err = journal_dirty_metadata(handle, bh);
172 if (err)
173 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
174 return err;
175}
176
177
178#define ext3_journal_get_undo_access(handle, bh) \
179 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh))
180#define ext3_journal_get_write_access(handle, bh) \
181 __ext3_journal_get_write_access(__FUNCTION__, (handle), (bh))
182#define ext3_journal_revoke(handle, blocknr, bh) \
183 __ext3_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh))
184#define ext3_journal_get_create_access(handle, bh) \
185 __ext3_journal_get_create_access(__FUNCTION__, (handle), (bh))
186#define ext3_journal_dirty_metadata(handle, bh) \
187 __ext3_journal_dirty_metadata(__FUNCTION__, (handle), (bh))
188#define ext3_journal_forget(handle, bh) \
189 __ext3_journal_forget(__FUNCTION__, (handle), (bh))
190
191int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
192
193handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks);
194int __ext3_journal_stop(const char *where, handle_t *handle);
195
196static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
197{
198 return ext3_journal_start_sb(inode->i_sb, nblocks);
199}
200
201#define ext3_journal_stop(handle) \
202 __ext3_journal_stop(__FUNCTION__, (handle))
203
204static inline handle_t *ext3_journal_current_handle(void)
205{
206 return journal_current_handle();
207}
208
209static inline int ext3_journal_extend(handle_t *handle, int nblocks)
210{
211 return journal_extend(handle, nblocks);
212}
213
214static inline int ext3_journal_restart(handle_t *handle, int nblocks)
215{
216 return journal_restart(handle, nblocks);
217}
218
219static inline int ext3_journal_blocks_per_page(struct inode *inode)
220{
221 return journal_blocks_per_page(inode);
222}
223
224static inline int ext3_journal_force_commit(journal_t *journal)
225{
226 return journal_force_commit(journal);
227}
228
229/* super.c */
230int ext3_force_commit(struct super_block *sb);
231
232static inline int ext3_should_journal_data(struct inode *inode)
233{
234 if (!S_ISREG(inode->i_mode))
235 return 1;
236 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
237 return 1;
238 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
239 return 1;
240 return 0;
241}
242
243static inline int ext3_should_order_data(struct inode *inode)
244{
245 if (!S_ISREG(inode->i_mode))
246 return 0;
247 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
248 return 0;
249 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
250 return 1;
251 return 0;
252}
253
254static inline int ext3_should_writeback_data(struct inode *inode)
255{
256 if (!S_ISREG(inode->i_mode))
257 return 0;
258 if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
259 return 0;
260 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
261 return 1;
262 return 0;
263}
264
265#endif /* _LINUX_EXT3_JBD_H */