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.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 9B285C4320E for ; Wed, 11 Aug 2021 11:51:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 01BBA60F56 for ; Wed, 11 Aug 2021 11:51:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 01BBA60F56 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5DF0B6B0071; Wed, 11 Aug 2021 07:51:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 567CD6B0072; Wed, 11 Aug 2021 07:51:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42F618D0001; Wed, 11 Aug 2021 07:51:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id 24DAC6B0071 for ; Wed, 11 Aug 2021 07:51:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C58E918121F9A for ; Wed, 11 Aug 2021 11:51:51 +0000 (UTC) X-FDA: 78462635622.09.105A624 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf23.hostedemail.com (Postfix) with ESMTP id 2A19490093E2 for ; Wed, 11 Aug 2021 11:51:51 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id C07CA67373; Wed, 11 Aug 2021 13:51:47 +0200 (CEST) Date: Wed, 11 Aug 2021 13:51:47 +0200 From: Christoph Hellwig To: Jan Kara Cc: Christoph Hellwig , Qian Cai , Jens Axboe , Tejun Heo , linux-block@vger.kernel.org, Andrew Morton , cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: move the bdi from the request_queue to the gendisk Message-ID: <20210811115147.GA27860@lst.de> References: <20210809141744.1203023-1-hch@lst.de> <20210810200256.GA30809@lst.de> <20210811112514.GC14725@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210811112514.GC14725@quack2.suse.cz> User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2A19490093E2 Authentication-Results: imf23.hostedemail.com; dkim=none; spf=none (imf23.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none X-Stat-Signature: 8jdqzbcsj8r1cdqwyt4o5w3n95jgo8u5 X-HE-Tag: 1628682711-306999 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 Wed, Aug 11, 2021 at 01:25:14PM +0200, Jan Kara wrote: > Well, non-default bdi_writeback structures do hold bdi reference - see > wb_exit() which drops the reference. I think the problem rather was that a > block device's inode->i_wb was pointing to the default bdi_writeback > structure and that got freed after bdi_put() before block device inode was > shutdown through bdput()... So what I think we need is that if the inode > references the default writeback structure, it actually holds a reference > to the bdi. Qian, can you test the patch below instead of the one I sent yesterday? diff --git a/mm/backing-dev.c b/mm/backing-dev.c index cd06dca232c3..edfb7ce2cc93 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -283,8 +283,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, memset(wb, 0, sizeof(*wb)); - if (wb != &bdi->wb) - bdi_get(bdi); + bdi_get(bdi); wb->bdi = bdi; wb->last_old_flush = jiffies; INIT_LIST_HEAD(&wb->b_dirty); @@ -362,8 +361,7 @@ static void wb_exit(struct bdi_writeback *wb) percpu_counter_destroy(&wb->stat[i]); fprop_local_destroy_percpu(&wb->completions); - if (wb != &wb->bdi->wb) - bdi_put(wb->bdi); + bdi_put(wb->bdi); } #ifdef CONFIG_CGROUP_WRITEBACK