From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 02/18] xfs_scrub: remove moveon from the fscounters functions
Date: Tue, 22 Oct 2019 11:50:33 -0700 [thread overview]
Message-ID: <157177023383.1461658.2534164192787910385.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 fscounters functions with direct error
returns. Drop the xfs_ prefixes while we're at it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
scrub/fscounters.c | 129 ++++++++++++++++++++--------------------------------
scrub/fscounters.h | 4 +-
scrub/phase6.c | 12 +++--
scrub/phase7.c | 15 ++++--
4 files changed, 68 insertions(+), 92 deletions(-)
diff --git a/scrub/fscounters.c b/scrub/fscounters.c
index e064c865..2581947f 100644
--- a/scrub/fscounters.c
+++ b/scrub/fscounters.c
@@ -25,8 +25,8 @@
/* Count the number of inodes in the filesystem. */
/* INUMBERS wrapper routines. */
-struct xfs_count_inodes {
- bool moveon;
+struct count_inodes {
+ int error;
uint64_t counters[0];
};
@@ -34,13 +34,14 @@ struct xfs_count_inodes {
* Count the number of inodes. Use INUMBERS to figure out how many inodes
* exist in the filesystem, assuming we've already scrubbed that.
*/
-static bool
-xfs_count_inodes_ag(
- struct scrub_ctx *ctx,
- const char *descr,
- uint32_t agno,
- uint64_t *count)
+static void
+count_ag_inodes(
+ struct workqueue *wq,
+ xfs_agnumber_t agno,
+ void *arg)
{
+ struct count_inodes *ci = arg;
+ struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
struct xfs_inumbers_req *ireq;
uint64_t nr = 0;
unsigned int i;
@@ -48,107 +49,78 @@ xfs_count_inodes_ag(
ireq = xfrog_inumbers_alloc_req(64, 0);
if (!ireq) {
- str_liberror(ctx, ENOMEM, _("allocating inumbers request"));
- return false;
+ ci->error = errno;
+ return;
}
xfrog_inumbers_set_ag(ireq, agno);
- while (!(error = xfrog_inumbers(&ctx->mnt, ireq))) {
+ while (!ci->error && (error = xfrog_inumbers(&ctx->mnt, ireq)) == 0) {
if (ireq->hdr.ocount == 0)
break;
for (i = 0; i < ireq->hdr.ocount; i++)
nr += ireq->inumbers[i].xi_alloccount;
}
+ if (error)
+ ci->error = error;
free(ireq);
- if (error) {
- str_liberror(ctx, error, descr);
- return false;
- }
-
- *count = nr;
- return true;
-}
-
-/* Scan all the inodes in an AG. */
-static void
-xfs_count_ag_inodes(
- struct workqueue *wq,
- xfs_agnumber_t agno,
- void *arg)
-{
- struct xfs_count_inodes *ci = arg;
- struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
- char descr[DESCR_BUFSZ];
- bool moveon;
-
- snprintf(descr, DESCR_BUFSZ, _("dev %d:%d AG %u inodes"),
- major(ctx->fsinfo.fs_datadev),
- minor(ctx->fsinfo.fs_datadev),
- agno);
-
- moveon = xfs_count_inodes_ag(ctx, descr, agno, &ci->counters[agno]);
- if (!moveon)
- ci->moveon = false;
+ ci->counters[agno] = nr;
}
-/* Count all the inodes in a filesystem. */
-bool
-xfs_count_all_inodes(
+/*
+ * Count all the inodes in a filesystem. Returns 0 or a positive error number.
+ */
+int
+scrub_count_all_inodes(
struct scrub_ctx *ctx,
uint64_t *count)
{
- struct xfs_count_inodes *ci;
+ struct count_inodes *ci;
xfs_agnumber_t agno;
struct workqueue wq;
- bool moveon = true;
- int ret;
+ int ret, ret2;
- ci = calloc(1, sizeof(struct xfs_count_inodes) +
+ ci = calloc(1, sizeof(struct count_inodes) +
(ctx->mnt.fsgeom.agcount * sizeof(uint64_t)));
if (!ci)
- return false;
- ci->moveon = true;
+ return errno;
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
- if (ret) {
- moveon = false;
- str_liberror(ctx, ret, _("creating icount workqueue"));
+ if (ret)
goto out_free;
- }
- for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++) {
- ret = workqueue_add(&wq, xfs_count_ag_inodes, agno, ci);
- if (ret) {
- moveon = false;
- str_liberror(ctx, ret, _("queueing icount work"));
+
+ for (agno = 0; agno < ctx->mnt.fsgeom.agcount && !ci->error; agno++) {
+ ret = workqueue_add(&wq, count_ag_inodes, agno, ci);
+ if (ret)
break;
- }
}
- ret = workqueue_terminate(&wq);
- if (ret) {
- moveon = false;
- str_liberror(ctx, ret, _("finishing icount work"));
- }
+ ret2 = workqueue_terminate(&wq);
+ if (!ret && ret2)
+ ret = ret2;
workqueue_destroy(&wq);
- if (!moveon)
+ if (ci->error) {
+ ret = ci->error;
goto out_free;
+ }
for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++)
*count += ci->counters[agno];
- moveon = ci->moveon;
out_free:
free(ci);
- return moveon;
+ return ret;
}
-/* Estimate the number of blocks and inodes in the filesystem. */
-bool
-xfs_scan_estimate_blocks(
+/*
+ * Estimate the number of blocks and inodes in the filesystem. Returns 0
+ * or a positive error number.
+ */
+int
+scrub_scan_estimate_blocks(
struct scrub_ctx *ctx,
unsigned long long *d_blocks,
unsigned long long *d_bfree,
@@ -164,17 +136,13 @@ xfs_scan_estimate_blocks(
/* Grab the fstatvfs counters, since it has to report accurately. */
error = fstatvfs(ctx->mnt.fd, &sfs);
- if (error) {
- str_errno(ctx, ctx->mntpoint);
- return false;
- }
+ if (error)
+ return errno;
/* Fetch the filesystem counters. */
error = ioctl(ctx->mnt.fd, XFS_IOC_FSCOUNTS, &fc);
- if (error) {
- str_errno(ctx, ctx->mntpoint);
- return false;
- }
+ if (error)
+ return errno;
/*
* XFS reserves some blocks to prevent hard ENOSPC, so add those
@@ -182,7 +150,8 @@ xfs_scan_estimate_blocks(
*/
error = ioctl(ctx->mnt.fd, XFS_IOC_GET_RESBLKS, &rb);
if (error)
- str_errno(ctx, ctx->mntpoint);
+ return errno;
+
sfs.f_bfree += rb.resblks_avail;
*d_blocks = sfs.f_blocks;
@@ -194,5 +163,5 @@ xfs_scan_estimate_blocks(
*f_files = sfs.f_files;
*f_free = sfs.f_ffree;
- return true;
+ return 0;
}
diff --git a/scrub/fscounters.h b/scrub/fscounters.h
index e3a79740..1fae58a6 100644
--- a/scrub/fscounters.h
+++ b/scrub/fscounters.h
@@ -6,10 +6,10 @@
#ifndef XFS_SCRUB_FSCOUNTERS_H_
#define XFS_SCRUB_FSCOUNTERS_H_
-bool xfs_scan_estimate_blocks(struct scrub_ctx *ctx,
+int scrub_scan_estimate_blocks(struct scrub_ctx *ctx,
unsigned long long *d_blocks, unsigned long long *d_bfree,
unsigned long long *r_blocks, unsigned long long *r_bfree,
unsigned long long *f_files, unsigned long long *f_free);
-bool xfs_count_all_inodes(struct scrub_ctx *ctx, uint64_t *count);
+int scrub_count_all_inodes(struct scrub_ctx *ctx, uint64_t *count);
#endif /* XFS_SCRUB_FSCOUNTERS_H_ */
diff --git a/scrub/phase6.c b/scrub/phase6.c
index 0f22af59..6a8dabe1 100644
--- a/scrub/phase6.c
+++ b/scrub/phase6.c
@@ -776,17 +776,19 @@ xfs_estimate_verify_work(
unsigned long long r_bfree;
unsigned long long f_files;
unsigned long long f_free;
- bool moveon;
+ int ret;
- moveon = xfs_scan_estimate_blocks(ctx, &d_blocks, &d_bfree,
+ ret = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree,
&r_blocks, &r_bfree, &f_files, &f_free);
- if (!moveon)
- return moveon;
+ if (ret) {
+ str_liberror(ctx, ret, _("estimating verify work"));
+ return false;
+ }
*items = cvt_off_fsb_to_b(&ctx->mnt, d_blocks + r_blocks);
if (scrub_data == 1)
*items -= cvt_off_fsb_to_b(&ctx->mnt, d_bfree + r_bfree);
*nr_threads = disk_heads(ctx->datadev);
*rshift = 20;
- return moveon;
+ return true;
}
diff --git a/scrub/phase7.c b/scrub/phase7.c
index 2622bc45..64e52359 100644
--- a/scrub/phase7.c
+++ b/scrub/phase7.c
@@ -156,14 +156,19 @@ xfs_scan_summary(
ptvar_free(ptvar);
/* Scan the whole fs. */
- moveon = xfs_count_all_inodes(ctx, &counted_inodes);
- if (!moveon)
+ error = scrub_count_all_inodes(ctx, &counted_inodes);
+ if (error) {
+ str_liberror(ctx, error, _("counting inodes"));
+ moveon = false;
goto out;
+ }
- moveon = xfs_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, &r_blocks,
+ error = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, &r_blocks,
&r_bfree, &f_files, &f_free);
- if (!moveon)
- return moveon;
+ if (error) {
+ str_liberror(ctx, error, _("estimating verify work"));
+ return false;
+ }
/*
* If we counted blocks with fsmap, then dblocks includes
next prev parent reply other threads:[~2019-10-22 18:50 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 ` Darrick J. Wong [this message]
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 ` [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:38 ` [PATCH 02/18] xfs_scrub: remove moveon from the fscounters 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:41 ` [PATCH 02/18] xfs_scrub: remove moveon from the fscounters 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=157177023383.1461658.2534164192787910385.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).