From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 01/13] libfrog: fix workqueue error communication problems
Date: Mon, 26 Aug 2019 14:28:24 -0700 [thread overview]
Message-ID: <156685490445.2841546.18161974605479380089.stgit@magnolia> (raw)
In-Reply-To: <156685489821.2841546.10616502094098044568.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Convert all the workqueue functions to return positive error codes so
that we can move away from the libc-style indirect errno handling and
towards passing error codes directly back to callers.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
libfrog/workqueue.c | 4 ++--
scrub/common.h | 2 ++
scrub/fscounters.c | 5 ++---
scrub/inodes.c | 5 ++---
scrub/phase2.c | 8 +++-----
scrub/phase4.c | 6 +++---
scrub/read_verify.c | 3 +--
scrub/spacemap.c | 11 ++++-------
scrub/vfs.c | 3 +--
9 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/libfrog/workqueue.c b/libfrog/workqueue.c
index 73114773..a806da3e 100644
--- a/libfrog/workqueue.c
+++ b/libfrog/workqueue.c
@@ -106,8 +106,8 @@ workqueue_add(
}
wi = malloc(sizeof(struct workqueue_item));
- if (wi == NULL)
- return ENOMEM;
+ if (!wi)
+ return errno;
wi->function = func;
wi->index = index;
diff --git a/scrub/common.h b/scrub/common.h
index e85a0333..33555891 100644
--- a/scrub/common.h
+++ b/scrub/common.h
@@ -28,6 +28,8 @@ void __str_out(struct scrub_ctx *ctx, const char *descr, enum error_level level,
#define str_errno(ctx, str) \
__str_out(ctx, str, S_ERROR, errno, __FILE__, __LINE__, NULL)
+#define str_liberror(ctx, error, str) \
+ __str_out(ctx, str, S_ERROR, error, __FILE__, __LINE__, NULL)
#define str_error(ctx, str, ...) \
__str_out(ctx, str, S_ERROR, 0, __FILE__, __LINE__, __VA_ARGS__)
#define str_warn(ctx, str, ...) \
diff --git a/scrub/fscounters.c b/scrub/fscounters.c
index c90143c0..ee07da9e 100644
--- a/scrub/fscounters.c
+++ b/scrub/fscounters.c
@@ -115,15 +115,14 @@ xfs_count_all_inodes(
scrub_nproc_workqueue(ctx));
if (ret) {
moveon = false;
- str_info(ctx, ctx->mntpoint, _("Could not create workqueue."));
+ str_liberror(ctx, ret, _("creating icount workqueue"));
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_info(ctx, ctx->mntpoint,
-_("Could not queue AG %u icount work."), agno);
+ str_liberror(ctx, ret, _("queueing icount work"));
break;
}
}
diff --git a/scrub/inodes.c b/scrub/inodes.c
index ae59d7ef..dcce2df0 100644
--- a/scrub/inodes.c
+++ b/scrub/inodes.c
@@ -240,7 +240,7 @@ xfs_scan_all_inodes(
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
if (ret) {
- str_info(ctx, ctx->mntpoint, _("Could not create workqueue."));
+ str_liberror(ctx, ret, _("creating bulkstat workqueue"));
return false;
}
@@ -248,8 +248,7 @@ xfs_scan_all_inodes(
ret = workqueue_add(&wq, xfs_scan_ag_inodes, agno, &si);
if (ret) {
si.moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue AG %u bulkstat work."), agno);
+ str_liberror(ctx, ret, _("queueing bulkstat work"));
break;
}
}
diff --git a/scrub/phase2.c b/scrub/phase2.c
index a80da7fd..8c8aad97 100644
--- a/scrub/phase2.c
+++ b/scrub/phase2.c
@@ -124,7 +124,7 @@ xfs_scan_metadata(
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
if (ret) {
- str_info(ctx, ctx->mntpoint, _("Could not create workqueue."));
+ str_liberror(ctx, ret, _("creating scrub workqueue"));
return false;
}
@@ -145,8 +145,7 @@ xfs_scan_metadata(
ret = workqueue_add(&wq, xfs_scan_ag_metadata, agno, &moveon);
if (ret) {
moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue AG %u scrub work."), agno);
+ str_liberror(ctx, ret, _("queueing per-AG scrub work"));
goto out;
}
}
@@ -157,8 +156,7 @@ _("Could not queue AG %u scrub work."), agno);
ret = workqueue_add(&wq, xfs_scan_fs_metadata, 0, &moveon);
if (ret) {
moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue filesystem scrub work."));
+ str_liberror(ctx, ret, _("queueing per-FS scrub work"));
goto out;
}
diff --git a/scrub/phase4.c b/scrub/phase4.c
index c4da4852..10199ca1 100644
--- a/scrub/phase4.c
+++ b/scrub/phase4.c
@@ -74,7 +74,7 @@ xfs_process_action_items(
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
if (ret) {
- str_error(ctx, ctx->mntpoint, _("Could not create workqueue."));
+ str_liberror(ctx, ret, _("creating repair workqueue"));
return false;
}
for (agno = 0; agno < ctx->mnt.fsgeom.agcount; agno++) {
@@ -82,8 +82,8 @@ xfs_process_action_items(
ret = workqueue_add(&wq, xfs_repair_ag, agno, &moveon);
if (ret) {
moveon = false;
- str_error(ctx, ctx->mntpoint,
-_("Could not queue repair work."));
+ str_liberror(ctx, ret,
+ _("queueing repair work"));
break;
}
}
diff --git a/scrub/read_verify.c b/scrub/read_verify.c
index 4a9b91f2..c7e34cf5 100644
--- a/scrub/read_verify.c
+++ b/scrub/read_verify.c
@@ -197,8 +197,7 @@ read_verify_queue(
ret = workqueue_add(&rvp->wq, read_verify, 0, tmp);
if (ret) {
- str_info(rvp->ctx, rvp->ctx->mntpoint,
-_("Could not queue read-verify work."));
+ str_liberror(rvp->ctx, ret, _("queueing read-verify work"));
free(tmp);
return false;
}
diff --git a/scrub/spacemap.c b/scrub/spacemap.c
index c3621a3a..03d05eed 100644
--- a/scrub/spacemap.c
+++ b/scrub/spacemap.c
@@ -200,7 +200,7 @@ xfs_scan_all_spacemaps(
ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
scrub_nproc_workqueue(ctx));
if (ret) {
- str_info(ctx, ctx->mntpoint, _("Could not create workqueue."));
+ str_liberror(ctx, ret, _("creating fsmap workqueue"));
return false;
}
if (ctx->fsinfo.fs_rt) {
@@ -208,8 +208,7 @@ xfs_scan_all_spacemaps(
ctx->mnt.fsgeom.agcount + 1, &sbx);
if (ret) {
sbx.moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue rtdev fsmap work."));
+ str_liberror(ctx, ret, _("queueing rtdev fsmap work"));
goto out;
}
}
@@ -218,8 +217,7 @@ _("Could not queue rtdev fsmap work."));
ctx->mnt.fsgeom.agcount + 2, &sbx);
if (ret) {
sbx.moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue logdev fsmap work."));
+ str_liberror(ctx, ret, _("queueing logdev fsmap work"));
goto out;
}
}
@@ -227,8 +225,7 @@ _("Could not queue logdev fsmap work."));
ret = workqueue_add(&wq, xfs_scan_ag_blocks, agno, &sbx);
if (ret) {
sbx.moveon = false;
- str_info(ctx, ctx->mntpoint,
-_("Could not queue AG %u fsmap work."), agno);
+ str_liberror(ctx, ret, _("queueing per-AG fsmap work"));
break;
}
}
diff --git a/scrub/vfs.c b/scrub/vfs.c
index 0e971d27..e5ed5d83 100644
--- a/scrub/vfs.c
+++ b/scrub/vfs.c
@@ -103,8 +103,7 @@ queue_subdir(
error = workqueue_add(wq, scan_fs_dir, 0, new_sftd);
if (error) {
dec_nr_dirs(sft);
- str_info(ctx, ctx->mntpoint,
-_("Could not queue subdirectory scan work."));
+ str_liberror(ctx, error, _("queueing directory scan work"));
return false;
}
next prev parent reply other threads:[~2019-08-26 21:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-26 21:28 [PATCH 00/13] libfrog/xfs_scrub: fix error handling Darrick J. Wong
2019-08-26 21:28 ` Darrick J. Wong [this message]
2019-08-26 21:28 ` [PATCH 02/13] libfrog: fix missing error checking in workqueue code Darrick J. Wong
2019-08-26 21:28 ` [PATCH 03/13] libfrog: split workqueue destroy functions Darrick J. Wong
2019-08-26 21:28 ` [PATCH 04/13] xfs_scrub: redistribute read verify pool flush and destroy responsibilities Darrick J. Wong
2019-08-26 21:28 ` [PATCH 05/13] libfrog: fix per-thread variable error communication problems Darrick J. Wong
2019-08-26 21:28 ` [PATCH 06/13] libfrog: add missing per-thread variable error handling Darrick J. Wong
2019-08-26 21:29 ` [PATCH 07/13] libfrog: fix bitmap error communication problems Darrick J. Wong
2019-08-26 21:29 ` [PATCH 08/13] libfrog: fix missing error checking in bitmap code Darrick J. Wong
2019-08-26 21:29 ` [PATCH 09/13] xfs_scrub: fix per-thread counter error communication problems Darrick J. Wong
2019-08-26 21:29 ` [PATCH 10/13] xfs_scrub: report all progressbar creation failures Darrick J. Wong
2019-08-26 21:29 ` [PATCH 11/13] xfs_scrub: check progress bar timedwait failures Darrick J. Wong
2019-08-26 21:29 ` [PATCH 12/13] xfs_scrub: move all the queue_subdir error reporting to callers Darrick J. Wong
2019-08-26 21:29 ` [PATCH 13/13] xfs_scrub: fix error handling problems in vfs.c Darrick J. Wong
2019-09-06 3:36 [PATCH 00/13] libfrog/xfs_scrub: fix error handling Darrick J. Wong
2019-09-06 3:36 ` [PATCH 01/13] libfrog: fix workqueue error communication problems Darrick J. Wong
2019-09-25 21:33 [PATCH 00/13] libfrog/xfs_scrub: fix error handling Darrick J. Wong
2019-09-25 21:33 ` [PATCH 01/13] libfrog: fix workqueue error communication problems Darrick J. Wong
2019-09-30 19:23 ` Eric Sandeen
2019-09-30 19:29 ` Darrick J. Wong
2019-09-30 19:35 ` Eric Sandeen
2019-09-30 20:32 ` Eric Sandeen
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=156685490445.2841546.18161974605479380089.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).