Re: [PATCH 11/21] xfs: repair superblocks

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

 



On Fri, Apr 06, 2018 at 11:05:20AM +1000, Dave Chinner wrote:
> On Mon, Apr 02, 2018 at 12:57:24PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > 
> > If one of the backup superblocks is found to differ seriously from
> > superblock 0, write out a fresh copy from the in-core sb.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> .....
> > +/* Repair the superblock. */
> > +int
> > +xfs_repair_superblock(
> > +	struct xfs_scrub_context	*sc)
> > +{
> > +	struct xfs_mount		*mp = sc->mp;
> > +	struct xfs_buf			*bp;
> > +	struct xfs_dsb			*sbp;
> > +	xfs_agnumber_t			agno;
> > +	int				error;
> > +
> > +	/* Don't try to repair AG 0's sb; let xfs_repair deal with it. */
> > +	agno = sc->sm->sm_agno;
> > +	if (agno == 0)
> > +		return -EOPNOTSUPP;
> > +
> > +	error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp,
> > +		  XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
> > +		  XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL);
> 
> If we are just overwriting the superblock, then use
> xfs_trans_get_buf() so we don't need to do IO here.

Ok.

> > +	if (error)
> > +		return error;
> > +	bp->b_ops = &xfs_sb_buf_ops;
> > +
> > +	/* Copy AG 0's superblock to this one. */
> > +	sbp = XFS_BUF_TO_SBP(bp);
> > +	memset(sbp, 0, mp->m_sb.sb_sectsize);
> 
> That's a bit nasty. struct xfs_dsb is not a sector size in length.
> 
> 	xfs_buf_zero(bp, 0, BBTOB(bp->b_length));

Fixed.

> > +	xfs_sb_to_disk(sbp, &mp->m_sb);
> > +	sbp->sb_bad_features2 = sbp->sb_features2;
> 
> Why is sb_bad_features2 not correct when taken from the incore
> superblock?

It is correct, this is unnecessary.

> > +	/* Write this to disk. */
> > +	xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_SB_BUF);
> > +	xfs_trans_log_buf(sc->tp, bp, 0, mp->m_sb.sb_sectsize - 1);
> 
> And why log this rather than just write it straight to disk? We've
> never logged secondary superblocks before, so why now?

Ok, will do.  I might as well change the sb scrubber to use uncached
buffers while I'm at it (separate patch, obviously).

> >  int xfs_repair_setup_btree_extent_collection(struct xfs_scrub_context *sc);
> >  
> >  /* Metadata repairers */
> > +int xfs_repair_superblock(struct xfs_scrub_context *sc);
> >  
> >  #else
> >  
> > @@ -106,6 +107,8 @@ xfs_repair_calc_ag_resblks(
> >  	return 0;
> >  }
> >  
> > +#define xfs_repair_superblock		(NULL)
> 
> Static inline, returns -EOPNOTSUPP. Or, as I'm suspecting that
> all the patches are goign to do this - have a generic
> xfs_repair_notsupported() function and define the functions
> to that.

Working on it. :)

--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