From: Jan Kara <jack@suse.cz>
To: Eryu Guan <guaneryu@gmail.com>
Cc: Joseph Qi <joseph.qi@huawei.com>,
linux-ext4@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>
Subject: Re: [BUG] infinite loop when unmounting ext3/4
Date: Thu, 23 Jul 2015 22:41:55 +0200 [thread overview]
Message-ID: <20150723204155.GA7814@quack.suse.cz> (raw)
In-Reply-To: <20150720072356.GC18016@dhcp-13-216.nay.redhat.com>
On Mon 20-07-15 15:23:56, Eryu Guan wrote:
> On Thu, Jul 16, 2015 at 02:18:16PM +0800, Joseph Qi wrote:
> > I got the problem.
> > I am not sure why old code uses "result <= 0" even if
> > it won't return negative value. Could we use "result == 0" instead of
> > "result <= 0"?
>
> I thought about this too, but I'm not sure if it has other side effects.
> Someone else familiar with this code could comment on this?
Well, we should rather decide, what is the right behavior of the
checkpointing code when the journal is aborted. When journal gets aborted,
we are in serious trouble. Our standard answer to this is to stop modifying
the filesystem as that has a chance of corrupting it even more. I think
that avoiding checkpointing on a filesystem with aborted journal is thus
what we really want.
To fix the issue you've reported, we just need to teach
jbd2_log_do_checkpoint() to cleanup all the buffers in the transactions
when the journal is aborted so that journal_destroy() can proceed. I can
have a look at it sometime next week unless someone beats me to it.
Honza
> > On 2015/7/15 22:30, Eryu Guan wrote:
> > > Hi all,
> > >
> > > I found an infinite loop when unmounting a known bad ext3 image (using
> > > ext4 driver) with 4.2-rc1 kernel.
> > >
> > > The fs image can be found here
> > > https://bugzilla.kernel.org/show_bug.cgi?id=10882#c1
> > >
> > > Reproduce steps:
> > > mount -o loop ext3.img /mnt/ext3
> > > rm -rf /mnt/ext3/{dev,proc,sys}
> > > umount /mnt/ext3 # never return
> > >
> > > And this issue was introduced by
> > > 6f6a6fd jbd2: fix ocfs2 corrupt when updating journal superblock fails
> > >
> > > It's looping in
> > > fs/jbd2/journal.c:jbd2_journal_destroy()
> > > ...
> > > 1693 while (journal->j_checkpoint_transactions != NULL) {
> > > 1694 spin_unlock(&journal->j_list_lock);
> > > 1695 mutex_lock(&journal->j_checkpoint_mutex);
> > > 1696 jbd2_log_do_checkpoint(journal);
> > > 1697 mutex_unlock(&journal->j_checkpoint_mutex);
> > > 1698 spin_lock(&journal->j_list_lock);
> > > 1699 }
> > > ...
> > >
> > > Because jbd2_cleanup_journal_tail() is returning -EIO on aborted journal
> > > now instead of 1, and jbd2_log_do_checkpoint() won't cleanup
> > > journal->j_checkpoint_transactions in this while loop.
> > >
> > > A quick hack would be
> > >
> > > diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
> > > index 4227dc4..1b2ea47 100644
> > > --- a/fs/jbd2/checkpoint.c
> > > +++ b/fs/jbd2/checkpoint.c
> > > @@ -220,11 +220,13 @@ int jbd2_log_do_checkpoint(journal_t *journal)
> > > * don't need checkpointing, just eliminate them from the
> > > * journal straight away.
> > > */
> > > - result = jbd2_cleanup_journal_tail(journal);
> > > - trace_jbd2_checkpoint(journal, result);
> > > - jbd_debug(1, "cleanup_journal_tail returned %d\n", result);
> > > - if (result <= 0)
> > > - return result;
> > > + if (!is_journal_aborted(journal)) {
> > > + result = jbd2_cleanup_journal_tail(journal);
> > > + trace_jbd2_checkpoint(journal, result);
> > > + jbd_debug(1, "cleanup_journal_tail returned %d\n", result);
> > > + if (result <= 0)
> > > + return result;
> > > + }
> > >
> > > /*
> > > * OK, we need to start writing disk blocks. Take one transaction
> > >
> > > to restore the old behavior (continue on aborted journal). Maybe someone
> > > has a better fix.
> > >
> > > Thanks,
> > > Eryu
> > >
> > > .
> > >
> >
> >
> --
> 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.com>
SUSE Labs, CR
next prev parent reply other threads:[~2015-07-23 20:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-15 14:30 [BUG] infinite loop when unmounting ext3/4 Eryu Guan
2015-07-16 6:18 ` Joseph Qi
2015-07-20 7:23 ` Eryu Guan
2015-07-23 20:41 ` Jan Kara [this message]
2015-07-27 19:54 ` Jan Kara
2015-07-28 7:15 ` Eryu Guan
2015-07-28 19:04 ` Theodore Ts'o
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=20150723204155.GA7814@quack.suse.cz \
--to=jack@suse.cz \
--cc=guaneryu@gmail.com \
--cc=joseph.qi@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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 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).