]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - scrub/phase2.c
edf66df6a7fa9c0243a2f9d8f403d72bc4783000
2 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it would be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include <sys/types.h>
25 #include <sys/statvfs.h>
29 #include "workqueue.h"
30 #include "xfs_scrub.h"
34 /* Phase 2: Check internal metadata. */
36 /* Scrub each AG's metadata btrees. */
43 struct scrub_ctx
*ctx
= (struct scrub_ctx
*)wq
->wq_ctx
;
46 char descr
[DESCR_BUFSZ
];
48 snprintf(descr
, DESCR_BUFSZ
, _("AG %u"), agno
);
51 * First we scrub and fix the AG headers, because we need
52 * them to work well enough to check the AG btrees.
54 moveon
= xfs_scrub_ag_headers(ctx
, agno
);
58 /* Now scrub the AG btrees. */
59 moveon
= xfs_scrub_ag_metadata(ctx
, agno
);
68 /* Scrub whole-FS metadata btrees. */
75 struct scrub_ctx
*ctx
= (struct scrub_ctx
*)wq
->wq_ctx
;
79 moveon
= xfs_scrub_fs_metadata(ctx
);
84 /* Scan all filesystem metadata. */
87 struct scrub_ctx
*ctx
)
94 ret
= workqueue_create(&wq
, (struct xfs_mount
*)ctx
,
95 scrub_nproc_workqueue(ctx
));
97 str_info(ctx
, ctx
->mntpoint
, _("Could not create workqueue."));
102 * In case we ever use the primary super scrubber to perform fs
103 * upgrades (followed by a full scrub), do that before we launch
106 moveon
= xfs_scrub_primary_super(ctx
);
110 for (agno
= 0; moveon
&& agno
< ctx
->geo
.agcount
; agno
++) {
111 ret
= workqueue_add(&wq
, xfs_scan_ag_metadata
, agno
, &moveon
);
114 str_info(ctx
, ctx
->mntpoint
,
115 _("Could not queue AG %u scrub work."), agno
);
123 ret
= workqueue_add(&wq
, xfs_scan_fs_metadata
, 0, &moveon
);
126 str_info(ctx
, ctx
->mntpoint
,
127 _("Could not queue filesystem scrub work."));
132 workqueue_destroy(&wq
);
136 /* Estimate how much work we're going to do. */
138 xfs_estimate_metadata_work(
139 struct scrub_ctx
*ctx
,
141 unsigned int *nr_threads
,
144 *items
= xfs_scrub_estimate_ag_work(ctx
);
145 *nr_threads
= scrub_nproc(ctx
);