From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B62C0C63697 for ; Thu, 26 Nov 2020 18:00:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DDC8207BC for ; Thu, 26 Nov 2020 18:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391689AbgKZSAv (ORCPT ); Thu, 26 Nov 2020 13:00:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:59130 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391576AbgKZSAu (ORCPT ); Thu, 26 Nov 2020 13:00:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 52B7BABD2; Thu, 26 Nov 2020 18:00:49 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id BB5021E10D0; Thu, 26 Nov 2020 19:00:48 +0100 (CET) Date: Thu, 26 Nov 2020 19:00:48 +0100 From: Jan Kara To: Christoph Hellwig Cc: Jens Axboe , Tejun Heo , Josef Bacik , Coly Li , Mike Snitzer , Greg Kroah-Hartman , Jan Kara , Johannes Thumshirn , dm-devel@redhat.com, Jan Kara , linux-block@vger.kernel.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 36/44] block: allocate struct hd_struct as part of struct bdev_inode Message-ID: <20201126180048.GA422@quack2.suse.cz> References: <20201126130422.92945-1-hch@lst.de> <20201126130422.92945-37-hch@lst.de> <20201126173518.GV422@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126173518.GV422@quack2.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-bcache@vger.kernel.org On Thu 26-11-20 18:35:18, Jan Kara wrote: > On Thu 26-11-20 14:04:14, Christoph Hellwig wrote: > > Allocate hd_struct together with struct block_device to pre-load > > the lifetime rule changes in preparation of merging the two structures. > > > > Note that part0 was previously embedded into struct gendisk, but is > > a separate allocation now, and already points to the block_device instead > > of the hd_struct. The lifetime of struct gendisk is still controlled by > > the struct device embedded in the part0 hd_struct. > > > > Signed-off-by: Christoph Hellwig > > Just one comment below. With that fixed feel free to add: > > Reviewed-by: Jan Kara > > > diff --git a/block/partitions/core.c b/block/partitions/core.c > > index f397ec9922bd6e..9c7e6730fa6098 100644 > > --- a/block/partitions/core.c > > +++ b/block/partitions/core.c > > @@ -265,9 +265,9 @@ static const struct attribute_group *part_attr_groups[] = { > > static void part_release(struct device *dev) > > { > > struct hd_struct *p = dev_to_part(dev); > > + > > blk_free_devt(dev->devt); > > - hd_free_part(p); > > - kfree(p); > > + bdput(p->bdev); > > } > > I don't think hd_struct holds a reference to block_device, does it? > bdev_alloc() now just assigns bdev->bd_part->bdev = bdev... Now I understood this is probably correct - each partition (including gendisk as 0 partition) holds the initial bdev reference and only when corresponding kobject is getting destroyed we stop holding onto that reference. Right? Honza -- Jan Kara SUSE Labs, CR