linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Valerie Aurora <val@vaaconsulting.com>
Cc: Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org,
	Masayoshi MIZUMA <m.mizuma@jp.fujitsu.com>,
	Greg Freemyer <greg.freemyer@gmail.com>,
	linux-ext4@vger.kernel.org, Eric Sandeen <sandeen@redhat.com>
Subject: Re: [RFC PATCH 1/3] VFS: Fix s_umount thaw/write deadlock
Date: Mon, 19 Sep 2011 09:25:17 +1000	[thread overview]
Message-ID: <20110918232517.GG15688@dastard> (raw)
In-Reply-To: <CAD-Xuj=XnUBQ=-gmrdaBj6ABJei25ELR-Mg1XMRw4wEL=JwWcQ@mail.gmail.com>

On Wed, Sep 14, 2011 at 04:53:38PM -0700, Valerie Aurora wrote:
> On Wed, Sep 14, 2011 at 7:00 AM, Jan Kara <jack@suse.cz> wrote:
> > On Mon 12-09-11 19:57:11, Valerie Aurora wrote:
> >> Val, if you are sending patches as attachments, make them at least
> >> text/plain please!
> 
> Oops, sorry.
> 
> >> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> >> index 04cf3b9..d1dca03 100644
> >> --- a/fs/fs-writeback.c
> >> +++ b/fs/fs-writeback.c
> >> @@ -537,6 +537,9 @@ static long writeback_sb_inodes(struct super_block *sb,
> >>       long write_chunk;
> >>       long wrote = 0;  /* count both pages and inodes */
> >>
> >> +     if (vfs_is_frozen(sb))
> >> +             return 0;
> >> +
> >  Umm, maybe we could make this more robust by skipping the superblock in
> > __writeback_inodes_wb() and just explicitely stopping the writeback when
> > work->sb is set (i.e. writeback is required only for frozen sb) in
> > wb_writeback()?
> 
> Sorry, I don't quite understand what the goal is here?  I'm happy to
> make the change, just want to make sure I'm accomplishing what you
> want.
> 
> >>       while (!list_empty(&wb->b_io)) {
> >>               struct inode *inode = wb_inode(wb->b_io.prev);
> >>
> >> @@ -1238,39 +1241,43 @@ EXPORT_SYMBOL(writeback_inodes_sb);
> >>   * writeback_inodes_sb_if_idle       -       start writeback if none underway
> >>   * @sb: the superblock
> >>   *
> >> - * Invoke writeback_inodes_sb if no writeback is currently underway.
> >> - * Returns 1 if writeback was started, 0 if not.
> >> + * Invoke writeback_inodes_sb if no writeback is currently underway
> >> + * and no one else holds the s_umount lock.  Returns 1 if writeback
> >> + * was started, 0 if not.
> >>   */
> >>  int writeback_inodes_sb_if_idle(struct super_block *sb)
> >>  {
> >>       if (!writeback_in_progress(sb->s_bdi)) {
> >> -             down_read(&sb->s_umount);
> >> -             writeback_inodes_sb(sb);
> >> -             up_read(&sb->s_umount);
> >> -             return 1;
> >> -     } else
> >> -             return 0;
> >> +             if (down_read_trylock(&sb->s_umount)) {
> >  What's exactly the deadlock trylock protects from here? Or is it just an
> > optimization?
> 
> The trylock is an optimization Dave Chinner suggested.  The first
> version I wrote acquired the lock and then checked vfs_is_frozen().

It's not so much an optimisation, but the general case of avoiding
read-write deadlocks such that freezing can trigger. I think remount
can trigger the same deadlock as freezing, so the trylock avoids both
deadlock cases rather than just working around the freeze problem....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com
--
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

  parent reply	other threads:[~2011-09-18 23:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13  2:53 [RFC PATCH 0/3] VFS: Fix s_umount thaw/write deadlock Valerie Aurora
2011-09-13  2:57 ` [RFC PATCH 1/3] " Valerie Aurora
2011-09-14 14:00   ` Jan Kara
2011-09-14 23:53     ` Valerie Aurora
2011-09-15 16:22       ` Jan Kara
2011-09-18 23:25       ` Dave Chinner [this message]
2011-09-20 22:51   ` Christoph Hellwig
2011-09-14 13:05 ` [RFC PATCH 0/3] " Jan Kara
2011-09-14 23:22   ` Valerie Aurora
2011-10-27 21:39 ` Christoph Hellwig
2011-10-27 22:08   ` Valerie Aurora
2011-10-30  0:59     ` Valerie Aurora
2011-11-28 20:58       ` Valerie Aurora

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=20110918232517.GG15688@dastard \
    --to=david@fromorbit.com \
    --cc=greg.freemyer@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=m.mizuma@jp.fujitsu.com \
    --cc=sandeen@redhat.com \
    --cc=val@vaaconsulting.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 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).