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=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 B1E47C63798 for ; Fri, 27 Nov 2020 13:19:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E13CE22245 for ; Fri, 27 Nov 2020 13:19:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E13CE22245 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 3DE526B006E; Fri, 27 Nov 2020 08:19:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3902C6B0070; Fri, 27 Nov 2020 08:19:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A7556B0073; Fri, 27 Nov 2020 08:19:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 160186B006E for ; Fri, 27 Nov 2020 08:19:04 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D764421E4 for ; Fri, 27 Nov 2020 13:19:03 +0000 (UTC) X-FDA: 77530253766.10.car01_25053c727388 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id B6E1C16A4AB for ; Fri, 27 Nov 2020 13:19:03 +0000 (UTC) X-HE-Tag: car01_25053c727388 X-Filterd-Recvd-Size: 2817 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Nov 2020 13:19:03 +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 E6B3BABD7; Fri, 27 Nov 2020 13:19:01 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7BE0A1E1318; Fri, 27 Nov 2020 14:19:01 +0100 (CET) Date: Fri, 27 Nov 2020 14:19:01 +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 43/44] block: merge struct block_device and struct hd_struct Message-ID: <20201127131901.GE27162@quack2.suse.cz> References: <20201126130422.92945-1-hch@lst.de> <20201126130422.92945-44-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126130422.92945-44-hch@lst.de> 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 14:04:21, Christoph Hellwig wrote: > Instead of having two structures that represent each block device with > different life time rules, merge them into a single one. This also > greatly simplifies the reference counting rules, as we can use the inode > reference count as the main reference count for the new struct > block_device, with the device model reference front ending it for device > model interaction. The percpu refcount in struct hd_struct is entirely > gone given that struct block_device must be opened and thus valid for > the duration of the I/O. The percpu refcount is long gone after the series refactoring... > @@ -939,13 +910,13 @@ void blk_request_module(dev_t devt) > */ > struct block_device *bdget_disk(struct gendisk *disk, int partno) > { > - struct hd_struct *part; > struct block_device *bdev = NULL; > > - part = disk_get_part(disk, partno); > - if (part) > - bdev = bdget_part(part); > - disk_put_part(part); > + rcu_read_lock(); > + bdev = __disk_get_part(disk, partno); > + if (bdev) > + bdgrab(bdev); Again I think you need to accommodate for bdgrab() returning NULL here when we race with partition destruction... > + rcu_read_unlock(); > > return bdev; > } Honza -- Jan Kara SUSE Labs, CR