From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org, darrick.wong@oracle.com
Subject: Re: [PATCH 7/9] xfs: optimize xfs_reflink_cancel_cow_blocks
Date: Wed, 12 Oct 2016 10:13:25 -0400 [thread overview]
Message-ID: <20161012141324.GC56019@bfoster.bfoster> (raw)
In-Reply-To: <1476106685-29048-8-git-send-email-hch@lst.de>
On Mon, Oct 10, 2016 at 03:38:03PM +0200, Christoph Hellwig wrote:
> Rewrite xfs_reflink_cancel_cow_blocks so that we only do a search for
> the first extent in the extent list and then iterate over the remaining
> extents using the extent index, passing the extent we operate on
> directly to xfs_bmap_del_extent_delay or xfs_bmap_del_extent_cow instead
> of going through xfs_bunmapi and doing yet another extent list lookup.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/xfs_reflink.c | 59 +++++++++++++++++++++++-----------------------------
> 1 file changed, 26 insertions(+), 33 deletions(-)
>
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 5d230ea..08170bb 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -512,58 +512,52 @@ xfs_reflink_cancel_cow_blocks(
> xfs_fileoff_t offset_fsb,
> xfs_fileoff_t end_fsb)
> {
> - struct xfs_bmbt_irec irec;
> - xfs_filblks_t count_fsb;
> + struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
> + struct xfs_bmbt_irec got, prev, del;
> + xfs_extnum_t idx;
> xfs_fsblock_t firstfsb;
> struct xfs_defer_ops dfops;
> - int error = 0;
> - int nimaps;
> + int error = 0, eof = 0;
>
> if (!xfs_is_reflink_inode(ip))
> return 0;
>
> - /* Go find the old extent in the CoW fork. */
> - while (offset_fsb < end_fsb) {
> - nimaps = 1;
> - count_fsb = (xfs_filblks_t)(end_fsb - offset_fsb);
> - error = xfs_bmapi_read(ip, offset_fsb, count_fsb, &irec,
> - &nimaps, XFS_BMAPI_COWFORK);
> - if (error)
> - break;
> - ASSERT(nimaps == 1);
> + xfs_bmap_search_extents(ip, offset_fsb, XFS_COW_FORK, &eof, &idx,
> + &got, &prev);
> + if (eof)
> + return 0;
>
> - trace_xfs_reflink_cancel_cow(ip, &irec);
> + do {
> + if (got.br_startoff >= end_fsb)
> + break;
How about using a while loop..?
while (got.br_startoff < end_fsb) {
...
Otherwise, looks fine:
Reviewed-by: Brian Foster <bfoster@redhat.com>
>
> - if (irec.br_startblock == DELAYSTARTBLOCK) {
> - /* Free a delayed allocation. */
> - xfs_mod_fdblocks(ip->i_mount, irec.br_blockcount,
> - false);
> - ip->i_delayed_blks -= irec.br_blockcount;
> + del = got;
> + xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb);
> + trace_xfs_reflink_cancel_cow(ip, &del);
>
> - /* Remove the mapping from the CoW fork. */
> - error = xfs_bunmapi_cow(ip, &irec);
> + if (isnullstartblock(del.br_startblock)) {
> + error = xfs_bmap_del_extent_delay(ip, XFS_COW_FORK,
> + &idx, &got, &del);
> if (error)
> break;
> - } else if (irec.br_startblock == HOLESTARTBLOCK) {
> - /* empty */
> } else {
> xfs_trans_ijoin(*tpp, ip, 0);
> xfs_defer_init(&dfops, &firstfsb);
>
> /* Free the CoW orphan record. */
> error = xfs_refcount_free_cow_extent(ip->i_mount,
> - &dfops, irec.br_startblock,
> - irec.br_blockcount);
> + &dfops, del.br_startblock,
> + del.br_blockcount);
> if (error)
> break;
>
> xfs_bmap_add_free(ip->i_mount, &dfops,
> - irec.br_startblock, irec.br_blockcount,
> + del.br_startblock, del.br_blockcount,
> NULL);
>
> /* Update quota accounting */
> xfs_trans_mod_dquot_byino(*tpp, ip, XFS_TRANS_DQ_BCOUNT,
> - -(long)irec.br_blockcount);
> + -(long)del.br_blockcount);
>
> /* Roll the transaction */
> error = xfs_defer_finish(tpp, &dfops, ip);
> @@ -573,14 +567,13 @@ xfs_reflink_cancel_cow_blocks(
> }
>
> /* Remove the mapping from the CoW fork. */
> - error = xfs_bunmapi_cow(ip, &irec);
> - if (error)
> - break;
> + xfs_bmap_del_extent_cow(ip, &idx, &got, &del);
> }
>
> - /* Roll on... */
> - offset_fsb = irec.br_startoff + irec.br_blockcount;
> - }
> + if (++idx >= ifp->if_bytes / sizeof(struct xfs_bmbt_rec))
> + return 0;
> + xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &got);
> + } while (1);
>
> return error;
> }
> --
> 2.10.1.382.ga23ca1b
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-10-12 14:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-10 13:37 optimize the COW I/O path Christoph Hellwig
2016-10-10 13:37 ` [PATCH 1/9] iomap: add IOMAP_REPORT Christoph Hellwig
2016-10-11 1:45 ` Darrick J. Wong
2016-10-11 4:58 ` Christoph Hellwig
[not found] ` <20161011144557.GA16368@lst.de>
2016-10-11 16:22 ` Darrick J. Wong
2016-10-10 13:37 ` [PATCH 2/9] xfs: add xfs_trim_extent Christoph Hellwig
2016-10-10 13:37 ` [PATCH 3/9] xfs: handle "raw" delayed extents xfs_reflink_trim_around_shared Christoph Hellwig
2016-10-10 13:38 ` [PATCH 4/9] xfs: don't bother looking at the refcount tree for reads Christoph Hellwig
2016-10-10 13:38 ` [PATCH 5/9] xfs: optimize writes to reflink files Christoph Hellwig
2016-10-12 14:12 ` Brian Foster
2016-10-13 6:49 ` Christoph Hellwig
2016-10-13 13:26 ` Brian Foster
2016-10-13 18:28 ` Darrick J. Wong
2016-10-10 13:38 ` [PATCH 6/9] xfs: refactor xfs_bunmapi_cow Christoph Hellwig
2016-10-12 14:13 ` Brian Foster
2016-10-13 6:54 ` Christoph Hellwig
2016-10-13 13:26 ` Brian Foster
2016-10-10 13:38 ` [PATCH 7/9] xfs: optimize xfs_reflink_cancel_cow_blocks Christoph Hellwig
2016-10-12 14:13 ` Brian Foster [this message]
2016-10-13 7:01 ` Christoph Hellwig
2016-10-10 13:38 ` [PATCH 8/9] xfs: optimize xfs_reflink_end_cow Christoph Hellwig
2016-10-12 14:15 ` Brian Foster
2016-10-13 7:06 ` Christoph Hellwig
2016-10-13 13:27 ` Brian Foster
2016-10-10 13:38 ` [PATCH 9/9] xfs: remove xfs_bunmapi_cow Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2016-10-15 8:52 optimize the COW I/O path V2 Christoph Hellwig
2016-10-15 8:52 ` [PATCH 7/9] xfs: optimize xfs_reflink_cancel_cow_blocks Christoph Hellwig
2016-10-17 17:52 ` Brian Foster
2016-10-17 18:33 ` 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=20161012141324.GC56019@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=darrick.wong@oracle.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).