From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> 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@xxxxxxxxxx> --- 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; }