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.3 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=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 7E46EC5519F for ; Mon, 30 Nov 2020 09:09:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3D9D207BC for ; Mon, 30 Nov 2020 09:09:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3D9D207BC 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 D1D8E6B0036; Mon, 30 Nov 2020 04:09:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCF1B8D0002; Mon, 30 Nov 2020 04:09:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE3E38D0001; Mon, 30 Nov 2020 04:09:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id A4A996B0036 for ; Mon, 30 Nov 2020 04:09:27 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 69862180AD806 for ; Mon, 30 Nov 2020 09:09:27 +0000 (UTC) X-FDA: 77540511174.21.vest73_5700c56273a0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 4BC97180445F4 for ; Mon, 30 Nov 2020 09:09:27 +0000 (UTC) X-HE-Tag: vest73_5700c56273a0 X-Filterd-Recvd-Size: 2710 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Mon, 30 Nov 2020 09:09:26 +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 84675AC6A; Mon, 30 Nov 2020 09:09:25 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 0D4011E131B; Mon, 30 Nov 2020 10:09:25 +0100 (CET) Date: Mon, 30 Nov 2020 10:09:25 +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 16/45] block: switch bdgrab to use igrab Message-ID: <20201130090925.GB11250@quack2.suse.cz> References: <20201128161510.347752-1-hch@lst.de> <20201128161510.347752-17-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201128161510.347752-17-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 Sat 28-11-20 17:14:41, Christoph Hellwig wrote: > All of the current callers already have a reference, but to prepare for > additional users ensure bdgrab returns NULL if the block device is beeing ^^^ being > freed. > > Signed-off-by: Christoph Hellwig Otherwise looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/block_dev.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/fs/block_dev.c b/fs/block_dev.c > index d707ab376da86e..962fabe8a67b83 100644 > --- a/fs/block_dev.c > +++ b/fs/block_dev.c > @@ -894,10 +894,14 @@ static struct block_device *bdget(dev_t dev) > /** > * bdgrab -- Grab a reference to an already referenced block device > * @bdev: Block device to grab a reference to. > + * > + * Returns the block_device with an additional reference when successful, > + * or NULL if the inode is already beeing freed. > */ > struct block_device *bdgrab(struct block_device *bdev) > { > - ihold(bdev->bd_inode); > + if (!igrab(bdev->bd_inode)) > + return NULL; > return bdev; > } > EXPORT_SYMBOL(bdgrab); > -- > 2.29.2 > -- Jan Kara SUSE Labs, CR