public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Davies <jonathan.davies@nutanix.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Jonathan Davies <jonathan.davies@nutanix.com>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ext4: notify sysfs on errors_count value change
Date: Fri, 11 Jun 2021 14:02:08 +0000	[thread overview]
Message-ID: <20210611140209.28903-1-jonathan.davies@nutanix.com> (raw)

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@nutanix.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


             reply	other threads:[~2021-06-11 14:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 14:02 Jonathan Davies [this message]
2021-06-24 16:24 ` [PATCH] ext4: notify sysfs on errors_count value change Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210611140209.28903-1-jonathan.davies@nutanix.com \
    --to=jonathan.davies@nutanix.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox