From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754161AbbDHNle (ORCPT ); Wed, 8 Apr 2015 09:41:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48005 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754005AbbDHNld (ORCPT ); Wed, 8 Apr 2015 09:41:33 -0400 Date: Wed, 8 Apr 2015 09:40:34 -0400 From: Jarod Wilson To: Ming Lei Cc: Linux Kernel Mailing List , Christoph Hellwig , Jens Axboe , Tejun Heo , Alexander Viro , Markus Pargmann , Stefan Weinhuber , Stefan Haberland , Sebastian Ott , Fabian Frederick , David Herrmann , Mike Galbraith , Andrew Morton , Peter Zijlstra , "nbd-general@lists.sourceforge.net" , linux-s390@vger.kernel.org Subject: Re: [PATCH 2/7] block: loop: don't hold lo_ctl_mutex in lo_open Message-ID: <20150408134034.GH14217@redhat.com> References: <1428218688-4092-1-git-send-email-ming.lei@canonical.com> <1428474226-27386-1-git-send-email-jarod@redhat.com> <1428474226-27386-3-git-send-email-jarod@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed, Apr 08, 2015 at 02:50:59PM +0800, Ming Lei wrote: > Hi Jarod, > > On Wed, Apr 8, 2015 at 2:23 PM, Jarod Wilson wrote: > > From: Ming Lei > > > > The lo_ctl_mutex is held for running all ioctl handlers, and > > in some ioctl handlers, ioctl_by_bdev(BLKRRPART) is called for > > rereading partitions, which requires bd_mutex. > > > > So it is easy to cause failure because trylock(bd_mutex) may > > fail inside blkdev_reread_part(), and follows the lock context: > > > > blkid or other application: > > ->open() > > ->mutex_lock(bd_mutex) > > ->lo_open() > > ->mutex_lock(lo_ctl_mutex) > > > > losetup(set fd ioctl): > > ->mutex_lock(lo_ctl_mutex) > > ->ioctl_by_bdev(BLKRRPART) > > ->trylock(bd_mutex) > > > > This patch trys to eliminate the ABBA lock dependency by removing > > lo_ctl_mutext in lo_open() with the following approach: > > > > 1) introduce lo_open_mutex to protect lo_refcnt and avoid acquiring > > lo_ctl_mutex in lo_open(): > > It is a bit quick since I said the lo_open_mutex can be removed, > and Christoph agreed that too. > > So looks we still need to post another version, :-) Ah. I missed that bit. Just trying to keep up momentum. -- Jarod Wilson jarod@redhat.com