-// SPDX-License-Identifier: GPL-2.0+
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
- * Copyright (C) 2018 Oracle. All Rights Reserved.
- * Author: Darrick J. Wong <darrick.wong@oracle.com>
+ * Copyright (C) 2018-2024 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <djwong@kernel.org>
*/
#ifndef XFS_SCRUB_XFS_SCRUB_H_
#define XFS_SCRUB_XFS_SCRUB_H_
+#include "libfrog/fsgeom.h"
+
+extern char *progname;
+
#define _PATH_PROC_MOUNTS "/proc/mounts"
-extern unsigned int nr_threads;
+extern unsigned int force_nr_threads;
extern unsigned int bg_mode;
extern unsigned int debug;
-extern int nproc;
extern bool verbose;
extern long page_size;
extern bool want_fstrim;
extern bool stderr_isatty;
extern bool stdout_isatty;
extern bool is_service;
+extern bool use_force_rebuild;
enum scrub_mode {
SCRUB_MODE_DRY_RUN,
/* How does the user want us to react to errors? */
enum error_action error_action;
- /* fd to filesystem mount point */
- int mnt_fd;
+ /* xfrog context for the mount point */
+ struct xfs_fd mnt;
/* Number of threads for metadata scrubbing */
unsigned int nr_io_threads;
/* XFS specific geometry */
- struct xfs_fsop_geom geo;
struct fs_path fsinfo;
- unsigned int agblklog;
- unsigned int blocklog;
- unsigned int inodelog;
- unsigned int inopblog;
void *fshandle;
size_t fshandle_len;
/* Mutable scrub state; use lock. */
pthread_mutex_t lock;
- struct xfs_action_list *action_lists;
+ struct action_list *action_lists;
unsigned long long max_errors;
unsigned long long runtime_errors;
- unsigned long long errors_found;
+ unsigned long long corruptions_found;
+ unsigned long long unfixable_errors;
unsigned long long warnings_found;
unsigned long long inodes_checked;
unsigned long long bytes_checked;
/* Phase helper functions */
void xfs_shutdown_fs(struct scrub_ctx *ctx);
-bool xfs_cleanup_fs(struct scrub_ctx *ctx);
-bool xfs_setup_fs(struct scrub_ctx *ctx);
-bool xfs_scan_metadata(struct scrub_ctx *ctx);
-bool xfs_scan_inodes(struct scrub_ctx *ctx);
-bool xfs_scan_connections(struct scrub_ctx *ctx);
-bool xfs_scan_blocks(struct scrub_ctx *ctx);
-bool xfs_scan_summary(struct scrub_ctx *ctx);
-bool xfs_repair_fs(struct scrub_ctx *ctx);
+int scrub_cleanup(struct scrub_ctx *ctx);
+int phase1_func(struct scrub_ctx *ctx);
+int phase2_func(struct scrub_ctx *ctx);
+int phase3_func(struct scrub_ctx *ctx);
+int phase4_func(struct scrub_ctx *ctx);
+int phase5_func(struct scrub_ctx *ctx);
+int phase6_func(struct scrub_ctx *ctx);
+int phase7_func(struct scrub_ctx *ctx);
/* Progress estimator functions */
-uint64_t xfs_estimate_inodes(struct scrub_ctx *ctx);
-unsigned int xfs_scrub_estimate_ag_work(struct scrub_ctx *ctx);
-bool xfs_estimate_metadata_work(struct scrub_ctx *ctx, uint64_t *items,
- unsigned int *nr_threads, int *rshift);
-bool xfs_estimate_inodes_work(struct scrub_ctx *ctx, uint64_t *items,
- unsigned int *nr_threads, int *rshift);
-bool xfs_estimate_repair_work(struct scrub_ctx *ctx, uint64_t *items,
- unsigned int *nr_threads, int *rshift);
-bool xfs_estimate_verify_work(struct scrub_ctx *ctx, uint64_t *items,
- unsigned int *nr_threads, int *rshift);
+unsigned int scrub_estimate_ag_work(struct scrub_ctx *ctx);
+int phase2_estimate(struct scrub_ctx *ctx, uint64_t *items,
+ unsigned int *nr_threads, int *rshift);
+int phase3_estimate(struct scrub_ctx *ctx, uint64_t *items,
+ unsigned int *nr_threads, int *rshift);
+int phase4_estimate(struct scrub_ctx *ctx, uint64_t *items,
+ unsigned int *nr_threads, int *rshift);
+int phase5_estimate(struct scrub_ctx *ctx, uint64_t *items,
+ unsigned int *nr_threads, int *rshift);
+int phase6_estimate(struct scrub_ctx *ctx, uint64_t *items,
+ unsigned int *nr_threads, int *rshift);
#endif /* XFS_SCRUB_XFS_SCRUB_H_ */