From: Jan Kara <jack@suse.cz>
To: Ming Lei <ming.lei@canonical.com>
Cc: Jan Kara <jack@suse.cz>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ted Tso <tytso@mit.edu>,
linux-ext4@vger.kernel.org,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
Ming Lei <tom.leiming@gmail.com>
Subject: Re: [PATCH] ext4: fix checking on nr_to_write
Date: Tue, 15 Oct 2013 14:34:39 +0200 [thread overview]
Message-ID: <20131015123439.GC12428@quack.suse.cz> (raw)
In-Reply-To: <20131015191556.50c3eb03@tom-ThinkPad-T410>
On Tue 15-10-13 19:15:56, Ming Lei wrote:
> > This won't quite work because if the page is fully mapped
> > mpage_process_page_bufs() will immediately submit the page and decrease
> > nr_to_write. So now you would end up writing less than you were asked for
> > in some cases.
>
> Yes, your are right, so how about below?
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 32c04ab..3cf7abb 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2295,6 +2295,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
> struct address_space *mapping = mpd->inode->i_mapping;
> struct pagevec pvec;
> unsigned int nr_pages;
> + int left = mpd->wbc->nr_to_write;
'long' please. Otherwise the patch looks fine. Thanks!
Honza
> pgoff_t index = mpd->first_page;
> pgoff_t end = mpd->last_page;
> int tag;
> @@ -2330,6 +2331,17 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
> if (page->index > end)
> goto out;
>
> + /*
> + * Accumulated enough dirty pages? This doesn't apply
> + * to WB_SYNC_ALL mode. For integrity sync we have to
> + * keep going because someone may be concurrently
> + * dirtying pages, and we might have synced a lot of
> + * newly appeared dirty pages, but have not synced all
> + * of the old dirty pages.
> + */
> + if (mpd->wbc->sync_mode == WB_SYNC_NONE && left <= 0)
> + goto out;
> +
> /* If we can't merge this page, we are done. */
> if (mpd->map.m_len > 0 && mpd->next_page != page->index)
> goto out;
> @@ -2364,19 +2376,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
> if (err <= 0)
> goto out;
> err = 0;
> -
> - /*
> - * Accumulated enough dirty pages? This doesn't apply
> - * to WB_SYNC_ALL mode. For integrity sync we have to
> - * keep going because someone may be concurrently
> - * dirtying pages, and we might have synced a lot of
> - * newly appeared dirty pages, but have not synced all
> - * of the old dirty pages.
> - */
> - if (mpd->wbc->sync_mode == WB_SYNC_NONE &&
> - mpd->next_page - mpd->first_page >=
> - mpd->wbc->nr_to_write)
> - goto out;
> + left--;
> }
> pagevec_release(&pvec);
> cond_resched();
>
>
> > Attached patch should do what's needed. Can you try whether
> > it fixes the problem for you (it seems to work OK in my testing).
>
> In fact, I had wrote and tested your attached patch before my last post,
> and it may trigger BUG() in mpage_release_unused_pages(), that is because
> we touch mpd->next_page without locking current page, so it is better to
> not increase mpd->next_page if the current page won't be processed.
>
>
> Thanks,
> --
> Ming Lei
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2013-10-15 12:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-13 16:39 [PATCH] ext4: fix checking on nr_to_write Ming Lei
2013-10-14 0:42 ` Ming Lei
2013-10-14 12:58 ` Jan Kara
2013-10-14 13:50 ` Ming Lei
2013-10-14 17:34 ` Jan Kara
2013-10-15 2:25 ` Ming Lei
2013-10-15 10:39 ` Jan Kara
2013-10-15 11:15 ` Ming Lei
2013-10-15 12:34 ` Jan Kara [this message]
2013-10-15 14:53 ` Ming Lei
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=20131015123439.GC12428@quack.suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@canonical.com \
--cc=tom.leiming@gmail.com \
--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).