+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2018 Oracle. All Rights Reserved.
- *
* Author: Darrick J. Wong <darrick.wong@oracle.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include <stdio.h>
-#include <mntent.h>
+#include "xfs.h"
#include <unistd.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/statvfs.h>
-#include <sys/vfs.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdint.h>
-#include <stdbool.h>
#include <pthread.h>
-#include <errno.h>
-#include <linux/fs.h>
#include "libfrog.h"
#include "workqueue.h"
#include "input.h"
#include "path.h"
#include "handle.h"
#include "bitops.h"
-#include "xfs_arch.h"
-#include "xfs_format.h"
#include "avl64.h"
#include "list.h"
#include "xfs_scrub.h"
#include "common.h"
#include "disk.h"
#include "scrub.h"
+#include "repair.h"
/* Phase 1: Find filesystem geometry (and clean up after) */
xfs_cleanup_fs(
struct scrub_ctx *ctx)
{
+ int error;
+
+ xfs_action_lists_free(&ctx->action_lists);
if (ctx->fshandle)
free_handle(ctx->fshandle, ctx->fshandle_len);
if (ctx->rtdev)
if (ctx->datadev)
disk_close(ctx->datadev);
fshandle_destroy();
- close(ctx->mnt_fd);
+ error = close(ctx->mnt_fd);
+ if (error)
+ str_errno(ctx, _("closing mountpoint fd"));
fs_table_destroy();
return true;
xfs_setup_fs(
struct scrub_ctx *ctx)
{
- struct fs_path *fsp;
int error;
/*
return false;
}
- ctx->nr_io_threads = nproc;
- if (verbose) {
- fprintf(stdout, _("%s: using %d threads to scrub.\n"),
- ctx->mntpoint, scrub_nproc(ctx));
- fflush(stdout);
- }
-
if (!platform_test_xfs_fd(ctx->mnt_fd)) {
- str_error(ctx, ctx->mntpoint,
+ str_info(ctx, ctx->mntpoint,
_("Does not appear to be an XFS filesystem!"));
return false;
}
return false;
}
+ if (!xfs_action_lists_alloc(ctx->geo.agcount, &ctx->action_lists)) {
+ str_error(ctx, ctx->mntpoint, _("Not enough memory."));
+ return false;
+ }
+
ctx->agblklog = log2_roundup(ctx->geo.agblocks);
ctx->blocklog = highbit32(ctx->geo.blocksize);
ctx->inodelog = highbit32(ctx->geo.inodesize);
return false;
}
- /* Go find the XFS devices if we have a usable fsmap. */
- fs_table_initialise(0, NULL, 0, NULL);
- errno = 0;
- fsp = fs_table_lookup(ctx->mntpoint, FS_MOUNT_POINT);
- if (!fsp) {
- str_error(ctx, ctx->mntpoint,
-_("Unable to find XFS information."));
- return false;
- }
- memcpy(&ctx->fsinfo, fsp, sizeof(struct fs_path));
-
/* Did we find the log and rt devices, if they're present? */
if (ctx->geo.logstart == 0 && ctx->fsinfo.fs_log == NULL) {
- str_error(ctx, ctx->mntpoint,
+ str_info(ctx, ctx->mntpoint,
_("Unable to find log device path."));
return false;
}
if (ctx->geo.rtblocks && ctx->fsinfo.fs_rt == NULL) {
- str_error(ctx, ctx->mntpoint,
+ str_info(ctx, ctx->mntpoint,
_("Unable to find realtime device path."));
return false;
}
return false;
}
+ ctx->nr_io_threads = disk_heads(ctx->datadev);
+ if (verbose) {
+ fprintf(stdout, _("%s: using %d threads to scrub.\n"),
+ ctx->mntpoint, scrub_nproc(ctx));
+ fflush(stdout);
+ }
+
if (ctx->fsinfo.fs_log) {
ctx->logdev = disk_open(ctx->fsinfo.fs_log);
if (error) {
* this point are most probably corruption errors (as opposed to
* purely setup errors).
*/
- ctx->need_repair = true;
+ log_info(ctx, _("Invoking online scrub."), ctx);
+ ctx->scrub_setup_succeeded = true;
return true;
}