linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Ensure that inode is non-NULL before calling ext4_error_inode
@ 2014-04-02 14:36 Matthew Wilcox
  2014-04-02 15:32 ` Theodore Ts'o
  2014-04-02 16:47 ` Jan Kara
  0 siblings, 2 replies; 3+ messages in thread
From: Matthew Wilcox @ 2014-04-02 14:36 UTC (permalink / raw)
  To: linux-ext4


__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.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
---
 fs/ext4/ext4_jbd2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 3fe29de..383d586 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -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, "
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: Ensure that inode is non-NULL before calling ext4_error_inode
  2014-04-02 14:36 [PATCH] ext4: Ensure that inode is non-NULL before calling ext4_error_inode Matthew Wilcox
@ 2014-04-02 15:32 ` Theodore Ts'o
  2014-04-02 16:47 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2014-04-02 15:32 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-ext4

On Wed, Apr 02, 2014 at 10:36:30AM -0400, Matthew Wilcox wrote:
> 
> __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.
> 
> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>

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):

http://git.kernel.org/cgit/linux/kernel/git/tytso/ext4.git/commit/?h=dev&id=0edaa0178ea7142691ae9c10baa42b3e6466d047

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: Ensure that inode is non-NULL before calling ext4_error_inode
  2014-04-02 14:36 [PATCH] ext4: Ensure that inode is non-NULL before calling ext4_error_inode Matthew Wilcox
  2014-04-02 15:32 ` Theodore Ts'o
@ 2014-04-02 16:47 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2014-04-02 16:47 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-ext4

On Wed 02-04-14 10:36:30, Matthew Wilcox wrote:
> 
> __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
  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.

> 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:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza
> 
> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
> ---
>  fs/ext4/ext4_jbd2.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
> index 3fe29de..383d586 100644
> --- a/fs/ext4/ext4_jbd2.c
> +++ b/fs/ext4/ext4_jbd2.c
> @@ -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, "
> -- 
> 1.9.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-02 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 14:36 [PATCH] ext4: Ensure that inode is non-NULL before calling ext4_error_inode Matthew Wilcox
2014-04-02 15:32 ` Theodore Ts'o
2014-04-02 16:47 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).