[PATCH v4 2/8] ovl: setup overlayfs' private bdi
From: Josef Bacik
Date: Fri Nov 06 2026 - 08:41:37 EST
From: Chengguang Xu <charliecgxu@xxxxxxxxxxx>
Setup overlayfs' private bdi so that we can collect
overlayfs' own dirty inodes.
Signed-off-by: Chengguang Xu <charliecgxu@xxxxxxxxxxx>
[josef: only for an overlay that tracks dirty inodes]
Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
fs/overlayfs/super.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 81da70fd53a6..22a8d4eb3b7c 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1490,6 +1490,16 @@ static int ovl_fill_super_creds(struct fs_context *fc, struct super_block *sb)
if (!ofs->workdir)
sb->s_flags |= SB_RDONLY;
+ /*
+ * Dirty overlay inodes go on the lists of this bdi. fsync_mode
+ * is final once ovl_get_workdir() has returned.
+ */
+ if (ovl_tracks_dirty(ofs)) {
+ err = super_setup_bdi(sb);
+ if (err)
+ return err;
+ }
+
sb->s_stack_depth = upper_sb->s_stack_depth;
sb->s_time_gran = upper_sb->s_time_gran;
}
--
2.55.0