linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 03/20] xfs: add repair helpers for the reverse mapping btree
Date: Wed, 28 Mar 2018 10:03:27 +1100	[thread overview]
Message-ID: <20180327230327.GU18129@dastard> (raw)
In-Reply-To: <152210857318.13184.219852203461550085.stgit@magnolia>

On Mon, Mar 26, 2018 at 04:56:13PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add a couple of functions to the reverse mapping btree that will be used
> to repair the rmapbt.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Not exactly sure how/what these will be used for yet, so it's hard
to say if they are correct or not. :P

Couple of things, though.

> @@ -2454,3 +2482,54 @@ xfs_rmap_record_exists(
>  		     irec.rm_startblock + irec.rm_blockcount >= bno + len);
>  	return 0;
>  }
> +
> +struct xfs_rmap_has_other_keys {
> +	uint64_t			owner;
> +	uint64_t			offset;
> +	bool				*has_rmap;

Seems very strange this is a pointer, given we are passing the
structure.

> +	unsigned int			flags;
> +};

struct xfs_rmap_key_state

> +/* For each rmap given, figure out if it doesn't match the key we want. */
> +STATIC int
> +xfs_rmap_has_other_keys_helper(
> +	struct xfs_btree_cur		*cur,
> +	struct xfs_rmap_irec		*rec,
> +	void				*priv)

And this can become just xfs_rmap_has_other_keys()

> +{
> +	struct xfs_rmap_has_other_keys	*rhok = priv;
> +
> +	if (rhok->owner == rec->rm_owner && rhok->offset == rec->rm_offset &&
> +	    ((rhok->flags & rec->rm_flags) & XFS_RMAP_KEY_FLAGS) == rhok->flags)
> +		return 0;
> +	*rhok->has_rmap = true;
> +	return XFS_BTREE_QUERY_RANGE_ABORT;
> +}
> +
> +/*
> + * Given an extent and some owner info, can we find records overlapping
> + * the extent whose owner info does not match the given owner?
> + */
> +int
> +xfs_rmap_has_other_keys(
> +	struct xfs_btree_cur		*cur,
> +	xfs_agblock_t			bno,
> +	xfs_extlen_t			len,
> +	struct xfs_owner_info		*oinfo,
> +	bool				*has_rmap)
> +{
> +	struct xfs_rmap_irec		low = {0};
> +	struct xfs_rmap_irec		high;
> +	struct xfs_rmap_has_other_keys	rhok;
> +
> +	xfs_owner_info_unpack(oinfo, &rhok.owner, &rhok.offset, &rhok.flags);
> +	*has_rmap = false;
> +	rhok.has_rmap = has_rmap;

Oh, you're embedding another bool variable in it. I think it would
be better to copy in/out of the internal structure rather than
pass a pointer of unknown scope around....

	rhok.has_rmap = *has_rmap;

> +
> +	low.rm_startblock = bno;
> +	memset(&high, 0xFF, sizeof(high));
> +	high.rm_startblock = bno + len - 1;
> +
> +	return xfs_rmap_query_range(cur, &low, &high,
> +			xfs_rmap_has_other_keys_helper, &rhok);

	error = xfs_rmap_query_range(..., &rhok)
	*has_rmap = rhok.has_rmap;
	return error;

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2018-03-27 23:03 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-26 23:55 [PATCH v14 00/20] xfs-4.17: online repair support Darrick J. Wong
2018-03-26 23:56 ` [PATCH 01/20] xfs: add helpers to calculate btree size Darrick J. Wong
2018-03-27 22:54   ` Dave Chinner
2018-03-26 23:56 ` [PATCH 02/20] xfs: expose various functions to repair code Darrick J. Wong
2018-03-27 22:55   ` Dave Chinner
2018-03-26 23:56 ` [PATCH 03/20] xfs: add repair helpers for the reverse mapping btree Darrick J. Wong
2018-03-27 23:03   ` Dave Chinner [this message]
2018-03-27 23:29     ` Darrick J. Wong
2018-03-26 23:56 ` [PATCH 04/20] xfs: add repair helpers for the reference count btree Darrick J. Wong
2018-03-27 23:04   ` Dave Chinner
2018-03-26 23:56 ` [PATCH 05/20] xfs: add BMAPI_NORMAP flag to perform block remapping without updating rmpabt Darrick J. Wong
2018-03-27 23:09   ` Dave Chinner
2018-03-26 23:56 ` [PATCH 06/20] xfs: halt auto-reclamation activities while rebuilding rmap Darrick J. Wong
2018-03-27 23:15   ` Dave Chinner
2018-03-27 23:50     ` Darrick J. Wong
2018-03-26 23:56 ` [PATCH 07/20] xfs: create tracepoints for online repair Darrick J. Wong
2018-03-27 23:18   ` Dave Chinner
2018-03-27 23:33     ` Darrick J. Wong
2018-03-26 23:56 ` [PATCH 08/20] xfs: implement the metadata repair ioctl flag Darrick J. Wong
2018-03-27 23:55   ` Dave Chinner
2018-03-28  4:58     ` Darrick J. Wong
2018-03-28 23:19       ` Darrick J. Wong
2018-03-28 23:42         ` Dave Chinner
2018-03-26 23:56 ` [PATCH 09/20] xfs: add helper routines for the repair code Darrick J. Wong
2018-03-26 23:56 ` [PATCH 10/20] xfs: repair superblocks Darrick J. Wong
2018-03-26 23:57 ` [PATCH 11/20] xfs: repair the AGF and AGFL Darrick J. Wong
2018-03-26 23:57 ` [PATCH 12/20] xfs: repair the AGI Darrick J. Wong
2018-03-26 23:57 ` [PATCH 13/20] xfs: repair free space btrees Darrick J. Wong
2018-03-26 23:57 ` [PATCH 14/20] xfs: repair inode btrees Darrick J. Wong
2018-03-26 23:57 ` [PATCH 15/20] xfs: repair the rmapbt Darrick J. Wong
2018-03-26 23:57 ` [PATCH 16/20] xfs: repair refcount btrees Darrick J. Wong
2018-03-26 23:57 ` [PATCH 17/20] xfs: repair inode records Darrick J. Wong
2018-03-26 23:57 ` [PATCH 18/20] xfs: zap broken inode forks Darrick J. Wong
2018-03-26 23:57 ` [PATCH 19/20] xfs: repair inode block maps Darrick J. Wong
2018-03-26 23:58 ` [PATCH 20/20] xfs: repair damaged symlinks Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2018-03-15 20:26 [PATCH v13 00/20] xfs-4.17: online repair support Darrick J. Wong
2018-03-15 20:26 ` [PATCH 03/20] xfs: add repair helpers for the reverse mapping btree Darrick J. Wong
2018-02-23  2:01 [PATCH v12 00/20] xfs: online repair support Darrick J. Wong
2018-02-23  2:02 ` [PATCH 03/20] xfs: add repair helpers for the reverse mapping btree 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=20180327230327.GU18129@dastard \
    --to=david@fromorbit.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).