Skip to content

Commit

Permalink
ext4: notify sysfs on errors_count value change
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jjd27 authored and tytso committed Jun 30, 2021
1 parent acc6100 commit d578b99
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -3624,6 +3624,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 ext4_sb_info *sbi);
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);
Expand Down
2 changes: 2 additions & 0 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ static void flush_stashed_error_work(struct work_struct *work)
goto write_directly;
}
jbd2_journal_stop(handle);
ext4_notify_error_sysfs(sbi);
return;
}
write_directly:
Expand All @@ -726,6 +727,7 @@ static void flush_stashed_error_work(struct work_struct *work)
* out and hope for the best.
*/
ext4_commit_super(sbi->s_sb);
ext4_notify_error_sysfs(sbi);
}

#define ext4_error_ratelimit(sb) \
Expand Down
5 changes: 5 additions & 0 deletions fs/ext4/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ static struct kobj_type ext4_feat_ktype = {
.release = (void (*)(struct kobject *))kfree,
};

void ext4_notify_error_sysfs(struct ext4_sb_info *sbi)
{
sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
}

static struct kobject *ext4_root;

static struct kobject *ext4_feat;
Expand Down

0 comments on commit d578b99

Please sign in to comment.