From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753070AbbGVVXd (ORCPT ); Wed, 22 Jul 2015 17:23:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49984 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752966AbbGVVXc (ORCPT ); Wed, 22 Jul 2015 17:23:32 -0400 Date: Wed, 22 Jul 2015 23:13:53 +0200 From: Oleg Nesterov To: Jan Kara Cc: Al Viro , Dave Chinner , Dave Hansen , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] fix the broken lockdep logic in __sb_start_write() Message-ID: <20150722211353.GB19636@redhat.com> References: <20150720170044.GA3868@redhat.com> <20150720170103.GA3903@redhat.com> <20150721083842.GB6533@quack.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150721083842.GB6533@quack.suse.cz> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/21, Jan Kara wrote: > > On Mon 20-07-15 19:01:03, Oleg Nesterov wrote: > > 1. wait_event(frozen < level) without rwsem_acquire_read() is just > > wrong from lockdep perspective. If we are going to deadlock > > because the caller is buggy, lockdep detect this problem. > > > > 2. __sb_start_write() can race with thaw_super() + freeze_super(), > > and after "goto retry" the 2nd acquire_freeze_lock() is wrong. > > > > 3. The "tell lockdep we are doing trylock" hack doesn't look nice. > > > > I think this is correct, but this logic should be more explicit. > > Yes, the recursive read_lock() is fine if we hold the lock on a > > higher level. But we do not need to fool lockdep. If we can not > > deadlock in this case then try-lock must not fail and we can use > > use wait == F throughout this code. > > > > Note: as Dave Chinner explains, the "trylock" hack and the fat comment > > can be probably removed. But this needs a separate change and it will > > be trivial: just kill __sb_start_write() and rename do_sb_start_write() > > back to __sb_start_write(). > > The patch looks good. Did you test this BTW? You can add: Yes, but "artificially". I just wrote the function which takes/drops SB_FREEZE_FS twice with and then without SB_FREEZE_WRITE. It worked as expected, lockdep complained when SB_FREEZE_WRITE wasn't held. > Reviewed-by: Jan Kara Thanks! Oleg.