From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/11] xfs: split XFS_BMAPI_DELALLOC handling from xfs_bmapi_write
Date: Thu, 31 Jan 2019 14:28:39 -0500 [thread overview]
Message-ID: <20190131192839.GI36239@bfoster> (raw)
In-Reply-To: <20190131075524.4769-8-hch@lst.de>
On Thu, Jan 31, 2019 at 08:55:20AM +0100, Christoph Hellwig wrote:
> Delalloc conversion has traditionally been part of our function to
> allocate blocks on disk (first xfs_bmapi, then xfs_bmapi_write), but
> delalloc conversion is a little special as we really do not want
> to allocate blocks over holes, for which we don't have reservations.
>
> Split the delalloc conversions into a separate helper to keep the
> code simple and structured.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/libxfs/xfs_bmap.c | 104 +++++++++++++++++++++------------------
> fs/xfs/libxfs/xfs_bmap.h | 4 --
> 2 files changed, 57 insertions(+), 51 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index d75f45d9b7d1..818cd018d510 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
...
> @@ -4487,21 +4452,66 @@ xfs_bmapi_convert_delalloc(
> xfs_fileoff_t offset_fsb,
> struct xfs_bmbt_irec *imap)
> {
> - int flags = XFS_BMAPI_DELALLOC, nimaps = 1, error;
> + struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
> + struct xfs_bmalloca bma = { NULL };
> + int error;
>
...
> +
> + bma.tp = tp;
> + bma.ip = ip;
> + bma.wasdel = true;
> + bma.offset = bma.got.br_startoff;
> + bma.length = bma.got.br_blockcount;
Do we need a MAXEXTLEN cap here? Otherwise the rest looks sane to me.
Brian
> + bma.total = XFS_EXTENTADD_SPACE_RES(ip->i_mount, XFS_DATA_FORK);
> + bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork);
> + if (whichfork == XFS_COW_FORK)
> + bma.flags = XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC;
> +
> + if (!xfs_iext_peek_prev_extent(ifp, &bma.icur, &bma.prev))
> + bma.prev.br_startoff = NULLFILEOFF;
> +
> + error = xfs_bmapi_allocate(&bma);
> + if (error)
> + goto out_finish;
> + if (WARN_ON_ONCE(bma.blkno == NULLFSBLOCK)) {
> + error = -ENOSPC;
> + goto out_finish;
> + }
> +
> + ASSERT(!isnullstartblock(bma.got.br_startblock));
> + ASSERT(bma.got.br_startblock || XFS_IS_REALTIME_INODE(ip));
> + *imap = bma.got;
> +
> + if (whichfork == XFS_COW_FORK) {
> + error = xfs_refcount_alloc_cow_extent(tp, bma.blkno,
> + bma.length);
> + if (error)
> + goto out_finish;
> + }
> +
> + error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags,
> + whichfork);
> +out_finish:
> + xfs_bmapi_finish(&bma, whichfork, error);
> return error;
> }
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index c385987251cd..5bdfa8001f07 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -95,9 +95,6 @@ struct xfs_extent_free_item
> /* Map something in the CoW fork. */
> #define XFS_BMAPI_COWFORK 0x200
>
> -/* Only convert delalloc space, don't allocate entirely new extents */
> -#define XFS_BMAPI_DELALLOC 0x400
> -
> /* Only convert unwritten extents, don't allocate new blocks */
> #define XFS_BMAPI_CONVERT_ONLY 0x800
>
> @@ -117,7 +114,6 @@ struct xfs_extent_free_item
> { XFS_BMAPI_ZERO, "ZERO" }, \
> { XFS_BMAPI_REMAP, "REMAP" }, \
> { XFS_BMAPI_COWFORK, "COWFORK" }, \
> - { XFS_BMAPI_DELALLOC, "DELALLOC" }, \
> { XFS_BMAPI_CONVERT_ONLY, "CONVERT_ONLY" }, \
> { XFS_BMAPI_NODISCARD, "NODISCARD" }, \
> { XFS_BMAPI_NORMAP, "NORMAP" }
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-01-31 19:28 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 7:55 make delalloc conversion more robust and clear Christoph Hellwig
2019-01-31 7:55 ` [PATCH 01/11] FOLD: improve xfs_bmapi_delalloc Christoph Hellwig
2019-01-31 18:09 ` Brian Foster
2019-02-01 7:23 ` Christoph Hellwig
2019-02-01 7:28 ` Christoph Hellwig
2019-02-01 12:46 ` Brian Foster
2019-02-01 16:08 ` Christoph Hellwig
2019-01-31 7:55 ` [PATCH 02/11] xfs: remove the io_type field from the writeback context and ioend Christoph Hellwig
2019-01-31 18:10 ` Brian Foster
2019-01-31 7:55 ` [PATCH 03/11] xfs: remove the s_maxbytes checks in xfs_map_blocks Christoph Hellwig
2019-01-31 18:10 ` Brian Foster
2019-01-31 7:55 ` [PATCH 04/11] xfs: don't try to map blocks beyond i_size in writeback Christoph Hellwig
2019-01-31 18:11 ` Brian Foster
2019-02-01 7:25 ` Christoph Hellwig
2019-02-01 12:46 ` Brian Foster
2019-02-01 16:07 ` Christoph Hellwig
2019-01-31 7:55 ` [PATCH 05/11] xfs: simplify the xfs_bmap_btree_to_extents calling conventions Christoph Hellwig
2019-01-31 18:11 ` Brian Foster
2019-01-31 7:55 ` [PATCH 06/11] xfs: factor out two helpers from xfs_bmapi_write Christoph Hellwig
2019-01-31 18:28 ` Brian Foster
2019-01-31 7:55 ` [PATCH 07/11] xfs: split XFS_BMAPI_DELALLOC handling " Christoph Hellwig
2019-01-31 19:28 ` Brian Foster [this message]
2019-01-31 7:55 ` [PATCH 08/11] xfs: move transaction handling to xfs_bmapi_convert_delalloc Christoph Hellwig
2019-01-31 19:28 ` Brian Foster
2019-01-31 7:55 ` [PATCH 09/11] xfs: move stat accounting " Christoph Hellwig
2019-01-31 19:29 ` Brian Foster
2019-01-31 7:55 ` [PATCH 10/11] xfs: move xfs_iomap_write_allocate to xfs_aops.c Christoph Hellwig
2019-01-31 19:31 ` Brian Foster
2019-01-31 7:55 ` [PATCH 11/11] xfs: retry COW fork delalloc conversion when no extent was found Christoph Hellwig
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=20190131192839.GI36239@bfoster \
--to=bfoster@redhat.com \
--cc=hch@lst.de \
--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;
as well as URLs for NNTP newsgroup(s).