2 * Interface between ext4 and JBD
7 #include <trace/events/ext4.h>
9 int __ext4_journal_get_write_access(const char *where
, unsigned int line
,
10 handle_t
*handle
, struct buffer_head
*bh
)
14 if (ext4_handle_valid(handle
)) {
15 err
= jbd2_journal_get_write_access(handle
, bh
);
17 ext4_journal_abort_handle(where
, line
, __func__
, bh
,
24 * The ext4 forget function must perform a revoke if we are freeing data
25 * which has been journaled. Metadata (eg. indirect blocks) must be
26 * revoked in all cases.
28 * "bh" may be NULL: a metadata block may have been freed from memory
29 * but there may still be a record of it in the journal, and that record
30 * still needs to be revoked.
32 * If the handle isn't valid we're not journaling, but we still need to
33 * call into ext4_journal_revoke() to put the buffer head.
35 int __ext4_forget(const char *where
, unsigned int line
, handle_t
*handle
,
36 int is_metadata
, struct inode
*inode
,
37 struct buffer_head
*bh
, ext4_fsblk_t blocknr
)
43 trace_ext4_forget(inode
, is_metadata
, blocknr
);
44 BUFFER_TRACE(bh
, "enter");
46 jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, "
48 bh
, is_metadata
, inode
->i_mode
,
49 test_opt(inode
->i_sb
, DATA_FLAGS
));
51 /* In the no journal case, we can just do a bforget and return */
52 if (!ext4_handle_valid(handle
)) {
57 /* Never use the revoke function if we are doing full data
58 * journaling: there is no need to, and a V1 superblock won't
59 * support it. Otherwise, only skip the revoke on un-journaled
62 if (test_opt(inode
->i_sb
, DATA_FLAGS
) == EXT4_MOUNT_JOURNAL_DATA
||
63 (!is_metadata
&& !ext4_should_journal_data(inode
))) {
65 BUFFER_TRACE(bh
, "call jbd2_journal_forget");
66 err
= jbd2_journal_forget(handle
, bh
);
68 ext4_journal_abort_handle(where
, line
, __func__
,
76 * data!=journal && (is_metadata || should_journal_data(inode))
78 BUFFER_TRACE(bh
, "call jbd2_journal_revoke");
79 err
= jbd2_journal_revoke(handle
, blocknr
, bh
);
81 ext4_journal_abort_handle(where
, line
, __func__
,
83 __ext4_abort(inode
->i_sb
, where
, line
,
84 "error %d when attempting revoke", err
);
86 BUFFER_TRACE(bh
, "exit");
90 int __ext4_journal_get_create_access(const char *where
, unsigned int line
,
91 handle_t
*handle
, struct buffer_head
*bh
)
95 if (ext4_handle_valid(handle
)) {
96 err
= jbd2_journal_get_create_access(handle
, bh
);
98 ext4_journal_abort_handle(where
, line
, __func__
,
104 int __ext4_handle_dirty_metadata(const char *where
, unsigned int line
,
105 handle_t
*handle
, struct inode
*inode
,
106 struct buffer_head
*bh
)
110 if (ext4_handle_valid(handle
)) {
111 err
= jbd2_journal_dirty_metadata(handle
, bh
);
113 ext4_journal_abort_handle(where
, line
, __func__
,
117 mark_buffer_dirty_inode(bh
, inode
);
119 mark_buffer_dirty(bh
);
120 if (inode
&& inode_needs_sync(inode
)) {
121 sync_dirty_buffer(bh
);
122 if (buffer_req(bh
) && !buffer_uptodate(bh
)) {
123 struct ext4_super_block
*es
;
125 es
= EXT4_SB(inode
->i_sb
)->s_es
;
126 es
->s_last_error_block
=
127 cpu_to_le64(bh
->b_blocknr
);
128 ext4_error_inode(inode
, where
, line
,
130 "IO error syncing itable block");
138 int __ext4_handle_dirty_super(const char *where
, unsigned int line
,
139 handle_t
*handle
, struct super_block
*sb
)
141 struct buffer_head
*bh
= EXT4_SB(sb
)->s_sbh
;
144 if (ext4_handle_valid(handle
)) {
145 err
= jbd2_journal_dirty_metadata(handle
, bh
);
147 ext4_journal_abort_handle(where
, line
, __func__
,