aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-09-04 10:18:14 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-09-04 10:18:14 -0400
commit9ea7a0df63630ad8197716cd313ea66e28906fc0 (patch)
tree2f9cb8bb3f4c709aa666c7863b496f2757b261fb /fs/ext4
parent56889787cfa77dfd96f0b3a3e6a4f26c2e4a5134 (diff)
jbd2: add debugging information to jbd2_journal_dirty_metadata()
Add debugging information in case jbd2_journal_dirty_metadata() is called with a buffer_head which didn't have jbd2_journal_get_write_access() called on it, or if the journal_head has the wrong transaction in it. In addition, return an error code. This won't change anything for ocfs2, which will BUG_ON() the non-zero exit code. For ext4, the caller of this function is ext4_handle_dirty_metadata(), and on seeing a non-zero return code, will call __ext4_journal_stop(), which will print the function and line number of the (buggy) calling function and abort the journal. This will allow us to recover instead of bug halting, which is better from a robustness and reliability point of view. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/ext4_jbd2.c8
-rw-r--r--fs/ext4/extents.c10
2 files changed, 12 insertions, 6 deletions
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index f5240aa15601..aca179017582 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -109,9 +109,11 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
109 109
110 if (ext4_handle_valid(handle)) { 110 if (ext4_handle_valid(handle)) {
111 err = jbd2_journal_dirty_metadata(handle, bh); 111 err = jbd2_journal_dirty_metadata(handle, bh);
112 if (err) 112 if (err) {
113 ext4_journal_abort_handle(where, line, __func__, 113 /* Errors can only happen if there is a bug */
114 bh, handle, err); 114 handle->h_err = err;
115 __ext4_journal_stop(where, line, handle);
116 }
115 } else { 117 } else {
116 if (inode) 118 if (inode)
117 mark_buffer_dirty_inode(bh, inode); 119 mark_buffer_dirty_inode(bh, inode);
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 9124cd24e093..2c5216a8d03b 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -96,13 +96,17 @@ static int ext4_ext_get_access(handle_t *handle, struct inode *inode,
96 * - ENOMEM 96 * - ENOMEM
97 * - EIO 97 * - EIO
98 */ 98 */
99static int ext4_ext_dirty(handle_t *handle, struct inode *inode, 99#define ext4_ext_dirty(handle, inode, path) \
100 struct ext4_ext_path *path) 100 __ext4_ext_dirty(__func__, __LINE__, (handle), (inode), (path))
101static int __ext4_ext_dirty(const char *where, unsigned int line,
102 handle_t *handle, struct inode *inode,
103 struct ext4_ext_path *path)
101{ 104{
102 int err; 105 int err;
103 if (path->p_bh) { 106 if (path->p_bh) {
104 /* path points to block */ 107 /* path points to block */
105 err = ext4_handle_dirty_metadata(handle, inode, path->p_bh); 108 err = __ext4_handle_dirty_metadata(where, line, handle,
109 inode, path->p_bh);
106 } else { 110 } else {
107 /* path points to leaf/index in inode body */ 111 /* path points to leaf/index in inode body */
108 err = ext4_mark_inode_dirty(handle, inode); 112 err = ext4_mark_inode_dirty(handle, inode);