]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs: explicitly unregister per-superblock BDIs
authorChristoph Hellwig <hch@lst.de>
Fri, 5 Nov 2021 20:36:58 +0000 (13:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:10:43 +0000 (15:10 +0200)
[ Upstream commit 0b3ea0926afb8dde70cfab00316ae0a70b93a7cc ]

Add a new SB_I_ flag to mark superblocks that have an ephemeral bdi
associated with them, and unregister it when the superblock is shut
down.

Link: https://lkml.kernel.org/r/20211021124441.668816-4-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Stable-dep-of: 4bcda1eaf184 ("mount: handle OOM on mnt_warn_timestamp_expiry")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/super.c
include/linux/fs.h

index 39d866f7d7c6be1cafa87440728a44c16d0eafc1..eeb8f745a8bf706fe4f54670f6bdaeeed4b1d18a 100644 (file)
@@ -486,6 +486,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;
        }
@@ -1592,6 +1594,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;
 }
index 27da89d0ed5acc6e2c3ea8294dde88436fe5b09e..bf35cf9e312a5aab2b9fafe53e38d96b89b41834 100644 (file)
@@ -1476,6 +1476,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 {