From: Jan Kara Subject: Re: [PATCH 06/19] quota: Remove state_lock Date: Tue, 23 Nov 2010 11:55:30 +0100 Message-ID: <20101123105530.GA6113@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> 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]:47858 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945Ab0KWKzc (ORCPT ); Tue, 23 Nov 2010 05:55:32 -0500 Content-Disposition: inline In-Reply-To: <8739qtkptf.fsf@dmon-lap.sw.ru> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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). > > b) We read an uptodate value from quota state variable. > All callers which modify the state already holds onoff_mutex so > implicit mem barriers always guaranteed. Yes, so eventually the quota state is guaranteed to have a consistent value but it says nothing about when and what reader not using onoff_mutex sees. Honza -- Jan Kara SUSE Labs, CR