From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 15/18] xfs_scrub: remove moveon from phase 2 functions
Date: Tue, 22 Oct 2019 11:52:03 -0700 [thread overview]
Message-ID: <157177032323.1461658.21686041578460153.stgit@magnolia> (raw)
In-Reply-To: <157177022106.1461658.18024534947316119946.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Replace the moveon returns in the phase 2 code with a direct integer
error return.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
scrub/phase2.c | 88 +++++++++++++++++++++++++++++++++++---------------------
1 file changed, 55 insertions(+), 33 deletions(-)
diff --git a/scrub/phase2.c b/scrub/phase2.c
index 7388b8e2..81b2b3dc 100644
--- a/scrub/phase2.c
+++ b/scrub/phase2.c
@@ -19,13 +19,13 @@
/* Scrub each AG's metadata btrees. */
static void
-xfs_scan_ag_metadata(
+scan_ag_metadata(
struct workqueue *wq,
xfs_agnumber_t agno,
void *arg)
{
struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
- bool *pmoveon = arg;
+ bool *aborted = arg;
struct action_list alist;
struct action_list immediate_alist;
unsigned long long broken_primaries;
@@ -33,6 +33,9 @@ xfs_scan_ag_metadata(
char descr[DESCR_BUFSZ];
int ret;
+ if (*aborted)
+ return;
+
action_list_init(&alist);
action_list_init(&immediate_alist);
snprintf(descr, DESCR_BUFSZ, _("AG %u"), agno);
@@ -84,48 +87,52 @@ _("Filesystem might not be repairable."));
/* Everything else gets fixed during phase 4. */
action_list_defer(ctx, agno, &alist);
-
return;
err:
- *pmoveon = false;
+ *aborted = true;
}
/* Scrub whole-FS metadata btrees. */
static void
-xfs_scan_fs_metadata(
+scan_fs_metadata(
struct workqueue *wq,
xfs_agnumber_t agno,
void *arg)
{
struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
- bool *pmoveon = arg;
+ bool *aborted = arg;
struct action_list alist;
int ret;
+ if (*aborted)
+ return;
+
action_list_init(&alist);
ret = xfs_scrub_fs_metadata(ctx, &alist);
- if (ret)
- *pmoveon = false;
+ if (ret) {
+ *aborted = true;
+ return;
+ }
action_list_defer(ctx, agno, &alist);
}
/* Scan all filesystem metadata. */
-bool
-xfs_scan_metadata(
+int
+phase2_func(
struct scrub_ctx *ctx)
{
struct action_list alist;
struct workqueue wq;
xfs_agnumber_t agno;
- bool moveon = true;
- int ret;
+ bool aborted = false;
+ int ret, ret2;
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
if (ret) {
str_liberror(ctx, ret, _("creating scrub workqueue"));
- return false;
+ return ret;
}
/*
@@ -135,48 +142,53 @@ xfs_scan_metadata(
*/
action_list_init(&alist);
ret = xfs_scrub_primary_super(ctx, &alist);
- if (ret) {
- moveon = false;
+ if (ret)
goto out;
- }
ret = action_list_process_or_defer(ctx, 0, &alist);
- if (ret) {
- moveon = false;
+ if (ret)
goto out;
- }
- for (agno = 0; moveon && agno < ctx->mnt.fsgeom.agcount; agno++) {
- ret = workqueue_add(&wq, xfs_scan_ag_metadata, agno, &moveon);
+ for (agno = 0; !aborted && agno < ctx->mnt.fsgeom.agcount; agno++) {
+ ret = workqueue_add(&wq, scan_ag_metadata, agno, &aborted);
if (ret) {
- moveon = false;
str_liberror(ctx, ret, _("queueing per-AG scrub work"));
goto out;
}
}
- if (!moveon)
+ if (aborted)
goto out;
- ret = workqueue_add(&wq, xfs_scan_fs_metadata, 0, &moveon);
+ ret = workqueue_add(&wq, scan_fs_metadata, 0, &aborted);
if (ret) {
- moveon = false;
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"));
+ ret2 = workqueue_terminate(&wq);
+ if (ret2) {
+ str_liberror(ctx, ret2, _("finishing scrub work"));
+ if (!ret && ret2)
+ ret = ret2;
}
workqueue_destroy(&wq);
- return moveon;
+
+ if (!ret && aborted)
+ ret = ECANCELED;
+ return ret;
}
-/* Estimate how much work we're going to do. */
bool
-xfs_estimate_metadata_work(
+xfs_scan_metadata(
+ struct scrub_ctx *ctx)
+{
+ return phase2_func(ctx) == 0;
+}
+
+/* Estimate how much work we're going to do. */
+int
+phase2_estimate(
struct scrub_ctx *ctx,
uint64_t *items,
unsigned int *nr_threads,
@@ -185,5 +197,15 @@ xfs_estimate_metadata_work(
*items = scrub_estimate_ag_work(ctx);
*nr_threads = scrub_nproc(ctx);
*rshift = 0;
- return true;
+ return 0;
+}
+
+bool
+xfs_estimate_metadata_work(
+ struct scrub_ctx *ctx,
+ uint64_t *items,
+ unsigned int *nr_threads,
+ int *rshift)
+{
+ return phase2_estimate(ctx, items, nr_threads, rshift) == 0;
}
next prev parent reply other threads:[~2019-10-22 18:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 18:50 [PATCH 00/18] xfs_scrub: remove moveon space aliens Darrick J. Wong
2019-10-22 18:50 ` [PATCH 01/18] xfs_scrub: remove moveon from filemap iteration Darrick J. Wong
2019-11-06 21:01 ` [PATCH v2 " Darrick J. Wong
2019-11-06 21:37 ` Eric Sandeen
2019-10-22 18:50 ` [PATCH 02/18] xfs_scrub: remove moveon from the fscounters functions Darrick J. Wong
2019-10-22 18:50 ` [PATCH 03/18] xfs_scrub: remove moveon from inode iteration Darrick J. Wong
2019-10-22 18:50 ` [PATCH 04/18] xfs_scrub: remove moveon from vfs directory tree iteration Darrick J. Wong
2019-10-22 18:50 ` [PATCH 05/18] xfs_scrub: remove moveon from spacemap Darrick J. Wong
2019-11-06 21:02 ` [PATCH v2 " Darrick J. Wong
2019-10-22 18:51 ` [PATCH 06/18] xfs_scrub: remove moveon from unicode name collision helpers Darrick J. Wong
2019-10-22 18:51 ` [PATCH 07/18] xfs_scrub: remove moveon from progress report helpers Darrick J. Wong
2019-10-22 18:51 ` [PATCH 08/18] xfs_scrub: remove moveon from scrub ioctl wrappers Darrick J. Wong
2019-10-22 18:51 ` [PATCH 09/18] xfs_scrub: remove moveon from repair action list helpers Darrick J. Wong
2019-10-22 18:51 ` [PATCH 10/18] xfs_scrub: remove moveon from phase 7 functions Darrick J. Wong
2019-10-22 18:51 ` [PATCH 11/18] xfs_scrub: remove moveon from phase 6 functions Darrick J. Wong
2019-11-06 21:02 ` [PATCH v2 " Darrick J. Wong
2019-10-22 18:51 ` [PATCH 12/18] xfs_scrub: remove moveon from phase 5 functions Darrick J. Wong
2019-10-22 18:51 ` [PATCH 13/18] xfs_scrub: remove moveon from phase 4 functions Darrick J. Wong
2019-10-22 18:51 ` [PATCH 14/18] xfs_scrub: remove moveon from phase 3 functions Darrick J. Wong
2019-10-22 18:52 ` Darrick J. Wong [this message]
2019-10-22 18:52 ` [PATCH 16/18] xfs_scrub: remove moveon from phase 1 functions Darrick J. Wong
2019-10-22 18:52 ` [PATCH 17/18] xfs_scrub: remove XFS_ITERATE_INODES_ABORT from inode iterator Darrick J. Wong
2019-10-22 18:52 ` [PATCH 18/18] xfs_scrub: remove moveon from main program Darrick J. Wong
2019-11-06 21:03 ` [PATCH v2 " Darrick J. Wong
2019-11-06 22:24 ` [PATCH 00/18] xfs_scrub: remove moveon space aliens Eric Sandeen
-- strict thread matches above, loose matches on Subject: below --
2019-09-25 21:38 Darrick J. Wong
2019-09-25 21:39 ` [PATCH 15/18] xfs_scrub: remove moveon from phase 2 functions Darrick J. Wong
2019-09-06 3:40 [PATCH 00/18] xfs_scrub: remove moveon space aliens Darrick J. Wong
2019-09-06 3:42 ` [PATCH 15/18] xfs_scrub: remove moveon from phase 2 functions Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=157177032323.1461658.21686041578460153.stgit@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).