From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752573AbbHMKCI (ORCPT ); Thu, 13 Aug 2015 06:02:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:43052 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752537AbbHMKCG (ORCPT ); Thu, 13 Aug 2015 06:02:06 -0400 Date: Thu, 13 Aug 2015 12:02:00 +0200 From: Jan Kara To: Oleg Nesterov Cc: Al Viro , Dave Chinner , Dave Hansen , Jan Kara , "Paul E. McKenney" , Peter Zijlstra , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/8] fix the broken lockdep logic in __sb_start_write() Message-ID: <20150813100200.GE26599@quack.suse.cz> References: <20150811170343.GA26881@redhat.com> <20150811170401.GA26904@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150811170401.GA26904@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 11-08-15 19:04:01, 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(). > > Signed-off-by: Oleg Nesterov Just a nit below... > + if (wait) > + rwsem_acquire_read(&sb->s_writers.lock_map[level-1], 0, 0, ip); If we provided also __sb_writers_acquire() helper (in addition to _nowait) variant, we could use these helpers in __sb_start_write() / __sb_end_write() as well which would look better to me when we already have them. Once this is updated, feel free to add: Reviewed-by: Jan Kara Honza -- Jan Kara SUSE Labs, CR