From: Darrick J. Wong Date: Thu, 28 Jun 2018 20:11:57 +0000 (-0500) Subject: xfs: repair superblocks X-Git-Tag: v4.18.0-rc0~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b153fb40c81b5f1a56d160666b8123264e6ba129;p=thirdparty%2Fxfsprogs-dev.git xfs: repair superblocks Source kernel commit: d25522f10cfa342a20867086a516c45c87b0877c 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 Reviewed-by: Allison Henderson Reviewed-by: Dave Chinner Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index acb34f88f..63a79ea4a 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -1081,3 +1081,25 @@ xfs_sb_read_secondary( *bpp = bp; return 0; } + +/* Get an uninitialised secondary superblock buffer. */ +int +xfs_sb_get_secondary( + struct xfs_mount *mp, + struct xfs_trans *tp, + xfs_agnumber_t agno, + struct xfs_buf **bpp) +{ + struct xfs_buf *bp; + + ASSERT(agno != 0 && agno != NULLAGNUMBER); + bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, + XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)), + XFS_FSS_TO_BB(mp, 1), 0); + if (!bp) + return -ENOMEM; + bp->b_ops = &xfs_sb_buf_ops; + xfs_buf_oneshot(bp); + *bpp = bp; + return 0; +} diff --git a/libxfs/xfs_sb.h b/libxfs/xfs_sb.h index 03e0cc6bf..244e0162c 100644 --- a/libxfs/xfs_sb.h +++ b/libxfs/xfs_sb.h @@ -50,5 +50,8 @@ extern int xfs_fs_geometry(struct xfs_sb *sbp, struct xfs_fsop_geom *geo, extern int xfs_sb_read_secondary(struct xfs_mount *mp, struct xfs_trans *tp, xfs_agnumber_t agno, struct xfs_buf **bpp); +extern int xfs_sb_get_secondary(struct xfs_mount *mp, + struct xfs_trans *tp, xfs_agnumber_t agno, + struct xfs_buf **bpp); #endif /* __XFS_SB_H__ */