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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 36BE6C64E75 for ; Wed, 25 Nov 2020 12:10:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B28A52083E for ; Wed, 25 Nov 2020 12:10:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qBMGf8Zl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B28A52083E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 014F46B0075; Wed, 25 Nov 2020 07:10:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F2D406B007B; Wed, 25 Nov 2020 07:10:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E43BF6B007D; Wed, 25 Nov 2020 07:10:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0186.hostedemail.com [216.40.44.186]) by kanga.kvack.org (Postfix) with ESMTP id CDA616B0075 for ; Wed, 25 Nov 2020 07:10:10 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9829B181AEF23 for ; Wed, 25 Nov 2020 12:10:10 +0000 (UTC) X-FDA: 77522822580.23.nose08_0704f5e27376 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 78A6D37606 for ; Wed, 25 Nov 2020 12:10:10 +0000 (UTC) X-HE-Tag: nose08_0704f5e27376 X-Filterd-Recvd-Size: 4750 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Nov 2020 12:10:09 +0000 (UTC) Received: by mail-io1-f47.google.com with SMTP id t8so1894489iov.8 for ; Wed, 25 Nov 2020 04:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7Gu8dfUtFbW1JkuoI0JsJxuRwdXnhq5kHzNpgpg59Vg=; b=qBMGf8ZlpGBDrQf4OZ1U5hpBWVyNLxT8t7mb89EQfIXn+CYHj49+4NspUMpFZN+IBb ow2ADzA501Y4hGPFKjrnnAGIPGi9hyvAwwXtpDtFAkYj7ksmhQny5Q5+xlY6jtJjsSvN iA9i5fMRanrtfyZfe3+dWZgmeaV0x4lRD+7LgXZczkfB+RbnQDZrkTxOZ7Es8MQAef6B e5RRaQ3t+46Lg0Zd/h/8g8StzDseAQGAZgvUuKfsUJH8/o4saKvewPtw+57G9TyZa/BY /ViJEbywwBG8XKFF7bgqckI6jrquPx5+GfHPK5ghMTcJ5KumQuJnVjVzT50eAtnQOxE9 Uwfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=7Gu8dfUtFbW1JkuoI0JsJxuRwdXnhq5kHzNpgpg59Vg=; b=VeNC61KwqjHqwxtyFvkToNPx3UR/3Xe0aoq6jbMhjVjkUwWx2IlQZyGUmYbiS8G0pQ bzU7W6QMtumZAfiZE2l6ty2W7LopqU9aypZ2GivlNQUj6k1VlY6+ZBpK7BCBGz/zxBqz G274UkSZKhKvCWhWN/0zED/W3bfJz+/d8MENaZZWmBmsoHmzxoKLO4pdvDq9PXNPnxCX 4IsxF3HafpYWOvGHYvtEIv5/0lXLipb4jAVlRkT0+W43bql5As6A686CCIwDj8gS32F7 0iX6p460KJEbv0rlzUVlmX+Xnza643j9X/xXUoqZjNoZvMjs3U/sz25rx8dpE75HA9Ti 9+Sw== X-Gm-Message-State: AOAM532NFrMz6CpKlRYMUnZB9GIrklE9BG/+qb5ZpbJkaBlTtT5MRx1A sJv8dKiQh9ZqXHqiQZDovk0= X-Google-Smtp-Source: ABdhPJzrP+6qlAsvVf6NJAz9IW3W/tDwuPyEzkZeYfjLrVcKdFZvzQhG4Xm+JItZe22HwNKBFUD46g== X-Received: by 2002:a5e:8206:: with SMTP id l6mr2327550iom.126.1606306209079; Wed, 25 Nov 2020 04:10:09 -0800 (PST) Received: from localhost (dhcp-6c-ae-f6-dc-d8-61.cpe.echoes.net. [72.28.8.195]) by smtp.gmail.com with ESMTPSA id v85sm1343250ilk.50.2020.11.25.04.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 04:10:08 -0800 (PST) Date: Wed, 25 Nov 2020 07:09:46 -0500 From: Tejun Heo To: Jan Kara Cc: Christoph Hellwig , Jens Axboe , Josef Bacik , Konrad Rzeszutek Wilk , Coly Li , Mike Snitzer , dm-devel@redhat.com, Richard Weinberger , Jan Kara , linux-block@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 11/20] block: reference struct block_device from struct hd_struct Message-ID: References: <20201118084800.2339180-1-hch@lst.de> <20201118084800.2339180-12-hch@lst.de> <20201125114044.GC16944@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201125114044.GC16944@quack2.suse.cz> 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: Hey, Jan, On Wed, Nov 25, 2020 at 12:40:44PM +0100, Jan Kara wrote: > > I don't think this is necessary now that the bdev and inode lifetimes are > > one. Before, punching out the association early was necessary because we > > could be in a situation where we can successfully look up a part from idr > > and then try to pin the associated disk which may already be freed. With the > > new code, the lookup is through the inode whose lifetime is one and the same > > with gendisk, so use-after-free isn't possible and __blkdev_get() will > > reliably reject such open attempts. > > I think the remove_inode_hash() call is actually still needed. Consider a > situation when the disk is unplugged, gendisk gets destroyed, bdev still > lives on (e.g. because it is still open). Device gets re-plugged, gendisk > for the same device number gets created. But we really need new bdev for > this because from higher level POV this is completely new device. And the > old bdev needs to live on as long as it is open. So IMO we still need to > just unhash the inode and leave it lingering in the background. You're absolutely right. I was only thinking about the lifetime problem described in the comment. So, it just needs an updated comment there, I think. Thanks. -- tejun