#include <sys/types.h>
#include <sys/statvfs.h>
#include "list.h"
-#include "path.h"
-#include "workqueue.h"
+#include "libfrog/paths.h"
+#include "libfrog/workqueue.h"
#include "xfs_scrub.h"
#include "common.h"
#include "scrub.h"
{
struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
bool *pmoveon = arg;
- struct xfs_action_list alist;
- struct xfs_action_list immediate_alist;
+ struct action_list alist;
+ struct action_list immediate_alist;
unsigned long long broken_primaries;
unsigned long long broken_secondaries;
- bool moveon;
char descr[DESCR_BUFSZ];
+ int ret;
- xfs_action_list_init(&alist);
- xfs_action_list_init(&immediate_alist);
+ action_list_init(&alist);
+ action_list_init(&immediate_alist);
snprintf(descr, DESCR_BUFSZ, _("AG %u"), agno);
/*
* First we scrub and fix the AG headers, because we need
* them to work well enough to check the AG btrees.
*/
- moveon = xfs_scrub_ag_headers(ctx, agno, &alist);
- if (!moveon)
+ ret = xfs_scrub_ag_headers(ctx, agno, &alist);
+ if (ret)
goto err;
/* Repair header damage. */
- moveon = xfs_action_list_process_or_defer(ctx, agno, &alist);
- if (!moveon)
+ ret = action_list_process_or_defer(ctx, agno, &alist);
+ if (ret)
goto err;
/* Now scrub the AG btrees. */
- moveon = xfs_scrub_ag_metadata(ctx, agno, &alist);
- if (!moveon)
+ ret = xfs_scrub_ag_metadata(ctx, agno, &alist);
+ if (ret)
goto err;
/*
*/
broken_secondaries = 0;
broken_primaries = 0;
- xfs_action_list_find_mustfix(&alist, &immediate_alist,
+ action_list_find_mustfix(&alist, &immediate_alist,
&broken_primaries, &broken_secondaries);
if (broken_secondaries && !debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) {
if (broken_primaries)
}
/* Repair (inode) btree damage. */
- moveon = xfs_action_list_process_or_defer(ctx, agno, &immediate_alist);
- if (!moveon)
+ ret = action_list_process_or_defer(ctx, agno, &immediate_alist);
+ if (ret)
goto err;
/* Everything else gets fixed during phase 4. */
- xfs_action_list_defer(ctx, agno, &alist);
+ action_list_defer(ctx, agno, &alist);
return;
err:
{
struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
bool *pmoveon = arg;
- struct xfs_action_list alist;
- bool moveon;
+ struct action_list alist;
+ int ret;
- xfs_action_list_init(&alist);
- moveon = xfs_scrub_fs_metadata(ctx, &alist);
- if (!moveon)
+ action_list_init(&alist);
+ ret = xfs_scrub_fs_metadata(ctx, &alist);
+ if (ret)
*pmoveon = false;
- xfs_action_list_defer(ctx, agno, &alist);
+ action_list_defer(ctx, agno, &alist);
}
/* Scan all filesystem metadata. */
xfs_scan_metadata(
struct scrub_ctx *ctx)
{
- struct xfs_action_list alist;
+ struct action_list alist;
struct workqueue wq;
xfs_agnumber_t agno;
bool moveon = true;
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
if (ret) {
- str_info(ctx, ctx->mntpoint, _("Could not create workqueue."));
+ str_liberror(ctx, ret, _("creating scrub workqueue"));
return false;
}
* upgrades (followed by a full scrub), do that before we launch
* anything else.
*/
- xfs_action_list_init(&alist);
- moveon = xfs_scrub_primary_super(ctx, &alist);
- if (!moveon)
+ action_list_init(&alist);
+ ret = xfs_scrub_primary_super(ctx, &alist);
+ if (ret) {
+ moveon = false;
goto out;
- moveon = xfs_action_list_process_or_defer(ctx, 0, &alist);
- if (!moveon)
+ }
+ ret = action_list_process_or_defer(ctx, 0, &alist);
+ if (ret) {
+ moveon = false;
goto out;
+ }
for (agno = 0; moveon && agno < ctx->mnt.fsgeom.agcount; agno++) {
ret = workqueue_add(&wq, xfs_scan_ag_metadata, agno, &moveon);
if (ret) {
moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue AG %u scrub work."), agno);
+ str_liberror(ctx, ret, _("queueing per-AG scrub work"));
goto out;
}
}
ret = workqueue_add(&wq, xfs_scan_fs_metadata, 0, &moveon);
if (ret) {
moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue filesystem scrub work."));
+ str_liberror(ctx, ret, _("queueing per-FS scrub work"));
goto out;
}
out:
+ ret = workqueue_terminate(&wq);
+ if (ret) {
+ moveon = false;
+ str_liberror(ctx, ret, _("finishing scrub work"));
+ }
workqueue_destroy(&wq);
return moveon;
}
unsigned int *nr_threads,
int *rshift)
{
- *items = xfs_scrub_estimate_ag_work(ctx);
+ *items = scrub_estimate_ag_work(ctx);
*nr_threads = scrub_nproc(ctx);
*rshift = 0;
return true;