linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@oracle.com>
To: Mitch Harder <mitch.harder@sabayonlinux.org>
Cc: "Maria Wikström" <maria@ponstudios.se>,
	"Zhong, Xin" <xin.zhong@intel.com>,
	"Johannes Hirte" <johannes.hirte@fem.tu-ilmenau.de>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2]Btrfs: pwrite blocked when writing from the mmaped buffer of the same page
Date: Fri, 25 Feb 2011 14:19:50 -0500	[thread overview]
Message-ID: <1298661529-sup-6456@think> (raw)
In-Reply-To: <AANLkTik3KtjzP4zVU-foQUxEvZEtrTi7T2aj6PJzUV43@mail.gmail.com>

Excerpts from Mitch Harder's message of 2011-02-25 13:43:37 -0500:
> > The loop is more-or-less following this process (from within the
> > "while (iov_iter_count(&i) > 0) {}" loop):
> >
> > (1) Reserve some space with btrfs_delalloc_reserve_space()
> > (2) Prepare the reserved space with prepare_pages()
> > (3) Call btrfs_copy_from_user() to copy to the prepared space.
> > -------------> From btrfs_copy_from_user()
> > (4) ........Try to copy with copied = iov_iter_copy_from_user_atomic()
> > (5) ........The above operation results with copied == 0. Break and
> > return with a return value of 0 bytes copied.
> > (6) There is no special handling for copied == 0 in the "while
> > (iov_iter_count(&i) > 0) {}" loop, so it loops back around, reserves
> > some more space, and tries again.
> >
> > If I look back at how the code was set up before the patch at the head
> > of this thread was applied (Btrfs: pwrite blocked when writing from
> > the mmaped buffer of the same page), the btrfs_copy_from_user()
> > function had some handling for "copied == 0" that would change the
> > scope of the amount to write, and loop back to try the write again.
> >
> > I attempted to construct a patch that just reverted the handling for
> > "copied == 0" in btrfs_copy_from_user(), however, that just resulted
> > in my computer locking up when it reached the point where it was
> > previously beginning to allocate disk space.
> >
> > So, I apologize for not having a patch to address the issue I'm
> > seeing, but I hope I've added some insight.
> >
> 
> Some clarification on my previous message...
> 
> After looking at my ftrace log more closely, I can see where Btrfs is
> trying to release the allocated pages.  However, the calculation for
> the number of dirty_pages is equal to 1 when "copied == 0".
> 
> So I'm seeing at least two problems:
> (1)  It keeps looping when "copied == 0".
> (2)  One dirty page is not being released on every loop even though
> "copied == 0" (at least this problem keeps it from being an infinite
> loop by eventually exhausting reserveable space on the disk).

Very nice, I think you're exactly right.  I should be able to reproduce this
now, thanks!

-chris

  reply	other threads:[~2011-02-25 19:19 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-09  9:30 [PATCH v2]Btrfs: pwrite blocked when writing from the mmaped buffer of the same page Zhong, Xin
2011-01-27 13:09 ` Johannes Hirte
2011-01-27 22:12   ` Maria Wikström
2011-01-28  1:26     ` Zhong, Xin
2011-01-28  2:54       ` Johannes Hirte
2011-01-28  3:53         ` Zhong, Xin
2011-02-01 23:34           ` Johannes Hirte
2011-02-11  4:39             ` Zhong, Xin
2011-02-18 11:31               ` Maria Wikström
2011-02-21  1:51                 ` Zhong, Xin
2011-02-24 14:51                   ` Maria Wikström
2011-02-24 15:55                     ` Mitch Harder
2011-02-24 16:00                       ` Chris Mason
2011-02-24 16:03                         ` Mitch Harder
2011-02-24 16:19                           ` Chris Mason
2011-02-24 16:32                             ` Mitch Harder
     [not found]                               ` <AANLkTinvyb-bTVVignd1KGojvh-QrYCFmCnwYKBsYC_2@mail.gmail.com>
2011-02-25 17:11                                 ` Mitch Harder
2011-02-25 18:43                                   ` Mitch Harder
2011-02-25 19:19                                     ` Chris Mason [this message]
2011-02-28  1:46                                     ` [PATCH] btrfs file write debugging patch Chris Mason
2011-02-28  8:56                                       ` Zhong, Xin
2011-02-28 14:02                                         ` Chris Mason
2011-02-28 10:13                                       ` Johannes Hirte
2011-02-28 14:00                                         ` Chris Mason
2011-02-28 16:10                                         ` Josef Bacik
2011-02-28 16:45                                           ` Maria Wikström
2011-02-28 17:47                                             ` Mitch Harder
2011-02-28 20:20                                               ` Mitch Harder
2011-03-01  5:09                                                 ` Mitch Harder
2011-03-01 10:14                                                 ` Zhong, Xin
2011-03-01 11:56                                                   ` Zhong, Xin
2011-03-01 14:54                                                     ` Mitch Harder
2011-03-01 14:51                                                   ` Mitch Harder
2011-03-01 21:56                                                 ` Piotr Szymaniak
2011-02-24 23:35                   ` [PATCH v2]Btrfs: pwrite blocked when writing from the mmaped buffer of the same page Piotr Szymaniak
2011-02-22 22:27               ` Johannes Hirte
2011-02-23  7:27                 ` Zhong, Xin
2011-02-23 21:56                   ` Chris Mason
2011-02-23 23:02                     ` Johannes Hirte
2011-02-24 15:23                       ` Chris Mason
2011-01-28 16:47         ` Maria Wikström
2011-01-28 18:27           ` Rui Miguel Silva
2011-01-29 15:38             ` Maria Wikström

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=1298661529-sup-6456@think \
    --to=chris.mason@oracle.com \
    --cc=johannes.hirte@fem.tu-ilmenau.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=maria@ponstudios.se \
    --cc=mitch.harder@sabayonlinux.org \
    --cc=xin.zhong@intel.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).