From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 05/11] xfs: simplify the xfs_bmap_btree_to_extents calling conventions
Date: Thu, 31 Jan 2019 13:11:17 -0500 [thread overview]
Message-ID: <20190131181116.GG36239@bfoster> (raw)
In-Reply-To: <20190131075524.4769-6-hch@lst.de>
On Thu, Jan 31, 2019 at 08:55:18AM +0100, Christoph Hellwig wrote:
> Move boilerplate code from the callers into xfs_bmap_btree_to_extents:
>
> - exit early without failure if we don't need to convert to the
> extent format
> - assert that we have a btree cursor
> - don't reinitialize the passed in logflags argument
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/libxfs/xfs_bmap.c | 78 ++++++++++++++--------------------------
> 1 file changed, 26 insertions(+), 52 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 65940b79019a..a0443158a40e 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -577,42 +577,44 @@ __xfs_bmap_add_free(
> */
>
> /*
> - * Transform a btree format file with only one leaf node, where the
> - * extents list will fit in the inode, into an extents format file.
> - * Since the file extents are already in-core, all we have to do is
> - * give up the space for the btree root and pitch the leaf block.
> + * Convert the inode format to extent format if it currently is in btree format,
> + * but the extent list is small enough that it fits into the extent format.
> + 8
> + * Since the extents are already in-core, all we have to do is give up the space
> + * for the btree root and pitch the leaf block.
> */
> STATIC int /* error */
> xfs_bmap_btree_to_extents(
> - xfs_trans_t *tp, /* transaction pointer */
> - xfs_inode_t *ip, /* incore inode pointer */
> - xfs_btree_cur_t *cur, /* btree cursor */
> + struct xfs_trans *tp, /* transaction pointer */
> + struct xfs_inode *ip, /* incore inode pointer */
> + struct xfs_btree_cur *cur, /* btree cursor */
> int *logflagsp, /* inode logging flags */
> int whichfork) /* data or attr fork */
> {
> - /* REFERENCED */
> + struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
> + struct xfs_mount *mp = ip->i_mount;
> + struct xfs_btree_block *rblock = ifp->if_broot;
> struct xfs_btree_block *cblock;/* child btree block */
> xfs_fsblock_t cbno; /* child block number */
> xfs_buf_t *cbp; /* child block's buffer */
> int error; /* error return value */
> - struct xfs_ifork *ifp; /* inode fork data */
> - xfs_mount_t *mp; /* mount point structure */
> __be64 *pp; /* ptr to block address */
> - struct xfs_btree_block *rblock;/* root btree block */
> struct xfs_owner_info oinfo;
>
> - mp = ip->i_mount;
> - ifp = XFS_IFORK_PTR(ip, whichfork);
> + /* check if we actually need the extent format first: */
> + if (!xfs_bmap_wants_extents(ip, whichfork))
> + return 0;
> +
> + ASSERT(cur);
> ASSERT(whichfork != XFS_COW_FORK);
> ASSERT(ifp->if_flags & XFS_IFEXTENTS);
> ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
> - rblock = ifp->if_broot;
> ASSERT(be16_to_cpu(rblock->bb_level) == 1);
> ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1);
> ASSERT(xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0) == 1);
> +
> pp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, ifp->if_broot_bytes);
> cbno = be64_to_cpu(*pp);
> - *logflagsp = 0;
> #ifdef DEBUG
> XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
> xfs_btree_check_lptr(cur, cbno, 1));
> @@ -635,7 +637,7 @@ xfs_bmap_btree_to_extents(
> ASSERT(ifp->if_broot == NULL);
> ASSERT((ifp->if_flags & XFS_IFBROOT) == 0);
> XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
> - *logflagsp = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
> + *logflagsp |= XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
> return 0;
> }
>
> @@ -4424,19 +4426,10 @@ xfs_bmapi_write(
> }
> *nmap = n;
>
> - /*
> - * Transform from btree to extents, give it cur.
> - */
> - if (xfs_bmap_wants_extents(ip, whichfork)) {
> - int tmp_logflags = 0;
> -
> - ASSERT(bma.cur);
> - error = xfs_bmap_btree_to_extents(tp, ip, bma.cur,
> - &tmp_logflags, whichfork);
> - bma.logflags |= tmp_logflags;
> - if (error)
> - goto error0;
> - }
> + error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags,
> + whichfork);
> + if (error)
> + goto error0;
>
> ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE ||
> XFS_IFORK_NEXTENTS(ip, whichfork) >
> @@ -4572,13 +4565,7 @@ xfs_bmapi_remap(
> if (error)
> goto error0;
>
> - if (xfs_bmap_wants_extents(ip, whichfork)) {
> - int tmp_logflags = 0;
> -
> - error = xfs_bmap_btree_to_extents(tp, ip, cur,
> - &tmp_logflags, whichfork);
> - logflags |= tmp_logflags;
> - }
> + error = xfs_bmap_btree_to_extents(tp, ip, cur, &logflags, whichfork);
>
> error0:
> if (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS)
> @@ -5442,24 +5429,11 @@ __xfs_bunmapi(
> error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0,
> &tmp_logflags, whichfork);
> logflags |= tmp_logflags;
> - if (error)
> - goto error0;
> - }
> - /*
> - * transform from btree to extents, give it cur
> - */
> - else if (xfs_bmap_wants_extents(ip, whichfork)) {
> - ASSERT(cur != NULL);
> - error = xfs_bmap_btree_to_extents(tp, ip, cur, &tmp_logflags,
> + } else {
> + error = xfs_bmap_btree_to_extents(tp, ip, cur, &logflags,
> whichfork);
> - logflags |= tmp_logflags;
> - if (error)
> - goto error0;
> }
> - /*
> - * transform from extents to local?
> - */
> - error = 0;
> +
> error0:
> /*
> * Log everything. Do this after conversion, there's no point in
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-01-31 18:11 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 [this message]
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
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=20190131181116.GG36239@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).