From patchwork Sat Aug 13 00:17:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 9278199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D811360231 for ; Sat, 13 Aug 2016 00:17:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9F1028B2E for ; Sat, 13 Aug 2016 00:17:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE98328B33; Sat, 13 Aug 2016 00:17:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F122E28B2E for ; Sat, 13 Aug 2016 00:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752147AbcHMARh (ORCPT ); Fri, 12 Aug 2016 20:17:37 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:38716 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975AbcHMARg (ORCPT ); Fri, 12 Aug 2016 20:17:36 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 817528EE202; Fri, 12 Aug 2016 17:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1471047455; bh=kesYpMAxZpqr92uK6CIgD+G1G85S6dwW60QK+bhWWjg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=SPLYb89NIiKiR46G0fkHme6u23jp2QOgtCKjPJdKJbepk7Q8wjbic3vJ89KmdQzLD LtFf+XO/4ghmZlCtMTyoc0joLuFpiKY7BIGEp7NT6VxyuoXrN5tVaapRV4lT8DgJBy rCh1TstCprRxMogf5fJRh9biaBjFWTEx68xoYwUE= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9zj9LOzw0x6n; Fri, 12 Aug 2016 17:17:35 -0700 (PDT) Received: from [153.66.254.194] (unknown [50.46.144.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 799698EE07D; Fri, 12 Aug 2016 17:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1471047453; bh=kesYpMAxZpqr92uK6CIgD+G1G85S6dwW60QK+bhWWjg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Rw0oyr6S4KSLZqbGiLxw0WqXh0gQJUiL1wWFZOllszumf1cDZue9nU34B1sT20qiE 07p03tBXJYe30LILkNANtq7tr+JW6JX5QtnVzjfFfweUyGJP4HqLh0s0Gx9RIVELjG f4pJt6Ud+YgWxWLiB3874xUBLq8wrNddhX+gxDEo= Message-ID: <1471047451.2407.95.camel@HansenPartnership.com> Subject: Re: Time to make dynamically allocated devt the default for scsi disks? From: James Bottomley To: Dan Williams , linux-block@vger.kernel.org, linux-scsi Cc: Jens Axboe , "Martin K. Petersen" , Christoph Hellwig , Tejun Heo , Dave Hansen Date: Fri, 12 Aug 2016 17:17:31 -0700 In-Reply-To: References: X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 2016-08-12 at 14:29 -0700, Dan Williams wrote: > Before spending effort trying to flush the destruction of old bdi > instances before new ones are registered, is it rather time to > complete the conversion of sd to only use dynamically allocated devt? Do we have to go that far? Surely your fix is extensible: the only reason it doesn't work for us is that the gendisk holds the parent without a reference, so we can free the SCSI device before its child gendisk (good job no-one actually uses gendisk->parent after we've released it ...). If we fix that it would mean SCSI can't release the sdev until after the queue is dead and the bdi namespace released, so isn't something like this the easy fix? James --- -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/block/genhd.c b/block/genhd.c index fcd6d4f..54ae4ae 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -514,7 +514,7 @@ static void register_disk(struct device *parent, struct gendisk *disk) struct hd_struct *part; int err; - ddev->parent = parent; + ddev->parent = get_device(parent); dev_set_name(ddev, "%s", disk->disk_name); @@ -1144,6 +1144,7 @@ static void disk_release(struct device *dev) hd_free_part(&disk->part0); if (disk->queue) blk_put_queue(disk->queue); + put_device(dev->parent); kfree(disk); } struct class block_class = {