From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 14/18] xfs_scrub: remove moveon from phase 3 functions
Date: Thu, 05 Sep 2019 20:42:23 -0700 [thread overview]
Message-ID: <156774134389.2646807.7574306592470108275.stgit@magnolia> (raw)
In-Reply-To: <156774125578.2646807.1183436616735969617.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Replace the moveon returns in the phase 3 code with a direct integer
error return.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
scrub/phase3.c | 73 +++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 48 insertions(+), 25 deletions(-)
diff --git a/scrub/phase3.c b/scrub/phase3.c
index a5f95004..354cc8ed 100644
--- a/scrub/phase3.c
+++ b/scrub/phase3.c
@@ -38,12 +38,12 @@ scrub_fd(
struct scrub_inode_ctx {
struct ptcounter *icount;
- bool moveon;
+ bool aborted;
};
/* Report a filesystem error that the vfs fed us on close. */
static void
-xfs_scrub_inode_vfs_error(
+report_close_error(
struct scrub_ctx *ctx,
struct xfs_bulkstat *bstat)
{
@@ -58,7 +58,7 @@ xfs_scrub_inode_vfs_error(
/* Verify the contents, xattrs, and extent maps of an inode. */
static int
-xfs_scrub_inode(
+scrub_inode(
struct scrub_ctx *ctx,
struct xfs_handle *handle,
struct xfs_bulkstat *bstat,
@@ -68,7 +68,6 @@ xfs_scrub_inode(
struct scrub_inode_ctx *ictx = arg;
struct ptcounter *icount = ictx->icount;
xfs_agnumber_t agno;
- bool moveon = true;
int fd = -1;
int error;
@@ -136,61 +135,75 @@ xfs_scrub_inode(
out:
if (error)
- moveon = false;
+ ictx->aborted = true;
+
error = ptcounter_add(icount, 1);
if (error) {
str_liberror(ctx, error,
_("incrementing scanned inode counter"));
- return false;
+ ictx->aborted = true;
}
progress_add(1);
action_list_defer(ctx, agno, &alist);
if (fd >= 0) {
- error = close(fd);
- if (error)
- xfs_scrub_inode_vfs_error(ctx, bstat);
+ int err2;
+
+ err2 = close(fd);
+ if (err2) {
+ report_close_error(ctx, bstat);
+ ictx->aborted = true;
+ }
}
- if (!moveon)
- ictx->moveon = false;
- return ictx->moveon ? 0 : XFS_ITERATE_INODES_ABORT;
+
+ if (!error && ictx->aborted)
+ error = ECANCELED;
+ return error;
}
/* Verify all the inodes in a filesystem. */
-bool
-xfs_scan_inodes(
+int
+phase3_func(
struct scrub_ctx *ctx)
{
- struct scrub_inode_ctx ictx;
+ struct scrub_inode_ctx ictx = { NULL };
uint64_t val;
int err;
- ictx.moveon = true;
err = ptcounter_alloc(scrub_nproc(ctx), &ictx.icount);
if (err) {
str_liberror(ctx, err, _("creating scanned inode counter"));
- return false;
+ return err;
}
- err = scrub_scan_all_inodes(ctx, xfs_scrub_inode, &ictx);
+ err = scrub_scan_all_inodes(ctx, scrub_inode, &ictx);
+ if (!err && ictx.aborted)
+ err = ECANCELED;
if (err)
- ictx.moveon = false;
- if (!ictx.moveon)
goto free;
+
xfs_scrub_report_preen_triggers(ctx);
err = ptcounter_value(ictx.icount, &val);
if (err) {
str_liberror(ctx, err, _("summing scanned inode counter"));
- return false;
+ return err;
}
+
ctx->inodes_checked = val;
free:
ptcounter_free(ictx.icount);
- return ictx.moveon;
+ return err;
}
-/* Estimate how much work we're going to do. */
bool
-xfs_estimate_inodes_work(
+xfs_scan_inodes(
+ struct scrub_ctx *ctx)
+{
+ return phase3_func(ctx) == 0;
+}
+
+/* Estimate how much work we're going to do. */
+int
+phase3_estimate(
struct scrub_ctx *ctx,
uint64_t *items,
unsigned int *nr_threads,
@@ -199,5 +212,15 @@ xfs_estimate_inodes_work(
*items = ctx->mnt_sv.f_files - ctx->mnt_sv.f_ffree;
*nr_threads = scrub_nproc(ctx);
*rshift = 0;
- return true;
+ return 0;
+}
+
+bool
+xfs_estimate_inodes_work(
+ struct scrub_ctx *ctx,
+ uint64_t *items,
+ unsigned int *nr_threads,
+ int *rshift)
+{
+ return phase3_estimate(ctx, items, nr_threads, rshift) == 0;
}
next prev parent reply other threads:[~2019-09-06 3:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 3:40 [PATCH 00/18] xfs_scrub: remove moveon space aliens Darrick J. Wong
2019-09-06 3:41 ` [PATCH 01/18] xfs_scrub: remove moveon from filemap iteration Darrick J. Wong
2019-09-06 3:41 ` [PATCH 02/18] xfs_scrub: remove moveon from the fscounters functions Darrick J. Wong
2019-09-06 3:41 ` [PATCH 03/18] xfs_scrub: remove moveon from inode iteration Darrick J. Wong
2019-09-06 3:41 ` [PATCH 04/18] xfs_scrub: remove moveon from vfs directory tree iteration Darrick J. Wong
2019-09-06 3:41 ` [PATCH 05/18] xfs_scrub: remove moveon from spacemap Darrick J. Wong
2019-09-06 3:41 ` [PATCH 06/18] xfs_scrub: remove moveon from unicode name collision helpers Darrick J. Wong
2019-09-06 3:41 ` [PATCH 07/18] xfs_scrub: remove moveon from progress report helpers Darrick J. Wong
2019-09-06 3:41 ` [PATCH 08/18] xfs_scrub: remove moveon from scrub ioctl wrappers Darrick J. Wong
2019-09-06 3:41 ` [PATCH 09/18] xfs_scrub: remove moveon from repair action list helpers Darrick J. Wong
2019-09-06 3:41 ` [PATCH 10/18] xfs_scrub: remove moveon from phase 7 functions Darrick J. Wong
2019-09-06 3:42 ` [PATCH 11/18] xfs_scrub: remove moveon from phase 6 functions Darrick J. Wong
2019-09-06 3:42 ` [PATCH 12/18] xfs_scrub: remove moveon from phase 5 functions Darrick J. Wong
2019-09-06 3:42 ` [PATCH 13/18] xfs_scrub: remove moveon from phase 4 functions Darrick J. Wong
2019-09-06 3:42 ` Darrick J. Wong [this message]
2019-09-06 3:42 ` [PATCH 15/18] xfs_scrub: remove moveon from phase 2 functions Darrick J. Wong
2019-09-06 3:42 ` [PATCH 16/18] xfs_scrub: remove moveon from phase 1 functions Darrick J. Wong
2019-09-06 3:42 ` [PATCH 17/18] xfs_scrub: remove XFS_ITERATE_INODES_ABORT from inode iterator Darrick J. Wong
2019-09-06 3:42 ` [PATCH 18/18] xfs_scrub: remove moveon from main program Darrick J. Wong
2019-09-25 21:38 [PATCH 00/18] xfs_scrub: remove moveon space aliens Darrick J. Wong
2019-09-25 21:39 ` [PATCH 14/18] xfs_scrub: remove moveon from phase 3 functions Darrick J. Wong
2019-10-22 18:50 [PATCH 00/18] xfs_scrub: remove moveon space aliens Darrick J. Wong
2019-10-22 18:51 ` [PATCH 14/18] xfs_scrub: remove moveon from phase 3 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=156774134389.2646807.7574306592470108275.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).