diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2020-10-25 17:14:55 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2020-10-26 18:32:21 -0700 |
commit | 3ba0842d0c3523ec2e9bcc4c76ce8839f0e91e12 (patch) | |
tree | 48cce58e1a4116f75bec5e5b9a8e55cbbd745698 /fs/xfs/scrub/fscounters.c | |
parent | f77263d6cd87c8cbd60a14d7ad2821790163135a (diff) |
xfs: repair summary countersrepair-hard-problems_2020-10-26
Use the same summary counter calculation infrastructure to generate new
values for the in-core summary counters. The difference between the
scrubber and the repairer is that the repairer will freeze the fs during
setup, which means that the values should match exactly.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/scrub/fscounters.c')
-rw-r--r-- | fs/xfs/scrub/fscounters.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/xfs/scrub/fscounters.c b/fs/xfs/scrub/fscounters.c index e6469f4245ad..7652f82ffbcb 100644 --- a/fs/xfs/scrub/fscounters.c +++ b/fs/xfs/scrub/fscounters.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2019 Oracle. All Rights Reserved. * Author: Darrick J. Wong <darrick.wong@oracle.com> @@ -42,6 +42,10 @@ * structures as quickly as it can. We snapshot the percpu counters before and * after this operation and use the difference in counter values to guess at * our tolerance for mismatch between expected and actual counter values. + * + * NOTE: If the calling application has permitted us to repair the counters, + * we /must/ prevent all other filesystem activity by freezing it. Since we've + * frozen the filesystem, we can require an exact match. */ /* @@ -141,8 +145,14 @@ xchk_setup_fscounters( * likelihood of background perturbations to the counters throwing off * our calculations. If a previous check failed and userspace told us * to freeze the fs, do that instead. + * + * If we're repairing, we need to prevent any other thread from + * changing the global fs summary counters while we're repairing them. + * This requires the fs to be frozen, which will disable background + * reclaim and purge all inactive inodes. */ - if (sc->flags & XCHK_TRY_HARDER) { + if ((sc->flags & XCHK_TRY_HARDER) || + (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)) { error = xchk_fs_freeze(sc); if (error) return error; @@ -307,6 +317,8 @@ out_unlock: * Otherwise, we /might/ have a problem. If the change in the summations is * more than we want to tolerate, the filesystem is probably busy and we should * just send back INCOMPLETE and see if userspace will try again. + * + * If we're repairing then we require an exact match. */ static inline bool xchk_fscount_within_range( @@ -329,6 +341,10 @@ xchk_fscount_within_range( if (curr_value == expected) return true; + /* We require exact matches when repair is running. */ + if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) + return false; + min_value = min(old_value, curr_value); max_value = max(old_value, curr_value); |