Re: [PATCH v2 03/22] xfs: add helpers to collect and sift btree block pointers during repair

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 29, 2018 at 01:10:01PM +1000, Dave Chinner wrote:
> On Thu, May 17, 2018 at 08:51:55PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > 
> > Add some helpers to assemble a list of fs block extents.  Generally,
> > repair functions will iterate the rmapbt to make a list (1) of all
> > extents owned by the nominal owner of the metadata structure; then they
> > will iterate all other structures with the same rmap owner to make a
> > list (2) of active blocks; and finally we have a subtraction function to
> > subtract all the blocks in (2) from (1), with the result that (1) is now
> > a list of blocks that were owned by the old btree and must be disposed.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > ---
> > v2: document the design of how repair functions are supposed to work,
> >     implement review comments
> > ---
> 
> Much easier to understand now. Thanks!
> 
> Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
> 
> One thing for a followup patch, though.
> 
> > +/* Collect a dead btree extent for later disposal. */
> > +int
> > +xfs_repair_collect_btree_extent(
> > +	struct xfs_scrub_context	*sc,
> > +	struct xfs_repair_extent_list	*exlist,
> > +	xfs_fsblock_t			fsbno,
> > +	xfs_extlen_t			len)
> > +{
> > +	struct xfs_repair_extent	*rex;
> > +
> > +	trace_xfs_repair_collect_btree_extent(sc->mp,
> > +			XFS_FSB_TO_AGNO(sc->mp, fsbno),
> > +			XFS_FSB_TO_AGBNO(sc->mp, fsbno), len);
> > +
> > +	rex = kmem_alloc(sizeof(struct xfs_repair_extent), KM_MAYFAIL);
> > +	if (!rex)
> > +		return -ENOMEM;
> > +
> > +	INIT_LIST_HEAD(&rex->list);
> > +	rex->fsbno = fsbno;
> > +	rex->len = len;
> 
> This allocation is repeated a couple of times. Single function to do
> it would be nice to encapsulate alloc+setup - something like rex =
> alloc_rex(fsbno, len) which returns NULL if it fails.
> 
> > +		case LEFT_ALIGNED | RIGHT_ALIGNED:
> > +			/* Total overlap, just delete ex. */
> > +			lp = lp->next;
> > +			list_del(&ex->list);
> > +			kmem_free(ex);
> > +			break;
> > +		case 0:
> > +			/*
> > +			 * Deleting from the middle: add the new right extent
> > +			 * and then shrink the left extent.
> > +			 */
> > +			newex = kmem_alloc(sizeof(struct xfs_repair_extent),
> > +					KM_MAYFAIL);
> > +			if (!newex) {
> > +				error = -ENOMEM;
> > +				goto out;
> > +			}
> > +			INIT_LIST_HEAD(&newex->list);
> > +			newex->fsbno = sub_fsb + sub_len;
> > +			newex->len = ex->fsbno + ex->len - newex->fsbno;
> 
> This is the other place it is called...

<nod> I'll add this to the pile of enhancements to come after
upstreaming; maybe this will turn into more generic per-ag bitmap
structure.

I'd also like to replace the list usage in the later repair patches with
some kind of sort-once array structure and an xfs_btree_bulkload to
reduce overhead and memory consumption.

--D

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@xxxxxxxxxxxxx
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux