X-Spam-Checker-Version: SpamAssassin 3.4.0-r929098 (2010-03-30) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.4.0-r929098 Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id q5K85QUl004299 for ; Wed, 20 Jun 2012 03:05:26 -0500 X-ASG-Debug-ID: 1340179524-04cb6c3b938bd2f0001-NocioJ Received: from bombadil.infradead.org (173-166-109-252-newengland.hfc.comcastbusiness.net [173.166.109.252]) by cuda.sgi.com with ESMTP id 8EGqPe4tcZloj2hI (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 20 Jun 2012 01:05:25 -0700 (PDT) X-Barracuda-Envelope-From: BATV+07022375f4c7a0425589+3223+infradead.org+hch@bombadil.srs.infradead.org X-Barracuda-Apparent-Source-IP: 173.166.109.252 Received: from hch by bombadil.infradead.org with local (Exim 4.76 #1 (Red Hat Linux)) id 1ShFul-000209-Nj; Wed, 20 Jun 2012 08:05:23 +0000 Date: Wed, 20 Jun 2012 04:05:23 -0400 From: Christoph Hellwig To: Brian Foster Cc: xfs@oss.sgi.com Subject: Re: [PATCH v2] xfs: re-enable xfsaild idle mode and fix associated races Message-ID: <20120620080523.GA26167@infradead.org> X-ASG-Orig-Subj: Re: [PATCH v2] xfs: re-enable xfsaild idle mode and fix associated races References: <1339087793-45731-1-git-send-email-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1339087793-45731-1-git-send-email-bfoster@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html X-Barracuda-Connect: 173-166-109-252-newengland.hfc.comcastbusiness.net[173.166.109.252] X-Barracuda-Start-Time: 1340179525 X-Barracuda-Encrypted: AES256-SHA X-Barracuda-URL: http://192.48.176.15:80/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-Spam-Score: 0.10 X-Barracuda-Spam-Status: No, SCORE=0.10 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1.3 tests=RDNS_DYNAMIC X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.100380 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_DYNAMIC Delivered to trusted network by host with dynamic-looking rDNS On Thu, Jun 07, 2012 at 12:49:53PM -0400, Brian Foster wrote: > xfsaild idle mode logic currently leads to a couple hangs: > > 1.) If xfsaild is rescheduled in during an incremental scan > (i.e., tout != 0) and the target has been updated since > the previous run, we can hit the new target and go into > idle mode with a still populated ail. > 2.) A wake up is only issued when the target is pushed forward. > The wake up can race with xfsaild if it is currently in the > process of entering idle mode, causing future wake up > events to be lost. > > Both hangs are reproducible by running xfstests 273 in a loop. > Modify xfsaild to enter idle mode only when the ail is empty > and the push target has not been moved forward since the last > push. What tree is this against? The current XFS tree never fully idles, so something is missing here, probably just in the patch description. > spin_lock(&ailp->xa_lock); > + > + /* barrier matches the xa_target update in xfs_ail_push() */ > + smp_rmb(); > + target = ailp->xa_target; > + ailp->xa_target_prev = target; > + > lip = xfs_trans_ail_cursor_first(ailp, &cur, ailp->xa_last_pushed_lsn); > if (!lip) { > /* > + > + spin_lock(&ailp->xa_lock); > + > + /* > + * Idle if the AIL is empty and we are not racing with a target > + * update. The barrier matches the xa_target update in > + * xfs_ail_push(). > + */ > + smp_rmb(); Given that both sides are under xa_lock I can't see any need for barriers here. > + if (!xfs_ail_min(ailp) && (ailp->xa_target == ailp->xa_target_prev)) { > + spin_unlock(&ailp->xa_lock); > + schedule(); > + tout = 0; > + continue; > + } This seems to add the actual idling, but in a rather confusing way. Can you add the xfs_ail_min and target checks to the end of xfsaild_push so that they are in one place with the other decisions for the timeout. Please also add a comment explaining the conditions when we want to idle. Also two small style nipicks: - please make sure lines are shorter than 80 characters - no need for the braces around the target comparism above.