ext4: Ensure that inode is non-NULL before calling ext4_error_inode
PATCH 1/1 ext4: Ensure that inode is non-NULL before calling ext4_error_inode
__ext4_handle_dirty_metadata can be called with a NULL inode, but ext4_error_inode can't. This is supposed to be a "can't happen" path, so we need to find out whether it can legitimately happen or whether there's some other bug that is causing this to happen. This prevents a NULL pointer reference, so it should be included regardless of what the underlying error is.
--- fs/ext4/ext4_jbd2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/ext4_jbd2.c +2 -1
@@ -259,7 +259,8 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,if (WARN_ON_ONCE (err)) {ext4_journal_abort_handle (where, line, __func__, bh, handle, err); -ext4_error_inode (inode, where, line, +if (inode) +ext4_error_inode (inode, where, line, bh->b_blocknr,"journal_dirty_metadata failed: " "handle type %u started at line %u, "
Signature · 1 line
1.9.0
Theodore Ts'o
maintainerQuoted 9 lines · Matthew Wilcox
__ext4_handle_dirty_metadatacan be called with a NULL inode, butext4_error_inodecan't. This is supposed to be a "can't happen" path, so we need to find out whether it can legitimately happen or whether there's some other bug that is causing this to happen. This prevents a NULL pointer reference, so it should be included regardless of what the underlying error is.Signed-off-by Matthew Wilcox <[email protected]>
This was fixed by the following commit which will be shortly pushed to Linus. Admittedly, I should have done a better job noting it in the commit description (sorry about that):
In my patch I made sure we printed something so there would be better chance of debugging the problem:
+ if (inode == NULL) {
+ pr_err("EXT4: jbd2_journal_dirty_metadata "
+ "failed: handle type %u started at " + "line %u, credits %u/%u, errcode %d", + handle->h_type, + handle->h_line_no, + handle->h_requested_credits, + handle->h_buffer_credits, err);
+ return err;
+ }
It turns out this case does happen if we are journalling fs-level metadata, such as block group descriptor.
- Ted
Quoted 4 lines · Matthew Wilcox
__ext4_handle_dirty_metadatacan be called with a NULL inode, butext4_error_inodecan't. This is supposed to be a "can't happen" path, so we need to find out whether it can legitimately happen or whether
It can legitimately happen - there is metadata (like bitmaps, inode
table, group descriptor) which doesn't belong to any inode. Thus we leave inode argument as NULL for these.
Quoted 3 lines
there's some other bug that is causing this to happen. This prevents a NULL pointer reference, so it should be included regardless of what the underlying error is.
I'd prefer wrapping that several-line error into braces. But whatever.
Feel free to add:
Honza
Quoted 27 lines
Signed-off-by Matthew Wilcox <[email protected]>--- fs/ext4/ext4_jbd2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/ext4/ext4_jbd2.c +2
-1@@ -259,7 +259,8 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,if (WARN_ON_ONCE (err)) {ext4_journal_abort_handle (where, line, __func__, bh, handle, err); -ext4_error_inode (inode, where, line, +if (inode) +ext4_error_inode (inode, where, line, bh->b_blocknr,"journal_dirty_metadata failed: " "handle type %u started at line %u, "Signature · 6 lines
1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR