linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/8] xfs: create a function to query all records in a btree
Date: Tue, 21 Feb 2017 09:35:15 -0500	[thread overview]
Message-ID: <20170221143514.GD3207@bfoster.bfoster> (raw)
In-Reply-To: <148738066286.29384.6059407136436797506.stgit@birch.djwong.org>

On Fri, Feb 17, 2017 at 05:17:42PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Create a helper function that will query all records in a btree.
> This will be used by the online repair functions to examine every
> record in a btree to rebuild a second btree.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_alloc.c |   15 +++++++++++++++
>  fs/xfs/libxfs/xfs_alloc.h |    2 ++
>  fs/xfs/libxfs/xfs_btree.c |   15 +++++++++++++++
>  fs/xfs/libxfs/xfs_btree.h |    2 ++
>  fs/xfs/libxfs/xfs_rmap.c  |   28 +++++++++++++++++++++-------
>  fs/xfs/libxfs/xfs_rmap.h  |    2 ++
>  6 files changed, 57 insertions(+), 7 deletions(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 526df17..ba15f30 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -2917,3 +2917,18 @@ xfs_alloc_query_range(
>  	return xfs_btree_query_range(cur, &low_brec, &high_brec,
>  			xfs_alloc_query_range_helper, &query);
>  }
> +
> +/* Find all free space records. */
> +int
> +xfs_alloc_query_all(
> +	struct xfs_btree_cur			*cur,
> +	xfs_alloc_query_range_fn		fn,
> +	void					*priv)
> +{
> +	struct xfs_alloc_query_range_info	query;
> +
> +	ASSERT(cur->bc_btnum == XFS_BTNUM_BNO);
> +	query.priv = priv;
> +	query.fn = fn;
> +	return xfs_btree_query_all(cur, xfs_alloc_query_range_helper, &query);
> +}
> diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
> index f534998..a2101de 100644
> --- a/fs/xfs/libxfs/xfs_alloc.h
> +++ b/fs/xfs/libxfs/xfs_alloc.h
> @@ -232,5 +232,7 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur,
>  		struct xfs_alloc_rec_incore *low_rec,
>  		struct xfs_alloc_rec_incore *high_rec,
>  		xfs_alloc_query_range_fn fn, void *priv);
> +int xfs_alloc_query_all(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn,
> +		void *priv);
>  
>  #endif	/* __XFS_ALLOC_H__ */
> diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
> index 2849d3f..ca94b87 100644
> --- a/fs/xfs/libxfs/xfs_btree.c
> +++ b/fs/xfs/libxfs/xfs_btree.c
> @@ -4823,6 +4823,21 @@ xfs_btree_query_range(
>  			fn, priv);
>  }
>  
> +/* Query a btree for all records. */
> +int
> +xfs_btree_query_all(
> +	struct xfs_btree_cur		*cur,
> +	xfs_btree_query_range_fn	fn,
> +	void				*priv)
> +{
> +	union xfs_btree_irec		low_rec;
> +	union xfs_btree_irec		high_rec;
> +
> +	memset(&low_rec, 0, sizeof(low_rec));
> +	memset(&high_rec, 0xFF, sizeof(high_rec));
> +	return xfs_btree_query_range(cur, &low_rec, &high_rec, fn, priv);
> +}
> +
>  /*
>   * Calculate the number of blocks needed to store a given number of records
>   * in a short-format (per-AG metadata) btree.
> diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
> index 33a8f86..5114055 100644
> --- a/fs/xfs/libxfs/xfs_btree.h
> +++ b/fs/xfs/libxfs/xfs_btree.h
> @@ -494,6 +494,8 @@ typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur,
>  int xfs_btree_query_range(struct xfs_btree_cur *cur,
>  		union xfs_btree_irec *low_rec, union xfs_btree_irec *high_rec,
>  		xfs_btree_query_range_fn fn, void *priv);
> +int xfs_btree_query_all(struct xfs_btree_cur *cur, xfs_btree_query_range_fn fn,
> +		void *priv);
>  
>  typedef int (*xfs_btree_visit_blocks_fn)(struct xfs_btree_cur *cur, int level,
>  		void *data);
> diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
> index 3a8cc71..3840556 100644
> --- a/fs/xfs/libxfs/xfs_rmap.c
> +++ b/fs/xfs/libxfs/xfs_rmap.c
> @@ -2001,14 +2001,14 @@ xfs_rmap_query_range_helper(
>  /* Find all rmaps between two keys. */
>  int
>  xfs_rmap_query_range(
> -	struct xfs_btree_cur		*cur,
> -	struct xfs_rmap_irec		*low_rec,
> -	struct xfs_rmap_irec		*high_rec,
> -	xfs_rmap_query_range_fn	fn,
> -	void				*priv)
> +	struct xfs_btree_cur			*cur,
> +	struct xfs_rmap_irec			*low_rec,
> +	struct xfs_rmap_irec			*high_rec,
> +	xfs_rmap_query_range_fn			fn,
> +	void					*priv)
>  {
> -	union xfs_btree_irec		low_brec;
> -	union xfs_btree_irec		high_brec;
> +	union xfs_btree_irec			low_brec;
> +	union xfs_btree_irec			high_brec;
>  	struct xfs_rmap_query_range_info	query;
>  
>  	low_brec.r = *low_rec;
> @@ -2019,6 +2019,20 @@ xfs_rmap_query_range(
>  			xfs_rmap_query_range_helper, &query);
>  }
>  
> +/* Find all rmaps. */
> +int
> +xfs_rmap_query_all(
> +	struct xfs_btree_cur			*cur,
> +	xfs_rmap_query_range_fn			fn,
> +	void					*priv)
> +{
> +	struct xfs_rmap_query_range_info	query;
> +
> +	query.priv = priv;
> +	query.fn = fn;
> +	return xfs_btree_query_all(cur, xfs_rmap_query_range_helper, &query);
> +}
> +
>  /* Clean up after calling xfs_rmap_finish_one. */
>  void
>  xfs_rmap_finish_one_cleanup(
> diff --git a/fs/xfs/libxfs/xfs_rmap.h b/fs/xfs/libxfs/xfs_rmap.h
> index 7899305..faf2c1a 100644
> --- a/fs/xfs/libxfs/xfs_rmap.h
> +++ b/fs/xfs/libxfs/xfs_rmap.h
> @@ -162,6 +162,8 @@ typedef int (*xfs_rmap_query_range_fn)(
>  int xfs_rmap_query_range(struct xfs_btree_cur *cur,
>  		struct xfs_rmap_irec *low_rec, struct xfs_rmap_irec *high_rec,
>  		xfs_rmap_query_range_fn fn, void *priv);
> +int xfs_rmap_query_all(struct xfs_btree_cur *cur, xfs_rmap_query_range_fn fn,
> +		void *priv);
>  
>  enum xfs_rmap_intent_type {
>  	XFS_RMAP_MAP,
> 
> --
> 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

  reply	other threads:[~2017-02-21 14:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-18  1:17 [RFC PATCH v6 0/8] vfs/xfs/ext4: GETFSMAP support Darrick J. Wong
2017-02-18  1:17 ` [PATCH 1/8] vfs: add common GETFSMAP ioctl definitions Darrick J. Wong
2017-02-18  1:17 ` [PATCH 2/8] xfs: plumb in needed functions for range querying of the freespace btrees Darrick J. Wong
2017-02-21 14:35   ` Brian Foster
2017-02-21 17:22     ` Darrick J. Wong
2017-02-21 17:34   ` [PATCH v2 " Darrick J. Wong
2017-02-22 15:02     ` Brian Foster
2017-02-18  1:17 ` [PATCH 3/8] xfs: provide a query_range function for " Darrick J. Wong
2017-02-21 14:35   ` Brian Foster
2017-02-18  1:17 ` [PATCH 4/8] xfs: create a function to query all records in a btree Darrick J. Wong
2017-02-21 14:35   ` Brian Foster [this message]
2017-02-18  1:17 ` [PATCH 5/8] xfs: introduce the XFS_IOC_GETFSMAP ioctl Darrick J. Wong
2017-02-22 15:02   ` Brian Foster
2017-02-22 21:17     ` Darrick J. Wong
2017-02-23 14:45       ` Brian Foster
2017-02-23 20:44         ` Darrick J. Wong
2017-02-23 23:43           ` Brian Foster
2017-02-24  0:54             ` Darrick J. Wong
2017-02-18  1:17 ` [PATCH 6/8] xfs: have getfsmap fall back to the freesp btrees when rmap is not present Darrick J. Wong
2017-02-24 13:04   ` Brian Foster
2017-02-24 17:48     ` Darrick J. Wong
2017-02-24 22:33       ` Darrick J. Wong
2017-02-18  1:18 ` [PATCH 7/8] xfs: getfsmap should fall back to rtbitmap when rtrmapbt " Darrick J. Wong
2017-02-18  1:18 ` [PATCH 8/8] ext4: support GETFSMAP ioctls Darrick J. Wong
2017-02-21 22:14 ` [PATCH] ioctl_getfsmap.2: document the GETFSMAP ioctl 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=20170221143514.GD3207@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --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).