From: Josef Bacik <jbacik@fusionio.com>
To: Wang Shilong <wangshilong1991@gmail.com>
Cc: Josef Bacik <JBacik@fusionio.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: fix bad extent logging
Date: Tue, 9 Apr 2013 09:09:16 -0400 [thread overview]
Message-ID: <20130409130916.GE2010@localhost.localdomain> (raw)
In-Reply-To: <99952820-CF63-4765-84E2-91A0F8F8B60D@gmail.com>
On Tue, Apr 09, 2013 at 06:04:27AM -0600, Wang Shilong wrote:
> Hello Josef,
>
> > A user sent me a btrfs-image of a file system that was panicing on mount during
> > the log recovery. I had originally thought these problems were from a bug in
> > the free space cache code, but that was just a symptom of the problem. The
> > problem is if your application does something like this
> >
> > [prealloc][prealloc][prealloc]
> >
> > the internal extent maps will merge those all together into one extent map, even
> > though on disk they are 3 separate extents. So if you go to write into one of
> > these ranges the extent map will be right since we use the physical extent when
> > doing the write, but when we log the extents they will use the wrong sizes for
> > the remainder prealloc space. If this doesn't happen to trip up the free space
> > cache (which it won't in a lot of cases) then you will get bogus entries in your
> > extent tree which will screw stuff up later. The data and such will still work,
> > but everything else is broken. This patch fixes this by not allowing extents
> > that are on the modified list to be merged. This has the side effect that we
> > are no longer adding everything to the modified list all the time, which means
> > we now have to call btrfs_drop_extents every time we log an extent into the
> > tree. So this allows me to drop all this speciality code I was using to get
> > around calling btrfs_drop_extents. With this patch the testcase I've created no
> > longer creates a bogus file system after replaying the log. Thanks,
> >
> > Signed-off-by: Josef Bacik <jbacik@fusionio.com>
> >
>
> <snip>
> > while (1) {
> > write_lock(&em_tree->lock);
> > - err = add_extent_mapping(em_tree, hole_em);
> > - if (!err)
> > - list_move(&hole_em->list,
> > - &em_tree->modified_extents);
> > + err = add_extent_mapping(em_tree, hole_em, 1);
> > write_unlock(&em_tree->lock);
> > if (err != -EEXIST)
> > break;
> > @@ -5989,7 +5977,8 @@ static int merge_extent_mapping(struct extent_map_tree *em_tree,
> > em->block_start += start_diff;
> > em->block_len -= start_diff;
> > }
> > - return add_extent_mapping(em_tree, em);
> > + printk(KERN_ERR "merging here for %Lu\n", em->orig_start);
>
> How about using something like pr_debug here.
> When i tested btrfs-next, i found it hit too much.
>
That was just me forgetting to delete that printk, I'll fix it up, sorry,
Josef
prev parent reply other threads:[~2013-04-09 13:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-05 20:56 [PATCH] Btrfs: fix bad extent logging Josef Bacik
2013-04-09 12:04 ` Wang Shilong
2013-04-09 13:09 ` Josef Bacik [this message]
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=20130409130916.GE2010@localhost.localdomain \
--to=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wangshilong1991@gmail.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