]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: move the realtime summary file scrubber to a separate source file
authorDarrick J. Wong <djwong@kernel.org>
Thu, 10 Aug 2023 14:48:09 +0000 (07:48 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 10 Aug 2023 14:48:09 +0000 (07:48 -0700)
Move the realtime summary file checking code to a separate file in
preparation to actually implement it.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/Makefile
fs/xfs/scrub/rtbitmap.c
fs/xfs/scrub/rtsummary.c [new file with mode: 0644]

index d59fcf3fd0d54cac6df9f2e24076c4c036e48bdb..7762c01a85cfb7d055ada1050a0e1170d2a8ec73 100644 (file)
@@ -169,7 +169,12 @@ xfs-y                              += $(addprefix scrub/, \
                                   )
 
 xfs-$(CONFIG_XFS_ONLINE_SCRUB_STATS) += scrub/stats.o
-xfs-$(CONFIG_XFS_RT)           += scrub/rtbitmap.o
+
+xfs-$(CONFIG_XFS_RT)           += $(addprefix scrub/, \
+                                  rtbitmap.o \
+                                  rtsummary.o \
+                                  )
+
 xfs-$(CONFIG_XFS_QUOTA)                += scrub/quota.o
 
 # online repair
index d42e5fc20ebd0f8def7ded39804aecddaf022e6b..0bf56d92d70a2989158609caff36feacd1f0e786 100644 (file)
@@ -124,43 +124,6 @@ out:
        return error;
 }
 
-/* Scrub the realtime summary. */
-int
-xchk_rtsummary(
-       struct xfs_scrub        *sc)
-{
-       struct xfs_inode        *rsumip = sc->mp->m_rsumip;
-       struct xfs_inode        *old_ip = sc->ip;
-       uint                    old_ilock_flags = sc->ilock_flags;
-       int                     error = 0;
-
-       /*
-        * We ILOCK'd the rt bitmap ip in the setup routine, now lock the
-        * rt summary ip in compliance with the rt inode locking rules.
-        *
-        * Since we switch sc->ip to rsumip we have to save the old ilock
-        * flags so that we don't mix up the inode state that @sc tracks.
-        */
-       sc->ip = rsumip;
-       sc->ilock_flags = 0;
-       xchk_ilock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
-
-       /* Invoke the fork scrubber. */
-       error = xchk_metadata_inode_forks(sc);
-       if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
-               goto out;
-
-       /* XXX: implement this some day */
-       xchk_set_incomplete(sc);
-out:
-       /* Switch back to the rtbitmap inode and lock flags. */
-       xchk_iunlock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
-       sc->ilock_flags = old_ilock_flags;
-       sc->ip = old_ip;
-       return error;
-}
-
-
 /* xref check that the extent is not free in the rtbitmap */
 void
 xchk_xref_is_used_rt_space(
diff --git a/fs/xfs/scrub/rtsummary.c b/fs/xfs/scrub/rtsummary.c
new file mode 100644 (file)
index 0000000..f96d0c7
--- /dev/null
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2017-2023 Oracle.  All Rights Reserved.
+ * Author: Darrick J. Wong <djwong@kernel.org>
+ */
+#include "xfs.h"
+#include "xfs_fs.h"
+#include "xfs_shared.h"
+#include "xfs_format.h"
+#include "xfs_trans_resv.h"
+#include "xfs_mount.h"
+#include "xfs_btree.h"
+#include "xfs_inode.h"
+#include "xfs_log_format.h"
+#include "xfs_trans.h"
+#include "xfs_rtalloc.h"
+#include "scrub/scrub.h"
+#include "scrub/common.h"
+
+/* Scrub the realtime summary. */
+int
+xchk_rtsummary(
+       struct xfs_scrub        *sc)
+{
+       struct xfs_inode        *rsumip = sc->mp->m_rsumip;
+       struct xfs_inode        *old_ip = sc->ip;
+       uint                    old_ilock_flags = sc->ilock_flags;
+       int                     error = 0;
+
+       /*
+        * We ILOCK'd the rt bitmap ip in the setup routine, now lock the
+        * rt summary ip in compliance with the rt inode locking rules.
+        *
+        * Since we switch sc->ip to rsumip we have to save the old ilock
+        * flags so that we don't mix up the inode state that @sc tracks.
+        */
+       sc->ip = rsumip;
+       sc->ilock_flags = 0;
+       xchk_ilock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
+
+       /* Invoke the fork scrubber. */
+       error = xchk_metadata_inode_forks(sc);
+       if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
+               goto out;
+
+       /* XXX: implement this some day */
+       xchk_set_incomplete(sc);
+out:
+       /* Switch back to the rtbitmap inode and lock flags. */
+       xchk_iunlock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
+       sc->ilock_flags = old_ilock_flags;
+       sc->ip = old_ip;
+       return error;
+}