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 (cuda1.sgi.com [192.48.157.11]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id q0OBqcNV249841 for ; Tue, 24 Jan 2012 05:52:38 -0600 X-ASG-Debug-ID: 1327405956-04bdf006bc40150001-NocioJ Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by cuda.sgi.com with ESMTP id 84hnEWWBx0SjoK5l (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 24 Jan 2012 03:52:37 -0800 (PST) X-Barracuda-Envelope-From: jack@suse.cz X-Barracuda-Apparent-Source-IP: 195.135.220.15 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 8D9AB8FB75; Tue, 24 Jan 2012 12:52:35 +0100 (CET) Received: by quack.suse.cz (Postfix, from userid 1000) id 8A475205DF; Tue, 24 Jan 2012 12:52:34 +0100 (CET) Date: Tue, 24 Jan 2012 12:52:34 +0100 From: Jan Kara To: Dave Chinner Cc: Jan Kara , linux-fsdevel@vger.kernel.org, Eric Sandeen , Dave Chinner , Surbhi Palande , Kamal Mostafa , Christoph Hellwig , LKML , xfs@oss.sgi.com, linux-ext4@vger.kernel.org, Ben Myers , Alex Elder Subject: Re: [PATCH 4/8] xfs: Move ilock before transaction start in xfs_setattr_size() Message-ID: <20120124115234.GD15974@quack.suse.cz> X-ASG-Orig-Subj: Re: [PATCH 4/8] xfs: Move ilock before transaction start in xfs_setattr_size() References: <1327091686-23177-1-git-send-email-jack@suse.cz> <1327091686-23177-5-git-send-email-jack@suse.cz> <20120124065945.GL15102@dastard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120124065945.GL15102@dastard> User-Agent: Mutt/1.5.20 (2009-06-14) X-Barracuda-Connect: cantor2.suse.de[195.135.220.15] X-Barracuda-Start-Time: 1327405956 X-Barracuda-Encrypted: AES256-SHA X-Barracuda-URL: http://192.48.157.11: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=2.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.1 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.86553 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- On Tue 24-01-12 17:59:45, Dave Chinner wrote: > On Fri, Jan 20, 2012 at 09:34:42PM +0100, Jan Kara wrote: > > In xfs we first take ilock and start transaction afterwards. > > The correct order is to allocate the transaction, reserve the space > for it and then take the ilock. We cannot hold the ilock over the > transaction reservation because that can deadlock the journal. > > That is, to make space for the new transaction reservation, we may > need to take the ilock to flush the inode and allow the journal tail > to move forwards to make space for the new transaction. If we > already hold the ilock, then it can't be flushed, we can't make > space available in the journal and hence deadlock. Thanks for clarification! > Maybe you confused the ilock vs the iolock. We can hold the iolock > over the trans alloc/reserve because that lock is not required to > move the tail of the journal, so the deadlock doesn't exist. Ups! I now had a look at what xfs_rw_ilock() does. I always thought it's just a plain rw semaphore and now I see it takes several locks depending on the argument. Ugh, a bit surprising for XFS newcomer as me ;) But now things become clearer so I fix my patches with this new knowledge in mind. So just disregard my locking comments. They were likely bogus. Honza -- Jan Kara SUSE Labs, CR