From patchwork Thu Oct 21 12:44:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12574941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61D54C433F5 for ; Thu, 21 Oct 2021 12:44:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D7640610A2 for ; Thu, 21 Oct 2021 12:44:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D7640610A2 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 78CB66B0073; Thu, 21 Oct 2021 08:44:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73B61900002; Thu, 21 Oct 2021 08:44:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 605A06B0075; Thu, 21 Oct 2021 08:44:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 4E7D86B0073 for ; Thu, 21 Oct 2021 08:44:56 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0793B8249980 for ; Thu, 21 Oct 2021 12:44:56 +0000 (UTC) X-FDA: 78720414192.30.AB0CE7B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 8FB5E90000B5 for ; Thu, 21 Oct 2021 12:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=vl3hjutl474IpUwXxU604+NLLsL0S4mgEjix5/Vk13k=; b=c5wm2WZo7QOeZctOZf/JkC6KeS VQ/Xc7HSH3XZ+HYG/vAr+3T449gcJb28cyxzjiXKCzB6SqTb8jGklEe2PGAAIFtX/jmCbpbEftMgf Zb7sy61TFef8NjuXC7RXft+gY/E84tQ0S9jqUOPNrIuJDnhIYBY1u6oaYWLAT/vVCONPkKHxiu3cG WOKHnkIYB5LTHEWzcLIDtNVChBuqrzYVENUc1HcLycMI7lP44EThrRYntKbE/f8pABJjxh8aMzZM+ f5j8teexAflYQyQtt7GjaOudZ1ydwALezKy140hwTqsuWnZOcDOpWcODR0UWbrAEmhDUHmZLjoExx IVZcIxpA==; Received: from [2001:4bb8:180:8777:dd70:8011:36d9:4c23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRA-007Wxh-Qs; Thu, 21 Oct 2021 12:44:49 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Jan Kara , linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/5] mm: export bdi_unregister Date: Thu, 21 Oct 2021 14:44:37 +0200 Message-Id: <20211021124441.668816-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211021124441.668816-1-hch@lst.de> References: <20211021124441.668816-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Stat-Signature: 5o5fjhipxg6ehogfq38pubkgf9318bmq Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=c5wm2WZo; spf=none (imf23.hostedemail.com: domain of BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8FB5E90000B5 X-HE-Tag: 1634820290-285362 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: To wind down the magic auto-unregister semantics we'll need to push this into modular code. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/backing-dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 4a9d4e27d0d9b..8a46a0a4b72fa 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -958,6 +958,7 @@ void bdi_unregister(struct backing_dev_info *bdi) bdi->owner = NULL; } } +EXPORT_SYMBOL(bdi_unregister); static void release_bdi(struct kref *ref) { From patchwork Thu Oct 21 12:44:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12574947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E63FDC433FE for ; Thu, 21 Oct 2021 12:45:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9886C60F46 for ; Thu, 21 Oct 2021 12:45:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9886C60F46 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 E43F8900003; Thu, 21 Oct 2021 08:45:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5581900002; Thu, 21 Oct 2021 08:45:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C45A9900003; Thu, 21 Oct 2021 08:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id A131B900002 for ; Thu, 21 Oct 2021 08:45:03 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5C7A38249980 for ; Thu, 21 Oct 2021 12:45:03 +0000 (UTC) X-FDA: 78720414486.11.9D6F629 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP id 1B4EDE0016BB for ; Thu, 21 Oct 2021 12:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=+8TMfo1y4J7RHdkJjy5rwVtPpxeRVjv8U26oS2pTWBA=; b=pNihMQiG5s/jsP//Uf7A2ys5xR nq9YKCa4rZDjhvyCMa/N4qA/vSu/ifCbunLQ/f9+0Fst1rYftsZuD9Xd9oidLgdf7blUHaO87FkIN /Zjzc7o5rgs8di3XaUU2suuTi9l1T8y1fZ05d2HCt8rfT/Dp5qbVHD1vZE2fkH9e/+z178+B5ggG0 ajjj2d1YjVJAzPJm9I/YxzdmjABW+ojALElxav8a76A1v2S0ZndGoSLDo/+VEqE403uJUidjKmf7I a3OYiY4F3068CTYCR3RBbsFr7BLomhI6ujfQqIrp62lVjdvXh+NWj4tdZJC4JkfNXEFgIyDdbOBuT bsMWbwvg==; Received: from [2001:4bb8:180:8777:dd70:8011:36d9:4c23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRD-007WyC-Ga; Thu, 21 Oct 2021 12:44:51 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Jan Kara , linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/5] mtd: call bdi_unregister explicitly Date: Thu, 21 Oct 2021 14:44:38 +0200 Message-Id: <20211021124441.668816-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211021124441.668816-1-hch@lst.de> References: <20211021124441.668816-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: 1B4EDE0016BB Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pNihMQiG; spf=none (imf30.hostedemail.com: domain of BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none X-Stat-Signature: 6fq6imsym597gsr6pdadytpnqrx9m1x7 X-Rspamd-Server: rspam06 X-HE-Tag: 1634820296-707395 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: Call bdi_unregister explicitly instead of relying on the automatic unregistration. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- drivers/mtd/mtdcore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index c8fd7f758938b..c904e23c82379 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -2409,6 +2409,7 @@ static void __exit cleanup_mtd(void) if (proc_mtd) remove_proc_entry("mtd", NULL); class_unregister(&mtd_class); + bdi_unregister(mtd_bdi); bdi_put(mtd_bdi); idr_destroy(&mtd_idr); } From patchwork Thu Oct 21 12:44:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12574943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E92FC433F5 for ; Thu, 21 Oct 2021 12:45:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E2EFA60F02 for ; Thu, 21 Oct 2021 12:45:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E2EFA60F02 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 8285C6B0074; Thu, 21 Oct 2021 08:45:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D7A56B0075; Thu, 21 Oct 2021 08:45:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EE016B0078; Thu, 21 Oct 2021 08:45:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 5EC636B0074 for ; Thu, 21 Oct 2021 08:45:00 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1919A181EBF24 for ; Thu, 21 Oct 2021 12:45:00 +0000 (UTC) X-FDA: 78720414360.40.DA07FDF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id AF4AFF000090 for ; Thu, 21 Oct 2021 12:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=LC7mRcFEYrQtFmIVnfiPrgBMPLuCs796AzRXNvRQVCk=; b=4sANb6B4HPdEWzSF690I7qe2PU Jo02Sb4Xcno0v2wXF6XqSgFRoH+l43ZY492oJPU0XKW6QrRiwG8TqtsqQW+YSyhnnkuD0Zf4U8+1q 57XnTKACiv7WXb9ejHYoIsyLBGwZ//f++i+cEHDPZF243+p2au2kO9IFf50HDUNRAtv0YrgQ/r6+H YHvld8VcNphO6+OMG1FTF0nTNg9wTUftEFZMcbEs34z0k+C01FqyCPLcyrZDXpawa+jQxS+rQ7ROC /RgJ6kWcLvifQHNifULbHiE5C7wNgLKcrlLl9ZakzjCkk6YwpzVlt6PbhogsWgi1s66/FYQT9K3K2 JMlcOp3Q==; Received: from [2001:4bb8:180:8777:dd70:8011:36d9:4c23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRG-007Wyx-5f; Thu, 21 Oct 2021 12:44:54 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Jan Kara , linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/5] fs: explicitly unregister per-superblock BDIs Date: Thu, 21 Oct 2021 14:44:39 +0200 Message-Id: <20211021124441.668816-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211021124441.668816-1-hch@lst.de> References: <20211021124441.668816-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: AF4AFF000090 X-Stat-Signature: gsxeu33dyk5t9zzeeeztfmh1oigpb9xn Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=4sANb6B4; dmarc=none; spf=none (imf16.hostedemail.com: domain of BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org X-HE-Tag: 1634820296-443323 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: Add a new SB_I_ flag to mark superblocks that have an ephemeral bdi associated with them, an unregister it when the superblock is shut down. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- fs/super.c | 3 +++ include/linux/fs.h | 1 + 2 files changed, 4 insertions(+) diff --git a/fs/super.c b/fs/super.c index bcef3a6f4c4b5..3bfc0f8fbd5bc 100644 --- a/fs/super.c +++ b/fs/super.c @@ -476,6 +476,8 @@ void generic_shutdown_super(struct super_block *sb) spin_unlock(&sb_lock); up_write(&sb->s_umount); if (sb->s_bdi != &noop_backing_dev_info) { + if (sb->s_iflags & SB_I_PERSB_BDI) + bdi_unregister(sb->s_bdi); bdi_put(sb->s_bdi); sb->s_bdi = &noop_backing_dev_info; } @@ -1562,6 +1564,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) } WARN_ON(sb->s_bdi != &noop_backing_dev_info); sb->s_bdi = bdi; + sb->s_iflags |= SB_I_PERSB_BDI; return 0; } diff --git a/include/linux/fs.h b/include/linux/fs.h index e7a633353fd20..226de651f52e6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1443,6 +1443,7 @@ extern int send_sigurg(struct fown_struct *fown); #define SB_I_UNTRUSTED_MOUNTER 0x00000040 #define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */ +#define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */ /* Possible states of 'frozen' field */ enum { From patchwork Thu Oct 21 12:44:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12574945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0616BC4332F for ; Thu, 21 Oct 2021 12:45:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD8506121E for ; Thu, 21 Oct 2021 12:45:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AD8506121E 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 458A26B0075; Thu, 21 Oct 2021 08:45:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E1726B0078; Thu, 21 Oct 2021 08:45:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2334A6B007B; Thu, 21 Oct 2021 08:45:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 11D806B0075 for ; Thu, 21 Oct 2021 08:45:02 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B93F58249980 for ; Thu, 21 Oct 2021 12:45:01 +0000 (UTC) X-FDA: 78720414402.27.D73FDA7 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id 86334801A8A7 for ; Thu, 21 Oct 2021 12:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=acZg4wkuvbE9IZmYXfy6RNvUK0RdFUpI4ihnDw7DO/4=; b=23/nBcxqvr25HYTCsBEfXIijFk ELgOpFDemlWuE6yzeZPeI0cnUS3BlCWJ7gtrwjSBYNFmYaGpGrFHVfx8FMCx4FPSQIToNuyvdbWed o9ZDZhZeIIC6vkJqkQbYK55S5jFnixaZIV4qWd/2YKxKWiXtxH3agwhjPr0ksDmwd7RslsfNgE1sr KCBIsRHSv7ZyUmupZ1WGDM8aw1gn7tVAwaq6rPCOADkcaBVK40wCuRKELz+/Up/SRLMIRPoDAffjc /L+pCNsJ2JohFC1GSFMiQJhGDeTJw5Zjml93VDjKBFmW6BWCnDSUb6KmRWaUvzn6PzXolaDiYR/9d 9wHc6NvA==; Received: from [2001:4bb8:180:8777:dd70:8011:36d9:4c23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRI-007X0C-RZ; Thu, 21 Oct 2021 12:44:57 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Jan Kara , linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/5] mm: don't automatically unregister bdis Date: Thu, 21 Oct 2021 14:44:40 +0200 Message-Id: <20211021124441.668816-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211021124441.668816-1-hch@lst.de> References: <20211021124441.668816-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 86334801A8A7 X-Stat-Signature: rp53h7yqjaw5kqqbythz678hekuspj4n Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="23/nBcxq"; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org X-HE-Tag: 1634820300-658520 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: All BDI users now unregister explicitly. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/backing-dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 8a46a0a4b72fa..768e9ae489f66 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -965,8 +965,7 @@ static void release_bdi(struct kref *ref) struct backing_dev_info *bdi = container_of(ref, struct backing_dev_info, refcnt); - if (test_bit(WB_registered, &bdi->wb.state)) - bdi_unregister(bdi); + WARN_ON_ONCE(test_bit(WB_registered, &bdi->wb.state)); WARN_ON_ONCE(bdi->dev); wb_exit(&bdi->wb); kfree(bdi); From patchwork Thu Oct 21 12:44:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12574949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1076CC433EF for ; Thu, 21 Oct 2021 12:45:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BA38360F02 for ; Thu, 21 Oct 2021 12:45:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BA38360F02 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 DCD16900002; Thu, 21 Oct 2021 08:45:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7FDD940007; Thu, 21 Oct 2021 08:45:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8149900005; Thu, 21 Oct 2021 08:45:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id A9F1B900002 for ; Thu, 21 Oct 2021 08:45:04 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6075D2C6AF for ; Thu, 21 Oct 2021 12:45:04 +0000 (UTC) X-FDA: 78720414528.31.26CAB31 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 03D4520019C4 for ; Thu, 21 Oct 2021 12:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OdstAJJ/aNxAfiq3+i1crM5pZ57n3VavG4zixG5t6MY=; b=pcHEnwMXx537KKcW7aTqEKyhWh /+zcUhPuTBrY7E8EEIhV9YJDk+OtDP4J91xvJpoT0cJThFOmVVtsbn5Jci1Jik6BWAeE0/tmyYK3C RVo8Q8whjQYbu0UpH463xncgxbnL2rcB1ugWOZ+B44yaNFVMfUeX0GZS7hq4Z5cYfUREZunllDZVZ R9jMQ6tOwXQitYBib19oALNXB0tISM4c1hQwVEsu3IqO9LZXsTJPHW/poGNsGKCle5NXXO1w/2Bsz OQaVxlq0QpWXkBWNzF2RDuA5eXQdJcVsdI8EXxksma1BojPeL/lMzqGKA6w0QS42iyLgakLJTdNd9 ddJRG4cw==; Received: from [2001:4bb8:180:8777:dd70:8011:36d9:4c23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRL-007X1k-GZ; Thu, 21 Oct 2021 12:44:59 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Jan Kara , linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 5/5] mm: simplify bdi refcounting Date: Thu, 21 Oct 2021 14:44:41 +0200 Message-Id: <20211021124441.668816-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211021124441.668816-1-hch@lst.de> References: <20211021124441.668816-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 03D4520019C4 X-Stat-Signature: yrku1remuemiiythzk6hjhkgb4hrfwzj Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pcHEnwMX; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f538400d2eeb65ed2b85+6633+infradead.org+hch@bombadil.srs.infradead.org X-HE-Tag: 1634820304-659289 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: Move grabbing and releasing the bdi refcount out of the common wb_init/wb_exit helpers into code that is only used for the non-default memcg driven bdi_writeback structures. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/backing-dev.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 768e9ae489f66..5ccb250898083 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -291,8 +291,6 @@ 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); wb->bdi = bdi; wb->last_old_flush = jiffies; INIT_LIST_HEAD(&wb->b_dirty); @@ -316,7 +314,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, err = fprop_local_init_percpu(&wb->completions, gfp); if (err) - goto out_put_bdi; + return err; for (i = 0; i < NR_WB_STAT_ITEMS; i++) { err = percpu_counter_init(&wb->stat[i], 0, gfp); @@ -330,9 +328,6 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, while (i--) percpu_counter_destroy(&wb->stat[i]); fprop_local_destroy_percpu(&wb->completions); -out_put_bdi: - if (wb != &bdi->wb) - bdi_put(bdi); return err; } @@ -373,8 +368,6 @@ 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); } #ifdef CONFIG_CGROUP_WRITEBACK @@ -397,6 +390,7 @@ static void cgwb_release_workfn(struct work_struct *work) struct bdi_writeback *wb = container_of(work, struct bdi_writeback, release_work); struct blkcg *blkcg = css_to_blkcg(wb->blkcg_css); + struct backing_dev_info *bdi = wb->bdi; mutex_lock(&wb->bdi->cgwb_release_mutex); wb_shutdown(wb); @@ -416,6 +410,7 @@ static void cgwb_release_workfn(struct work_struct *work) percpu_ref_exit(&wb->refcnt); wb_exit(wb); + bdi_put(bdi); WARN_ON_ONCE(!list_empty(&wb->b_attached)); kfree_rcu(wb, rcu); } @@ -497,6 +492,7 @@ static int cgwb_create(struct backing_dev_info *bdi, INIT_LIST_HEAD(&wb->b_attached); INIT_WORK(&wb->release_work, cgwb_release_workfn); set_bit(WB_registered, &wb->state); + bdi_get(bdi); /* * The root wb determines the registered state of the whole bdi and @@ -528,6 +524,7 @@ static int cgwb_create(struct backing_dev_info *bdi, goto out_put; err_fprop_exit: + bdi_put(bdi); fprop_local_destroy_percpu(&wb->memcg_completions); err_ref_exit: percpu_ref_exit(&wb->refcnt);