From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH 07/19] fs: Add freezing handling to mnt_want_write() / mnt_drop_write() Date: Thu, 29 Mar 2012 14:11:56 +0200 Message-ID: <20120329121156.GD17298@quack.suse.cz> References: <1332978214-15535-1-git-send-email-jack@suse.cz> <1332978214-15535-8-git-send-email-jack@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jan Kara , linux-fsdevel@vger.kernel.org, Al Viro , dchinner@redhat.com, sandeen@redhat.com, Kamal Mostafa To: Szeredi Miklos Return-path: Received: from cantor2.suse.de ([195.135.220.15]:51109 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845Ab2C2MMK (ORCPT ); Thu, 29 Mar 2012 08:12:10 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu 29-03-12 12:19:43, Szeredi Miklos wrote: > On Thu, Mar 29, 2012 at 1:43 AM, Jan Kara wrote: > > Most of places where we want freeze protection coincides with the places where > > we also have remount-ro protection. So make mnt_want_write() and > > mnt_drop_write() (and their _file alternative) prevent freezing as well. > > For the few cases that are really interested only in remount-ro protection > > provide new function variants. > > The underlying mechanism of mnt_want_write() and sb_start_write() is > basically the same: > > - increment per-CPU counter > - mb > - check flag > - retry loop for races Well, __mnt_want_write() has the special handling of MNT_WRITE_HOLD. Otherwise yes, the locking logic is rather similar. > It is scalable but still there is a non-zero overhead, and duplicating > it doesn't seem to make a lot of sense. Why not instead try to use a > common abstraction for both? I'm not sure here. Are you concerned about performance - i.e. you would like to merge the remount-ro counter and topmost anti-freeze counter? That cannot work because in some cases you want remount-ro protection but not freezing protection. In particular when you have file open for writing, you want to refuse remount-ro but still allow freezing. If you are concerned about code / source size, the implementations of the protection mechanisms could be possibly merged but I'm not sure it's worth the hassle since we'd save like 50 LOC. MNT_WRITE_HOLD is one difference, how each of the implementation detects whether we have succeeded in taking our lock is another difference... Honza -- Jan Kara SUSE Labs, CR