All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.com>,
	linux-ext4@vger.kernel.org,
	"ocfs2-devel@oss.oracle.com" <ocfs2-devel@oss.oracle.com>
Subject: Re: [PATCH] jbd2: fix ocfs2 corrupt when updating journal superblock fails
Date: Fri, 19 Jun 2015 10:48:31 -0400	[thread overview]
Message-ID: <20150619144831.GL4076@thunk.org> (raw)
In-Reply-To: <5574F060.2080503@huawei.com>

This patch caused test ext4/306 to fail, because it caused resize2fs
to fail.  The problem is that jbd2_cleanup_journal_tail() will return
1 if there is nothing to cleanup, and a negative error number if there
is an error.  Unfortunately, this patch hunk:

On Mon, Jun 08, 2015 at 09:31:12AM +0800, Joseph Qi wrote:
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index b96bd80..6b33a42 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -1950,7 +1966,13 @@ int jbd2_journal_flush(journal_t *journal)
>  		return -EIO;
> 
>  	mutex_lock(&journal->j_checkpoint_mutex);
> -	jbd2_cleanup_journal_tail(journal);
> +	if (!err) {
> +		err = jbd2_cleanup_journal_tail(journal);
> +		if (err < 0) {
> +			mutex_unlock(&journal->j_checkpoint_mutex);
> +			goto out;
> +		}
> +	}

... would let the non-negative return value leak out to
jbd2_journal_flush(), and its callers are *not* prepared to handle the
non-negative return value (since jbd2_journal_flush wasn't doing this
before.)

I've fixed this by adding a "err = 0;" after the if statement.

          	   	   	    	 - Ted

WARNING: multiple messages have this Message-ID (diff)
From: Theodore Ts'o <tytso@mit.edu>
To: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.com>,
	linux-ext4@vger.kernel.org,
	"ocfs2-devel@oss.oracle.com" <ocfs2-devel@oss.oracle.com>
Subject: [Ocfs2-devel] [PATCH] jbd2: fix ocfs2 corrupt when updating journal superblock fails
Date: Fri, 19 Jun 2015 10:48:31 -0400	[thread overview]
Message-ID: <20150619144831.GL4076@thunk.org> (raw)
In-Reply-To: <5574F060.2080503@huawei.com>

This patch caused test ext4/306 to fail, because it caused resize2fs
to fail.  The problem is that jbd2_cleanup_journal_tail() will return
1 if there is nothing to cleanup, and a negative error number if there
is an error.  Unfortunately, this patch hunk:

On Mon, Jun 08, 2015 at 09:31:12AM +0800, Joseph Qi wrote:
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index b96bd80..6b33a42 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -1950,7 +1966,13 @@ int jbd2_journal_flush(journal_t *journal)
>  		return -EIO;
> 
>  	mutex_lock(&journal->j_checkpoint_mutex);
> -	jbd2_cleanup_journal_tail(journal);
> +	if (!err) {
> +		err = jbd2_cleanup_journal_tail(journal);
> +		if (err < 0) {
> +			mutex_unlock(&journal->j_checkpoint_mutex);
> +			goto out;
> +		}
> +	}

... would let the non-negative return value leak out to
jbd2_journal_flush(), and its callers are *not* prepared to handle the
non-negative return value (since jbd2_journal_flush wasn't doing this
before.)

I've fixed this by adding a "err = 0;" after the if statement.

          	   	   	    	 - Ted

  reply	other threads:[~2015-06-19 14:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-08  1:31 [PATCH] jbd2: fix ocfs2 corrupt when updating journal superblock fails Joseph Qi
2015-06-08  1:31 ` [Ocfs2-devel] " Joseph Qi
2015-06-19 14:48 ` Theodore Ts'o [this message]
2015-06-19 14:48   ` Theodore Ts'o
2015-06-23  0:48   ` Joseph Qi
2015-06-23  0:48     ` [Ocfs2-devel] " Joseph Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150619144831.GL4076@thunk.org \
    --to=tytso@mit.edu \
    --cc=joseph.qi@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mfasheh@suse.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.