[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210611140209.28903-1-jonathan.davies@nutanix.com>
Date: Fri, 11 Jun 2021 14:02:08 +0000
From: Jonathan Davies <jonathan.davies@...anix.com>
To: Theodore Ts'o <tytso@....edu>
Cc: Jonathan Davies <jonathan.davies@...anix.com>,
Andreas Dilger <adilger.kernel@...ger.ca>,
linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] ext4: notify sysfs on errors_count value change
After s_error_count is incremented, signal the change in the
corresponding sysfs attribute via sysfs_notify. This allows userspace to
poll() on changes to /sys/fs/ext4/*/errors_count.
Signed-off-by: Jonathan Davies <jonathan.davies@...anix.com>
---
fs/ext4/ext4.h | 1 +
fs/ext4/super.c | 1 +
fs/ext4/sysfs.c | 7 +++++++
3 files changed, 9 insertions(+)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 37002663..f313f5be 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3614,6 +3614,7 @@ extern const struct inode_operations ext4_symlink_inode_operations;
extern const struct inode_operations ext4_fast_symlink_inode_operations;
/* sysfs.c */
+extern void ext4_notify_error_sysfs(struct super_block *sb);
extern int ext4_register_sysfs(struct super_block *sb);
extern void ext4_unregister_sysfs(struct super_block *sb);
extern int __init ext4_init_sysfs(void);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d29f6aa..2525239 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5579,6 +5579,7 @@ static void ext4_update_super(struct super_block *sb)
if (!es->s_error_count)
mod_timer(&sbi->s_err_report, jiffies + 24*60*60*HZ);
le32_add_cpu(&es->s_error_count, sbi->s_add_error_count);
+ ext4_notify_error_sysfs(sb);
sbi->s_add_error_count = 0;
}
spin_unlock(&sbi->s_error_lock);
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 55fcab6..254b7fc 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -506,6 +506,13 @@ static struct kobj_type ext4_feat_ktype = {
.release = (void (*)(struct kobject *))kfree,
};
+void ext4_notify_error_sysfs(struct super_block *sb)
+{
+ struct ext4_sb_info *sbi = EXT4_SB(sb);
+
+ sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
+}
+
static struct kobject *ext4_root;
static struct kobject *ext4_feat;
--
2.9.3
Powered by blists - more mailing lists