public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: david@fromorbit.com
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 32/51] xfs_repair: add fixed-location per-AG rmaps
Date: Wed, 21 Oct 2015 14:08:34 -0700	[thread overview]
Message-ID: <20151021210834.GL10397@birch.djwong.org> (raw)
In-Reply-To: <20151007050838.1504.57156.stgit@birch.djwong.org>

On Tue, Oct 06, 2015 at 10:08:38PM -0700, Darrick J. Wong wrote:
> Add reverse-mappings for fixed-location per-AG metadata such as inode
> chunks, superblocks, and the log to the raw rmap list, then merge the
> raw rmap data (which also has the BMBT data) into the main rmap list.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  repair/phase4.c |   41 +++++++++++++++++++++++++++++++++++++++++
>  repair/rmap.c   |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  repair/rmap.h   |    2 ++
>  3 files changed, 94 insertions(+)
> 
> 
> diff --git a/repair/phase4.c b/repair/phase4.c
> index bc43cd8..cbdb92e 100644
> --- a/repair/phase4.c
> +++ b/repair/phase4.c
> @@ -157,6 +157,40 @@ process_ags(
>  	do_inode_prefetch(mp, ag_stride, process_ag_func, true, false);
>  }
>  
> +static void
> +check_rmap_btrees(
> +	work_queue_t	*wq,
> +	xfs_agnumber_t	agno,
> +	void		*arg)
> +{
> +	int		error;
> +
> +	error = add_fixed_ag_rmap_data(wq->mp, agno);
> +	if (error)
> +		do_error(
> +_("unable to add AG %u metadata reverse-mapping data.\n"), agno);
> +
> +	error = fold_raw_rmaps(wq->mp, agno);
> +	if (error)
> +		do_error(
> +_("unable to merge AG %u metadata reverse-mapping data.\n"), agno);
> +}
> +
> +static void
> +process_rmap_data(
> +	struct xfs_mount	*mp)
> +{
> +	struct work_queue	wq;
> +	xfs_agnumber_t		i;
> +
> +	if (!needs_rmap_work(mp))
> +		return;
> +
> +	create_work_queue(&wq, mp, libxfs_nproc());
> +	for (i = 0; i < mp->m_sb.sb_agcount; i++)
> +		queue_work(&wq, check_rmap_btrees, i, NULL);
> +	destroy_work_queue(&wq);
> +}
>  
>  void
>  phase4(xfs_mount_t *mp)
> @@ -306,6 +340,13 @@ phase4(xfs_mount_t *mp)
>  	 * already in phase 3.
>  	 */
>  	process_ags(mp);
> +
> +	/*
> +	 * Process all the reverse-mapping data that we collected.  This
> +	 * involves checking the rmap data against the btree.
> +	 */
> +	process_rmap_data(mp);
> +
>  	print_final_rpt();
>  
>  	/*
> diff --git a/repair/rmap.c b/repair/rmap.c
> index 40bdae3..a5ea685 100644
> --- a/repair/rmap.c
> +++ b/repair/rmap.c
> @@ -344,6 +344,57 @@ err:
>  	return error;
>  }
>  
> +/**
> + * add_fixed_ag_rmap_data() - Add fixed per-AG metadata to the rmap list.
> + *			      This includes sb/agi/agf/agfl headers, inode
> + *			      chunks, and the log.
> + *
> + * @mp: XFS mountpoint.
> + * @agno: AG number.
> + */
> +int
> +add_fixed_ag_rmap_data(
> +	struct xfs_mount	*mp,
> +	xfs_agnumber_t		agno)
> +{
> +	xfs_fsblock_t		fsbno;
> +	xfs_agblock_t		agbno;
> +	ino_tree_node_t		*ino_rec;
> +	int			error;
> +
> +	if (!needs_rmap_work(mp))
> +		return 0;
> +
> +	/* sb/agi/agf/agfl headers */
> +	error = add_ag_rmap(mp, agno, 0, XFS_BNO_BLOCK(mp),
> +			XFS_RMAP_OWN_FS);
> +	if (error)
> +		goto out;
> +
> +	/* inodes */
> +	ino_rec = findfirst_inode_rec(agno);
> +	for (; ino_rec != NULL; ino_rec = next_ino_rec(ino_rec)) {
> +		agbno = XFS_AGINO_TO_AGBNO(mp, ino_rec->ino_startnum);
> +		error = add_ag_rmap(mp, agno, agbno,
> +				64 / mp->m_sb.sb_inopblock, /* XXX */

This won't work with sparse inode support turned on, because inode chunks
can be shorter than 64 inodes.  Assuming ir_holemask is accurate, it
shouldn't be difficult to make this emit the correct records.

Fixed now.

--D

> +				XFS_RMAP_OWN_INODES);
> +		if (error)
> +			goto out;
> +	}
> +
> +	/* log */
> +	fsbno = mp->m_sb.sb_logstart;
> +	if (fsbno && XFS_FSB_TO_AGNO(mp, fsbno) == agno) {
> +		agbno = XFS_FSB_TO_AGBNO(mp, mp->m_sb.sb_logstart);
> +		error = add_ag_rmap(mp, agno, agbno, mp->m_sb.sb_logblocks,
> +				XFS_RMAP_OWN_LOG);
> +		if (error)
> +			goto out;
> +	}
> +out:
> +	return error;
> +}
> +
>  #ifdef RMAP_DEBUG
>  static void
>  dump_rmap(
> diff --git a/repair/rmap.h b/repair/rmap.h
> index 57d56a0..7bab450 100644
> --- a/repair/rmap.h
> +++ b/repair/rmap.h
> @@ -31,4 +31,6 @@ extern int add_ag_rmap(struct xfs_mount *, xfs_agnumber_t agno,
>  extern int add_bmbt_rmap(struct xfs_mount *, xfs_ino_t, int, xfs_fsblock_t);
>  extern int fold_raw_rmaps(struct xfs_mount *mp, xfs_agnumber_t agno);
>  
> +extern int add_fixed_ag_rmap_data(struct xfs_mount *, xfs_agnumber_t);
> +
>  #endif /* RMAP_H_ */
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-10-21 21:08 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-07  5:05 [RFCv3 00/51] xfsprogs: add reverse-mapping, reflink, and dedupe support Darrick J. Wong
2015-10-07  5:05 ` [PATCH 01/51] libxcmd: provide a common function to report command runtimes Darrick J. Wong
2015-10-13 17:48   ` Christoph Hellwig
2015-10-13 22:39     ` Darrick J. Wong
2015-10-14  5:35   ` [PATCH v2 " Darrick J. Wong
2015-10-14  7:31     ` Christoph Hellwig
2015-10-07  5:05 ` [PATCH 02/51] libxfs: add reflink and dedupe ioctls Darrick J. Wong
2015-10-07  5:05 ` [PATCH 03/51] xfs_io: support reflink and dedupe of file ranges Darrick J. Wong
2015-10-14  5:36   ` [PATCH v2 " Darrick J. Wong
2015-11-09  7:54     ` Christoph Hellwig
2015-11-09 18:33       ` Darrick J. Wong
2015-11-09 18:57         ` Darrick J. Wong
2015-11-09 21:35           ` Dave Chinner
2015-11-10  6:27             ` Darrick J. Wong
2015-10-07  5:05 ` [PATCH 04/51] xfs_io: unshare blocks via fallocate Darrick J. Wong
2015-10-07  5:05 ` [PATCH 05/51] xfs_db: enable blocktrash for checksummed filesystems Darrick J. Wong
2015-10-07  5:05 ` [PATCH 06/51] xfs_db: trash the block at the top of the cursor stack Darrick J. Wong
2015-10-07  5:05 ` [PATCH 07/51] xfs_db: enable blockget for v5 filesystems Darrick J. Wong
2015-10-14 17:08   ` Christoph Hellwig
2015-10-14 18:20     ` Darrick J. Wong
2015-10-14 18:23       ` Christoph Hellwig
2015-10-14 19:52         ` Darrick J. Wong
2015-10-14 21:26         ` Dave Chinner
2015-10-07  5:06 ` [PATCH 08/51] libxfs: reorder xfs_bmap_add_free args Darrick J. Wong
2015-10-07  5:06 ` [PATCH 09/51] libxfs: add the reverse-mapping btree Darrick J. Wong
2015-10-07  5:06 ` [PATCH 10/51] libxfs: resync xfs_prealloc_blocks with the kernel Darrick J. Wong
2015-10-07  5:06 ` [PATCH 11/51] xfs: rmap btree transaction reservations Darrick J. Wong
2015-10-07  5:06 ` [PATCH 12/51] xfs: rmap btree requires more reserved free space Darrick J. Wong
2015-10-07  5:06 ` [PATCH 13/51] libxfs: propagate a bunch of case changes to mkfs and repair Darrick J. Wong
2015-10-07  5:06 ` [PATCH 14/51] libxfs: fix min freelist length calculation Darrick J. Wong
2015-10-07  5:06 ` [PATCH 15/51] libxfs: add the RMAP CRC to the xfs_magics list Darrick J. Wong
2015-10-07  5:06 ` [PATCH 16/51] libxfs: enhance rmapbt definition to support reflink Darrick J. Wong
2015-10-07  5:07 ` [PATCH 17/51] libxfs: refactor short btree block verification Darrick J. Wong
2015-10-07  5:07 ` [PATCH 18/51] xfs: don't update rmapbt when fixing agfl Darrick J. Wong
2015-10-07  5:07 ` [PATCH 19/51] libxfs: implement XFS_IOC_SWAPEXT when rmap btree is enabled Darrick J. Wong
2015-10-07  5:07 ` [PATCH 20/51] xfs_db: display rmap btree contents Darrick J. Wong
2015-10-07  5:07 ` [PATCH 21/51] xfs_dump: display enhanced rmapbt fields Darrick J. Wong
2015-10-07  5:07 ` [PATCH 22/51] xfs_db: check rmapbt Darrick J. Wong
2015-10-07  5:07 ` [PATCH 23/51] xfs_db: copy the rmap btree Darrick J. Wong
2015-10-07  5:07 ` [PATCH 24/51] xfs_growfs: report rmapbt presence Darrick J. Wong
2015-10-07  5:07 ` [PATCH 25/51] xfs_repair: use rmap btree data to check block types Darrick J. Wong
2015-10-07  5:08 ` [PATCH 26/51] xfs_repair: mask off length appropriately Darrick J. Wong
2015-10-07  5:08 ` [PATCH 27/51] xfs_repair: fix fino_bno calculation when rmapbt is enabled Darrick J. Wong
2015-10-07  5:08 ` [PATCH 28/51] xfs_repair: create a slab API for allocating arrays in large chunks Darrick J. Wong
2015-10-07  5:08 ` [PATCH 29/51] xfs_repair: collect reverse-mapping data for refcount/rmap tree rebuilding Darrick J. Wong
2015-10-07  5:08 ` [PATCH 30/51] xfs_repair: record and merge raw rmap data Darrick J. Wong
2015-10-07  5:08 ` [PATCH 31/51] xfs_repair: add inode bmbt block rmaps Darrick J. Wong
2015-10-07  5:08 ` [PATCH 32/51] xfs_repair: add fixed-location per-AG rmaps Darrick J. Wong
2015-10-21 21:08   ` Darrick J. Wong [this message]
2015-10-07  5:08 ` [PATCH 33/51] xfs_repair: check existing rmapbt entries against observed rmaps Darrick J. Wong
2015-10-07  5:08 ` [PATCH 34/51] xfs_repair: rebuild reverse-mapping btree Darrick J. Wong
2015-10-07  5:09 ` [PATCH 35/51] xfs_repair: add per-AG btree blocks to rmap data and add to rmapbt Darrick J. Wong
2015-10-07  5:09 ` [PATCH 36/51] mkfs.xfs: Create rmapbt filesystems Darrick J. Wong
2015-10-07  5:09 ` [PATCH 37/51] xfs_mkfs: initialize extra fields during mkfs Darrick J. Wong
2015-10-07  5:09 ` [PATCH 38/51] libxfs: add support for refcount btrees Darrick J. Wong
2015-10-07  5:09 ` [PATCH 39/51] xfs_db: dump refcount btree data Darrick J. Wong
2015-10-07  5:09 ` [PATCH 40/51] xfs_db: add support for checking the refcount btree Darrick J. Wong
2015-10-07  5:09 ` [PATCH 41/51] xfs_db: metadump should copy the refcount btree too Darrick J. Wong
2015-10-07  5:09 ` [PATCH 42/51] xfs_growfs: report the presence of the reflink feature Darrick J. Wong
2015-10-07  5:09 ` [PATCH 43/51] xfs_repair: check the existing refcount btree Darrick J. Wong
2015-10-07  5:09 ` [PATCH 44/51] xfs_repair: handle multiple owners of data blocks Darrick J. Wong
2015-10-07  5:10 ` [PATCH 45/51] xfs_repair: process reverse-mapping data into refcount data Darrick J. Wong
2015-10-07  5:10 ` [PATCH 46/51] xfs_repair: record reflink inode state Darrick J. Wong
2015-10-07  5:10 ` [PATCH 47/51] xfs_repair: fix inode reflink flags Darrick J. Wong
2015-10-07  5:10 ` [PATCH 48/51] xfs_repair: check the refcount btree against our observed reference counts when -n Darrick J. Wong
2015-10-07  5:10 ` [PATCH 49/51] xfs_repair: rebuild the refcount btree Darrick J. Wong
2015-10-07  5:10 ` [PATCH 50/51] mkfs.xfs: format reflink enabled filesystems Darrick J. Wong
2015-10-07  5:10 ` [PATCH 51/51] mkfs: hack around not having enough log blocks 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=20151021210834.GL10397@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /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