From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 12/13] xfs_scrub: move all the queue_subdir error reporting to callers
Date: Mon, 26 Aug 2019 14:29:40 -0700 [thread overview]
Message-ID: <156685498062.2841546.15534699593624208130.stgit@magnolia> (raw)
In-Reply-To: <156685489821.2841546.10616502094098044568.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Change queue_subdir to return a positive error code to callers and move
the error reporting to the callers. This continues the process of
changing internal functions to return error codes.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
scrub/vfs.c | 44 +++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/scrub/vfs.c b/scrub/vfs.c
index 8aa58d6e..7053dbd6 100644
--- a/scrub/vfs.c
+++ b/scrub/vfs.c
@@ -72,7 +72,7 @@ dec_nr_dirs(
}
/* Queue a directory for scanning. */
-static bool
+static int
queue_subdir(
struct scrub_ctx *ctx,
struct scan_fs_tree *sft,
@@ -81,33 +81,34 @@ queue_subdir(
bool is_rootdir)
{
struct scan_fs_tree_dir *new_sftd;
- int error;
+ int ret;
new_sftd = malloc(sizeof(struct scan_fs_tree_dir));
- if (!new_sftd) {
- str_errno(ctx, _("creating directory scan context"));
- return false;
- }
+ if (!new_sftd)
+ return errno;
new_sftd->path = strdup(path);
if (!new_sftd->path) {
- str_errno(ctx, _("creating directory scan path"));
- free(new_sftd);
- return false;
+ ret = errno;
+ goto out_dir;
}
new_sftd->sft = sft;
new_sftd->rootdir = is_rootdir;
inc_nr_dirs(sft);
- error = workqueue_add(wq, scan_fs_dir, 0, new_sftd);
- if (error) {
+ ret = workqueue_add(wq, scan_fs_dir, 0, new_sftd);
+ if (ret) {
dec_nr_dirs(sft);
- str_liberror(ctx, error, _("queueing directory scan work"));
- return false;
+ goto out_path;
}
- return true;
+ return 0;
+out_path:
+ free(new_sftd->path);
+out_dir:
+ free(new_sftd);
+ return ret;
}
/* Scan a directory sub tree. */
@@ -183,10 +184,13 @@ scan_fs_dir(
/* If directory, call ourselves recursively. */
if (S_ISDIR(sb.st_mode) && strcmp(".", dirent->d_name) &&
strcmp("..", dirent->d_name)) {
- sft->moveon = queue_subdir(ctx, sft, wq, newpath,
- false);
- if (!sft->moveon)
+ error = queue_subdir(ctx, sft, wq, newpath, false);
+ if (error) {
+ str_liberror(ctx, error,
+_("queueing subdirectory scan"));
+ sft->moveon = false;
break;
+ }
}
}
@@ -229,9 +233,11 @@ scan_fs_tree(
return false;
}
- sft.moveon = queue_subdir(ctx, &sft, &wq, ctx->mntpoint, true);
- if (!sft.moveon)
+ ret = queue_subdir(ctx, &sft, &wq, ctx->mntpoint, true);
+ if (ret) {
+ str_liberror(ctx, ret, _("queueing directory scan"));
goto out_wq;
+ }
pthread_mutex_lock(&sft.lock);
if (sft.nr_dirs)
next prev parent reply other threads:[~2019-08-26 21:29 UTC|newest]
Thread overview: 17+ 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 ` [PATCH 01/13] libfrog: fix workqueue error communication problems Darrick J. Wong
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 ` Darrick J. Wong [this message]
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:37 ` [PATCH 12/13] xfs_scrub: move all the queue_subdir error reporting to callers Darrick J. Wong
2019-09-25 21:33 [PATCH 00/13] libfrog/xfs_scrub: fix error handling Darrick J. Wong
2019-09-25 21:34 ` [PATCH 12/13] xfs_scrub: move all the queue_subdir error reporting to callers Darrick J. Wong
2019-10-09 21:54 ` 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=156685498062.2841546.15534699593624208130.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).