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: 1544363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=LX8F5yZB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZnJZ50R0z9sRR for ; Thu, 21 Oct 2021 23:45:34 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=btab1Z72B1j8eslIBiknsTSBbAzTZKT4YpaEFtBw3ZA=; b=LX8F5yZBdRe6Nn +7kCeX8lkxJQom53fqOhAYoDZRBK2GusMJYqSmO0jA0A1go/0Fyh0taYY4Zb9tSw8Vv3XXYzAedL3 7h1cOKJlnc/ihYG0T7Prv5aDuAhZyUwa65UoCKHtj1wxkTDUcLytoLhwIvC9ZXA1n3uE1wFSj7tKv A7ViJm3fwWIcFa8Hq2Pgei8xFKiB3rGje0/I3tXBKc4pLKXQ1D2HG1TQQO4W3YZ+BQkDqzqwWflNo 3GlvWK2yn+q17TtyjrEfb4W+a412xKfk5WWCugjJX1DoYRRY7jK59urIAgmuyX37lmhfRtv6MGH4u VFQxoFtxVgcIqOol/MfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRM-007X2v-I0; Thu, 21 Oct 2021 12:45:00 +0000 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-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1544364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mjv1GlPb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZnJl0Wwgz9sRR for ; Thu, 21 Oct 2021 23:45:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6YKe8vI+uHc5SD4ETQbCVCBCJaWEx1j4KEEYvVc6MY8=; b=mjv1GlPbiha3Xu Tk84IsJxLxBjcTme5VUkxJDlv9bzHIW7JHJwElS5WcDV21vKc9ys5iwBIHM5+YJeADgy85skm92CP 9c6E7CdzE3Jl0798KDSzH9uCEXjmaWg6kkU+w43SSYQnMa/1kheva7EGBGFAbu8PBMkHWa8ZIkjm0 zqr+mHxgwJqgVTeDBVGi/eqeczksuvK5/IANWEIb2dLwEzMAXv0WnEdMc10SyQo4Vf8vFr/m1YdX6 6EHQZLaUO5pOXuxgCKoFCSAX1Pel8mlUX5Gz4HUs7P9+uLx4ChlsgG0yhnF3aGCx1BbB34Ibyo50n 5zdilcokeTKSlRpnO8Jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRZ-007X71-IN; Thu, 21 Oct 2021 12:45:13 +0000 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-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1544365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=WDQzQR+u; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZnJy26tbz9sRR for ; Thu, 21 Oct 2021 23:45:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a6vYkj3V73RCV59KBhgIga36RM0Zj6FE72djzrBuBmQ=; b=WDQzQR+ud/Xknq OuKVgzO/UW0MSxe+Kh/bPjWY9FoAqoVDiIofYC4/HeAcrDkxCQ8zvbIyUAifNcwQ88rvtXRi4gaUL 33x84YUguUJzr0ndYMCOeEaaUZNNZ/MHqzFE7f50esBZyVx/U1sYKNxSkjrHl3fBMQC7uHxcKSBE1 5Mnkj703HCNgwAJ/828p2LTkx8REe1hwUTOr0VYT0sOzW2l3QZHtLMPrgT7G4FeFhMcqU4ISHbFIv y815uC07i3pqkXgW2qTRKfe9IfQij/q5ykrtcv5zkT7CW6YGpjWtDNQ63Ppzlk/sHtodzkj0vWRbS 3ihLBHiFEABRURZywUyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXRn-007XCB-CT; Thu, 21 Oct 2021 12:45:27 +0000 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-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1544366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=y+0nZuV2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZnKJ3K6Zz9sRR for ; Thu, 21 Oct 2021 23:46:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZPI9f+kJAOAxI2Vjp1aYln+GD3RE8cnAm+44661rRi8=; b=y+0nZuV2I9bnrL Yi1dfpD23xB2DMrKSVrD7JyPXgQ7J3wb/V/TruzEDtF3uRat9ZpV66CGkasGAmGfGsKcUUweGjnFS hl4dqkt4m8OzKXaUkUgGwbn0q7PxTzMJtOSgj6FnspXhiaG6gLLgfHN8/EV4tGBqwcjvfQ7LKedBF JY91JBxPihMKtEmQT6jnZpRXO2+PltVJr7CpSvx1XidJu5PTxoFehNFLxfhbb0M/geQszojbFqEkQ 6P15qSxJ5rrWa5er3HTABsWrkt/Ib7V+WqWMmT137KR9O2hnsiDdqHYGjygLxy3zAcwlLj2+FTg5A 0vxdM0oqQXRBRpoet3dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXS2-007XHK-9d; Thu, 21 Oct 2021 12:45:42 +0000 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-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 1544367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=0nVcgkRh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZnKm08CRz9sRR for ; Thu, 21 Oct 2021 23:46:36 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zB+b4d1cZn0lQfIBfKqGdX1k8UOfvi8iM1U44A+0LJo=; b=0nVcgkRhOgTvjZ 2cL7kBEVHlNLsOZ4l0nySIR3hcdsKeT05K3NhlmOHYfUvUcsqmM9rFUGmV7IPOw+gOp5aMR3AYup4 XPEEDSCaN/l9Up+Cs+F0NMi5ui1VUKaWDV0V2EhCf+3ITnZSkeVTTe2hTZ8vSd5IcntC7vYcH6ttG pcKduaC9OoR5IRo7ibLtWC9n/bbfDhMpgEH7vkDWRXi9gZaiXeVXS49fj+EHDDC6Na3NSt57Rr4bm yjTnc1XfsBBmflVpS9ZwxiczY/IkUVT5864efbhUOQtw3WcgofFYjYkxy3o1iB+xTBV6ktXaoTcGj GgausfIGczJ49fT9ISBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdXSO-007XS6-Es; Thu, 21 Oct 2021 12:46:04 +0000 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-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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);