From: Christoph Hellwig <hch@infradead.org>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org, edwin@etorok.net,
Brian Foster <bfoster@redhat.com>
Subject: Re: [PATCH v4.2 3/9] xfs: redesign the reflink remap loop to fix blkres depletion crash
Date: Wed, 1 Jul 2020 09:20:58 +0100 [thread overview]
Message-ID: <20200701082058.GC20101@infradead.org> (raw)
In-Reply-To: <20200625172310.GO7606@magnolia>
On Thu, Jun 25, 2020 at 10:23:10AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> The existing reflink remapping loop has some structural problems that
> need addressing:
>
> The biggest problem is that we create one transaction for each extent in
> the source file without accounting for the number of mappings there are
> for the same range in the destination file. In other words, we don't
> know the number of remap operations that will be necessary and we
> therefore cannot guess the block reservation required. On highly
> fragmented filesystems (e.g. ones with active dedupe) we guess wrong,
> run out of block reservation, and fail.
>
> The second problem is that we don't actually use the bmap intents to
> their full potential -- instead of calling bunmapi directly and having
> to deal with its backwards operation, we could call the deferred ops
> xfs_bmap_unmap_extent and xfs_refcount_decrease_extent instead. This
> makes the frontend loop much simpler.
>
> Solve all of these problems by refactoring the remapping loops so that
> we only perform one remapping operation per transaction, and each
> operation only tries to remap a single extent from source to dest.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v4.2: move qres conditional to the next patch, rename bmap helper, try
> to clear up some of the smap/dmap confusion
> ---
> fs/xfs/libxfs/xfs_bmap.h | 13 ++
> fs/xfs/xfs_reflink.c | 240 +++++++++++++++++++++++++---------------------
> fs/xfs/xfs_trace.h | 52 +---------
> 3 files changed, 142 insertions(+), 163 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index 2b18338d0643..e1bd484e5548 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -158,6 +158,13 @@ static inline int xfs_bmapi_whichfork(int bmapi_flags)
> { BMAP_ATTRFORK, "ATTR" }, \
> { BMAP_COWFORK, "COW" }
>
> +/* Return true if the extent is an allocated extent, written or not. */
> +static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec)
> +{
> + return irec->br_startblock != HOLESTARTBLOCK &&
> + irec->br_startblock != DELAYSTARTBLOCK &&
> + !isnullstartblock(irec->br_startblock);
> +}
I think reusing the previous name is a little dangerous. Maybe rename
this to ..._is_allocated_extent_ ?
>
> /*
> * Return true if the extent is a real, allocated extent, or false if it is a
And not for the previous one: if the real goes away in the name, it
should probably be updated here as well.
The rest looks fine:
Reviewed-by: Christoph Hellwig <hch@lst.de>
next prev parent reply other threads:[~2020-07-01 8:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 1:17 [PATCH v2 0/9] xfs: reflink cleanups Darrick J. Wong
2020-06-25 1:17 ` [PATCH 1/9] xfs: fix reflink quota reservation accounting error Darrick J. Wong
2020-06-25 12:26 ` Brian Foster
2020-07-01 8:07 ` Christoph Hellwig
2020-06-25 1:17 ` [PATCH 2/9] xfs: rename xfs_bmap_is_real_extent to is_written_extent Darrick J. Wong
2020-06-25 12:26 ` Brian Foster
2020-07-01 8:08 ` Christoph Hellwig
2020-06-25 1:17 ` [PATCH 3/9] xfs: redesign the reflink remap loop to fix blkres depletion crash Darrick J. Wong
2020-06-25 12:27 ` Brian Foster
2020-06-25 16:57 ` Darrick J. Wong
2020-06-25 17:23 ` [PATCH v4.2 " Darrick J. Wong
2020-06-26 11:57 ` Brian Foster
2020-06-26 16:40 ` Darrick J. Wong
2020-07-01 8:20 ` Christoph Hellwig [this message]
2020-06-25 1:18 ` [PATCH 4/9] xfs: only reserve quota blocks for bmbt changes if we're changing the data fork Darrick J. Wong
2020-06-25 12:27 ` Brian Foster
2020-07-01 8:21 ` Christoph Hellwig
2020-06-25 1:18 ` [PATCH 5/9] xfs: only reserve quota blocks if we're mapping into a hole Darrick J. Wong
2020-06-25 12:28 ` Brian Foster
2020-07-01 8:22 ` Christoph Hellwig
2020-06-25 1:18 ` [PATCH 6/9] xfs: reflink can skip remap existing mappings Darrick J. Wong
2020-06-25 12:28 ` Brian Foster
2020-06-25 16:49 ` Darrick J. Wong
2020-06-25 1:18 ` [PATCH 7/9] xfs: fix xfs_reflink_remap_prep calling conventions Darrick J. Wong
2020-07-01 8:23 ` Christoph Hellwig
2020-06-25 1:18 ` [PATCH 8/9] xfs: refactor locking and unlocking two inodes against userspace IO Darrick J. Wong
2020-07-01 8:26 ` Christoph Hellwig
2020-06-25 1:18 ` [PATCH 9/9] xfs: move helpers that lock and unlock " Darrick J. Wong
2020-07-01 8:27 ` Christoph Hellwig
2020-06-28 12:06 ` [PATCH v2 0/9] xfs: reflink cleanups Edwin Török
2020-06-28 22:36 ` Darrick J. Wong
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=20200701082058.GC20101@infradead.org \
--to=hch@infradead.org \
--cc=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=edwin@etorok.net \
--cc=linux-xfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox