All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naohiro Aota <Naohiro.Aota@wdc.com>
To: "dsterba@suse.cz" <dsterba@suse.cz>,
	Filipe Manana <fdmanana@gmail.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>,
	David Sterba <dsterba@suse.com>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Subject: Re: [PATCH] btrfs: properly split extent_map for REQ_OP_ZONE_APPEND
Date: Tue, 3 Aug 2021 23:51:57 +0000	[thread overview]
Message-ID: <20210803235157.seskvbshficvsymz@naota-xeon> (raw)
In-Reply-To: <20210728154703.GO5047@twin.jikos.cz>

On Wed, Jul 28, 2021 at 05:47:03PM +0200, David Sterba wrote:
> On Thu, Jul 01, 2021 at 05:55:51PM +0100, Filipe Manana wrote:
> > > > +       if (pre) {
> > > > +               /* Insert the middle extent_map */
> > > > +               split_mid->start = em->start + pre;
> > > > +               split_mid->len = em->len - pre - post;
> > > > +               split_mid->orig_start = split_mid->start;
> > > > +               split_mid->block_start = em->block_start + pre;
> > > > +               split_mid->block_len = split_mid->len;
> > > > +               split_mid->orig_block_len = split_mid->block_len;
> > > > +               split_mid->ram_bytes = split_mid->len;
> > > > +               split_mid->flags = flags;
> > > > +               split_mid->compress_type = em->compress_type;
> > > > +               split_mid->generation = em->generation;
> > > > +               add_extent_mapping(em_tree, split_mid, modified);
> > > > +       }
> > > > +
> > > > +       if (post) {
> > > > +               split_post->start = em->start + em->len - post;
> > > > +               split_post->len = post;
> > > > +               split_post->orig_start = split_post->start;
> > > > +               split_post->block_start = em->block_start + em->len - post;
> > > > +               split_post->block_len = split_post->len;
> > > > +               split_post->orig_block_len = split_post->block_len;
> > > > +               split_post->ram_bytes = split_post->len;
> > > > +               split_post->flags = flags;
> > > > +               split_post->compress_type = em->compress_type;
> > > > +               split_post->generation = em->generation;
> > > > +               add_extent_mapping(em_tree, split_post, modified);
> > > > +       }
> > >
> > > So this happens when running delalloc, after creating the original
> > > extent map and ordered extent, the original "em" must have had the
> > > PINNED flag set.
> > >
> > > The "pre" and "post" extent maps should have the PINNED flag set. It's
> > > important to have the flag set to prevent extent map merging, which
> > > could result in a log corruption if the file is being fsync'ed
> > > multiple times in the current transaction and running delalloc was
> > > triggered precisely by an fsync. The corruption result would be
> > > logging extent items with overlapping ranges, since we construct them
> > > based on extent maps, and that's why we have the PINNED flag to
> > > prevent merging.
> > 
> > Well, it actually happens that merging should not happen because the
> > original extent map was in the list of modified extents, and so should
> > be the new extent maps.
> > But we are really supposed to have the PINNED flag from the moment we
> > run delalloc and create a new extent map until the respective ordered
> > extent completes and unpins it.
> > 
> > Also EXTENT_FLAG_LOGGING should not be set at this point - if it were
> > we would screw up with a task logging the extent map.
> > 
> > Maybe assert that it is not set in the original extent map?
> > And also assert that the original em is in the list of modified
> > extents and has the PINNED flag set?
> 
> Agreed, the asserts should be here, Naohiro, please send a followup,
> thanks.

Sure. I'll soon send an update.

      reply	other threads:[~2021-08-03 23:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28  8:57 [PATCH] btrfs: properly split extent_map for REQ_OP_ZONE_APPEND Naohiro Aota
2021-06-28 11:50 ` Qu Wenruo
2021-06-28 12:08   ` Damien Le Moal
2021-06-28 12:12     ` Qu Wenruo
2021-06-30 19:25 ` David Sterba
2021-07-01 16:42 ` Filipe Manana
2021-07-01 16:55   ` Filipe Manana
2021-07-28 15:47     ` David Sterba
2021-08-03 23:51       ` Naohiro Aota [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=20210803235157.seskvbshficvsymz@naota-xeon \
    --to=naohiro.aota@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=fdmanana@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.