From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52325C3A5A7 for ; Wed, 4 Sep 2019 08:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33D952339D for ; Wed, 4 Sep 2019 08:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725966AbfIDIUP (ORCPT ); Wed, 4 Sep 2019 04:20:15 -0400 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:58844 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfIDIUP (ORCPT ); Wed, 4 Sep 2019 04:20:15 -0400 Received: from dread.disaster.area (pa49-181-255-194.pa.nsw.optusnet.com.au [49.181.255.194]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 771F443DE3D; Wed, 4 Sep 2019 18:20:13 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92) (envelope-from ) id 1i5QWQ-0002H3-5m; Wed, 04 Sep 2019 18:20:10 +1000 Date: Wed, 4 Sep 2019 18:20:10 +1000 From: Dave Chinner To: "Darrick J. Wong" Cc: sandeen@sandeen.net, linux-xfs@vger.kernel.org Subject: Re: [PATCH 3/3] xfs_scrub: remove unnecessary wakeup wait in scan_fs_tree Message-ID: <20190904082010.GE1119@dread.disaster.area> References: <156685447255.2840069.707517725113377305.stgit@magnolia> <156685449148.2840069.4205272438739819463.stgit@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <156685449148.2840069.4205272438739819463.stgit@magnolia> User-Agent: Mutt/1.10.1 (2018-07-13) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=FNpr/6gs c=1 sm=1 tr=0 a=YO9NNpcXwc8z/SaoS+iAiA==:117 a=YO9NNpcXwc8z/SaoS+iAiA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=J70Eh1EUuV4A:10 a=yPCof4ZbAAAA:8 a=20KFwNOVAAAA:8 a=7-415B0cAAAA:8 a=DqTArXTYNgyGctwU1tkA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On Mon, Aug 26, 2019 at 02:21:31PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong > > We don't need to wait on the condition variable if directory tree > scanning has already finished by the time we've finished queueing all > the directory work items. This is easy to trigger when the workqueue is > single-threaded, but in theory it could happen any time. > > Signed-off-by: Darrick J. Wong > --- > scrub/vfs.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > > diff --git a/scrub/vfs.c b/scrub/vfs.c > index b358ab4a..0e971d27 100644 > --- a/scrub/vfs.c > +++ b/scrub/vfs.c > @@ -235,7 +235,8 @@ scan_fs_tree( > goto out_wq; > > pthread_mutex_lock(&sft.lock); > - pthread_cond_wait(&sft.wakeup, &sft.lock); > + if (sft.nr_dirs) > + pthread_cond_wait(&sft.wakeup, &sft.lock); Ok, fixes a typical pthread counting conditional bug. :/ Reviewed-by: Dave Chinner -- Dave Chinner david@fromorbit.com