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 EDA4FC64E75 for ; Thu, 26 Nov 2020 18:00:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BF8420B80 for ; Thu, 26 Nov 2020 18:00:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BF8420B80 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7E7136B0070; Thu, 26 Nov 2020 13:00:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 796DD6B0072; Thu, 26 Nov 2020 13:00:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AD386B0073; Thu, 26 Nov 2020 13:00:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 5507D6B0070 for ; Thu, 26 Nov 2020 13:00:51 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 18FD6181AEF32 for ; Thu, 26 Nov 2020 18:00:51 +0000 (UTC) X-FDA: 77527335102.27.quilt02_4f0751227381 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id ECC923D663 for ; Thu, 26 Nov 2020 18:00:50 +0000 (UTC) X-HE-Tag: quilt02_4f0751227381 X-Filterd-Recvd-Size: 3167 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Nov 2020 18:00:50 +0000 (UTC) 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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