Skip to content

Commit b7d47a7

Browse files
author
Darrick J. Wong
committed
xfs: move the realtime summary file scrubber to a separate source file
Move the realtime summary file checking code to a separate file in preparation to actually implement it. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 294012f commit b7d47a7

File tree

3 files changed

+60
-38
lines changed

3 files changed

+60
-38
lines changed

fs/xfs/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ xfs-y += $(addprefix scrub/, \
169169
)
170170

171171
xfs-$(CONFIG_XFS_ONLINE_SCRUB_STATS) += scrub/stats.o
172-
xfs-$(CONFIG_XFS_RT) += scrub/rtbitmap.o
172+
173+
xfs-$(CONFIG_XFS_RT) += $(addprefix scrub/, \
174+
rtbitmap.o \
175+
rtsummary.o \
176+
)
177+
173178
xfs-$(CONFIG_XFS_QUOTA) += scrub/quota.o
174179

175180
# online repair

fs/xfs/scrub/rtbitmap.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -124,43 +124,6 @@ xchk_rtbitmap(
124124
return error;
125125
}
126126

127-
/* Scrub the realtime summary. */
128-
int
129-
xchk_rtsummary(
130-
struct xfs_scrub *sc)
131-
{
132-
struct xfs_inode *rsumip = sc->mp->m_rsumip;
133-
struct xfs_inode *old_ip = sc->ip;
134-
uint old_ilock_flags = sc->ilock_flags;
135-
int error = 0;
136-
137-
/*
138-
* We ILOCK'd the rt bitmap ip in the setup routine, now lock the
139-
* rt summary ip in compliance with the rt inode locking rules.
140-
*
141-
* Since we switch sc->ip to rsumip we have to save the old ilock
142-
* flags so that we don't mix up the inode state that @sc tracks.
143-
*/
144-
sc->ip = rsumip;
145-
sc->ilock_flags = 0;
146-
xchk_ilock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
147-
148-
/* Invoke the fork scrubber. */
149-
error = xchk_metadata_inode_forks(sc);
150-
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
151-
goto out;
152-
153-
/* XXX: implement this some day */
154-
xchk_set_incomplete(sc);
155-
out:
156-
/* Switch back to the rtbitmap inode and lock flags. */
157-
xchk_iunlock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
158-
sc->ilock_flags = old_ilock_flags;
159-
sc->ip = old_ip;
160-
return error;
161-
}
162-
163-
164127
/* xref check that the extent is not free in the rtbitmap */
165128
void
166129
xchk_xref_is_used_rt_space(

fs/xfs/scrub/rtsummary.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Copyright (C) 2017-2023 Oracle. All Rights Reserved.
4+
* Author: Darrick J. Wong <[email protected]>
5+
*/
6+
#include "xfs.h"
7+
#include "xfs_fs.h"
8+
#include "xfs_shared.h"
9+
#include "xfs_format.h"
10+
#include "xfs_trans_resv.h"
11+
#include "xfs_mount.h"
12+
#include "xfs_btree.h"
13+
#include "xfs_inode.h"
14+
#include "xfs_log_format.h"
15+
#include "xfs_trans.h"
16+
#include "xfs_rtalloc.h"
17+
#include "scrub/scrub.h"
18+
#include "scrub/common.h"
19+
20+
/* Scrub the realtime summary. */
21+
int
22+
xchk_rtsummary(
23+
struct xfs_scrub *sc)
24+
{
25+
struct xfs_inode *rsumip = sc->mp->m_rsumip;
26+
struct xfs_inode *old_ip = sc->ip;
27+
uint old_ilock_flags = sc->ilock_flags;
28+
int error = 0;
29+
30+
/*
31+
* We ILOCK'd the rt bitmap ip in the setup routine, now lock the
32+
* rt summary ip in compliance with the rt inode locking rules.
33+
*
34+
* Since we switch sc->ip to rsumip we have to save the old ilock
35+
* flags so that we don't mix up the inode state that @sc tracks.
36+
*/
37+
sc->ip = rsumip;
38+
sc->ilock_flags = 0;
39+
xchk_ilock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
40+
41+
/* Invoke the fork scrubber. */
42+
error = xchk_metadata_inode_forks(sc);
43+
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
44+
goto out;
45+
46+
/* XXX: implement this some day */
47+
xchk_set_incomplete(sc);
48+
out:
49+
/* Switch back to the rtbitmap inode and lock flags. */
50+
xchk_iunlock(sc, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM);
51+
sc->ilock_flags = old_ilock_flags;
52+
sc->ip = old_ip;
53+
return error;
54+
}

0 commit comments

Comments
 (0)