]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: repair superblocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 28 Jun 2018 20:11:57 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:57 +0000 (15:11 -0500)
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 <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_sb.c
libxfs/xfs_sb.h

index acb34f88f43fbd6dcc045c3d611ae5bdc342aa7a..63a79ea4a950342d2c1584c57508e2f242d5d5bb 100644 (file)
@@ -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;
+}
index 03e0cc6bf3a6395a88d354f71c4190e21edc1eb4..244e0162c49e7702c7a94a0961a9bc2d5a8f47fc 100644 (file)
@@ -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__ */