1d6910058SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2470decc6SDave Kleikamp /*
3f7f4bccbSMingming Cao * linux/include/linux/jbd2.h
4470decc6SDave Kleikamp *
5470decc6SDave Kleikamp * Written by Stephen C. Tweedie <[email protected]>
6470decc6SDave Kleikamp *
7470decc6SDave Kleikamp * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
8470decc6SDave Kleikamp *
9470decc6SDave Kleikamp * Definitions for transaction data structures for the buffer cache
10470decc6SDave Kleikamp * filesystem journaling support.
11470decc6SDave Kleikamp */
12470decc6SDave Kleikamp
13cd02ff0bSMingming Cao #ifndef _LINUX_JBD2_H
14cd02ff0bSMingming Cao #define _LINUX_JBD2_H
15470decc6SDave Kleikamp
16470decc6SDave Kleikamp /* Allow this file to be included directly into e2fsprogs */
17470decc6SDave Kleikamp #ifndef __KERNEL__
18470decc6SDave Kleikamp #include "jfs_compat.h"
19f7f4bccbSMingming Cao #define JBD2_DEBUG
20470decc6SDave Kleikamp #else
21470decc6SDave Kleikamp
22470decc6SDave Kleikamp #include <linux/types.h>
23470decc6SDave Kleikamp #include <linux/buffer_head.h>
24470decc6SDave Kleikamp #include <linux/journal-head.h>
25470decc6SDave Kleikamp #include <linux/stddef.h>
26470decc6SDave Kleikamp #include <linux/mutex.h>
27470decc6SDave Kleikamp #include <linux/timer.h>
285a0e3ad6STejun Heo #include <linux/slab.h>
29c290ea01SJan Kara #include <linux/bit_spinlock.h>
303f1266f1SChristoph Hellwig #include <linux/blkdev.h>
31dd348f05SEric Biggers #include <linux/crc32c.h>
32470decc6SDave Kleikamp #endif
33470decc6SDave Kleikamp
34470decc6SDave Kleikamp #define journal_oom_retry 1
35470decc6SDave Kleikamp
36470decc6SDave Kleikamp /*
37cd02ff0bSMingming Cao * Define JBD2_PARANIOD_IOFAIL to cause a kernel BUG() if ext4 finds
38470decc6SDave Kleikamp * certain classes of error which can occur due to failed IOs. Under
39cd02ff0bSMingming Cao * normal use we want ext4 to continue after such errors, because
40470decc6SDave Kleikamp * hardware _can_ fail, but for debugging purposes when running tests on
41470decc6SDave Kleikamp * known-good hardware we may want to trap these errors.
42470decc6SDave Kleikamp */
43cd02ff0bSMingming Cao #undef JBD2_PARANOID_IOFAIL
44470decc6SDave Kleikamp
45470decc6SDave Kleikamp /*
46470decc6SDave Kleikamp * The default maximum commit age, in seconds.
47470decc6SDave Kleikamp */
48cd02ff0bSMingming Cao #define JBD2_DEFAULT_MAX_COMMIT_AGE 5
49470decc6SDave Kleikamp
50e23291b9SJose R. Santos #ifdef CONFIG_JBD2_DEBUG
51470decc6SDave Kleikamp /*
52cd02ff0bSMingming Cao * Define JBD2_EXPENSIVE_CHECKING to enable more expensive internal
53470decc6SDave Kleikamp * consistency checks. By default we don't do this unless
54e23291b9SJose R. Santos * CONFIG_JBD2_DEBUG is on.
55470decc6SDave Kleikamp */
56cd02ff0bSMingming Cao #define JBD2_EXPENSIVE_CHECKING
57169f1a2aSPaul Gortmaker void __jbd2_debug(int level, const char *file, const char *func,
58169f1a2aSPaul Gortmaker unsigned int line, const char *fmt, ...);
59470decc6SDave Kleikamp
60cb3b3bf2SJan Kara #define jbd2_debug(n, fmt, a...) \
61169f1a2aSPaul Gortmaker __jbd2_debug((n), __FILE__, __func__, __LINE__, (fmt), ##a)
62470decc6SDave Kleikamp #else
63cb3b3bf2SJan Kara #define jbd2_debug(n, fmt, a...) no_printk(fmt, ##a)
64470decc6SDave Kleikamp #endif
65470decc6SDave Kleikamp
66d2eecb03STheodore Ts'o extern void *jbd2_alloc(size_t size, gfp_t flags);
67d2eecb03STheodore Ts'o extern void jbd2_free(void *ptr, size_t size);
68af1e76d6SMingming Cao
69f7f4bccbSMingming Cao #define JBD2_MIN_JOURNAL_BLOCKS 1024
709bd23c31SHarshad Shirwadkar #define JBD2_DEFAULT_FAST_COMMIT_BLOCKS 256
71470decc6SDave Kleikamp
72470decc6SDave Kleikamp #ifdef __KERNEL__
73470decc6SDave Kleikamp
74470decc6SDave Kleikamp /**
75470decc6SDave Kleikamp * typedef handle_t - The handle_t type represents a single atomic update being performed by some process.
76470decc6SDave Kleikamp *
77470decc6SDave Kleikamp * All filesystem modifications made by the process go
78470decc6SDave Kleikamp * through this handle. Recursive operations (such as quota operations)
79470decc6SDave Kleikamp * are gathered into a single update.
80470decc6SDave Kleikamp *
81470decc6SDave Kleikamp * The buffer credits field is used to account for journaled buffers
82470decc6SDave Kleikamp * being modified by the running process. To ensure that there is
83470decc6SDave Kleikamp * enough log space for all outstanding operations, we need to limit the
84470decc6SDave Kleikamp * number of outstanding buffers possible at any time. When the
85470decc6SDave Kleikamp * operation completes, any buffer credits not used are credited back to
86470decc6SDave Kleikamp * the transaction, so that at all times we know how many buffers the
87470decc6SDave Kleikamp * outstanding updates on a transaction might possibly touch.
88470decc6SDave Kleikamp *
89470decc6SDave Kleikamp * This is an opaque datatype.
90470decc6SDave Kleikamp **/
918aefcd55STheodore Ts'o typedef struct jbd2_journal_handle handle_t; /* Atomic operation type */
92470decc6SDave Kleikamp
93470decc6SDave Kleikamp
94470decc6SDave Kleikamp /**
95470decc6SDave Kleikamp * typedef journal_t - The journal_t maintains all of the journaling state information for a single filesystem.
96470decc6SDave Kleikamp *
97470decc6SDave Kleikamp * journal_t is linked to from the fs superblock structure.
98470decc6SDave Kleikamp *
99470decc6SDave Kleikamp * We use the journal_t to keep track of all outstanding transaction
100470decc6SDave Kleikamp * activity on the filesystem, and to manage the state of the log
101470decc6SDave Kleikamp * writing process.
102470decc6SDave Kleikamp *
103470decc6SDave Kleikamp * This is an opaque datatype.
104470decc6SDave Kleikamp **/
105470decc6SDave Kleikamp typedef struct journal_s journal_t; /* Journal control structure */
106470decc6SDave Kleikamp #endif
107470decc6SDave Kleikamp
108470decc6SDave Kleikamp /*
109470decc6SDave Kleikamp * Internal structures used by the logging mechanism:
110470decc6SDave Kleikamp */
111470decc6SDave Kleikamp
112f7f4bccbSMingming Cao #define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
113470decc6SDave Kleikamp
114470decc6SDave Kleikamp /*
115470decc6SDave Kleikamp * On-disk structures
116470decc6SDave Kleikamp */
117470decc6SDave Kleikamp
118470decc6SDave Kleikamp /*
119470decc6SDave Kleikamp * Descriptor block types:
120470decc6SDave Kleikamp */
121470decc6SDave Kleikamp
122f7f4bccbSMingming Cao #define JBD2_DESCRIPTOR_BLOCK 1
123f7f4bccbSMingming Cao #define JBD2_COMMIT_BLOCK 2
124f7f4bccbSMingming Cao #define JBD2_SUPERBLOCK_V1 3
125f7f4bccbSMingming Cao #define JBD2_SUPERBLOCK_V2 4
126f7f4bccbSMingming Cao #define JBD2_REVOKE_BLOCK 5
127470decc6SDave Kleikamp
128470decc6SDave Kleikamp /*
129470decc6SDave Kleikamp * Standard header for all descriptor blocks:
130470decc6SDave Kleikamp */
131470decc6SDave Kleikamp typedef struct journal_header_s
132470decc6SDave Kleikamp {
133470decc6SDave Kleikamp __be32 h_magic;
134470decc6SDave Kleikamp __be32 h_blocktype;
135470decc6SDave Kleikamp __be32 h_sequence;
136470decc6SDave Kleikamp } journal_header_t;
137470decc6SDave Kleikamp
138818d276cSGirish Shilamkar /*
139818d276cSGirish Shilamkar * Checksum types.
140818d276cSGirish Shilamkar */
141818d276cSGirish Shilamkar #define JBD2_CRC32_CHKSUM 1
142818d276cSGirish Shilamkar #define JBD2_MD5_CHKSUM 2
143818d276cSGirish Shilamkar #define JBD2_SHA1_CHKSUM 3
1448f888ef8SDarrick J. Wong #define JBD2_CRC32C_CHKSUM 4
145818d276cSGirish Shilamkar
146818d276cSGirish Shilamkar #define JBD2_CRC32_CHKSUM_SIZE 4
147818d276cSGirish Shilamkar
148818d276cSGirish Shilamkar #define JBD2_CHECKSUM_BYTES (32 / sizeof(u32))
149818d276cSGirish Shilamkar /*
150818d276cSGirish Shilamkar * Commit block header for storing transactional checksums:
1518f888ef8SDarrick J. Wong *
1528f888ef8SDarrick J. Wong * NOTE: If FEATURE_COMPAT_CHECKSUM (checksum v1) is set, the h_chksum*
1538f888ef8SDarrick J. Wong * fields are used to store a checksum of the descriptor and data blocks.
1548f888ef8SDarrick J. Wong *
1558f888ef8SDarrick J. Wong * If FEATURE_INCOMPAT_CSUM_V2 (checksum v2) is set, then the h_chksum
1568f888ef8SDarrick J. Wong * field is used to store crc32c(uuid+commit_block). Each journal metadata
1578f888ef8SDarrick J. Wong * block gets its own checksum, and data block checksums are stored in
1588f888ef8SDarrick J. Wong * journal_block_tag (in the descriptor). The other h_chksum* fields are
1598f888ef8SDarrick J. Wong * not used.
1608f888ef8SDarrick J. Wong *
161db9ee220SDarrick J. Wong * If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
162db9ee220SDarrick J. Wong * journal_block_tag3_t to store a full 32-bit checksum. Everything else
163db9ee220SDarrick J. Wong * is the same as v2.
164db9ee220SDarrick J. Wong *
165db9ee220SDarrick J. Wong * Checksum v1, v2, and v3 are mutually exclusive features.
166818d276cSGirish Shilamkar */
167818d276cSGirish Shilamkar struct commit_header {
168818d276cSGirish Shilamkar __be32 h_magic;
169818d276cSGirish Shilamkar __be32 h_blocktype;
170818d276cSGirish Shilamkar __be32 h_sequence;
171818d276cSGirish Shilamkar unsigned char h_chksum_type;
172818d276cSGirish Shilamkar unsigned char h_chksum_size;
173818d276cSGirish Shilamkar unsigned char h_padding[2];
174818d276cSGirish Shilamkar __be32 h_chksum[JBD2_CHECKSUM_BYTES];
175736603abSTheodore Ts'o __be64 h_commit_sec;
176736603abSTheodore Ts'o __be32 h_commit_nsec;
177818d276cSGirish Shilamkar };
178470decc6SDave Kleikamp
179470decc6SDave Kleikamp /*
180b517bea1SZach Brown * The block tag: used to describe a single buffer in the journal.
181b517bea1SZach Brown * t_blocknr_high is only used if INCOMPAT_64BIT is set, so this
182b517bea1SZach Brown * raw struct shouldn't be used for pointer math or sizeof() - use
183b517bea1SZach Brown * journal_tag_bytes(journal) instead to compute this.
184470decc6SDave Kleikamp */
185db9ee220SDarrick J. Wong typedef struct journal_block_tag3_s
186db9ee220SDarrick J. Wong {
187db9ee220SDarrick J. Wong __be32 t_blocknr; /* The on-disk block number */
188db9ee220SDarrick J. Wong __be32 t_flags; /* See below */
189db9ee220SDarrick J. Wong __be32 t_blocknr_high; /* most-significant high 32bits. */
190db9ee220SDarrick J. Wong __be32 t_checksum; /* crc32c(uuid+seq+block) */
191db9ee220SDarrick J. Wong } journal_block_tag3_t;
192db9ee220SDarrick J. Wong
193470decc6SDave Kleikamp typedef struct journal_block_tag_s
194470decc6SDave Kleikamp {
195470decc6SDave Kleikamp __be32 t_blocknr; /* The on-disk block number */
1968f888ef8SDarrick J. Wong __be16 t_checksum; /* truncated crc32c(uuid+seq+block) */
1978f888ef8SDarrick J. Wong __be16 t_flags; /* See below */
198b517bea1SZach Brown __be32 t_blocknr_high; /* most-significant high 32bits. */
199470decc6SDave Kleikamp } journal_block_tag_t;
200470decc6SDave Kleikamp
2011101cd4dSJan Kara /* Tail of descriptor or revoke block, for checksumming */
2028f888ef8SDarrick J. Wong struct jbd2_journal_block_tail {
2038f888ef8SDarrick J. Wong __be32 t_checksum; /* crc32c(uuid+descr_block) */
2048f888ef8SDarrick J. Wong };
2058f888ef8SDarrick J. Wong
206470decc6SDave Kleikamp /*
207470decc6SDave Kleikamp * The revoke descriptor: used on disk to describe a series of blocks to
208470decc6SDave Kleikamp * be revoked from the log
209470decc6SDave Kleikamp */
210f7f4bccbSMingming Cao typedef struct jbd2_journal_revoke_header_s
211470decc6SDave Kleikamp {
212470decc6SDave Kleikamp journal_header_t r_header;
213470decc6SDave Kleikamp __be32 r_count; /* Count of bytes used in the block */
214f7f4bccbSMingming Cao } jbd2_journal_revoke_header_t;
215470decc6SDave Kleikamp
216470decc6SDave Kleikamp /* Definitions for the journal tag flags word: */
217f7f4bccbSMingming Cao #define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
218f7f4bccbSMingming Cao #define JBD2_FLAG_SAME_UUID 2 /* block has same uuid as previous */
219f7f4bccbSMingming Cao #define JBD2_FLAG_DELETED 4 /* block deleted by this transaction */
220f7f4bccbSMingming Cao #define JBD2_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
221470decc6SDave Kleikamp
222470decc6SDave Kleikamp
223470decc6SDave Kleikamp /*
224470decc6SDave Kleikamp * The journal superblock. All fields are in big-endian byte order.
225470decc6SDave Kleikamp */
226470decc6SDave Kleikamp typedef struct journal_superblock_s
227470decc6SDave Kleikamp {
228470decc6SDave Kleikamp /* 0x0000 */
229470decc6SDave Kleikamp journal_header_t s_header;
230470decc6SDave Kleikamp
231470decc6SDave Kleikamp /* 0x000C */
232470decc6SDave Kleikamp /* Static information describing the journal */
233470decc6SDave Kleikamp __be32 s_blocksize; /* journal device blocksize */
234470decc6SDave Kleikamp __be32 s_maxlen; /* total blocks in journal file */
235470decc6SDave Kleikamp __be32 s_first; /* first block of log information */
236470decc6SDave Kleikamp
237470decc6SDave Kleikamp /* 0x0018 */
238470decc6SDave Kleikamp /* Dynamic information describing the current state of the log */
239470decc6SDave Kleikamp __be32 s_sequence; /* first commit ID expected in log */
240470decc6SDave Kleikamp __be32 s_start; /* blocknr of start of log */
241470decc6SDave Kleikamp
242470decc6SDave Kleikamp /* 0x0020 */
243f7f4bccbSMingming Cao /* Error value, as set by jbd2_journal_abort(). */
244470decc6SDave Kleikamp __be32 s_errno;
245470decc6SDave Kleikamp
246470decc6SDave Kleikamp /* 0x0024 */
247470decc6SDave Kleikamp /* Remaining fields are only valid in a version-2 superblock */
248470decc6SDave Kleikamp __be32 s_feature_compat; /* compatible feature set */
249470decc6SDave Kleikamp __be32 s_feature_incompat; /* incompatible feature set */
250470decc6SDave Kleikamp __be32 s_feature_ro_compat; /* readonly-compatible feature set */
251470decc6SDave Kleikamp /* 0x0030 */
252470decc6SDave Kleikamp __u8 s_uuid[16]; /* 128-bit uuid for journal */
253470decc6SDave Kleikamp
254470decc6SDave Kleikamp /* 0x0040 */
255470decc6SDave Kleikamp __be32 s_nr_users; /* Nr of filesystems sharing log */
256470decc6SDave Kleikamp
257470decc6SDave Kleikamp __be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
258470decc6SDave Kleikamp
259470decc6SDave Kleikamp /* 0x0048 */
260470decc6SDave Kleikamp __be32 s_max_transaction; /* Limit of journal blocks per trans.*/
261470decc6SDave Kleikamp __be32 s_max_trans_data; /* Limit of data blocks per trans. */
262470decc6SDave Kleikamp
263470decc6SDave Kleikamp /* 0x0050 */
2648f888ef8SDarrick J. Wong __u8 s_checksum_type; /* checksum type */
2658f888ef8SDarrick J. Wong __u8 s_padding2[3];
266e029c5f2SHarshad Shirwadkar /* 0x0054 */
267e029c5f2SHarshad Shirwadkar __be32 s_num_fc_blks; /* Number of fast commit blocks */
268c7fc6055SZhang Yi __be32 s_head; /* blocknr of head of log, only uptodate
269c7fc6055SZhang Yi * while the filesystem is clean */
270c7fc6055SZhang Yi /* 0x005C */
271c7fc6055SZhang Yi __u32 s_padding[40];
2728f888ef8SDarrick J. Wong __be32 s_checksum; /* crc32c(superblock) */
273470decc6SDave Kleikamp
274470decc6SDave Kleikamp /* 0x0100 */
275470decc6SDave Kleikamp __u8 s_users[16*48]; /* ids of all fs'es sharing the log */
276470decc6SDave Kleikamp /* 0x0400 */
277470decc6SDave Kleikamp } journal_superblock_t;
278470decc6SDave Kleikamp
279818d276cSGirish Shilamkar #define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
280818d276cSGirish Shilamkar
281f7f4bccbSMingming Cao #define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
282b517bea1SZach Brown #define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
283818d276cSGirish Shilamkar #define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
2848f888ef8SDarrick J. Wong #define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
285db9ee220SDarrick J. Wong #define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
286995a3ed6SHarshad Shirwadkar #define JBD2_FEATURE_INCOMPAT_FAST_COMMIT 0x00000020
287470decc6SDave Kleikamp
28856316a0dSDarrick J. Wong /* See "journal feature predicate functions" below */
28956316a0dSDarrick J. Wong
290470decc6SDave Kleikamp /* Features known to this kernel version: */
291818d276cSGirish Shilamkar #define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
292f7f4bccbSMingming Cao #define JBD2_KNOWN_ROCOMPAT_FEATURES 0
293b517bea1SZach Brown #define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
294818d276cSGirish Shilamkar JBD2_FEATURE_INCOMPAT_64BIT | \
295e93376c2SDarrick J. Wong JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
296db9ee220SDarrick J. Wong JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
297995a3ed6SHarshad Shirwadkar JBD2_FEATURE_INCOMPAT_CSUM_V3 | \
298995a3ed6SHarshad Shirwadkar JBD2_FEATURE_INCOMPAT_FAST_COMMIT)
299470decc6SDave Kleikamp
300470decc6SDave Kleikamp #ifdef __KERNEL__
301470decc6SDave Kleikamp
302470decc6SDave Kleikamp #include <linux/fs.h>
303470decc6SDave Kleikamp #include <linux/sched.h>
304b34090e5SJan Kara
305b34090e5SJan Kara enum jbd_state_bits {
306b34090e5SJan Kara BH_JBD /* Has an attached ext3 journal_head */
307b34090e5SJan Kara = BH_PrivateStart,
308b34090e5SJan Kara BH_JWrite, /* Being written to log (@@@ DEBUGGING) */
309b34090e5SJan Kara BH_Freed, /* Has been freed (truncated) */
310b34090e5SJan Kara BH_Revoked, /* Has been revoked from the log */
311b34090e5SJan Kara BH_RevokeValid, /* Revoked flag is valid */
312b34090e5SJan Kara BH_JBDDirty, /* Is dirty but journaled */
313b34090e5SJan Kara BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
314b34090e5SJan Kara BH_Shadow, /* IO on shadow buffer is running */
315b34090e5SJan Kara BH_Verified, /* Metadata block has been verified ok */
316b34090e5SJan Kara BH_JBDPrivateStart, /* First bit available for private use by FS */
317b34090e5SJan Kara };
318b34090e5SJan Kara
BUFFER_FNS(JBD,jbd)319b34090e5SJan Kara BUFFER_FNS(JBD, jbd)
320b34090e5SJan Kara BUFFER_FNS(JWrite, jwrite)
321b34090e5SJan Kara BUFFER_FNS(JBDDirty, jbddirty)
322b34090e5SJan Kara TAS_BUFFER_FNS(JBDDirty, jbddirty)
323b34090e5SJan Kara BUFFER_FNS(Revoked, revoked)
324b34090e5SJan Kara TAS_BUFFER_FNS(Revoked, revoked)
325b34090e5SJan Kara BUFFER_FNS(RevokeValid, revokevalid)
326b34090e5SJan Kara TAS_BUFFER_FNS(RevokeValid, revokevalid)
327b34090e5SJan Kara BUFFER_FNS(Freed, freed)
328b34090e5SJan Kara BUFFER_FNS(Shadow, shadow)
329b34090e5SJan Kara BUFFER_FNS(Verified, verified)
330b34090e5SJan Kara
331c290ea01SJan Kara static inline struct buffer_head *jh2bh(struct journal_head *jh)
332c290ea01SJan Kara {
333c290ea01SJan Kara return jh->b_bh;
334c290ea01SJan Kara }
335c290ea01SJan Kara
bh2jh(struct buffer_head * bh)336c290ea01SJan Kara static inline struct journal_head *bh2jh(struct buffer_head *bh)
337c290ea01SJan Kara {
338c290ea01SJan Kara return bh->b_private;
339c290ea01SJan Kara }
340c290ea01SJan Kara
jbd_lock_bh_journal_head(struct buffer_head * bh)341c290ea01SJan Kara static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
342c290ea01SJan Kara {
343c290ea01SJan Kara bit_spin_lock(BH_JournalHead, &bh->b_state);
344c290ea01SJan Kara }
345c290ea01SJan Kara
jbd_unlock_bh_journal_head(struct buffer_head * bh)346c290ea01SJan Kara static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
347c290ea01SJan Kara {
348c290ea01SJan Kara bit_spin_unlock(BH_JournalHead, &bh->b_state);
349c290ea01SJan Kara }
350470decc6SDave Kleikamp
35136df53f4SChris Snook #define J_ASSERT(assert) BUG_ON(!(assert))
352470decc6SDave Kleikamp
353470decc6SDave Kleikamp #define J_ASSERT_BH(bh, expr) J_ASSERT(expr)
354470decc6SDave Kleikamp #define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
355470decc6SDave Kleikamp
356cd02ff0bSMingming Cao #if defined(JBD2_PARANOID_IOFAIL)
357470decc6SDave Kleikamp #define J_EXPECT(expr, why...) J_ASSERT(expr)
358470decc6SDave Kleikamp #define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
359470decc6SDave Kleikamp #define J_EXPECT_JH(jh, expr, why...) J_ASSERT_JH(jh, expr)
360470decc6SDave Kleikamp #else
361470decc6SDave Kleikamp #define __journal_expect(expr, why...) \
362470decc6SDave Kleikamp ({ \
363470decc6SDave Kleikamp int val = (expr); \
364470decc6SDave Kleikamp if (!val) { \
365470decc6SDave Kleikamp printk(KERN_ERR \
36608ec8c38STheodore Ts'o "JBD2 unexpected failure: %s: %s;\n", \
36708ec8c38STheodore Ts'o __func__, #expr); \
368470decc6SDave Kleikamp printk(KERN_ERR why "\n"); \
369470decc6SDave Kleikamp } \
370470decc6SDave Kleikamp val; \
371470decc6SDave Kleikamp })
372470decc6SDave Kleikamp #define J_EXPECT(expr, why...) __journal_expect(expr, ## why)
373470decc6SDave Kleikamp #define J_EXPECT_BH(bh, expr, why...) __journal_expect(expr, ## why)
374470decc6SDave Kleikamp #define J_EXPECT_JH(jh, expr, why...) __journal_expect(expr, ## why)
375470decc6SDave Kleikamp #endif
376470decc6SDave Kleikamp
377c851ed54SJan Kara /* Flags in jbd_inode->i_flags */
378c851ed54SJan Kara #define __JI_COMMIT_RUNNING 0
37941617e1aSJan Kara #define __JI_WRITE_DATA 1
38041617e1aSJan Kara #define __JI_WAIT_DATA 2
38141617e1aSJan Kara
38241617e1aSJan Kara /*
38341617e1aSJan Kara * Commit of the inode data in progress. We use this flag to protect us from
384c851ed54SJan Kara * concurrent deletion of inode. We cannot use reference to inode for this
385c851ed54SJan Kara * since we cannot afford doing last iput() on behalf of kjournald
386c851ed54SJan Kara */
387c851ed54SJan Kara #define JI_COMMIT_RUNNING (1 << __JI_COMMIT_RUNNING)
38841617e1aSJan Kara /* Write allocated dirty buffers in this inode before commit */
38941617e1aSJan Kara #define JI_WRITE_DATA (1 << __JI_WRITE_DATA)
39041617e1aSJan Kara /* Wait for outstanding data writes for this inode before commit */
39141617e1aSJan Kara #define JI_WAIT_DATA (1 << __JI_WAIT_DATA)
392c851ed54SJan Kara
393c851ed54SJan Kara /**
3942bf31d94SMauro Carvalho Chehab * struct jbd2_inode - The jbd_inode type is the structure linking inodes in
395f69120ceSTobin C. Harding * ordered mode present in a transaction so that we can sync them during commit.
396c851ed54SJan Kara */
397c851ed54SJan Kara struct jbd2_inode {
398f69120ceSTobin C. Harding /**
399f69120ceSTobin C. Harding * @i_transaction:
400f69120ceSTobin C. Harding *
401f69120ceSTobin C. Harding * Which transaction does this inode belong to? Either the running
402f69120ceSTobin C. Harding * transaction or the committing one. [j_list_lock]
403f69120ceSTobin C. Harding */
404c851ed54SJan Kara transaction_t *i_transaction;
405c851ed54SJan Kara
406f69120ceSTobin C. Harding /**
407f69120ceSTobin C. Harding * @i_next_transaction:
408f69120ceSTobin C. Harding *
409f69120ceSTobin C. Harding * Pointer to the running transaction modifying inode's data in case
410f69120ceSTobin C. Harding * there is already a committing transaction touching it. [j_list_lock]
411f69120ceSTobin C. Harding */
412c851ed54SJan Kara transaction_t *i_next_transaction;
413c851ed54SJan Kara
414f69120ceSTobin C. Harding /**
415f69120ceSTobin C. Harding * @i_list: List of inodes in the i_transaction [j_list_lock]
416f69120ceSTobin C. Harding */
417c851ed54SJan Kara struct list_head i_list;
418c851ed54SJan Kara
419f69120ceSTobin C. Harding /**
420f69120ceSTobin C. Harding * @i_vfs_inode:
421f69120ceSTobin C. Harding *
422f69120ceSTobin C. Harding * VFS inode this inode belongs to [constant for lifetime of structure]
423f69120ceSTobin C. Harding */
424c851ed54SJan Kara struct inode *i_vfs_inode;
425c851ed54SJan Kara
426f69120ceSTobin C. Harding /**
427f69120ceSTobin C. Harding * @i_flags: Flags of inode [j_list_lock]
428f69120ceSTobin C. Harding */
42939e3ac25SBrian King unsigned long i_flags;
4306ba0e7dcSRoss Zwisler
4316ba0e7dcSRoss Zwisler /**
4326ba0e7dcSRoss Zwisler * @i_dirty_start:
4336ba0e7dcSRoss Zwisler *
4346ba0e7dcSRoss Zwisler * Offset in bytes where the dirty range for this inode starts.
4356ba0e7dcSRoss Zwisler * [j_list_lock]
4366ba0e7dcSRoss Zwisler */
4376ba0e7dcSRoss Zwisler loff_t i_dirty_start;
4386ba0e7dcSRoss Zwisler
4396ba0e7dcSRoss Zwisler /**
4406ba0e7dcSRoss Zwisler * @i_dirty_end:
4416ba0e7dcSRoss Zwisler *
4426ba0e7dcSRoss Zwisler * Inclusive offset in bytes where the dirty range for this inode
4436ba0e7dcSRoss Zwisler * ends. [j_list_lock]
4446ba0e7dcSRoss Zwisler */
4456ba0e7dcSRoss Zwisler loff_t i_dirty_end;
446c851ed54SJan Kara };
447c851ed54SJan Kara
448f7f4bccbSMingming Cao struct jbd2_revoke_table_s;
449470decc6SDave Kleikamp
450470decc6SDave Kleikamp /**
45115a119e0SHui Su * struct jbd2_journal_handle - The jbd2_journal_handle type is the concrete
45215a119e0SHui Su * type associated with handle_t.
453470decc6SDave Kleikamp * @h_transaction: Which compound transaction is this update a part of?
454f69120ceSTobin C. Harding * @h_journal: Which journal handle belongs to - used iff h_reserved set.
455f69120ceSTobin C. Harding * @h_rsv_handle: Handle reserved for finishing the logical operation.
456933f1c1eSJan Kara * @h_total_credits: Number of remaining buffers we are allowed to add to
457d82d47d5SRandy Dunlap * journal. These are dirty buffers and revoke descriptor blocks.
458fdc3ef88SJan Kara * @h_revoke_credits: Number of remaining revoke records available for handle
459f69120ceSTobin C. Harding * @h_ref: Reference count on this handle.
460f69120ceSTobin C. Harding * @h_err: Field for caller's use to track errors through large fs operations.
461f69120ceSTobin C. Harding * @h_sync: Flag for sync-on-close.
462f69120ceSTobin C. Harding * @h_reserved: Flag for handle for reserved credits.
463f69120ceSTobin C. Harding * @h_aborted: Flag indicating fatal error on handle.
464f69120ceSTobin C. Harding * @h_type: For handle statistics.
465f69120ceSTobin C. Harding * @h_line_no: For handle statistics.
466f69120ceSTobin C. Harding * @h_start_jiffies: Handle Start time.
467933f1c1eSJan Kara * @h_requested_credits: Holds @h_total_credits after handle is started.
468fdc3ef88SJan Kara * @h_revoke_credits_requested: Holds @h_revoke_credits after handle is started.
469f69120ceSTobin C. Harding * @saved_alloc_context: Saved context while transaction is open.
470470decc6SDave Kleikamp **/
471470decc6SDave Kleikamp
472470decc6SDave Kleikamp /* Docbook can't yet cope with the bit fields, but will leave the documentation
473470decc6SDave Kleikamp * in so it can be fixed later.
474470decc6SDave Kleikamp */
475470decc6SDave Kleikamp
4768aefcd55STheodore Ts'o struct jbd2_journal_handle
477470decc6SDave Kleikamp {
4788f7d89f3SJan Kara union {
479470decc6SDave Kleikamp transaction_t *h_transaction;
4808f7d89f3SJan Kara /* Which journal handle belongs to - used iff h_reserved set */
4818f7d89f3SJan Kara journal_t *h_journal;
4828f7d89f3SJan Kara };
4838f7d89f3SJan Kara
4848f7d89f3SJan Kara handle_t *h_rsv_handle;
485933f1c1eSJan Kara int h_total_credits;
486fdc3ef88SJan Kara int h_revoke_credits;
487fdc3ef88SJan Kara int h_revoke_credits_requested;
488470decc6SDave Kleikamp int h_ref;
489470decc6SDave Kleikamp int h_err;
490470decc6SDave Kleikamp
491470decc6SDave Kleikamp /* Flags [no locking] */
492f69120ceSTobin C. Harding unsigned int h_sync: 1;
493f69120ceSTobin C. Harding unsigned int h_reserved: 1;
494f69120ceSTobin C. Harding unsigned int h_aborted: 1;
495f69120ceSTobin C. Harding unsigned int h_type: 8;
496f69120ceSTobin C. Harding unsigned int h_line_no: 16;
497343d9c28STheodore Ts'o
498343d9c28STheodore Ts'o unsigned long h_start_jiffies;
499343d9c28STheodore Ts'o unsigned int h_requested_credits;
50081378da6SMichal Hocko
50181378da6SMichal Hocko unsigned int saved_alloc_context;
502470decc6SDave Kleikamp };
503470decc6SDave Kleikamp
504470decc6SDave Kleikamp
5058e85fb3fSJohann Lombardi /*
5068e85fb3fSJohann Lombardi * Some stats for checkpoint phase
5078e85fb3fSJohann Lombardi */
5088e85fb3fSJohann Lombardi struct transaction_chp_stats_s {
5098e85fb3fSJohann Lombardi unsigned long cs_chp_time;
510bf699327STheodore Ts'o __u32 cs_forced_to_close;
511bf699327STheodore Ts'o __u32 cs_written;
512bf699327STheodore Ts'o __u32 cs_dropped;
5138e85fb3fSJohann Lombardi };
5148e85fb3fSJohann Lombardi
515470decc6SDave Kleikamp /* The transaction_t type is the guts of the journaling mechanism. It
516470decc6SDave Kleikamp * tracks a compound transaction through its various states:
517470decc6SDave Kleikamp *
518470decc6SDave Kleikamp * RUNNING: accepting new updates
519470decc6SDave Kleikamp * LOCKED: Updates still running but we don't accept new ones
520470decc6SDave Kleikamp * RUNDOWN: Updates are tidying up but have finished requesting
521470decc6SDave Kleikamp * new buffers to modify (state not used for now)
522470decc6SDave Kleikamp * FLUSH: All updates complete, but we are still writing to disk
523470decc6SDave Kleikamp * COMMIT: All data on disk, writing commit record
524470decc6SDave Kleikamp * FINISHED: We still have to keep the transaction for checkpointing.
525470decc6SDave Kleikamp *
526470decc6SDave Kleikamp * The transaction keeps track of all of the buffers modified by a
527470decc6SDave Kleikamp * running transaction, and all of the buffers committed but not yet
528470decc6SDave Kleikamp * flushed to home for finished transactions.
52950a4952fSAlexander Lochmann * (Locking Documentation improved by LockDoc)
530470decc6SDave Kleikamp */
531470decc6SDave Kleikamp
532470decc6SDave Kleikamp /*
533470decc6SDave Kleikamp * Lock ranking:
534470decc6SDave Kleikamp *
535470decc6SDave Kleikamp * j_list_lock
536470decc6SDave Kleikamp * ->jbd_lock_bh_journal_head() (This is "innermost")
537470decc6SDave Kleikamp *
538470decc6SDave Kleikamp * j_state_lock
53946417064SThomas Gleixner * ->b_state_lock
540470decc6SDave Kleikamp *
54146417064SThomas Gleixner * b_state_lock
542470decc6SDave Kleikamp * ->j_list_lock
543470decc6SDave Kleikamp *
544470decc6SDave Kleikamp * j_state_lock
545470decc6SDave Kleikamp * ->j_list_lock (journal_unmap_buffer)
546470decc6SDave Kleikamp *
547470decc6SDave Kleikamp */
548470decc6SDave Kleikamp
549470decc6SDave Kleikamp struct transaction_s
550470decc6SDave Kleikamp {
551470decc6SDave Kleikamp /* Pointer to the journal for this transaction. [no locking] */
552470decc6SDave Kleikamp journal_t *t_journal;
553470decc6SDave Kleikamp
554470decc6SDave Kleikamp /* Sequence number for this transaction [no locking] */
555470decc6SDave Kleikamp tid_t t_tid;
556470decc6SDave Kleikamp
557470decc6SDave Kleikamp /*
558470decc6SDave Kleikamp * Transaction's current state
559f7f4bccbSMingming Cao * [no locking - only kjournald2 alters this]
560f5a7a6b0SJan Kara * [j_list_lock] guards transition of a transaction into T_FINISHED
561f5a7a6b0SJan Kara * state and subsequent call of __jbd2_journal_drop_transaction()
562470decc6SDave Kleikamp * FIXME: needs barriers
563470decc6SDave Kleikamp * KLUDGE: [use j_state_lock]
564470decc6SDave Kleikamp */
565470decc6SDave Kleikamp enum {
566470decc6SDave Kleikamp T_RUNNING,
567470decc6SDave Kleikamp T_LOCKED,
56896f1e097SJan Kara T_SWITCH,
569470decc6SDave Kleikamp T_FLUSH,
570470decc6SDave Kleikamp T_COMMIT,
571bbd2be36SJan Kara T_COMMIT_DFLUSH,
572bbd2be36SJan Kara T_COMMIT_JFLUSH,
573794446c6SDmitry Monakhov T_COMMIT_CALLBACK,
574470decc6SDave Kleikamp T_FINISHED
575470decc6SDave Kleikamp } t_state;
576470decc6SDave Kleikamp
577470decc6SDave Kleikamp /*
578470decc6SDave Kleikamp * Where in the log does this transaction's commit start? [no locking]
579470decc6SDave Kleikamp */
580470decc6SDave Kleikamp unsigned long t_log_start;
581470decc6SDave Kleikamp
5823042b1b4SAlexander Lochmann /*
5833042b1b4SAlexander Lochmann * Number of buffers on the t_buffers list [j_list_lock, no locks
5843042b1b4SAlexander Lochmann * needed for jbd2 thread]
5853042b1b4SAlexander Lochmann */
586470decc6SDave Kleikamp int t_nr_buffers;
587470decc6SDave Kleikamp
588470decc6SDave Kleikamp /*
589470decc6SDave Kleikamp * Doubly-linked circular list of all buffers reserved but not yet
5903042b1b4SAlexander Lochmann * modified by this transaction [j_list_lock, no locks needed fo
5913042b1b4SAlexander Lochmann * jbd2 thread]
592470decc6SDave Kleikamp */
593470decc6SDave Kleikamp struct journal_head *t_reserved_list;
594470decc6SDave Kleikamp
595470decc6SDave Kleikamp /*
596470decc6SDave Kleikamp * Doubly-linked circular list of all metadata buffers owned by this
5973042b1b4SAlexander Lochmann * transaction [j_list_lock, no locks needed for jbd2 thread]
598470decc6SDave Kleikamp */
599470decc6SDave Kleikamp struct journal_head *t_buffers;
600470decc6SDave Kleikamp
601470decc6SDave Kleikamp /*
602470decc6SDave Kleikamp * Doubly-linked circular list of all forget buffers (superseded
603470decc6SDave Kleikamp * buffers which we can un-checkpoint once this transaction commits)
604470decc6SDave Kleikamp * [j_list_lock]
605470decc6SDave Kleikamp */
606470decc6SDave Kleikamp struct journal_head *t_forget;
607470decc6SDave Kleikamp
608470decc6SDave Kleikamp /*
609470decc6SDave Kleikamp * Doubly-linked circular list of all buffers still to be flushed before
610470decc6SDave Kleikamp * this transaction can be checkpointed. [j_list_lock]
611470decc6SDave Kleikamp */
612470decc6SDave Kleikamp struct journal_head *t_checkpoint_list;
613470decc6SDave Kleikamp
614470decc6SDave Kleikamp /*
6153042b1b4SAlexander Lochmann * Doubly-linked circular list of metadata buffers being
6163042b1b4SAlexander Lochmann * shadowed by log IO. The IO buffers on the iobuf list and
6173042b1b4SAlexander Lochmann * the shadow buffers on this list match each other one for
6183042b1b4SAlexander Lochmann * one at all times. [j_list_lock, no locks needed for jbd2
6193042b1b4SAlexander Lochmann * thread]
620470decc6SDave Kleikamp */
621470decc6SDave Kleikamp struct journal_head *t_shadow_list;
622470decc6SDave Kleikamp
623470decc6SDave Kleikamp /*
624342af94eSMauricio Faria de Oliveira * List of inodes associated with the transaction; e.g., ext4 uses
625342af94eSMauricio Faria de Oliveira * this to track inodes in data=ordered and data=journal mode that
626342af94eSMauricio Faria de Oliveira * need special handling on transaction commit; also used by ocfs2.
627c851ed54SJan Kara * [j_list_lock]
628c851ed54SJan Kara */
629c851ed54SJan Kara struct list_head t_inode_list;
630c851ed54SJan Kara
631c851ed54SJan Kara /*
6328e85fb3fSJohann Lombardi * Longest time some handle had to wait for running transaction
6338e85fb3fSJohann Lombardi */
6348e85fb3fSJohann Lombardi unsigned long t_max_wait;
6358e85fb3fSJohann Lombardi
6368e85fb3fSJohann Lombardi /*
6378e85fb3fSJohann Lombardi * When transaction started
6388e85fb3fSJohann Lombardi */
6398e85fb3fSJohann Lombardi unsigned long t_start;
6408e85fb3fSJohann Lombardi
6418e85fb3fSJohann Lombardi /*
64250a4952fSAlexander Lochmann * When commit was requested [j_state_lock]
6439fff24aaSTheodore Ts'o */
6449fff24aaSTheodore Ts'o unsigned long t_requested;
6459fff24aaSTheodore Ts'o
6469fff24aaSTheodore Ts'o /*
64750a4952fSAlexander Lochmann * Checkpointing stats [j_list_lock]
6488e85fb3fSJohann Lombardi */
6498e85fb3fSJohann Lombardi struct transaction_chp_stats_s t_chp_stats;
6508e85fb3fSJohann Lombardi
6518e85fb3fSJohann Lombardi /*
652470decc6SDave Kleikamp * Number of outstanding updates running on this transaction
65332ea2750SAlexander Lochmann * [none]
654470decc6SDave Kleikamp */
655a51dca9cSTheodore Ts'o atomic_t t_updates;
656470decc6SDave Kleikamp
657470decc6SDave Kleikamp /*
6589f356e5aSJan Kara * Number of blocks reserved for this transaction in the journal.
6599f356e5aSJan Kara * This is including all credits reserved when starting transaction
6609f356e5aSJan Kara * handles as well as all journal descriptor blocks needed for this
6619f356e5aSJan Kara * transaction. [none]
662470decc6SDave Kleikamp */
663a51dca9cSTheodore Ts'o atomic_t t_outstanding_credits;
664470decc6SDave Kleikamp
665470decc6SDave Kleikamp /*
666fdc3ef88SJan Kara * Number of revoke records for this transaction added by already
667fdc3ef88SJan Kara * stopped handles. [none]
668fdc3ef88SJan Kara */
669fdc3ef88SJan Kara atomic_t t_outstanding_revokes;
670fdc3ef88SJan Kara
671fdc3ef88SJan Kara /*
672fdc3ef88SJan Kara * How many handles used this transaction? [none]
673fdc3ef88SJan Kara */
674fdc3ef88SJan Kara atomic_t t_handle_count;
675fdc3ef88SJan Kara
676fdc3ef88SJan Kara /*
677470decc6SDave Kleikamp * Forward and backward links for the circular list of all transactions
678470decc6SDave Kleikamp * awaiting checkpoint. [j_list_lock]
679470decc6SDave Kleikamp */
680470decc6SDave Kleikamp transaction_t *t_cpnext, *t_cpprev;
681470decc6SDave Kleikamp
682470decc6SDave Kleikamp /*
683470decc6SDave Kleikamp * When will the transaction expire (become due for commit), in jiffies?
684470decc6SDave Kleikamp * [no locking]
685470decc6SDave Kleikamp */
686470decc6SDave Kleikamp unsigned long t_expires;
687470decc6SDave Kleikamp
688470decc6SDave Kleikamp /*
689e07f7183SJosef Bacik * When this transaction started, in nanoseconds [no locking]
690e07f7183SJosef Bacik */
691e07f7183SJosef Bacik ktime_t t_start_time;
692e07f7183SJosef Bacik
693e07f7183SJosef Bacik /*
6947058548cSTheodore Ts'o * This transaction is being forced and some process is
6957058548cSTheodore Ts'o * waiting for it to finish.
6967058548cSTheodore Ts'o */
6970ccff1a4SH Hartley Sweeten unsigned int t_synchronous_commit:1;
69881be12c8SJan Kara
69981be12c8SJan Kara /* Disk flush needs to be sent to fs partition [no locking] */
70081be12c8SJan Kara int t_need_data_flush;
701470decc6SDave Kleikamp };
702470decc6SDave Kleikamp
7038e85fb3fSJohann Lombardi struct transaction_run_stats_s {
7048e85fb3fSJohann Lombardi unsigned long rs_wait;
7059fff24aaSTheodore Ts'o unsigned long rs_request_delay;
7068e85fb3fSJohann Lombardi unsigned long rs_running;
7078e85fb3fSJohann Lombardi unsigned long rs_locked;
7088e85fb3fSJohann Lombardi unsigned long rs_flushing;
7098e85fb3fSJohann Lombardi unsigned long rs_logging;
7108e85fb3fSJohann Lombardi
711bf699327STheodore Ts'o __u32 rs_handle_count;
712bf699327STheodore Ts'o __u32 rs_blocks;
713bf699327STheodore Ts'o __u32 rs_blocks_logged;
7148e85fb3fSJohann Lombardi };
7158e85fb3fSJohann Lombardi
7168e85fb3fSJohann Lombardi struct transaction_stats_s {
7178e85fb3fSJohann Lombardi unsigned long ts_tid;
7189fff24aaSTheodore Ts'o unsigned long ts_requested;
7198e85fb3fSJohann Lombardi struct transaction_run_stats_s run;
7208e85fb3fSJohann Lombardi };
7218e85fb3fSJohann Lombardi
7228e85fb3fSJohann Lombardi static inline unsigned long
jbd2_time_diff(unsigned long start,unsigned long end)7238e85fb3fSJohann Lombardi jbd2_time_diff(unsigned long start, unsigned long end)
7248e85fb3fSJohann Lombardi {
7258e85fb3fSJohann Lombardi if (end >= start)
7268e85fb3fSJohann Lombardi return end - start;
7278e85fb3fSJohann Lombardi
7288e85fb3fSJohann Lombardi return end + (MAX_JIFFY_OFFSET - start);
7298e85fb3fSJohann Lombardi }
7308e85fb3fSJohann Lombardi
7311a0d3786STheodore Ts'o #define JBD2_NR_BATCH 64
7321a0d3786STheodore Ts'o
7335b849b5fSHarshad Shirwadkar enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
7345b849b5fSHarshad Shirwadkar
7355b849b5fSHarshad Shirwadkar #define JBD2_FC_REPLAY_STOP 0
7365b849b5fSHarshad Shirwadkar #define JBD2_FC_REPLAY_CONTINUE 1
7375b849b5fSHarshad Shirwadkar
738470decc6SDave Kleikamp /**
739470decc6SDave Kleikamp * struct journal_s - The journal_s type is the concrete type associated with
740470decc6SDave Kleikamp * journal_t.
741470decc6SDave Kleikamp */
742470decc6SDave Kleikamp struct journal_s
743470decc6SDave Kleikamp {
744f69120ceSTobin C. Harding /**
745d699ae4fSAlexander Lochmann * @j_flags: General journaling state flags [j_state_lock,
746d699ae4fSAlexander Lochmann * no lock for quick racy checks]
747f69120ceSTobin C. Harding */
748470decc6SDave Kleikamp unsigned long j_flags;
749470decc6SDave Kleikamp
750f69120ceSTobin C. Harding /**
751f69120ceSTobin C. Harding * @j_errno:
752f69120ceSTobin C. Harding *
753470decc6SDave Kleikamp * Is there an outstanding uncleared error on the journal (from a prior
754470decc6SDave Kleikamp * abort)? [j_state_lock]
755470decc6SDave Kleikamp */
756470decc6SDave Kleikamp int j_errno;
757470decc6SDave Kleikamp
758f69120ceSTobin C. Harding /**
7597b97d868Szhangyi (F) * @j_abort_mutex: Lock the whole aborting procedure.
7607b97d868Szhangyi (F) */
7617b97d868Szhangyi (F) struct mutex j_abort_mutex;
7627b97d868Szhangyi (F)
7637b97d868Szhangyi (F) /**
764f69120ceSTobin C. Harding * @j_sb_buffer: The first part of the superblock buffer.
765f69120ceSTobin C. Harding */
766470decc6SDave Kleikamp struct buffer_head *j_sb_buffer;
767f69120ceSTobin C. Harding
768f69120ceSTobin C. Harding /**
769f69120ceSTobin C. Harding * @j_superblock: The second part of the superblock buffer.
770f69120ceSTobin C. Harding */
771470decc6SDave Kleikamp journal_superblock_t *j_superblock;
772470decc6SDave Kleikamp
773f69120ceSTobin C. Harding /**
774f69120ceSTobin C. Harding * @j_state_lock: Protect the various scalars in the journal.
775470decc6SDave Kleikamp */
776a931da6aSTheodore Ts'o rwlock_t j_state_lock;
777470decc6SDave Kleikamp
778f69120ceSTobin C. Harding /**
779f69120ceSTobin C. Harding * @j_barrier_count:
780f69120ceSTobin C. Harding *
781d699ae4fSAlexander Lochmann * Number of processes waiting to create a barrier lock [j_state_lock,
782d699ae4fSAlexander Lochmann * no lock for quick racy checks]
783470decc6SDave Kleikamp */
784470decc6SDave Kleikamp int j_barrier_count;
785470decc6SDave Kleikamp
786f69120ceSTobin C. Harding /**
787f69120ceSTobin C. Harding * @j_barrier: The barrier lock itself.
788f69120ceSTobin C. Harding */
789470decc6SDave Kleikamp struct mutex j_barrier;
790470decc6SDave Kleikamp
791f69120ceSTobin C. Harding /**
792f69120ceSTobin C. Harding * @j_running_transaction:
793f69120ceSTobin C. Harding *
794470decc6SDave Kleikamp * Transactions: The current running transaction...
795d699ae4fSAlexander Lochmann * [j_state_lock, no lock for quick racy checks] [caller holding
796d699ae4fSAlexander Lochmann * open handle]
797470decc6SDave Kleikamp */
798470decc6SDave Kleikamp transaction_t *j_running_transaction;
799470decc6SDave Kleikamp
800f69120ceSTobin C. Harding /**
801f69120ceSTobin C. Harding * @j_committing_transaction:
802f69120ceSTobin C. Harding *
803470decc6SDave Kleikamp * the transaction we are pushing to disk
804470decc6SDave Kleikamp * [j_state_lock] [caller holding open handle]
805470decc6SDave Kleikamp */
806470decc6SDave Kleikamp transaction_t *j_committing_transaction;
807470decc6SDave Kleikamp
808f69120ceSTobin C. Harding /**
809f69120ceSTobin C. Harding * @j_checkpoint_transactions:
810f69120ceSTobin C. Harding *
811470decc6SDave Kleikamp * ... and a linked circular list of all transactions waiting for
812470decc6SDave Kleikamp * checkpointing. [j_list_lock]
813470decc6SDave Kleikamp */
814470decc6SDave Kleikamp transaction_t *j_checkpoint_transactions;
815470decc6SDave Kleikamp
816f69120ceSTobin C. Harding /**
817f69120ceSTobin C. Harding * @j_wait_transaction_locked:
818f69120ceSTobin C. Harding *
819470decc6SDave Kleikamp * Wait queue for waiting for a locked transaction to start committing,
820f69120ceSTobin C. Harding * or for a barrier lock to be released.
821470decc6SDave Kleikamp */
822470decc6SDave Kleikamp wait_queue_head_t j_wait_transaction_locked;
823470decc6SDave Kleikamp
824f69120ceSTobin C. Harding /**
825f69120ceSTobin C. Harding * @j_wait_done_commit: Wait queue for waiting for commit to complete.
826f69120ceSTobin C. Harding */
827470decc6SDave Kleikamp wait_queue_head_t j_wait_done_commit;
828470decc6SDave Kleikamp
829f69120ceSTobin C. Harding /**
830f69120ceSTobin C. Harding * @j_wait_commit: Wait queue to trigger commit.
831f69120ceSTobin C. Harding */
832470decc6SDave Kleikamp wait_queue_head_t j_wait_commit;
833470decc6SDave Kleikamp
834f69120ceSTobin C. Harding /**
835f69120ceSTobin C. Harding * @j_wait_updates: Wait queue to wait for updates to complete.
836f69120ceSTobin C. Harding */
837470decc6SDave Kleikamp wait_queue_head_t j_wait_updates;
838470decc6SDave Kleikamp
839f69120ceSTobin C. Harding /**
840f69120ceSTobin C. Harding * @j_wait_reserved:
841f69120ceSTobin C. Harding *
842f69120ceSTobin C. Harding * Wait queue to wait for reserved buffer credits to drop.
843f69120ceSTobin C. Harding */
8448f7d89f3SJan Kara wait_queue_head_t j_wait_reserved;
8458f7d89f3SJan Kara
846f69120ceSTobin C. Harding /**
847ff780b91SHarshad Shirwadkar * @j_fc_wait:
848ff780b91SHarshad Shirwadkar *
849ff780b91SHarshad Shirwadkar * Wait queue to wait for completion of async fast commits.
850ff780b91SHarshad Shirwadkar */
851ff780b91SHarshad Shirwadkar wait_queue_head_t j_fc_wait;
852ff780b91SHarshad Shirwadkar
853ff780b91SHarshad Shirwadkar /**
854f69120ceSTobin C. Harding * @j_checkpoint_mutex:
855f69120ceSTobin C. Harding *
856f69120ceSTobin C. Harding * Semaphore for locking against concurrent checkpoints.
857f69120ceSTobin C. Harding */
858470decc6SDave Kleikamp struct mutex j_checkpoint_mutex;
859470decc6SDave Kleikamp
860f69120ceSTobin C. Harding /**
861f69120ceSTobin C. Harding * @j_chkpt_bhs:
862f69120ceSTobin C. Harding *
8631a0d3786STheodore Ts'o * List of buffer heads used by the checkpoint routine. This
8641a0d3786STheodore Ts'o * was moved from jbd2_log_do_checkpoint() to reduce stack
8651a0d3786STheodore Ts'o * usage. Access to this array is controlled by the
866f69120ceSTobin C. Harding * @j_checkpoint_mutex. [j_checkpoint_mutex]
8671a0d3786STheodore Ts'o */
8681a0d3786STheodore Ts'o struct buffer_head *j_chkpt_bhs[JBD2_NR_BATCH];
8691a0d3786STheodore Ts'o
870f69120ceSTobin C. Harding /**
8714ba3fcddSZhang Yi * @j_shrinker:
8724ba3fcddSZhang Yi *
8734ba3fcddSZhang Yi * Journal head shrinker, reclaim buffer's journal head which
8744ba3fcddSZhang Yi * has been written back.
8754ba3fcddSZhang Yi */
8764b403dfaSQi Zheng struct shrinker *j_shrinker;
8774ba3fcddSZhang Yi
8784ba3fcddSZhang Yi /**
8790705e8d1STheodore Ts'o * @j_checkpoint_jh_count:
8804ba3fcddSZhang Yi *
8814ba3fcddSZhang Yi * Number of journal buffers on the checkpoint list. [j_list_lock]
8824ba3fcddSZhang Yi */
8830705e8d1STheodore Ts'o struct percpu_counter j_checkpoint_jh_count;
8844ba3fcddSZhang Yi
8854ba3fcddSZhang Yi /**
8864ba3fcddSZhang Yi * @j_shrink_transaction:
8874ba3fcddSZhang Yi *
8884ba3fcddSZhang Yi * Record next transaction will shrink on the checkpoint list.
8894ba3fcddSZhang Yi * [j_list_lock]
8904ba3fcddSZhang Yi */
8914ba3fcddSZhang Yi transaction_t *j_shrink_transaction;
8924ba3fcddSZhang Yi
8934ba3fcddSZhang Yi /**
894f69120ceSTobin C. Harding * @j_head:
895f69120ceSTobin C. Harding *
896470decc6SDave Kleikamp * Journal head: identifies the first unused block in the journal.
897470decc6SDave Kleikamp * [j_state_lock]
898470decc6SDave Kleikamp */
899470decc6SDave Kleikamp unsigned long j_head;
900470decc6SDave Kleikamp
901f69120ceSTobin C. Harding /**
902f69120ceSTobin C. Harding * @j_tail:
903f69120ceSTobin C. Harding *
904470decc6SDave Kleikamp * Journal tail: identifies the oldest still-used block in the journal.
905470decc6SDave Kleikamp * [j_state_lock]
906470decc6SDave Kleikamp */
907470decc6SDave Kleikamp unsigned long j_tail;
908470decc6SDave Kleikamp
909f69120ceSTobin C. Harding /**
910f69120ceSTobin C. Harding * @j_free:
911f69120ceSTobin C. Harding *
912470decc6SDave Kleikamp * Journal free: how many free blocks are there in the journal?
913470decc6SDave Kleikamp * [j_state_lock]
914470decc6SDave Kleikamp */
915470decc6SDave Kleikamp unsigned long j_free;
916470decc6SDave Kleikamp
917f69120ceSTobin C. Harding /**
918f69120ceSTobin C. Harding * @j_first:
919f69120ceSTobin C. Harding *
920f69120ceSTobin C. Harding * The block number of the first usable block in the journal
921f69120ceSTobin C. Harding * [j_state_lock].
922470decc6SDave Kleikamp */
923470decc6SDave Kleikamp unsigned long j_first;
924f69120ceSTobin C. Harding
925f69120ceSTobin C. Harding /**
926f69120ceSTobin C. Harding * @j_last:
927f69120ceSTobin C. Harding *
928f69120ceSTobin C. Harding * The block number one beyond the last usable block in the journal
929f69120ceSTobin C. Harding * [j_state_lock].
930f69120ceSTobin C. Harding */
931470decc6SDave Kleikamp unsigned long j_last;
932470decc6SDave Kleikamp
933f69120ceSTobin C. Harding /**
9346866d7b3SHarshad Shirwadkar * @j_fc_first:
9356866d7b3SHarshad Shirwadkar *
9366866d7b3SHarshad Shirwadkar * The block number of the first fast commit block in the journal
9376866d7b3SHarshad Shirwadkar * [j_state_lock].
9386866d7b3SHarshad Shirwadkar */
9396866d7b3SHarshad Shirwadkar unsigned long j_fc_first;
9406866d7b3SHarshad Shirwadkar
9416866d7b3SHarshad Shirwadkar /**
9426866d7b3SHarshad Shirwadkar * @j_fc_off:
9436866d7b3SHarshad Shirwadkar *
944c460e5edSHarshad Shirwadkar * Number of fast commit blocks currently allocated. Accessed only
945c460e5edSHarshad Shirwadkar * during fast commit. Currently only process can do fast commit, so
946c460e5edSHarshad Shirwadkar * this field is not protected by any lock.
9476866d7b3SHarshad Shirwadkar */
9486866d7b3SHarshad Shirwadkar unsigned long j_fc_off;
9496866d7b3SHarshad Shirwadkar
9506866d7b3SHarshad Shirwadkar /**
9516866d7b3SHarshad Shirwadkar * @j_fc_last:
9526866d7b3SHarshad Shirwadkar *
9536866d7b3SHarshad Shirwadkar * The block number one beyond the last fast commit block in the journal
9546866d7b3SHarshad Shirwadkar * [j_state_lock].
9556866d7b3SHarshad Shirwadkar */
9566866d7b3SHarshad Shirwadkar unsigned long j_fc_last;
9576866d7b3SHarshad Shirwadkar
9586866d7b3SHarshad Shirwadkar /**
959f69120ceSTobin C. Harding * @j_dev: Device where we store the journal.
960470decc6SDave Kleikamp */
961470decc6SDave Kleikamp struct block_device *j_dev;
962f69120ceSTobin C. Harding
963f69120ceSTobin C. Harding /**
964f69120ceSTobin C. Harding * @j_blocksize: Block size for the location where we store the journal.
965f69120ceSTobin C. Harding */
966470decc6SDave Kleikamp int j_blocksize;
967f69120ceSTobin C. Harding
968f69120ceSTobin C. Harding /**
969f69120ceSTobin C. Harding * @j_blk_offset:
970f69120ceSTobin C. Harding *
971f69120ceSTobin C. Harding * Starting block offset into the device where we store the journal.
972f69120ceSTobin C. Harding */
97318eba7aaSMingming Cao unsigned long long j_blk_offset;
974f69120ceSTobin C. Harding
975f69120ceSTobin C. Harding /**
976f69120ceSTobin C. Harding * @j_devname: Journal device name.
977f69120ceSTobin C. Harding */
97805496769STheodore Ts'o char j_devname[BDEVNAME_SIZE+24];
979470decc6SDave Kleikamp
980f69120ceSTobin C. Harding /**
981f69120ceSTobin C. Harding * @j_fs_dev:
982f69120ceSTobin C. Harding *
983470decc6SDave Kleikamp * Device which holds the client fs. For internal journal this will be
984470decc6SDave Kleikamp * equal to j_dev.
985470decc6SDave Kleikamp */
986470decc6SDave Kleikamp struct block_device *j_fs_dev;
987470decc6SDave Kleikamp
988f69120ceSTobin C. Harding /**
989990b6b5bSZhihao Cheng * @j_fs_dev_wb_err:
990990b6b5bSZhihao Cheng *
991990b6b5bSZhihao Cheng * Records the errseq of the client fs's backing block device.
992990b6b5bSZhihao Cheng */
993990b6b5bSZhihao Cheng errseq_t j_fs_dev_wb_err;
994990b6b5bSZhihao Cheng
995990b6b5bSZhihao Cheng /**
996ede7dc7fSHarshad Shirwadkar * @j_total_len: Total maximum capacity of the journal region on disk.
997f69120ceSTobin C. Harding */
998ede7dc7fSHarshad Shirwadkar unsigned int j_total_len;
999470decc6SDave Kleikamp
1000f69120ceSTobin C. Harding /**
1001f69120ceSTobin C. Harding * @j_reserved_credits:
1002f69120ceSTobin C. Harding *
1003f69120ceSTobin C. Harding * Number of buffers reserved from the running transaction.
1004f69120ceSTobin C. Harding */
10058f7d89f3SJan Kara atomic_t j_reserved_credits;
10068f7d89f3SJan Kara
1007f69120ceSTobin C. Harding /**
1008f69120ceSTobin C. Harding * @j_list_lock: Protects the buffer lists and internal buffer state.
1009470decc6SDave Kleikamp */
1010470decc6SDave Kleikamp spinlock_t j_list_lock;
1011470decc6SDave Kleikamp
1012f69120ceSTobin C. Harding /**
1013f69120ceSTobin C. Harding * @j_inode:
1014f69120ceSTobin C. Harding *
1015f69120ceSTobin C. Harding * Optional inode where we store the journal. If present, all
1016f69120ceSTobin C. Harding * journal block numbers are mapped into this inode via bmap().
1017f69120ceSTobin C. Harding */
1018470decc6SDave Kleikamp struct inode *j_inode;
1019470decc6SDave Kleikamp
1020f69120ceSTobin C. Harding /**
1021f69120ceSTobin C. Harding * @j_tail_sequence:
1022f69120ceSTobin C. Harding *
1023470decc6SDave Kleikamp * Sequence number of the oldest transaction in the log [j_state_lock]
1024470decc6SDave Kleikamp */
1025470decc6SDave Kleikamp tid_t j_tail_sequence;
1026470decc6SDave Kleikamp
1027f69120ceSTobin C. Harding /**
1028f69120ceSTobin C. Harding * @j_transaction_sequence:
1029f69120ceSTobin C. Harding *
1030470decc6SDave Kleikamp * Sequence number of the next transaction to grant [j_state_lock]
1031470decc6SDave Kleikamp */
1032470decc6SDave Kleikamp tid_t j_transaction_sequence;
1033470decc6SDave Kleikamp
1034f69120ceSTobin C. Harding /**
1035f69120ceSTobin C. Harding * @j_commit_sequence:
1036f69120ceSTobin C. Harding *
1037470decc6SDave Kleikamp * Sequence number of the most recently committed transaction
1038d699ae4fSAlexander Lochmann * [j_state_lock, no lock for quick racy checks]
1039470decc6SDave Kleikamp */
1040470decc6SDave Kleikamp tid_t j_commit_sequence;
1041470decc6SDave Kleikamp
1042f69120ceSTobin C. Harding /**
1043f69120ceSTobin C. Harding * @j_commit_request:
1044f69120ceSTobin C. Harding *
1045470decc6SDave Kleikamp * Sequence number of the most recent transaction wanting commit
1046d699ae4fSAlexander Lochmann * [j_state_lock, no lock for quick racy checks]
1047470decc6SDave Kleikamp */
1048470decc6SDave Kleikamp tid_t j_commit_request;
1049470decc6SDave Kleikamp
1050f69120ceSTobin C. Harding /**
1051f69120ceSTobin C. Harding * @j_uuid:
1052f69120ceSTobin C. Harding *
1053470decc6SDave Kleikamp * Journal uuid: identifies the object (filesystem, LVM volume etc)
1054470decc6SDave Kleikamp * backed by this journal. This will eventually be replaced by an array
1055470decc6SDave Kleikamp * of uuids, allowing us to index multiple devices within a single
1056470decc6SDave Kleikamp * journal and to perform atomic updates across them.
1057470decc6SDave Kleikamp */
1058470decc6SDave Kleikamp __u8 j_uuid[16];
1059470decc6SDave Kleikamp
1060f69120ceSTobin C. Harding /**
1061f69120ceSTobin C. Harding * @j_task: Pointer to the current commit thread for this journal.
1062f69120ceSTobin C. Harding */
1063470decc6SDave Kleikamp struct task_struct *j_task;
1064470decc6SDave Kleikamp
1065f69120ceSTobin C. Harding /**
1066f69120ceSTobin C. Harding * @j_max_transaction_buffers:
1067f69120ceSTobin C. Harding *
1068470decc6SDave Kleikamp * Maximum number of metadata buffers to allow in a single compound
1069f69120ceSTobin C. Harding * commit transaction.
1070470decc6SDave Kleikamp */
1071470decc6SDave Kleikamp int j_max_transaction_buffers;
1072470decc6SDave Kleikamp
1073f69120ceSTobin C. Harding /**
1074fdc3ef88SJan Kara * @j_revoke_records_per_block:
1075fdc3ef88SJan Kara *
1076fdc3ef88SJan Kara * Number of revoke records that fit in one descriptor block.
1077fdc3ef88SJan Kara */
1078fdc3ef88SJan Kara int j_revoke_records_per_block;
1079fdc3ef88SJan Kara
1080fdc3ef88SJan Kara /**
10817e8fb2edSRandy Dunlap * @j_transaction_overhead_buffers:
1082e3a00a23SJan Kara *
1083e3a00a23SJan Kara * Number of blocks each transaction needs for its own bookkeeping
1084e3a00a23SJan Kara */
1085e3a00a23SJan Kara int j_transaction_overhead_buffers;
1086e3a00a23SJan Kara
1087e3a00a23SJan Kara /**
1088f69120ceSTobin C. Harding * @j_commit_interval:
1089f69120ceSTobin C. Harding *
1090470decc6SDave Kleikamp * What is the maximum transaction lifetime before we begin a commit?
1091470decc6SDave Kleikamp */
1092470decc6SDave Kleikamp unsigned long j_commit_interval;
1093470decc6SDave Kleikamp
1094f69120ceSTobin C. Harding /**
1095f69120ceSTobin C. Harding * @j_commit_timer: The timer used to wakeup the commit thread.
1096f69120ceSTobin C. Harding */
1097470decc6SDave Kleikamp struct timer_list j_commit_timer;
1098470decc6SDave Kleikamp
1099f69120ceSTobin C. Harding /**
1100f69120ceSTobin C. Harding * @j_revoke_lock: Protect the revoke table.
1101470decc6SDave Kleikamp */
1102470decc6SDave Kleikamp spinlock_t j_revoke_lock;
1103f69120ceSTobin C. Harding
1104f69120ceSTobin C. Harding /**
1105f69120ceSTobin C. Harding * @j_revoke:
1106f69120ceSTobin C. Harding *
1107f69120ceSTobin C. Harding * The revoke table - maintains the list of revoked blocks in the
1108f69120ceSTobin C. Harding * current transaction.
1109f69120ceSTobin C. Harding */
1110f7f4bccbSMingming Cao struct jbd2_revoke_table_s *j_revoke;
1111f69120ceSTobin C. Harding
1112f69120ceSTobin C. Harding /**
1113f69120ceSTobin C. Harding * @j_revoke_table: Alternate revoke tables for j_revoke.
1114f69120ceSTobin C. Harding */
1115f7f4bccbSMingming Cao struct jbd2_revoke_table_s *j_revoke_table[2];
1116470decc6SDave Kleikamp
1117f69120ceSTobin C. Harding /**
1118f69120ceSTobin C. Harding * @j_wbuf: Array of bhs for jbd2_journal_commit_transaction.
1119470decc6SDave Kleikamp */
1120470decc6SDave Kleikamp struct buffer_head **j_wbuf;
1121f69120ceSTobin C. Harding
1122f69120ceSTobin C. Harding /**
1123c460e5edSHarshad Shirwadkar * @j_fc_wbuf: Array of fast commit bhs for fast commit. Accessed only
1124c460e5edSHarshad Shirwadkar * during a fast commit. Currently only process can do fast commit, so
1125c460e5edSHarshad Shirwadkar * this field is not protected by any lock.
11266866d7b3SHarshad Shirwadkar */
11276866d7b3SHarshad Shirwadkar struct buffer_head **j_fc_wbuf;
11286866d7b3SHarshad Shirwadkar
11296866d7b3SHarshad Shirwadkar /**
1130f69120ceSTobin C. Harding * @j_wbufsize:
1131f69120ceSTobin C. Harding *
1132f69120ceSTobin C. Harding * Size of @j_wbuf array.
1133f69120ceSTobin C. Harding */
1134470decc6SDave Kleikamp int j_wbufsize;
1135470decc6SDave Kleikamp
1136f69120ceSTobin C. Harding /**
11376866d7b3SHarshad Shirwadkar * @j_fc_wbufsize:
11386866d7b3SHarshad Shirwadkar *
11396866d7b3SHarshad Shirwadkar * Size of @j_fc_wbuf array.
11406866d7b3SHarshad Shirwadkar */
11416866d7b3SHarshad Shirwadkar int j_fc_wbufsize;
11426866d7b3SHarshad Shirwadkar
11436866d7b3SHarshad Shirwadkar /**
1144f69120ceSTobin C. Harding * @j_last_sync_writer:
1145f69120ceSTobin C. Harding *
1146f69120ceSTobin C. Harding * The pid of the last person to run a synchronous operation
1147f69120ceSTobin C. Harding * through the journal.
1148e07f7183SJosef Bacik */
1149470decc6SDave Kleikamp pid_t j_last_sync_writer;
1150470decc6SDave Kleikamp
1151f69120ceSTobin C. Harding /**
1152f69120ceSTobin C. Harding * @j_average_commit_time:
1153f69120ceSTobin C. Harding *
1154f69120ceSTobin C. Harding * The average amount of time in nanoseconds it takes to commit a
1155e07f7183SJosef Bacik * transaction to disk. [j_state_lock]
1156e07f7183SJosef Bacik */
1157e07f7183SJosef Bacik u64 j_average_commit_time;
1158e07f7183SJosef Bacik
1159f69120ceSTobin C. Harding /**
1160f69120ceSTobin C. Harding * @j_min_batch_time:
1161f69120ceSTobin C. Harding *
1162f69120ceSTobin C. Harding * Minimum time that we should wait for additional filesystem operations
1163f69120ceSTobin C. Harding * to get batched into a synchronous handle in microseconds.
116430773840STheodore Ts'o */
116530773840STheodore Ts'o u32 j_min_batch_time;
1166f69120ceSTobin C. Harding
1167f69120ceSTobin C. Harding /**
1168f69120ceSTobin C. Harding * @j_max_batch_time:
1169f69120ceSTobin C. Harding *
1170f69120ceSTobin C. Harding * Maximum time that we should wait for additional filesystem operations
1171f69120ceSTobin C. Harding * to get batched into a synchronous handle in microseconds.
1172f69120ceSTobin C. Harding */
117330773840STheodore Ts'o u32 j_max_batch_time;
117430773840STheodore Ts'o
1175f69120ceSTobin C. Harding /**
1176f69120ceSTobin C. Harding * @j_commit_callback:
1177f69120ceSTobin C. Harding *
1178f69120ceSTobin C. Harding * This function is called when a transaction is closed.
1179f69120ceSTobin C. Harding */
11803e624fc7STheodore Ts'o void (*j_commit_callback)(journal_t *,
11813e624fc7STheodore Ts'o transaction_t *);
11823e624fc7STheodore Ts'o
1183342af94eSMauricio Faria de Oliveira /**
1184342af94eSMauricio Faria de Oliveira * @j_submit_inode_data_buffers:
1185342af94eSMauricio Faria de Oliveira *
1186342af94eSMauricio Faria de Oliveira * This function is called for all inodes associated with the
1187342af94eSMauricio Faria de Oliveira * committing transaction marked with JI_WRITE_DATA flag
1188342af94eSMauricio Faria de Oliveira * before we start to write out the transaction to the journal.
1189342af94eSMauricio Faria de Oliveira */
1190342af94eSMauricio Faria de Oliveira int (*j_submit_inode_data_buffers)
1191342af94eSMauricio Faria de Oliveira (struct jbd2_inode *);
1192342af94eSMauricio Faria de Oliveira
1193342af94eSMauricio Faria de Oliveira /**
1194342af94eSMauricio Faria de Oliveira * @j_finish_inode_data_buffers:
1195342af94eSMauricio Faria de Oliveira *
1196342af94eSMauricio Faria de Oliveira * This function is called for all inodes associated with the
1197342af94eSMauricio Faria de Oliveira * committing transaction marked with JI_WAIT_DATA flag
1198342af94eSMauricio Faria de Oliveira * after we have written the transaction to the journal
1199342af94eSMauricio Faria de Oliveira * but before we write out the commit block.
1200342af94eSMauricio Faria de Oliveira */
1201342af94eSMauricio Faria de Oliveira int (*j_finish_inode_data_buffers)
1202342af94eSMauricio Faria de Oliveira (struct jbd2_inode *);
1203342af94eSMauricio Faria de Oliveira
1204470decc6SDave Kleikamp /*
12058e85fb3fSJohann Lombardi * Journal statistics
12068e85fb3fSJohann Lombardi */
1207f69120ceSTobin C. Harding
1208f69120ceSTobin C. Harding /**
1209f69120ceSTobin C. Harding * @j_history_lock: Protect the transactions statistics history.
1210f69120ceSTobin C. Harding */
12118e85fb3fSJohann Lombardi spinlock_t j_history_lock;
1212f69120ceSTobin C. Harding
1213f69120ceSTobin C. Harding /**
1214f69120ceSTobin C. Harding * @j_proc_entry: procfs entry for the jbd statistics directory.
1215f69120ceSTobin C. Harding */
12168e85fb3fSJohann Lombardi struct proc_dir_entry *j_proc_entry;
1217f69120ceSTobin C. Harding
1218f69120ceSTobin C. Harding /**
1219f69120ceSTobin C. Harding * @j_stats: Overall statistics.
1220f69120ceSTobin C. Harding */
12218e85fb3fSJohann Lombardi struct transaction_stats_s j_stats;
12228e85fb3fSJohann Lombardi
1223f69120ceSTobin C. Harding /**
1224f69120ceSTobin C. Harding * @j_failed_commit: Failed journal commit ID.
1225f69120ceSTobin C. Harding */
1226624080edSTheodore Ts'o unsigned int j_failed_commit;
1227624080edSTheodore Ts'o
1228f69120ceSTobin C. Harding /**
1229f69120ceSTobin C. Harding * @j_private:
1230f69120ceSTobin C. Harding *
1231470decc6SDave Kleikamp * An opaque pointer to fs-private information. ext3 puts its
1232f69120ceSTobin C. Harding * superblock pointer here.
1233470decc6SDave Kleikamp */
1234470decc6SDave Kleikamp void *j_private;
123501b5adceSDarrick J. Wong
1236f69120ceSTobin C. Harding /**
1237f69120ceSTobin C. Harding * @j_csum_seed:
1238f69120ceSTobin C. Harding *
1239f69120ceSTobin C. Harding * Precomputed journal UUID checksum for seeding other checksums.
1240f69120ceSTobin C. Harding */
12414fd5ea43SDarrick J. Wong __u32 j_csum_seed;
1242ab714affSJan Kara
1243ab714affSJan Kara #ifdef CONFIG_DEBUG_LOCK_ALLOC
1244f69120ceSTobin C. Harding /**
1245f69120ceSTobin C. Harding * @j_trans_commit_map:
1246f69120ceSTobin C. Harding *
1247ab714affSJan Kara * Lockdep entity to track transaction commit dependencies. Handles
1248ab714affSJan Kara * hold this "lock" for read, when we wait for commit, we acquire the
1249ab714affSJan Kara * "lock" for writing. This matches the properties of jbd2 journalling
1250ab714affSJan Kara * where the running transaction has to wait for all handles to be
1251ab714affSJan Kara * dropped to commit that transaction and also acquiring a handle may
1252ab714affSJan Kara * require transaction commit to finish.
1253ab714affSJan Kara */
1254ab714affSJan Kara struct lockdep_map j_trans_commit_map;
1255ab714affSJan Kara #endif
1256ff780b91SHarshad Shirwadkar
1257ff780b91SHarshad Shirwadkar /**
1258ff780b91SHarshad Shirwadkar * @j_fc_cleanup_callback:
1259ff780b91SHarshad Shirwadkar *
1260ff780b91SHarshad Shirwadkar * Clean-up after fast commit or full commit. JBD2 calls this function
1261ff780b91SHarshad Shirwadkar * after every commit operation.
1262ff780b91SHarshad Shirwadkar */
1263e85c81baSXin Yin void (*j_fc_cleanup_callback)(struct journal_s *journal, int full, tid_t tid);
1264ff780b91SHarshad Shirwadkar
1265ea4b01d9SMauro Carvalho Chehab /**
12665b849b5fSHarshad Shirwadkar * @j_fc_replay_callback:
12675b849b5fSHarshad Shirwadkar *
12685b849b5fSHarshad Shirwadkar * File-system specific function that performs replay of a fast
12695b849b5fSHarshad Shirwadkar * commit. JBD2 calls this function for each fast commit block found in
12705b849b5fSHarshad Shirwadkar * the journal. This function should return JBD2_FC_REPLAY_CONTINUE
12715b849b5fSHarshad Shirwadkar * to indicate that the block was processed correctly and more fast
12725b849b5fSHarshad Shirwadkar * commit replay should continue. Return value of JBD2_FC_REPLAY_STOP
12735b849b5fSHarshad Shirwadkar * indicates the end of replay (no more blocks remaining). A negative
12745b849b5fSHarshad Shirwadkar * return value indicates error.
12755b849b5fSHarshad Shirwadkar */
12765b849b5fSHarshad Shirwadkar int (*j_fc_replay_callback)(struct journal_s *journal,
12775b849b5fSHarshad Shirwadkar struct buffer_head *bh,
12785b849b5fSHarshad Shirwadkar enum passtype pass, int off,
12795b849b5fSHarshad Shirwadkar tid_t expected_commit_id);
128062913ae9STheodore Ts'o
128162913ae9STheodore Ts'o /**
128262913ae9STheodore Ts'o * @j_bmap:
128362913ae9STheodore Ts'o *
128462913ae9STheodore Ts'o * Bmap function that should be used instead of the generic
128562913ae9STheodore Ts'o * VFS bmap function.
128662913ae9STheodore Ts'o */
128762913ae9STheodore Ts'o int (*j_bmap)(struct journal_s *journal, sector_t *block);
1288470decc6SDave Kleikamp };
1289470decc6SDave Kleikamp
12901eaa566dSJan Kara #define jbd2_might_wait_for_commit(j) \
12911eaa566dSJan Kara do { \
12921eaa566dSJan Kara rwsem_acquire(&j->j_trans_commit_map, 0, 0, _THIS_IP_); \
12935facae4fSQian Cai rwsem_release(&j->j_trans_commit_map, _THIS_IP_); \
12941eaa566dSJan Kara } while (0)
12951eaa566dSJan Kara
12965cf036d4SZhang Yi /*
12975cf036d4SZhang Yi * We can support any known requested features iff the
12985cf036d4SZhang Yi * superblock is not in version 1. Otherwise we fail to support any
12995cf036d4SZhang Yi * extended sb features.
13005cf036d4SZhang Yi */
jbd2_format_support_feature(journal_t * j)13015cf036d4SZhang Yi static inline bool jbd2_format_support_feature(journal_t *j)
13025cf036d4SZhang Yi {
13035cf036d4SZhang Yi return j->j_superblock->s_header.h_blocktype !=
13045cf036d4SZhang Yi cpu_to_be32(JBD2_SUPERBLOCK_V1);
13055cf036d4SZhang Yi }
13065cf036d4SZhang Yi
130756316a0dSDarrick J. Wong /* journal feature predicate functions */
130856316a0dSDarrick J. Wong #define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
130956316a0dSDarrick J. Wong static inline bool jbd2_has_feature_##name(journal_t *j) \
131056316a0dSDarrick J. Wong { \
13115cf036d4SZhang Yi return (jbd2_format_support_feature(j) && \
131256316a0dSDarrick J. Wong ((j)->j_superblock->s_feature_compat & \
131356316a0dSDarrick J. Wong cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname)) != 0); \
131456316a0dSDarrick J. Wong } \
131556316a0dSDarrick J. Wong static inline void jbd2_set_feature_##name(journal_t *j) \
131656316a0dSDarrick J. Wong { \
131756316a0dSDarrick J. Wong (j)->j_superblock->s_feature_compat |= \
131856316a0dSDarrick J. Wong cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
131956316a0dSDarrick J. Wong } \
132056316a0dSDarrick J. Wong static inline void jbd2_clear_feature_##name(journal_t *j) \
132156316a0dSDarrick J. Wong { \
132256316a0dSDarrick J. Wong (j)->j_superblock->s_feature_compat &= \
132356316a0dSDarrick J. Wong ~cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
132456316a0dSDarrick J. Wong }
132556316a0dSDarrick J. Wong
132656316a0dSDarrick J. Wong #define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
132756316a0dSDarrick J. Wong static inline bool jbd2_has_feature_##name(journal_t *j) \
132856316a0dSDarrick J. Wong { \
13295cf036d4SZhang Yi return (jbd2_format_support_feature(j) && \
133056316a0dSDarrick J. Wong ((j)->j_superblock->s_feature_ro_compat & \
133156316a0dSDarrick J. Wong cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname)) != 0); \
133256316a0dSDarrick J. Wong } \
133356316a0dSDarrick J. Wong static inline void jbd2_set_feature_##name(journal_t *j) \
133456316a0dSDarrick J. Wong { \
133556316a0dSDarrick J. Wong (j)->j_superblock->s_feature_ro_compat |= \
133656316a0dSDarrick J. Wong cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
133756316a0dSDarrick J. Wong } \
133856316a0dSDarrick J. Wong static inline void jbd2_clear_feature_##name(journal_t *j) \
133956316a0dSDarrick J. Wong { \
134056316a0dSDarrick J. Wong (j)->j_superblock->s_feature_ro_compat &= \
134156316a0dSDarrick J. Wong ~cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
134256316a0dSDarrick J. Wong }
134356316a0dSDarrick J. Wong
134456316a0dSDarrick J. Wong #define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
134556316a0dSDarrick J. Wong static inline bool jbd2_has_feature_##name(journal_t *j) \
134656316a0dSDarrick J. Wong { \
13475cf036d4SZhang Yi return (jbd2_format_support_feature(j) && \
134856316a0dSDarrick J. Wong ((j)->j_superblock->s_feature_incompat & \
134956316a0dSDarrick J. Wong cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname)) != 0); \
135056316a0dSDarrick J. Wong } \
135156316a0dSDarrick J. Wong static inline void jbd2_set_feature_##name(journal_t *j) \
135256316a0dSDarrick J. Wong { \
135356316a0dSDarrick J. Wong (j)->j_superblock->s_feature_incompat |= \
135456316a0dSDarrick J. Wong cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
135556316a0dSDarrick J. Wong } \
135656316a0dSDarrick J. Wong static inline void jbd2_clear_feature_##name(journal_t *j) \
135756316a0dSDarrick J. Wong { \
135856316a0dSDarrick J. Wong (j)->j_superblock->s_feature_incompat &= \
135956316a0dSDarrick J. Wong ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
136056316a0dSDarrick J. Wong }
136156316a0dSDarrick J. Wong
136256316a0dSDarrick J. Wong JBD2_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
136356316a0dSDarrick J. Wong
136456316a0dSDarrick J. Wong JBD2_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
136556316a0dSDarrick J. Wong JBD2_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
136656316a0dSDarrick J. Wong JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
136756316a0dSDarrick J. Wong JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
136856316a0dSDarrick J. Wong JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
1369995a3ed6SHarshad Shirwadkar JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
137056316a0dSDarrick J. Wong
13716a3afb6aSZhang Yi /* Journal high priority write IO operation flags */
13726a3afb6aSZhang Yi #define JBD2_JOURNAL_REQ_FLAGS (REQ_META | REQ_SYNC | REQ_IDLE)
13736a3afb6aSZhang Yi
1374470decc6SDave Kleikamp /*
1375470decc6SDave Kleikamp * Journal flag definitions
1376470decc6SDave Kleikamp */
1377f7f4bccbSMingming Cao #define JBD2_UNMOUNT 0x001 /* Journal thread is being destroyed */
1378f7f4bccbSMingming Cao #define JBD2_ABORT 0x002 /* Journaling has been aborted for errors. */
1379f7f4bccbSMingming Cao #define JBD2_ACK_ERR 0x004 /* The errno in the sb has been acked */
1380f7f4bccbSMingming Cao #define JBD2_FLUSHED 0x008 /* The journal superblock has been flushed */
1381f7f4bccbSMingming Cao #define JBD2_LOADED 0x010 /* The journal superblock has been loaded */
1382f7f4bccbSMingming Cao #define JBD2_BARRIER 0x020 /* Use IDE barriers */
1383c7fc6055SZhang Yi #define JBD2_CYCLE_RECORD 0x080 /* Journal cycled record log on
1384c7fc6055SZhang Yi * clean and empty filesystem
1385c7fc6055SZhang Yi * logging area */
1386ff780b91SHarshad Shirwadkar #define JBD2_FAST_COMMIT_ONGOING 0x100 /* Fast commit is ongoing */
1387ff780b91SHarshad Shirwadkar #define JBD2_FULL_COMMIT_ONGOING 0x200 /* Full commit is ongoing */
138801d5d965SLeah Rumancik #define JBD2_JOURNAL_FLUSH_DISCARD 0x0001
138901d5d965SLeah Rumancik #define JBD2_JOURNAL_FLUSH_ZEROOUT 0x0002
139001d5d965SLeah Rumancik #define JBD2_JOURNAL_FLUSH_VALID (JBD2_JOURNAL_FLUSH_DISCARD | \
139101d5d965SLeah Rumancik JBD2_JOURNAL_FLUSH_ZEROOUT)
1392470decc6SDave Kleikamp
1393470decc6SDave Kleikamp /*
1394470decc6SDave Kleikamp * Function declarations for the journaling transaction and buffer
1395470decc6SDave Kleikamp * management
1396470decc6SDave Kleikamp */
1397470decc6SDave Kleikamp
1398470decc6SDave Kleikamp /* Filing buffers */
139993108ebbSJan Kara extern bool __jbd2_journal_refile_buffer(struct journal_head *);
1400f7f4bccbSMingming Cao extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
1401f7f4bccbSMingming Cao extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
1402f7f4bccbSMingming Cao extern void jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
jbd2_file_log_bh(struct list_head * head,struct buffer_head * bh)1403f5113effSJan Kara static inline void jbd2_file_log_bh(struct list_head *head, struct buffer_head *bh)
1404f5113effSJan Kara {
1405f5113effSJan Kara list_add_tail(&bh->b_assoc_buffers, head);
1406f5113effSJan Kara }
jbd2_unfile_log_bh(struct buffer_head * bh)1407f5113effSJan Kara static inline void jbd2_unfile_log_bh(struct buffer_head *bh)
1408f5113effSJan Kara {
1409f5113effSJan Kara list_del_init(&bh->b_assoc_buffers);
1410f5113effSJan Kara }
1411470decc6SDave Kleikamp
1412470decc6SDave Kleikamp /* Log buffer allocation */
141332ab6715SJan Kara struct buffer_head *jbd2_journal_get_descriptor_buffer(transaction_t *, int);
14141101cd4dSJan Kara void jbd2_descriptor_block_csum_set(journal_t *, struct buffer_head *);
141518eba7aaSMingming Cao int jbd2_journal_next_log_block(journal_t *, unsigned long long *);
141679feb521SJan Kara int jbd2_journal_get_log_tail(journal_t *journal, tid_t *tid,
141779feb521SJan Kara unsigned long *block);
14186f6a6fdaSJoseph Qi int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block);
14193339578fSJan Kara void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block);
1420470decc6SDave Kleikamp
1421470decc6SDave Kleikamp /* Commit management */
1422f7f4bccbSMingming Cao extern void jbd2_journal_commit_transaction(journal_t *);
1423470decc6SDave Kleikamp
1424470decc6SDave Kleikamp /* Checkpoint list management */
142526770a71SYe Bin enum jbd2_shrink_type {JBD2_SHRINK_DESTROY, JBD2_SHRINK_BUSY_STOP, JBD2_SHRINK_BUSY_SKIP};
1426078760d9SYe Bin
142726770a71SYe Bin void __jbd2_journal_clean_checkpoint_list(journal_t *journal, enum jbd2_shrink_type type);
14284ba3fcddSZhang Yi unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal, unsigned long *nr_to_scan);
1429f7f4bccbSMingming Cao int __jbd2_journal_remove_checkpoint(struct journal_head *);
143046f881b5SZhang Yi int jbd2_journal_try_remove_checkpoint(struct journal_head *jh);
1431841df7dfSJan Kara void jbd2_journal_destroy_checkpoint(journal_t *journal);
1432f7f4bccbSMingming Cao void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);
1433470decc6SDave Kleikamp
1434e06c8227SJoel Becker
1435e06c8227SJoel Becker /*
1436e06c8227SJoel Becker * Triggers
1437e06c8227SJoel Becker */
1438e06c8227SJoel Becker
1439e06c8227SJoel Becker struct jbd2_buffer_trigger_type {
1440e06c8227SJoel Becker /*
144113ceef09SJan Kara * Fired a the moment data to write to the journal are known to be
144213ceef09SJan Kara * stable - so either at the moment b_frozen_data is created or just
144313ceef09SJan Kara * before a buffer is written to the journal. mapped_data is a mapped
144413ceef09SJan Kara * buffer that is the frozen data for commit.
1445e06c8227SJoel Becker */
144613ceef09SJan Kara void (*t_frozen)(struct jbd2_buffer_trigger_type *type,
1447e06c8227SJoel Becker struct buffer_head *bh, void *mapped_data,
1448e06c8227SJoel Becker size_t size);
1449e06c8227SJoel Becker
1450e06c8227SJoel Becker /*
1451e06c8227SJoel Becker * Fired during journal abort for dirty buffers that will not be
1452e06c8227SJoel Becker * committed.
1453e06c8227SJoel Becker */
1454e06c8227SJoel Becker void (*t_abort)(struct jbd2_buffer_trigger_type *type,
1455e06c8227SJoel Becker struct buffer_head *bh);
1456e06c8227SJoel Becker };
1457e06c8227SJoel Becker
145813ceef09SJan Kara extern void jbd2_buffer_frozen_trigger(struct journal_head *jh,
1459e06c8227SJoel Becker void *mapped_data,
1460e06c8227SJoel Becker struct jbd2_buffer_trigger_type *triggers);
1461e06c8227SJoel Becker extern void jbd2_buffer_abort_trigger(struct journal_head *jh,
1462e06c8227SJoel Becker struct jbd2_buffer_trigger_type *triggers);
1463e06c8227SJoel Becker
1464470decc6SDave Kleikamp /* Buffer IO */
1465f5113effSJan Kara extern int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
1466470decc6SDave Kleikamp struct journal_head *jh_in,
1467f5113effSJan Kara struct buffer_head **bh_out,
1468f5113effSJan Kara sector_t blocknr);
1469470decc6SDave Kleikamp
14700c2022ecSYongqiang Yang /* Transaction cache support */
14710c2022ecSYongqiang Yang extern void jbd2_journal_destroy_transaction_cache(void);
14720d52154bSChengguang Xu extern int __init jbd2_journal_init_transaction_cache(void);
14730c2022ecSYongqiang Yang extern void jbd2_journal_free_transaction(transaction_t *);
14740c2022ecSYongqiang Yang
1475470decc6SDave Kleikamp /*
1476470decc6SDave Kleikamp * Journal locking.
1477470decc6SDave Kleikamp *
1478470decc6SDave Kleikamp * We need to lock the journal during transaction state changes so that nobody
1479470decc6SDave Kleikamp * ever tries to take a handle on the running transaction while we are in the
1480470decc6SDave Kleikamp * middle of moving it to the commit phase. j_state_lock does this.
1481470decc6SDave Kleikamp *
1482470decc6SDave Kleikamp * Note that the locking is completely interrupt unsafe. We never touch
1483470decc6SDave Kleikamp * journal structures from interrupts.
1484470decc6SDave Kleikamp */
1485470decc6SDave Kleikamp
journal_current_handle(void)1486470decc6SDave Kleikamp static inline handle_t *journal_current_handle(void)
1487470decc6SDave Kleikamp {
1488470decc6SDave Kleikamp return current->journal_info;
1489470decc6SDave Kleikamp }
1490470decc6SDave Kleikamp
1491470decc6SDave Kleikamp /* The journaling code user interface:
1492470decc6SDave Kleikamp *
1493470decc6SDave Kleikamp * Create and destroy handles
1494470decc6SDave Kleikamp * Register buffer modifications against the current transaction.
1495470decc6SDave Kleikamp */
1496470decc6SDave Kleikamp
1497f7f4bccbSMingming Cao extern handle_t *jbd2_journal_start(journal_t *, int nblocks);
14988f7d89f3SJan Kara extern handle_t *jbd2__journal_start(journal_t *, int blocks, int rsv_blocks,
1499fdc3ef88SJan Kara int revoke_records, gfp_t gfp_mask,
1500fdc3ef88SJan Kara unsigned int type, unsigned int line_no);
1501f7f4bccbSMingming Cao extern int jbd2_journal_restart(handle_t *, int nblocks);
1502fdc3ef88SJan Kara extern int jbd2__journal_restart(handle_t *, int nblocks,
1503fdc3ef88SJan Kara int revoke_records, gfp_t gfp_mask);
15048f7d89f3SJan Kara extern int jbd2_journal_start_reserved(handle_t *handle,
15058f7d89f3SJan Kara unsigned int type, unsigned int line_no);
15068f7d89f3SJan Kara extern void jbd2_journal_free_reserved(handle_t *handle);
1507fdc3ef88SJan Kara extern int jbd2_journal_extend(handle_t *handle, int nblocks,
1508fdc3ef88SJan Kara int revoke_records);
1509f7f4bccbSMingming Cao extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
1510f7f4bccbSMingming Cao extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
1511f7f4bccbSMingming Cao extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
1512e06c8227SJoel Becker void jbd2_journal_set_triggers(struct buffer_head *,
1513e06c8227SJoel Becker struct jbd2_buffer_trigger_type *type);
1514f7f4bccbSMingming Cao extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
1515f7f4bccbSMingming Cao extern int jbd2_journal_forget (handle_t *, struct buffer_head *);
1516ccd16945SMatthew Wilcox (Oracle) int jbd2_journal_invalidate_folio(journal_t *, struct folio *,
1517ccd16945SMatthew Wilcox (Oracle) size_t offset, size_t length);
1518c56a6eb0SMatthew Wilcox (Oracle) bool jbd2_journal_try_to_free_buffers(journal_t *journal, struct folio *folio);
1519f7f4bccbSMingming Cao extern int jbd2_journal_stop(handle_t *);
152001d5d965SLeah Rumancik extern int jbd2_journal_flush(journal_t *journal, unsigned int flags);
1521f7f4bccbSMingming Cao extern void jbd2_journal_lock_updates (journal_t *);
1522f7f4bccbSMingming Cao extern void jbd2_journal_unlock_updates (journal_t *);
15234f981868SRitesh Harjani
15244f981868SRitesh Harjani void jbd2_journal_wait_updates(journal_t *);
1525470decc6SDave Kleikamp
1526f7f4bccbSMingming Cao extern journal_t * jbd2_journal_init_dev(struct block_device *bdev,
1527470decc6SDave Kleikamp struct block_device *fs_dev,
152818eba7aaSMingming Cao unsigned long long start, int len, int bsize);
1529f7f4bccbSMingming Cao extern journal_t * jbd2_journal_init_inode (struct inode *);
1530f7f4bccbSMingming Cao extern int jbd2_journal_update_format (journal_t *);
1531f7f4bccbSMingming Cao extern int jbd2_journal_check_used_features
1532470decc6SDave Kleikamp (journal_t *, unsigned long, unsigned long, unsigned long);
1533f7f4bccbSMingming Cao extern int jbd2_journal_check_available_features
1534470decc6SDave Kleikamp (journal_t *, unsigned long, unsigned long, unsigned long);
1535f7f4bccbSMingming Cao extern int jbd2_journal_set_features
1536470decc6SDave Kleikamp (journal_t *, unsigned long, unsigned long, unsigned long);
1537818d276cSGirish Shilamkar extern void jbd2_journal_clear_features
1538818d276cSGirish Shilamkar (journal_t *, unsigned long, unsigned long, unsigned long);
1539f7f4bccbSMingming Cao extern int jbd2_journal_load (journal_t *journal);
154044519fafSHidehiro Kawai extern int jbd2_journal_destroy (journal_t *);
1541f7f4bccbSMingming Cao extern int jbd2_journal_recover (journal_t *journal);
1542f7f4bccbSMingming Cao extern int jbd2_journal_wipe (journal_t *, int);
1543f7f4bccbSMingming Cao extern int jbd2_journal_skip_recovery (journal_t *);
1544d796c52eSTheodore Ts'o extern void jbd2_journal_update_sb_errno(journal_t *);
15456f6a6fdaSJoseph Qi extern int jbd2_journal_update_sb_log_tail (journal_t *, tid_t,
15466669797bSBart Van Assche unsigned long, blk_opf_t);
1547f7f4bccbSMingming Cao extern void jbd2_journal_abort (journal_t *, int);
1548f7f4bccbSMingming Cao extern int jbd2_journal_errno (journal_t *);
1549f7f4bccbSMingming Cao extern void jbd2_journal_ack_err (journal_t *);
1550f7f4bccbSMingming Cao extern int jbd2_journal_clear_err (journal_t *);
155118eba7aaSMingming Cao extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *);
1552f7f4bccbSMingming Cao extern int jbd2_journal_force_commit(journal_t *);
15539ff86446SDmitry Monakhov extern int jbd2_journal_force_commit_nested(journal_t *);
15546ba0e7dcSRoss Zwisler extern int jbd2_journal_inode_ranged_write(handle_t *handle,
15556ba0e7dcSRoss Zwisler struct jbd2_inode *inode, loff_t start_byte,
15566ba0e7dcSRoss Zwisler loff_t length);
15576ba0e7dcSRoss Zwisler extern int jbd2_journal_inode_ranged_wait(handle_t *handle,
15586ba0e7dcSRoss Zwisler struct jbd2_inode *inode, loff_t start_byte,
15596ba0e7dcSRoss Zwisler loff_t length);
1560aa3c0c61SMauricio Faria de Oliveira extern int jbd2_journal_finish_inode_data_buffers(
1561aa3c0c61SMauricio Faria de Oliveira struct jbd2_inode *jinode);
15627f5aa215SJan Kara extern int jbd2_journal_begin_ordered_truncate(journal_t *journal,
15637f5aa215SJan Kara struct jbd2_inode *inode, loff_t new_size);
1564c851ed54SJan Kara extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode);
1565c851ed54SJan Kara extern void jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_inode *jinode);
1566470decc6SDave Kleikamp
1567470decc6SDave Kleikamp /*
1568470decc6SDave Kleikamp * journal_head management
1569470decc6SDave Kleikamp */
1570f7f4bccbSMingming Cao struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh);
1571f7f4bccbSMingming Cao struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh);
1572f7f4bccbSMingming Cao void jbd2_journal_put_journal_head(struct journal_head *jh);
1573470decc6SDave Kleikamp
1574470decc6SDave Kleikamp /*
1575470decc6SDave Kleikamp * handle management
1576470decc6SDave Kleikamp */
1577e18b890bSChristoph Lameter extern struct kmem_cache *jbd2_handle_cache;
1578470decc6SDave Kleikamp
15793b0ba54dSSuren Baghdasaryan /*
15803b0ba54dSSuren Baghdasaryan * This specialized allocator has to be a macro for its allocations to be
15813b0ba54dSSuren Baghdasaryan * accounted separately (to have a separate alloc_tag). The typecast is
15823b0ba54dSSuren Baghdasaryan * intentional to enforce typesafety.
15833b0ba54dSSuren Baghdasaryan */
15842c321f3fSSuren Baghdasaryan #define jbd2_alloc_handle(_gfp_flags) \
15852c321f3fSSuren Baghdasaryan ((handle_t *)kmem_cache_zalloc(jbd2_handle_cache, _gfp_flags))
1586470decc6SDave Kleikamp
jbd2_free_handle(handle_t * handle)1587af1e76d6SMingming Cao static inline void jbd2_free_handle(handle_t *handle)
1588470decc6SDave Kleikamp {
1589f7f4bccbSMingming Cao kmem_cache_free(jbd2_handle_cache, handle);
1590470decc6SDave Kleikamp }
1591470decc6SDave Kleikamp
15928aefcd55STheodore Ts'o /*
15938aefcd55STheodore Ts'o * jbd2_inode management (optional, for those file systems that want to use
15948aefcd55STheodore Ts'o * dynamically allocated jbd2_inode structures)
15958aefcd55STheodore Ts'o */
15968aefcd55STheodore Ts'o extern struct kmem_cache *jbd2_inode_cache;
15978aefcd55STheodore Ts'o
15983b0ba54dSSuren Baghdasaryan /*
15993b0ba54dSSuren Baghdasaryan * This specialized allocator has to be a macro for its allocations to be
16003b0ba54dSSuren Baghdasaryan * accounted separately (to have a separate alloc_tag). The typecast is
16013b0ba54dSSuren Baghdasaryan * intentional to enforce typesafety.
16023b0ba54dSSuren Baghdasaryan */
16032c321f3fSSuren Baghdasaryan #define jbd2_alloc_inode(_gfp_flags) \
16042c321f3fSSuren Baghdasaryan ((struct jbd2_inode *)kmem_cache_alloc(jbd2_inode_cache, _gfp_flags))
16058aefcd55STheodore Ts'o
jbd2_free_inode(struct jbd2_inode * jinode)16068aefcd55STheodore Ts'o static inline void jbd2_free_inode(struct jbd2_inode *jinode)
16078aefcd55STheodore Ts'o {
16088aefcd55STheodore Ts'o kmem_cache_free(jbd2_inode_cache, jinode);
16098aefcd55STheodore Ts'o }
16108aefcd55STheodore Ts'o
1611470decc6SDave Kleikamp /* Primary revoke support */
1612470decc6SDave Kleikamp #define JOURNAL_REVOKE_DEFAULT_HASH 256
1613f7f4bccbSMingming Cao extern int jbd2_journal_init_revoke(journal_t *, int);
16140d52154bSChengguang Xu extern void jbd2_journal_destroy_revoke_record_cache(void);
16150d52154bSChengguang Xu extern void jbd2_journal_destroy_revoke_table_cache(void);
16160d52154bSChengguang Xu extern int __init jbd2_journal_init_revoke_record_cache(void);
16170d52154bSChengguang Xu extern int __init jbd2_journal_init_revoke_table_cache(void);
1618a399af4eSJan Kara struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size);
1619a399af4eSJan Kara void jbd2_journal_destroy_revoke_table(struct jbd2_revoke_table_s *table);
1620470decc6SDave Kleikamp
1621f7f4bccbSMingming Cao extern void jbd2_journal_destroy_revoke(journal_t *);
162218eba7aaSMingming Cao extern int jbd2_journal_revoke (handle_t *, unsigned long long, struct buffer_head *);
16239e6d3f9cSKemeng Shi extern void jbd2_journal_cancel_revoke(handle_t *, struct journal_head *);
16249bcf976cSJan Kara extern void jbd2_journal_write_revoke_records(transaction_t *transaction,
16259bcf976cSJan Kara struct list_head *log_bufs);
1626470decc6SDave Kleikamp
1627470decc6SDave Kleikamp /* Recovery revoke support */
162818eba7aaSMingming Cao extern int jbd2_journal_set_revoke(journal_t *, unsigned long long, tid_t);
162918eba7aaSMingming Cao extern int jbd2_journal_test_revoke(journal_t *, unsigned long long, tid_t);
1630f7f4bccbSMingming Cao extern void jbd2_journal_clear_revoke(journal_t *);
1631f7f4bccbSMingming Cao extern void jbd2_journal_switch_revoke_table(journal_t *journal);
16321ba37268SYongqiang Yang extern void jbd2_clear_buffer_revoked_flags(journal_t *journal);
1633470decc6SDave Kleikamp
1634470decc6SDave Kleikamp /*
1635470decc6SDave Kleikamp * The log thread user interface:
1636470decc6SDave Kleikamp *
1637470decc6SDave Kleikamp * Request space in the current transaction, and force transaction commit
1638470decc6SDave Kleikamp * transitions on demand.
1639470decc6SDave Kleikamp */
1640470decc6SDave Kleikamp
1641f7f4bccbSMingming Cao int jbd2_log_start_commit(journal_t *journal, tid_t tid);
1642f7f4bccbSMingming Cao int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
1643f7f4bccbSMingming Cao int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
1644b8a6176cSJan Kara int jbd2_transaction_committed(journal_t *journal, tid_t tid);
1645d76a3a77STheodore Ts'o int jbd2_complete_transaction(journal_t *journal, tid_t tid);
1646f7f4bccbSMingming Cao int jbd2_log_do_checkpoint(journal_t *journal);
1647bbd2be36SJan Kara int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid);
1648470decc6SDave Kleikamp
1649f7f4bccbSMingming Cao void __jbd2_log_wait_for_space(journal_t *journal);
1650f7f4bccbSMingming Cao extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
1651f7f4bccbSMingming Cao extern int jbd2_cleanup_journal_tail(journal_t *);
1652470decc6SDave Kleikamp
16536866d7b3SHarshad Shirwadkar /* Fast commit related APIs */
1654ff780b91SHarshad Shirwadkar int jbd2_fc_begin_commit(journal_t *journal, tid_t tid);
1655ff780b91SHarshad Shirwadkar int jbd2_fc_end_commit(journal_t *journal);
16560bce577bSHarshad Shirwadkar int jbd2_fc_end_commit_fallback(journal_t *journal);
1657ff780b91SHarshad Shirwadkar int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out);
1658f30ff35fSJan Kara int jbd2_submit_inode_data(journal_t *journal, struct jbd2_inode *jinode);
1659ff780b91SHarshad Shirwadkar int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode);
1660ff780b91SHarshad Shirwadkar int jbd2_fc_wait_bufs(journal_t *journal, int num_blks);
1661fa10db13SKemeng Shi void jbd2_fc_release_bufs(journal_t *journal);
1662ff780b91SHarshad Shirwadkar
1663470decc6SDave Kleikamp /*
1664470decc6SDave Kleikamp * is_journal_abort
1665470decc6SDave Kleikamp *
1666f7f4bccbSMingming Cao * Simple test wrapper function to test the JBD2_ABORT state flag. This
1667470decc6SDave Kleikamp * bit, when set, indicates that we have had a fatal error somewhere,
1668470decc6SDave Kleikamp * either inside the journaling layer or indicated to us by the client
1669470decc6SDave Kleikamp * (eg. ext3), and that we and should not commit any further
1670470decc6SDave Kleikamp * transactions.
1671470decc6SDave Kleikamp */
1672470decc6SDave Kleikamp
is_journal_aborted(journal_t * journal)1673470decc6SDave Kleikamp static inline int is_journal_aborted(journal_t *journal)
1674470decc6SDave Kleikamp {
1675f7f4bccbSMingming Cao return journal->j_flags & JBD2_ABORT;
1676470decc6SDave Kleikamp }
1677470decc6SDave Kleikamp
is_handle_aborted(handle_t * handle)1678470decc6SDave Kleikamp static inline int is_handle_aborted(handle_t *handle)
1679470decc6SDave Kleikamp {
168041a5b913STheodore Ts'o if (handle->h_aborted || !handle->h_transaction)
1681470decc6SDave Kleikamp return 1;
1682470decc6SDave Kleikamp return is_journal_aborted(handle->h_transaction->t_journal);
1683470decc6SDave Kleikamp }
1684470decc6SDave Kleikamp
jbd2_journal_abort_handle(handle_t * handle)1685f7f4bccbSMingming Cao static inline void jbd2_journal_abort_handle(handle_t *handle)
1686470decc6SDave Kleikamp {
1687470decc6SDave Kleikamp handle->h_aborted = 1;
1688470decc6SDave Kleikamp }
1689470decc6SDave Kleikamp
jbd2_init_fs_dev_write_error(journal_t * journal)1690990b6b5bSZhihao Cheng static inline void jbd2_init_fs_dev_write_error(journal_t *journal)
1691990b6b5bSZhihao Cheng {
1692224941e8SAl Viro struct address_space *mapping = journal->j_fs_dev->bd_mapping;
1693990b6b5bSZhihao Cheng
1694990b6b5bSZhihao Cheng /*
1695990b6b5bSZhihao Cheng * Save the original wb_err value of client fs's bdev mapping which
1696990b6b5bSZhihao Cheng * could be used to detect the client fs's metadata async write error.
1697990b6b5bSZhihao Cheng */
1698990b6b5bSZhihao Cheng errseq_check_and_advance(&mapping->wb_err, &journal->j_fs_dev_wb_err);
1699990b6b5bSZhihao Cheng }
1700990b6b5bSZhihao Cheng
jbd2_check_fs_dev_write_error(journal_t * journal)1701990b6b5bSZhihao Cheng static inline int jbd2_check_fs_dev_write_error(journal_t *journal)
1702990b6b5bSZhihao Cheng {
1703224941e8SAl Viro struct address_space *mapping = journal->j_fs_dev->bd_mapping;
1704990b6b5bSZhihao Cheng
1705990b6b5bSZhihao Cheng return errseq_check(&mapping->wb_err,
1706990b6b5bSZhihao Cheng READ_ONCE(journal->j_fs_dev_wb_err));
1707990b6b5bSZhihao Cheng }
1708990b6b5bSZhihao Cheng
1709470decc6SDave Kleikamp #endif /* __KERNEL__ */
1710470decc6SDave Kleikamp
1711470decc6SDave Kleikamp /* Comparison functions for transaction IDs: perform comparisons using
1712470decc6SDave Kleikamp * modulo arithmetic so that they work over sequence number wraps. */
1713470decc6SDave Kleikamp
tid_gt(tid_t x,tid_t y)1714470decc6SDave Kleikamp static inline int tid_gt(tid_t x, tid_t y)
1715470decc6SDave Kleikamp {
1716470decc6SDave Kleikamp int difference = (x - y);
1717470decc6SDave Kleikamp return (difference > 0);
1718470decc6SDave Kleikamp }
1719470decc6SDave Kleikamp
tid_geq(tid_t x,tid_t y)1720470decc6SDave Kleikamp static inline int tid_geq(tid_t x, tid_t y)
1721470decc6SDave Kleikamp {
1722470decc6SDave Kleikamp int difference = (x - y);
1723470decc6SDave Kleikamp return (difference >= 0);
1724470decc6SDave Kleikamp }
1725470decc6SDave Kleikamp
1726f7f4bccbSMingming Cao extern int jbd2_journal_blocks_per_page(struct inode *inode);
1727b517bea1SZach Brown extern size_t journal_tag_bytes(journal_t *journal);
1728470decc6SDave Kleikamp
jbd2_journal_has_csum_v2or3(journal_t * journal)1729db9ee220SDarrick J. Wong static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
1730db9ee220SDarrick J. Wong {
1731*f6fc1584SEric Biggers return jbd2_has_feature_csum2(journal) ||
1732*f6fc1584SEric Biggers jbd2_has_feature_csum3(journal);
1733db9ee220SDarrick J. Wong }
1734db9ee220SDarrick J. Wong
jbd2_journal_get_num_fc_blks(journal_superblock_t * jsb)17359bd23c31SHarshad Shirwadkar static inline int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb)
17369bd23c31SHarshad Shirwadkar {
17379bd23c31SHarshad Shirwadkar int num_fc_blocks = be32_to_cpu(jsb->s_num_fc_blks);
17389bd23c31SHarshad Shirwadkar
17399bd23c31SHarshad Shirwadkar return num_fc_blocks ? num_fc_blocks : JBD2_DEFAULT_FAST_COMMIT_BLOCKS;
17409bd23c31SHarshad Shirwadkar }
17419bd23c31SHarshad Shirwadkar
1742470decc6SDave Kleikamp /*
174376c39904SJan Kara * Return number of free blocks in the log. Must be called under j_state_lock.
174476c39904SJan Kara */
jbd2_log_space_left(journal_t * journal)174576c39904SJan Kara static inline unsigned long jbd2_log_space_left(journal_t *journal)
174676c39904SJan Kara {
174776c39904SJan Kara /* Allow for rounding errors */
1748add3efddSJan Kara long free = journal->j_free - 32;
174976c39904SJan Kara
175076c39904SJan Kara if (journal->j_committing_transaction) {
17519f356e5aSJan Kara free -= atomic_read(&journal->
175276c39904SJan Kara j_committing_transaction->t_outstanding_credits);
175376c39904SJan Kara }
1754add3efddSJan Kara return max_t(long, free, 0);
1755470decc6SDave Kleikamp }
1756470decc6SDave Kleikamp
1757470decc6SDave Kleikamp /*
1758470decc6SDave Kleikamp * Definitions which augment the buffer_head layer
1759470decc6SDave Kleikamp */
1760470decc6SDave Kleikamp
1761470decc6SDave Kleikamp /* journaling buffer types */
1762470decc6SDave Kleikamp #define BJ_None 0 /* Not journaled */
176387c89c23SJan Kara #define BJ_Metadata 1 /* Normal journaled metadata */
176487c89c23SJan Kara #define BJ_Forget 2 /* Buffer superseded by this transaction */
1765f5113effSJan Kara #define BJ_Shadow 3 /* Buffer contents being shadowed to the log */
1766e5a120aeSJan Kara #define BJ_Reserved 4 /* Buffer is reserved for access by journal */
1767e5a120aeSJan Kara #define BJ_Types 5
1768470decc6SDave Kleikamp
jbd2_chksum(journal_t * journal,u32 crc,const void * address,unsigned int length)176901b5adceSDarrick J. Wong static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
177001b5adceSDarrick J. Wong const void *address, unsigned int length)
177101b5adceSDarrick J. Wong {
1772dd348f05SEric Biggers return crc32c(crc, address, length);
177301b5adceSDarrick J. Wong }
177401b5adceSDarrick J. Wong
177506a407f1SDmitry Monakhov /* Return most recent uncommitted transaction */
jbd2_get_latest_transaction(journal_t * journal)177606a407f1SDmitry Monakhov static inline tid_t jbd2_get_latest_transaction(journal_t *journal)
177706a407f1SDmitry Monakhov {
177806a407f1SDmitry Monakhov tid_t tid;
177906a407f1SDmitry Monakhov
178006a407f1SDmitry Monakhov read_lock(&journal->j_state_lock);
178106a407f1SDmitry Monakhov tid = journal->j_commit_request;
178206a407f1SDmitry Monakhov if (journal->j_running_transaction)
178306a407f1SDmitry Monakhov tid = journal->j_running_transaction->t_tid;
178406a407f1SDmitry Monakhov read_unlock(&journal->j_state_lock);
178506a407f1SDmitry Monakhov return tid;
178606a407f1SDmitry Monakhov }
178706a407f1SDmitry Monakhov
jbd2_handle_buffer_credits(handle_t * handle)1788a9a8344eSJan Kara static inline int jbd2_handle_buffer_credits(handle_t *handle)
1789a9a8344eSJan Kara {
17903c845acdSJan Kara journal_t *journal;
17913c845acdSJan Kara
17923c845acdSJan Kara if (!handle->h_reserved)
17933c845acdSJan Kara journal = handle->h_transaction->t_journal;
17943c845acdSJan Kara else
17953c845acdSJan Kara journal = handle->h_journal;
1796fdc3ef88SJan Kara
1797933f1c1eSJan Kara return handle->h_total_credits -
1798fdc3ef88SJan Kara DIV_ROUND_UP(handle->h_revoke_credits_requested,
1799fdc3ef88SJan Kara journal->j_revoke_records_per_block);
1800a9a8344eSJan Kara }
1801a9a8344eSJan Kara
1802470decc6SDave Kleikamp #ifdef __KERNEL__
1803470decc6SDave Kleikamp
1804470decc6SDave Kleikamp #define buffer_trace_init(bh) do {} while (0)
1805470decc6SDave Kleikamp #define print_buffer_fields(bh) do {} while (0)
1806470decc6SDave Kleikamp #define print_buffer_trace(bh) do {} while (0)
1807470decc6SDave Kleikamp #define BUFFER_TRACE(bh, info) do {} while (0)
1808470decc6SDave Kleikamp #define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
1809470decc6SDave Kleikamp #define JBUFFER_TRACE(jh, info) do {} while (0)
1810470decc6SDave Kleikamp
1811470decc6SDave Kleikamp #endif /* __KERNEL__ */
1812470decc6SDave Kleikamp
18136a797d27SDarrick J. Wong #define EFSBADCRC EBADMSG /* Bad CRC detected */
18146a797d27SDarrick J. Wong #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
18156a797d27SDarrick J. Wong
1816cd02ff0bSMingming Cao #endif /* _LINUX_JBD2_H */
1817