Skip to contentSkip to conversation

ext4: notify sysfs on errors_count value change

PATCH Applied Jonathan Davies 2 participants 2 messages Jun 11, 2021 – Jun 24, 2021 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/ext4/ext4.h  | 1 +
 fs/ext4/super.c | 1 +
 fs/ext4/sysfs.c | 7 +++++++
 3 files changed, 9 insertions(+)
fs/ext4/ext4.h +1 -0
index 37002663..f313f5be 100644
@@ -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);
fs/ext4/super.c +1 -0
index d29f6aa..2525239 100644
@@ -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);
fs/ext4/sysfs.c +7 -0
index 55fcab6..254b7fc 100644
@@ -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;
Signature · 1 line
2.9.3
maintainer Applied
#1 lore raw
Quoted 5 lines · Jonathan Davies

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.

Applied, thanks.

- Ted