From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 7/8] xfs: rewrite xfs_bmap_count_leaves using xfs_iext_get_extent
Date: Tue, 29 Aug 2017 11:43:48 -0700 [thread overview]
Message-ID: <20170829184348.GZ4757@magnolia> (raw)
In-Reply-To: <20170829174835.2218-8-hch@lst.de>
On Tue, Aug 29, 2017 at 07:48:34PM +0200, Christoph Hellwig wrote:
> This avoids poking into the internals of the extent list. Also return
> the number of extents as the return value instead of an additional
> by reference argument, and make it available to callers outside of
> xfs_bmap_util.c
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/xfs_bmap_util.c | 21 ++++++++++-----------
> fs/xfs/xfs_bmap_util.h | 1 +
> 2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 93e955262d07..ea737ebafc53 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -222,22 +222,21 @@ xfs_bmap_eof(
> * Count leaf blocks given a range of extent records. Delayed allocation
> * extents are not counted towards the totals.
> */
> -STATIC void
> +xfs_extnum_t
> xfs_bmap_count_leaves(
> struct xfs_ifork *ifp,
> - xfs_extnum_t *numrecs,
> xfs_filblks_t *count)
> {
> - xfs_extnum_t i;
> - xfs_extnum_t nr_exts = xfs_iext_count(ifp);
> -
> - for (i = 0; i < nr_exts; i++) {
> - xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, i);
> - if (!isnullstartblock(xfs_bmbt_get_startblock(frp))) {
> - (*numrecs)++;
> - *count += xfs_bmbt_get_blockcount(frp);
> + struct xfs_bmbt_irec got;
> + xfs_extnum_t numrecs = 0, i = 0;
> +
> + while (xfs_iext_get_extent(ifp, i++, &got)) {
> + if (!isnullstartblock(got.br_startblock)) {
> + *count += got.br_blockcount;
> + numrecs++;
> }
> }
> + return numrecs;
> }
>
> /*
> @@ -370,7 +369,7 @@ xfs_bmap_count_blocks(
>
> switch (XFS_IFORK_FORMAT(ip, whichfork)) {
> case XFS_DINODE_FMT_EXTENTS:
> - xfs_bmap_count_leaves(ifp, nextents, count);
> + *nextents = xfs_bmap_count_leaves(ifp, count);
> return 0;
> case XFS_DINODE_FMT_BTREE:
> if (!(ifp->if_flags & XFS_IFEXTENTS)) {
> diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h
> index 0cede1043571..0eaa81dc49be 100644
> --- a/fs/xfs/xfs_bmap_util.h
> +++ b/fs/xfs/xfs_bmap_util.h
> @@ -70,6 +70,7 @@ int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
>
> xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
>
> +xfs_extnum_t xfs_bmap_count_leaves(struct xfs_ifork *ifp, xfs_filblks_t *count);
> int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
> int whichfork, xfs_extnum_t *nextents,
> xfs_filblks_t *count);
> --
> 2.11.0
>
> --
> 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:[~2017-08-29 18:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 17:48 a few extent lookup cleanups Christoph Hellwig
2017-08-29 17:48 ` [PATCH 1/8] xfs: add a xfs_iext_update_extent helper Christoph Hellwig
2017-08-29 18:09 ` Darrick J. Wong
2017-08-29 17:48 ` [PATCH 2/8] xfs: switch xfs_bmap_local_to_extents to use xfs_iext_insert Christoph Hellwig
2017-08-29 18:13 ` Darrick J. Wong
2017-08-29 17:48 ` [PATCH 3/8] xfs: use xfs_iext_get_extent in xfs_bmap_first_unused Christoph Hellwig
2017-08-29 18:41 ` Darrick J. Wong
2017-09-01 20:06 ` Christoph Hellwig
2017-09-01 20:08 ` Darrick J. Wong
2017-08-29 17:48 ` [PATCH 4/8] xfs: move some code around inside xfs_bmap_shift_extents Christoph Hellwig
2017-08-29 19:35 ` Darrick J. Wong
2017-08-29 17:48 ` [PATCH 5/8] xfs: use xfs_iext_*_extent helpers in xfs_bmap_shift_extents Christoph Hellwig
2017-08-30 0:05 ` Darrick J. Wong
2017-08-30 23:03 ` Darrick J. Wong
2017-08-29 17:48 ` [PATCH 6/8] xfs: use xfs_iext_*_extent helpers in xfs_bmap_split_extent_at Christoph Hellwig
2017-08-29 18:42 ` Darrick J. Wong
2017-08-29 17:48 ` [PATCH 7/8] xfs: rewrite xfs_bmap_count_leaves using xfs_iext_get_extent Christoph Hellwig
2017-08-29 18:43 ` Darrick J. Wong [this message]
2017-08-29 17:48 ` [PATCH 8/8] xfs: replace xfs_qm_get_rtblks with a direct call to xfs_bmap_count_leaves Christoph Hellwig
2017-08-29 18:44 ` Darrick J. Wong
2017-08-30 23:10 ` [PATCH 9/8] xfs: simplify the rmap code in xfs_bmse_merge Darrick J. Wong
2017-08-31 13:31 ` 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=20170829184348.GZ4757@magnolia \
--to=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