]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - scrub/phase2.c
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
9 #include <sys/statvfs.h>
12 #include "workqueue.h"
13 #include "xfs_scrub.h"
17 /* Phase 2: Check internal metadata. */
19 /* Scrub each AG's metadata btrees. */
26 struct scrub_ctx
*ctx
= (struct scrub_ctx
*)wq
->wq_ctx
;
29 char descr
[DESCR_BUFSZ
];
31 snprintf(descr
, DESCR_BUFSZ
, _("AG %u"), agno
);
34 * First we scrub and fix the AG headers, because we need
35 * them to work well enough to check the AG btrees.
37 moveon
= xfs_scrub_ag_headers(ctx
, agno
);
41 /* Now scrub the AG btrees. */
42 moveon
= xfs_scrub_ag_metadata(ctx
, agno
);
51 /* Scrub whole-FS metadata btrees. */
58 struct scrub_ctx
*ctx
= (struct scrub_ctx
*)wq
->wq_ctx
;
62 moveon
= xfs_scrub_fs_metadata(ctx
);
67 /* Scan all filesystem metadata. */
70 struct scrub_ctx
*ctx
)
77 ret
= workqueue_create(&wq
, (struct xfs_mount
*)ctx
,
78 scrub_nproc_workqueue(ctx
));
80 str_info(ctx
, ctx
->mntpoint
, _("Could not create workqueue."));
85 * In case we ever use the primary super scrubber to perform fs
86 * upgrades (followed by a full scrub), do that before we launch
89 moveon
= xfs_scrub_primary_super(ctx
);
93 for (agno
= 0; moveon
&& agno
< ctx
->geo
.agcount
; agno
++) {
94 ret
= workqueue_add(&wq
, xfs_scan_ag_metadata
, agno
, &moveon
);
97 str_info(ctx
, ctx
->mntpoint
,
98 _("Could not queue AG %u scrub work."), agno
);
106 ret
= workqueue_add(&wq
, xfs_scan_fs_metadata
, 0, &moveon
);
109 str_info(ctx
, ctx
->mntpoint
,
110 _("Could not queue filesystem scrub work."));
115 workqueue_destroy(&wq
);
119 /* Estimate how much work we're going to do. */
121 xfs_estimate_metadata_work(
122 struct scrub_ctx
*ctx
,
124 unsigned int *nr_threads
,
127 *items
= xfs_scrub_estimate_ag_work(ctx
);
128 *nr_threads
= scrub_nproc(ctx
);