Skip to content

Commit d578b99

Browse files
jjd27tytso
authored andcommitted
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. [ Moved call of ext4_notify_error_sysfs() to flush_stashed_error_work() to avoid BUG's caused by calling sysfs_notify trying to sleep after being called from an invalid context. -- TYT ] Signed-off-by: Jonathan Davies <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent acc6100 commit d578b99

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

fs/ext4/ext4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3624,6 +3624,7 @@ extern const struct inode_operations ext4_symlink_inode_operations;
36243624
extern const struct inode_operations ext4_fast_symlink_inode_operations;
36253625

36263626
/* sysfs.c */
3627+
extern void ext4_notify_error_sysfs(struct ext4_sb_info *sbi);
36273628
extern int ext4_register_sysfs(struct super_block *sb);
36283629
extern void ext4_unregister_sysfs(struct super_block *sb);
36293630
extern int __init ext4_init_sysfs(void);

fs/ext4/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ static void flush_stashed_error_work(struct work_struct *work)
718718
goto write_directly;
719719
}
720720
jbd2_journal_stop(handle);
721+
ext4_notify_error_sysfs(sbi);
721722
return;
722723
}
723724
write_directly:
@@ -726,6 +727,7 @@ static void flush_stashed_error_work(struct work_struct *work)
726727
* out and hope for the best.
727728
*/
728729
ext4_commit_super(sbi->s_sb);
730+
ext4_notify_error_sysfs(sbi);
729731
}
730732

731733
#define ext4_error_ratelimit(sb) \

fs/ext4/sysfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ static struct kobj_type ext4_feat_ktype = {
506506
.release = (void (*)(struct kobject *))kfree,
507507
};
508508

509+
void ext4_notify_error_sysfs(struct ext4_sb_info *sbi)
510+
{
511+
sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
512+
}
513+
509514
static struct kobject *ext4_root;
510515

511516
static struct kobject *ext4_feat;

0 commit comments

Comments
 (0)