From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 13/18] xfs_scrub: remove moveon from phase 4 functions
Date: Tue, 22 Oct 2019 11:51:50 -0700 [thread overview]
Message-ID: <157177031075.1461658.2997489260715360653.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 4 code with a direct integer
error return.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
scrub/phase4.c | 86 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 49 insertions(+), 37 deletions(-)
diff --git a/scrub/phase4.c b/scrub/phase4.c
index c6de1cd4..f9dcf9c8 100644
--- a/scrub/phase4.c
+++ b/scrub/phase4.c
@@ -22,13 +22,13 @@
/* Fix all the problems in our per-AG list. */
static void
-xfs_repair_ag(
+repair_ag(
struct workqueue *wq,
xfs_agnumber_t agno,
void *priv)
{
struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
- bool *pmoveon = priv;
+ bool *aborted = priv;
struct action_list *alist;
size_t unfixed;
size_t new_unfixed;
@@ -42,78 +42,73 @@ xfs_repair_ag(
do {
ret = action_list_process(ctx, ctx->mnt.fd, alist, flags);
if (ret) {
- *pmoveon = false;
+ *aborted = true;
return;
}
new_unfixed = action_list_length(alist);
if (new_unfixed == unfixed)
break;
unfixed = new_unfixed;
- } while (unfixed > 0 && *pmoveon);
-
- if (!*pmoveon)
- return;
+ if (*aborted)
+ return;
+ } while (unfixed > 0);
/* Try once more, but this time complain if we can't fix things. */
flags |= ALP_COMPLAIN_IF_UNFIXED;
ret = action_list_process(ctx, ctx->mnt.fd, alist, flags);
if (ret)
- *pmoveon = false;
+ *aborted = true;
}
/* Process all the action items. */
-static bool
-xfs_process_action_items(
+static int
+repair_everything(
struct scrub_ctx *ctx)
{
struct workqueue wq;
xfs_agnumber_t agno;
- bool moveon = true;
+ bool aborted = false;
int ret;
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
if (ret) {
str_liberror(ctx, ret, _("creating repair workqueue"));
- return false;
+ return ret;
}
- for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++) {
- if (action_list_length(&ctx->action_lists[agno]) > 0) {
- ret = workqueue_add(&wq, xfs_repair_ag, agno, &moveon);
- if (ret) {
- moveon = false;
- str_liberror(ctx, ret,
- _("queueing repair work"));
- break;
- }
- }
- if (!moveon)
+ for (agno = 0; !aborted && agno < ctx->mnt.fsgeom.agcount; agno++) {
+ if (action_list_length(&ctx->action_lists[agno]) == 0)
+ continue;
+
+ ret = workqueue_add(&wq, repair_ag, agno, &aborted);
+ if (ret) {
+ str_liberror(ctx, ret, _("queueing repair work"));
break;
+ }
}
ret = workqueue_terminate(&wq);
- if (ret) {
- moveon = false;
+ if (ret)
str_liberror(ctx, ret, _("finishing repair work"));
- }
workqueue_destroy(&wq);
+ if (aborted)
+ return ECANCELED;
+
pthread_mutex_lock(&ctx->lock);
- if (moveon &&
- ctx->corruptions_found == 0 &&
- ctx->unfixable_errors == 0 &&
+ if (ctx->corruptions_found == 0 && ctx->unfixable_errors == 0 &&
want_fstrim) {
fstrim(ctx);
progress_add(1);
}
pthread_mutex_unlock(&ctx->lock);
- return moveon;
+ return 0;
}
/* Fix everything that needs fixing. */
-bool
-xfs_repair_fs(
+int
+phase4_func(
struct scrub_ctx *ctx)
{
int ret;
@@ -126,14 +121,21 @@ xfs_repair_fs(
*/
ret = xfs_scrub_fs_summary(ctx, &ctx->action_lists[0]);
if (ret)
- return false;
+ return ret;
- return xfs_process_action_items(ctx);
+ return repair_everything(ctx);
}
-/* Estimate how much work we're going to do. */
bool
-xfs_estimate_repair_work(
+xfs_repair_fs(
+ struct scrub_ctx *ctx)
+{
+ return phase4_func(ctx) == 0;
+}
+
+/* Estimate how much work we're going to do. */
+int
+phase4_estimate(
struct scrub_ctx *ctx,
uint64_t *items,
unsigned int *nr_threads,
@@ -148,5 +150,15 @@ xfs_estimate_repair_work(
*items = need_fixing;
*nr_threads = scrub_nproc(ctx) + 1;
*rshift = 0;
- return true;
+ return 0;
+}
+
+bool
+xfs_estimate_repair_work(
+ struct scrub_ctx *ctx,
+ uint64_t *items,
+ unsigned int *nr_threads,
+ int *rshift)
+{
+ return phase4_estimate(ctx, items, nr_threads, rshift) == 0;
}
next prev parent reply other threads:[~2019-10-22 18:51 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 ` Darrick J. Wong [this message]
2019-10-22 18:51 ` [PATCH 14/18] xfs_scrub: remove moveon from phase 3 functions Darrick J. Wong
2019-10-22 18:52 ` [PATCH 15/18] xfs_scrub: remove moveon from phase 2 functions Darrick J. Wong
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 13/18] xfs_scrub: remove moveon from phase 4 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 13/18] xfs_scrub: remove moveon from phase 4 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=157177031075.1461658.2997489260715360653.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).