[Devel] [PATCH RHEL9 COMMIT] fs: Move s_err_event_sent() and s_abrt_event_sent() to super_block

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jan 27 17:36:55 MSK 2022


The commit is pushed to "branch-rh9-5.14.0-4.vz9.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.12.2
------>
commit 549f98069b9ddca83d6f59e8d1b4d6629d8ff556
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Jan 27 17:36:55 2022 +0300

    fs: Move s_err_event_sent() and s_abrt_event_sent() to super_block
    
    To_merge: ac6082c837be ("ext4: add generic uevent infrastructure")
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    ====================
    xfs: Add notification about fs events like for ext4
    
    This patchset generalizes ext4's related code and introduced the same
    uevent notifications for xfs.
    
    https://jira.sw.ru/browse/PSBM-135476
    Feature: fs: udev events support
---
 fs/ext4/ext4.h     | 3 ---
 fs/ext4/super.c    | 6 ++----
 fs/super.c         | 4 ++++
 include/linux/fs.h | 4 ++++
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index a9df91038463..5f6fdd5514b2 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1625,9 +1625,6 @@ struct ext4_sb_info {
 	/* Precomputed FS UUID checksum for seeding other checksums */
 	__u32 s_csum_seed;
 
-	bool s_err_event_sent;
-	bool s_abrt_event_sent;
-
 	/* Reclaim extents from extent status tree */
 	struct shrinker s_es_shrinker;
 	struct list_head s_es_list;	/* List of inodes with reclaimable extents */
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6396b601ae6b..623150be389d 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -649,16 +649,14 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
 	journal_t *journal = EXT4_SB(sb)->s_journal;
 	bool continue_fs = !force_ro && test_opt(sb, ERRORS_CONT);
 
-	if (!xchg(&EXT4_SB(sb)->s_err_event_sent, 1))
-		ext4_send_uevent(sb, FS_UA_ERROR);
+	ext4_send_uevent(sb, FS_UA_ERROR);
 
 	EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
 	if (test_opt(sb, WARN_ON_ERROR))
 		WARN_ON_ONCE(1);
 
 	if (!continue_fs && !sb_rdonly(sb)) {
-		if (!xchg(&EXT4_SB(sb)->s_abrt_event_sent, 1))
-			ext4_send_uevent(sb, FS_UA_ABORT);
+		ext4_send_uevent(sb, FS_UA_ABORT);
 
 		ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED);
 		if (journal)
diff --git a/fs/super.c b/fs/super.c
index 3526cf6b1179..9a3352907716 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1899,6 +1899,10 @@ void fs_send_uevent(struct super_block *sb, struct kobject *kobj,
 
 	if (!fs_events_wq)
 		return;
+	if (action == FS_UA_ERROR && xchg(&sb->s_err_event_sent, 1))
+		return;
+	if (action == FS_UA_ABORT && xchg(&sb->s_abrt_event_sent, 1))
+		return;
 
 	e = kzalloc(sizeof(*e), GFP_NOIO);
 	if (!e)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 45e7393858eb..cd71b108ee24 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1526,6 +1526,10 @@ struct super_block {
 	/* per-sb errseq_t for reporting writeback errors via syncfs */
 	errseq_t s_wb_err;
 
+	/* For fs_send_uevent() */
+	bool s_err_event_sent;
+	bool s_abrt_event_sent;
+
 	/* AIO completions deferred from interrupt context */
 	struct workqueue_struct *s_dio_done_wq;
 	struct hlist_head s_pins;


More information about the Devel mailing list