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 q4IAScku126049 for ; Fri, 18 May 2012 05:28:38 -0500 X-ASG-Debug-ID: 1337336916-04cb6c24fb7b1f50001-NocioJ Received: from ipmail07.adl2.internode.on.net (ipmail07.adl2.internode.on.net [150.101.137.131]) by cuda.sgi.com with ESMTP id Nr8pgt6Y0HCLbFDf for ; Fri, 18 May 2012 03:28:37 -0700 (PDT) X-Barracuda-Envelope-From: david@fromorbit.com X-Barracuda-Apparent-Source-IP: 150.101.137.131 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAKQjtk95LCDn/2dsb2JhbAA9CLNsgQiCFQEBBAE6HCMFCwgDDgouFCUDIROICQS8JRSKaxWFMQOVH492gns Received: from ppp121-44-32-231.lns20.syd6.internode.on.net (HELO dastard) ([121.44.32.231]) by ipmail07.adl2.internode.on.net with ESMTP; 18 May 2012 19:58:36 +0930 Received: from dave by dastard with local (Exim 4.76) (envelope-from ) id 1SVKQ9-0002Y2-V1; Fri, 18 May 2012 20:28:30 +1000 Date: Fri, 18 May 2012 20:28:29 +1000 From: Dave Chinner To: Jan Kara Cc: xfs@oss.sgi.com, sandeen@redhat.com, dchinner@redhat.com Subject: Re: Are two transactions running in parallel OK? Message-ID: <20120518102829.GY25351@dastard> X-ASG-Orig-Subj: Re: Are two transactions running in parallel OK? References: <20120517200831.GB23231@quack.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120517200831.GB23231@quack.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-Barracuda-Connect: ipmail07.adl2.internode.on.net[150.101.137.131] X-Barracuda-Start-Time: 1337336916 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.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1.3 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.97298 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- On Thu, May 17, 2012 at 10:08:31PM +0200, Jan Kara wrote: > Hello, > > I've been into a source of lockdep warning I got with XFS when testing my > filesystem freezing patches. The culprit seems to be that when doing direct > IO, XFS starts a transaction in xfs_setfilesize_trans_alloc() and attaches > that transaction to endio structure. Then it goes on and starts another > transaction in xfs_iomap_write_direct() which creates a possible deadlock > with filesystem freezing (if the second transaction start happens after we > start blocking new transactions, it gets blocked, but the first transaction > isn't ever completed). Both occur within the context of an active write IO - why would new transactions be blocked while there are still active write operations that require allocation transactions occurring? > So first I wanted to ask whether my analysis is correct. If yes, I was also > wondering whether this cannot cause a deadlock (at least in theory) if the > second transaction would block waiting for log space but we couldn't > possibly free enough of it due to the first transaction being held open? Don't think so. The first transaction reservation is for the inode size update, but it doesn't hold anything locked so it will not hold up log tail pushing so the second transaction reservation will not get blocked by it. The onyl way that could happen is if the combination of the two transactions is greater than 25% of the log, and given that the size update transaction reservation is only about 600 bytes, that can't occur.... > If freezing deadlock is the only problem with this code, then I guess we > could avoid waiting for filesystem freezing when starting the second > transaction (although it might end up being rather ugly). Or if anyone else > has other idea how to solve this, I'm listening ;). I'm confused about why the active sb_start_write() of the direct IO wouldn't hold off the freeze until the IO has completed. That should completely protect the write against freeze until the IO completes, which AFAICT means the lockdep report is a false positive.... Cheers, Dave. -- Dave Chinner david@fromorbit.com