From: Jan Kara Subject: Re: [PATCH 06/19] quota: Remove state_lock Date: Tue, 23 Nov 2010 12:33:22 +0100 Message-ID: <20101123113322.GB6113@quack.suse.cz> References: <1289477678-5669-1-git-send-email-dmonakhov@openvz.org> <1289477678-5669-7-git-send-email-dmonakhov@openvz.org> <20101122211209.GD6141@quack.suse.cz> <8739qtkptf.fsf@dmon-lap.sw.ru> <20101123105530.GA6113@quack.suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jan Kara , linux-fsdevel@vger.kernel.org, hch@infradead.org To: Dmitry Return-path: Received: from cantor.suse.de ([195.135.220.2]:49086 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751080Ab0KWLdX (ORCPT ); Tue, 23 Nov 2010 06:33:23 -0500 Content-Disposition: inline In-Reply-To: <20101123105530.GA6113@quack.suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue 23-11-10 11:55:30, Jan Kara wrote: > On Tue 23-11-10 00:31:56, Dmitry wrote: > > On Mon, 22 Nov 2010 22:12:09 +0100, Jan Kara wrote: > > > On Thu 11-11-10 15:14:25, Dmitry Monakhov wrote: > > > > The only reader which use state_lock is dqget(), and is it serialized > > > > with quota_disable via SRCU. And state_lock doesn't guaranties anything > > > > for that case. All methods which modify quota flags already protected by > > > > dqonoff_mutex. Get rid of useless state_lock. > > > dq_state_lock has two properties you miss here: > > > a) It guarantees we read a consistent value from a quota state variable. > > So what, it is not guaranteed anything. Quota make becomes disabled > > one nanosecond after check. > > And with srcu_read_lock we can be guarantee what quota will be available > > for the caller. Even in case of stale value. > Well, that's not completely my point. The point is that when we > manipulate flags in an non-atomic way (and using &=, |=, ... is a > non-atomic way), we are not really guaranteed what values a reader will see > while the change happens. So in theory the reader could see that all quotas > are disabled during a transition from usrquota enabled to usrquota+grpquota > enabled (I admit a stupid example but you get the point). Looking into the code once more I should add that this has been a possible problem even before your patch. So it's not a problem you introduced. You just made it more visible ;). Honza -- Jan Kara SUSE Labs, CR