[Devel] [PATCH RHEL9 COMMIT] fs: Make ext4_event_type more generic

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jan 27 17:36:50 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 7a01f711246c7549a3175ed3aa06f66ad2d49801
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Jan 27 17:36:50 2022 +0300

    fs: Make ext4_event_type more generic
    
    So it will be used in other fs also.
    
    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     | 10 ----------
 fs/ext4/super.c    | 42 ++++++++++++++++++------------------------
 include/linux/fs.h | 16 ++++++++++++++++
 3 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 5ea1ca7c57c3..a9df91038463 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3658,16 +3658,6 @@ extern int ext4_check_blockref(const char *, unsigned int,
 struct ext4_ext_path;
 struct ext4_extent;
 
-enum ext4_event_type {
-	EXT4_UA_MOUNT,
-	EXT4_UA_UMOUNT,
-	EXT4_UA_REMOUNT,
-	EXT4_UA_ERROR,
-	EXT4_UA_ABORT,
-	EXT4_UA_FREEZE,
-	EXT4_UA_UNFREEZE,
-};
-
 /*
  * Maximum number of logical blocks in a file; ext4_extent's ee_block is
  * __le32.
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 35e4bb7c0e68..7ede5fd72388 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -435,12 +435,6 @@ static int ext4_uuid_valid(const u8 *uuid)
 	return 0;
 }
 
-struct ext4_uevent {
-	struct super_block *sb;
-	enum ext4_event_type action;
-	struct work_struct work;
-};
-
 /**
  * ext4_send_uevent - prepare and send uevent
  *
@@ -450,7 +444,7 @@ struct ext4_uevent {
  */
 static void ext4_send_uevent_work(struct work_struct *w)
 {
-	struct ext4_uevent *e = container_of(w, struct ext4_uevent, work);
+	struct fs_uevent *e = container_of(w, struct fs_uevent, work);
 	struct super_block *sb = e->sb;
 	struct kobj_uevent_env *env;
 	const u8 *uuid = EXT4_SB(sb)->s_es->s_uuid;
@@ -476,27 +470,27 @@ static void ext4_send_uevent_work(struct work_struct *w)
 	}
 
 	switch (e->action) {
-	case EXT4_UA_MOUNT:
+	case FS_UA_MOUNT:
 		kaction = KOBJ_ONLINE;
 		ret = add_uevent_var(env, "FS_ACTION=%s", "MOUNT");
 		break;
-	case EXT4_UA_UMOUNT:
+	case FS_UA_UMOUNT:
 		kaction = KOBJ_OFFLINE;
 		ret = add_uevent_var(env, "FS_ACTION=%s", "UMOUNT");
 		break;
-	case EXT4_UA_REMOUNT:
+	case FS_UA_REMOUNT:
 		ret = add_uevent_var(env, "FS_ACTION=%s", "REMOUNT");
 		break;
-	case EXT4_UA_ERROR:
+	case FS_UA_ERROR:
 		ret = add_uevent_var(env, "FS_ACTION=%s", "ERROR");
 		break;
-	case EXT4_UA_ABORT:
+	case FS_UA_ABORT:
 		ret = add_uevent_var(env, "FS_ACTION=%s", "ABORT");
 		break;
-	case EXT4_UA_FREEZE:
+	case FS_UA_FREEZE:
 		ret = add_uevent_var(env, "FS_ACTION=%s", "FREEZE");
 		break;
-	case EXT4_UA_UNFREEZE:
+	case FS_UA_UNFREEZE:
 		ret = add_uevent_var(env, "FS_ACTION=%s", "UNFREEZE");
 		break;
 	default:
@@ -517,9 +511,9 @@ static void ext4_send_uevent_work(struct work_struct *w)
  * @action:		action type
  *
  */
-void ext4_send_uevent(struct super_block *sb, enum ext4_event_type action)
+void ext4_send_uevent(struct super_block *sb, enum fs_event_type action)
 {
-	struct ext4_uevent *e;
+	struct fs_uevent *e;
 
 	/*
 	 * May happen if called from ext4_put_super() -> __ext4_abort()
@@ -760,7 +754,7 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
 	bool continue_fs = !force_ro && test_opt(sb, ERRORS_CONT);
 
 	if (!xchg(&EXT4_SB(sb)->s_err_event_sent, 1))
-		ext4_send_uevent(sb, EXT4_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))
@@ -768,7 +762,7 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
 
 	if (!continue_fs && !sb_rdonly(sb)) {
 		if (!xchg(&EXT4_SB(sb)->s_abrt_event_sent, 1))
-			ext4_send_uevent(sb, EXT4_UA_ABORT);
+			ext4_send_uevent(sb, FS_UA_ABORT);
 
 		ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED);
 		if (journal)
@@ -1292,7 +1286,7 @@ static void ext4_put_super(struct super_block *sb)
 	int aborted = 0;
 	int i, err;
 
-	ext4_send_uevent(sb, EXT4_UA_UMOUNT);
+	ext4_send_uevent(sb, FS_UA_UMOUNT);
 	ext4_unregister_li_request(sb);
 	ext4_quota_off_umount(sb);
 
@@ -5329,7 +5323,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	atomic_set(&sbi->s_warning_count, 0);
 	atomic_set(&sbi->s_msg_count, 0);
 
-	ext4_send_uevent(sb, EXT4_UA_MOUNT);
+	ext4_send_uevent(sb, FS_UA_MOUNT);
 	kfree(orig_data);
 	return 0;
 
@@ -5978,7 +5972,7 @@ static int ext4_freeze(struct super_block *sb)
 	journal_t *journal;
 
 	if (sb_rdonly(sb)) {
-		ext4_send_uevent(sb, EXT4_UA_FREEZE);
+		ext4_send_uevent(sb, FS_UA_FREEZE);
 		return 0;
 	}
 
@@ -6007,7 +6001,7 @@ static int ext4_freeze(struct super_block *sb)
 		jbd2_journal_unlock_updates(journal);
 
 	if (!error)
-		ext4_send_uevent(sb, EXT4_UA_FREEZE);
+		ext4_send_uevent(sb, FS_UA_FREEZE);
 
 	return error;
 }
@@ -6018,7 +6012,7 @@ static int ext4_freeze(struct super_block *sb)
  */
 static int ext4_unfreeze(struct super_block *sb)
 {
-	ext4_send_uevent(sb, EXT4_UA_UNFREEZE);
+	ext4_send_uevent(sb, FS_UA_UNFREEZE);
 
 	if (sb_rdonly(sb) || ext4_forced_shutdown(EXT4_SB(sb)))
 		return 0;
@@ -6354,7 +6348,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 #endif
 	if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb))
 		ext4_stop_mmpd(sbi);
-	ext4_send_uevent(sb, EXT4_UA_REMOUNT);
+	ext4_send_uevent(sb, FS_UA_REMOUNT);
 	kfree(orig_data);
 	return err;
 }
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9f34e9384f88..075cca37d920 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3160,6 +3160,22 @@ static inline int ve_fsync_behavior(void)
 }
 #endif
 
+enum fs_event_type {
+	FS_UA_MOUNT,
+	FS_UA_UMOUNT,
+	FS_UA_REMOUNT,
+	FS_UA_ERROR,
+	FS_UA_ABORT,
+	FS_UA_FREEZE,
+	FS_UA_UNFREEZE,
+};
+
+struct fs_uevent {
+	struct super_block *sb;
+	enum fs_event_type action;
+	struct work_struct work;
+};
+
 #include <linux/err.h>
 
 /* needed for stackable file system support */


More information about the Devel mailing list