From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752484AbbEGMKD (ORCPT ); Thu, 7 May 2015 08:10:03 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:33602 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752090AbbEGMKB (ORCPT ); Thu, 7 May 2015 08:10:01 -0400 Date: Thu, 7 May 2015 21:09:44 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Sergey Senozhatsky , Andrew Morton , Nitin Gupta , linux-kernel@vger.kernel.org Subject: Re: [PATCHv4 00/10] add on-demand device creation Message-ID: <20150507120944.GA681@swordfish> References: <1430743142-15854-1-git-send-email-sergey.senozhatsky@gmail.com> <20150506050114.GA29132@blaptop> <20150506052557.GA820@swordfish> <20150506070756.GC820@swordfish> <20150506072656.GA8163@blaptop> <20150506081029.GA8385@swordfish> <20150506082036.GB8163@blaptop> <20150507003322.GA4153@swordfish> <20150507074159.GA3624@blaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150507074159.GA3624@blaptop> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (05/07/15 16:41), Minchan Kim wrote: > > Unfortunately, I can reproduce in a few second with this patch. > so I googled a bit, and it seems that zram is not the only one who suffered from add_disk() behaviour. http://www.spinics.net/lists/dm-devel/msg23465.html and there is http://git.kernel.dk/?p=linux-block.git;a=commitdiff;h=6cd18e71;hp=393a33970540ac6a2c894b0d6ef3f5d485860884 that looks interesting: | | Because of the peculiar way that md devices are created (automatically | when the device node is opened), a new device can be created and | registered immediately after the | blk_unregister_region(disk_devt(disk), disk->minors); | call in del_gendisk(). | | Therefore it is important that all visible artifacts of the previous | device are removed before this call. In particular, the 'bdi'. | basically, it destroys bdi during queue cleanup. > moved the > device_unregister(bdi->dev); > call from bdi_unregister() to bdi_destroy() it has been quite easy to > lose a race and have a new (e.g.) "md127" be created after the > blk_unregister_region() call and before bdi_destroy() is ultimately > called by the final 'put_disk', which must come after del_gendisk(). > > The new device finds that the bdi name is already registered in sysfs > and complains > >> [ 9627.630029] WARNING: CPU: 18 PID: 3330 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x5a/0x70() >> [ 9627.630032] sysfs: cannot create duplicate filename '/devices/virtual/bdi/9:127' > > We can fix this by moving the bdi_destroy() call out of > blk_release_queue() (which can happen very late when a refcount > reaches zero) and into blk_cleanup_queue() - which happens exactly when the md > device driver calls it. that does look like something that can happen in our case. and here: http://www.spinics.net/lists/dm-devel/msg23415.html is there any chance to ask you to test with these patches (no rush, take your time)? as I'm still unable to reproduce it locally. -ss