]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: superblock scrub should use short-lived buffers
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 28 Jun 2018 20:11:56 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:56 +0000 (15:11 -0500)
Source kernel commit: 689e11c84b15866619e7582486acacaf79d7e3e2

Secondary superblocks are rarely used, so create a helper to read a
given non-primary AG's superblock and ensure that it won't stick around
hogging memory.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_sb.c
libxfs/xfs_sb.h
libxfs/xfs_shared.h

index 20314c18112c26e9c9584468d649e38d1c731281..c5e9dbae9b6fe286404bc8d69767c1479124b784 100644 (file)
@@ -954,3 +954,25 @@ xfs_fs_geometry(
 
        return 0;
 }
+
+/* Read a secondary superblock. */
+int
+xfs_sb_read_secondary(
+       struct xfs_mount        *mp,
+       struct xfs_trans        *tp,
+       xfs_agnumber_t          agno,
+       struct xfs_buf          **bpp)
+{
+       struct xfs_buf          *bp;
+       int                     error;
+
+       ASSERT(agno != 0 && agno != NULLAGNUMBER);
+       error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
+                       XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
+                       XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_sb_buf_ops);
+       if (error)
+               return error;
+       xfs_buf_set_ref(bp, XFS_SSB_REF);
+       *bpp = bp;
+       return 0;
+}
index 63dcd2a1a65717353b539617e0480eb0fb8f2709..5166d78b2c342352afd3e46894ec221e35dc8201 100644 (file)
@@ -37,5 +37,8 @@ extern void   xfs_sb_quota_from_disk(struct xfs_sb *sbp);
 #define XFS_FS_GEOM_MAX_STRUCT_VER     (4)
 extern int     xfs_fs_geometry(struct xfs_sb *sbp, struct xfs_fsop_geom *geo,
                                int struct_version);
+extern int     xfs_sb_read_secondary(struct xfs_mount *mp,
+                               struct xfs_trans *tp, xfs_agnumber_t agno,
+                               struct xfs_buf **bpp);
 
 #endif /* __XFS_SB_H__ */
index 8efc06e62b13bef848640cd9fce071ef9ef972e0..ae99c260adb1b86279054b387a92857caa48a995 100644 (file)
@@ -112,6 +112,7 @@ void        xfs_log_get_max_trans_res(struct xfs_mount *mp,
 #define        XFS_ATTR_BTREE_REF      1
 #define        XFS_DQUOT_REF           1
 #define        XFS_REFC_BTREE_REF      1
+#define        XFS_SSB_REF             0
 
 /*
  * Flags for xfs_trans_ichgtime().