From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: sandeen@sandeen.net, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/3] xfs_scrub: fix nr_dirs accounting problems
Date: Wed, 4 Sep 2019 18:15:53 +1000 [thread overview]
Message-ID: <20190904081553.GD1119@dread.disaster.area> (raw)
In-Reply-To: <156685448524.2840069.582566075645213965.stgit@magnolia>
On Mon, Aug 26, 2019 at 02:21:25PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> When we're scanning the directory tree, we bump nr_dirs every time we
> think we're going to queue a new directory to process, and we decrement
> it every time we're finished doing something with a directory
> (successful or not). We forgot to undo a counter increment when
> workqueue_add fails, so refactor the code into helpers and call them
> as necessary for correct operation.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> scrub/vfs.c | 38 +++++++++++++++++++++++++++++---------
> 1 file changed, 29 insertions(+), 9 deletions(-)
>
>
> diff --git a/scrub/vfs.c b/scrub/vfs.c
> index ea2866d9..b358ab4a 100644
> --- a/scrub/vfs.c
> +++ b/scrub/vfs.c
> @@ -45,6 +45,32 @@ struct scan_fs_tree_dir {
>
> static void scan_fs_dir(struct workqueue *wq, xfs_agnumber_t agno, void *arg);
>
> +/* Increment the number of directories that are queued for processing. */
> +static void
> +inc_nr_dirs(
> + struct scan_fs_tree *sft)
> +{
> + pthread_mutex_lock(&sft->lock);
> + sft->nr_dirs++;
> + pthread_mutex_unlock(&sft->lock);
> +}
> +
> +/*
> + * Decrement the number of directories that are queued for processing and if
> + * we ran out of dirs to process, wake up anyone who was waiting for processing
> + * to finish.
> + */
> +static void
> +dec_nr_dirs(
> + struct scan_fs_tree *sft)
> +{
> + pthread_mutex_lock(&sft->lock);
> + sft->nr_dirs--;
> + if (sft->nr_dirs == 0)
> + pthread_cond_signal(&sft->wakeup);
> + pthread_mutex_unlock(&sft->lock);
> +}
> +
> /* Queue a directory for scanning. */
> static bool
> queue_subdir(
> @@ -73,11 +99,10 @@ queue_subdir(
> new_sftd->sft = sft;
> new_sftd->rootdir = is_rootdir;
>
> - pthread_mutex_lock(&sft->lock);
> - sft->nr_dirs++;
> - pthread_mutex_unlock(&sft->lock);
> + inc_nr_dirs(sft);
> 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."));
> return false;
Ok, that's the bug fix for the previous patch. Potentially should be
a separate patch, but right now there is so much outstanding that I
don't think it's worthwhile to respin the series just to fix that.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2019-09-04 8:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-26 21:21 [PATCH 0/3] xfs_scrub: fix bugs in vfs tree walk code Darrick J. Wong
2019-08-26 21:21 ` [PATCH 1/3] xfs_scrub: refactor queueing of subdir scan work item Darrick J. Wong
2019-09-04 8:12 ` Dave Chinner
2019-09-04 16:37 ` Darrick J. Wong
2019-08-26 21:21 ` [PATCH 2/3] xfs_scrub: fix nr_dirs accounting problems Darrick J. Wong
2019-09-04 8:15 ` Dave Chinner [this message]
2019-08-26 21:21 ` [PATCH 3/3] xfs_scrub: remove unnecessary wakeup wait in scan_fs_tree Darrick J. Wong
2019-09-04 8:20 ` Dave Chinner
2019-09-06 3:33 [PATCH 0/3] xfs_scrub: fix bugs in vfs tree walk code Darrick J. Wong
2019-09-06 3:34 ` [PATCH 2/3] xfs_scrub: fix nr_dirs accounting problems Darrick J. Wong
2019-09-25 21:31 [PATCH 0/3] xfs_scrub: fix bugs in vfs tree walk code Darrick J. Wong
2019-09-25 21:31 ` [PATCH 2/3] xfs_scrub: fix nr_dirs accounting problems 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=20190904081553.GD1119@dread.disaster.area \
--to=david@fromorbit.com \
--cc=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).