From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753384AbbD0Q2P (ORCPT ); Mon, 27 Apr 2015 12:28:15 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:46752 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753037AbbD0Q2M (ORCPT ); Mon, 27 Apr 2015 12:28:12 -0400 Message-ID: <553E638B.7040408@fb.com> Date: Mon, 27 Apr 2015 10:27:55 -0600 From: Jens Axboe User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: NeilBrown CC: Azat Khuzhin , Christoph Hellwig , "Kernel.org-Linux-RAID" , Guoqing Jiang , Tejun Heo , Jan Kara , lkml Subject: Re: [PATCH -stable] block: destroy bdi before blockdev is unregistered. References: <20150414171537.GH25394@azat> <20150423160551.45345f96@notabene.brown> <20150427141222.5dac22f1@notabene.brown> In-Reply-To: <20150427141222.5dac22f1@notabene.brown> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68,1.0.33,0.0.0000 definitions=2015-04-27_03:2015-04-27,2015-04-27,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/26/2015 10:12 PM, NeilBrown wrote: > > 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'. > > Since: > commit c4db59d31e39ea067c32163ac961e9c80198fd37 > Author: Christoph Hellwig > fs: don't reassign dirty inodes to default_backing_dev_info > > 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. > > Then it is only necessary for md to call blk_cleanup_queue() before > del_gendisk(). As loop.c devices are also created on demand by > opening the device node, we make the same change there. > > Fixes: c4db59d31e39ea067c32163ac961e9c80198fd37 > Reported-by: Azat Khuzhin > Cc: Christoph Hellwig > Cc: stable@vger.kernel.org (v4.0) > Signed-off-by: NeilBrown > > -- > Hi Jens, > if you could check this and forward on to Linus I'd really appreciate it. Yup, I added it. BTW, that line needs 3 '-', otherwise git am will pick up the comments below :-) Thanks Neil. -- Jens Axboe