Viewing: ext4-add-periodic-superblock-update.patch
From 45c922115d9e44c0d62fd2012ccb4d020bbe8edc Mon Sep 17 00:00:00 2001
From: "Vitaliy Kuznetsov" <vk.en.mail@gmail.com>
Date: Thu, 15 Jun 2023 11:17:14 +0300
Subject: [PATCH] ext4: Add periodic superblock update check
This patch introduces a mechanism to periodically check and update
the superblock within the ext4 file system. The main purpose of this
patch is to keep the disk superblock up to date. The update will be
performed if more than one hour has passed since the last update, and
if more than 16MB of data have been written to disk.
This check and update is performed within the ext4_journal_commit_callback
function, ensuring that the superblock is written while the disk is
active, rather than based on a timer that may trigger during disk idle
periods.
Signed-off-by: Vitaliy Kuznetsov <vk.en.mail@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Change-Id: I06eb9624b663a6ca6b15c6af2373b82f1bb63de6
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51340
---
fs/ext4/super.c | 3 ++-
fs/ext4/sysfs.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -753,7 +753,8 @@ static void update_super_work(struct work_struct *work)
* ext4 error handling code during handling of previous errors.
*/
if (!ext4_emergency_state(sbi->s_sb) &&
- !sb_rdonly(sbi->s_sb) && journal) {
+ !sb_rdonly(sbi->s_sb) && journal &&
+ !(journal->j_flags & JBD2_UNMOUNT)) {
struct buffer_head *sbh = sbi->s_sbh;
bool call_notify_err = false;
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -570,7 +570,8 @@ static const struct kobj_type ext4_feat_ktype = {
void ext4_notify_error_sysfs(struct ext4_sb_info *sbi)
{
- sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
+ if (sbi->s_add_error_count > 0)
+ sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
}
static struct kobject *ext4_root;
@@ -666,4 +667,3 @@ void ext4_exit_sysfs(void)
remove_proc_entry(proc_dirname, NULL);
ext4_proc_root = NULL;
}
-
--