From: Jan Kara <jack@suse.cz>
To: Dave Chinner <david@fromorbit.com>
Cc: Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, davej@redhat.com,
viro@zeniv.linux.org.uk, glommer@parallels.com
Subject: Re: [PATCH 07/11] writeback: periodically trim the writeback list
Date: Thu, 1 Aug 2013 11:03:48 +0200 [thread overview]
Message-ID: <20130801090348.GC19219@quack.suse.cz> (raw)
In-Reply-To: <20130801061618.GQ7118@dastard>
On Thu 01-08-13 16:16:18, Dave Chinner wrote:
> On Wed, Jul 31, 2013 at 05:15:42PM +0200, Jan Kara wrote:
> > On Wed 31-07-13 14:15:46, Dave Chinner wrote:
> > > From: Dave Chinner <dchinner@redhat.com>
> > >
> > > Inodes are removed lazily from the bdi writeback list, so in the
> > > absence of sync(2) work inodes will build up on the bdi writback
> > > list even though they are no longer under IO. Use the periodic
> > > kupdate work check to remove inodes no longer under IO from the
> > > writeback list.
> > >
> > > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > > ---
> > > fs/fs-writeback.c | 19 +++++++++++++++++++
> > > 1 file changed, 19 insertions(+)
> > >
> > > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> > > index 638f122..7c9bbf0 100644
> > > --- a/fs/fs-writeback.c
> > > +++ b/fs/fs-writeback.c
> > > @@ -962,6 +962,23 @@ static long wb_check_background_flush(struct bdi_writeback *wb)
> > > return 0;
> > > }
> > >
> > > +/*
> > > + * clean out writeback list for all inodes that don't have IO in progress
> > > + */
> > > +static void wb_trim_writeback_list(struct bdi_writeback *wb)
> > > +{
> > > + struct inode *inode;
> > > + struct inode *tmp;
> > > +
> > > + spin_lock(&wb->list_lock);
> > > + list_for_each_entry_safe(inode, tmp, &wb->b_writeback, i_wb_list) {
> > > + if (!mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK))
> > > + list_del_init(&inode->i_wb_list);
> > > + }
> > Oo, and here you manipulate i_wb_list without mapping->tree_lock so that
> > can race with the list_empty() check in bdi_mark_inode_writeback().
>
> I'm not sure it does - we only remove is the PAGECACHE_TAG_WRITEBACK
> is not set, and only insert after we set the tag. Hence, if we are
> walking the &wb->b_writeback list here and PAGECACHE_TAG_WRITEBACK
> is set because there is an insert in progress then we can't race
> with the insert because we won't be trying to delete it from the
> list...
The following race seems to be possible:
CPU1 CPU2
test_set_page_writeback()
spin_lock_irqsave(&mapping->tree_lock, flags);
ret = TestSetPageWriteback(page);
if (!ret) {
/* == false */
on_wblist = mapping_tagged(mapping,
PAGECACHE_TAG_WRITEBACK);
wb_trim_writeback_list()
spin_lock(&wb->list_lock);
...
if (!mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK)
radix_tree_tag_set(&mapping->page_tree, ...)
...
if (!on_wblist && mapping->host)
bdi_mark_inode_writeback(bdi, mapping->host);
if (list_empty(&inode->i_wb_list)) /* false */
list_del_init(&inode->i_wb_list);
And we end up with inode with PAGECACHE_TAG_WRITEBACK set but not on
i_wb_list.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2013-08-01 9:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-31 4:15 [PATCH 00/11] Sync and VFS scalability improvements Dave Chinner
2013-07-31 4:15 ` [PATCH 01/11] writeback: plug writeback at a high level Dave Chinner
2013-07-31 14:40 ` Jan Kara
2013-08-01 5:48 ` Dave Chinner
2013-08-01 8:34 ` Jan Kara
2013-07-31 4:15 ` [PATCH 02/11] inode: add IOP_NOTHASHED to avoid inode hash lock in evict Dave Chinner
2013-07-31 14:44 ` Jan Kara
2013-08-01 8:12 ` Christoph Hellwig
2013-08-02 1:11 ` Dave Chinner
2013-08-02 14:32 ` Christoph Hellwig
2013-07-31 4:15 ` [PATCH 03/11] inode: convert inode_sb_list_lock to per-sb Dave Chinner
2013-07-31 14:48 ` Jan Kara
2013-07-31 4:15 ` [PATCH 04/11] sync: serialise per-superblock sync operations Dave Chinner
2013-07-31 15:12 ` Jan Kara
2013-07-31 4:15 ` [PATCH 05/11] inode: rename i_wb_list to i_io_list Dave Chinner
2013-07-31 14:51 ` Jan Kara
2013-07-31 4:15 ` [PATCH 06/11] bdi: add a new writeback list for sync Dave Chinner
2013-07-31 15:11 ` Jan Kara
2013-08-01 5:59 ` Dave Chinner
2013-07-31 4:15 ` [PATCH 07/11] writeback: periodically trim the writeback list Dave Chinner
2013-07-31 15:15 ` Jan Kara
2013-08-01 6:16 ` Dave Chinner
2013-08-01 9:03 ` Jan Kara [this message]
2013-07-31 4:15 ` [PATCH 08/11] inode: convert per-sb inode list to a list_lru Dave Chinner
2013-08-01 8:19 ` Christoph Hellwig
2013-08-02 1:06 ` Dave Chinner
2013-07-31 4:15 ` [PATCH 09/11] fs: Use RCU lookups for inode cache Dave Chinner
2013-07-31 4:15 ` [PATCH 10/11] list_lru: don't need node lock in list_lru_count_node Dave Chinner
2013-07-31 4:15 ` [PATCH 11/11] list_lru: don't lock during add/del if unnecessary Dave Chinner
2013-07-31 6:48 ` [PATCH 00/11] Sync and VFS scalability improvements Sedat Dilek
2013-08-01 6:19 ` Dave Chinner
2013-08-01 6:31 ` Sedat Dilek
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=20130801090348.GC19219@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=davej@redhat.com \
--cc=david@fromorbit.com \
--cc=glommer@parallels.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).