[Devel] [PATCH RH9 12/12] ext4: send abort uevent on ext4 journal abort

Kirill Tkhai ktkhai at virtuozzo.com
Thu Oct 7 13:20:58 MSK 2021


From: Dmitry Monakhov <dmonakhov at openvz.org>

Currenlty error from device result in ext4_abort, but uevent not generated because
ext4_abort() caller's context do not allow GFP_KERNEL memory allocation.
Let's relax submission context requirement and deffer actual uevent submission
to work_queue.  It can be any workqueue I've pick rsv_conversion_wq because it is
already exists.

khorenko@: "system_wq" does not fit here because at the moment of
work execution sb can be already destroyed.
"EXT4_SB(sb)->rsv_conversion_wq" is flushed before sb is destroyed.

Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>

[aryabinin rh8 rebase]
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 fs/ext4/ext4.h  |    2 ++
 fs/ext4/super.c |    6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 70b3038fa0d1..5ea1ca7c57c3 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1626,6 +1626,7 @@ struct ext4_sb_info {
 	__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;
@@ -3662,6 +3663,7 @@ enum ext4_event_type {
 	EXT4_UA_UMOUNT,
 	EXT4_UA_REMOUNT,
 	EXT4_UA_ERROR,
+	EXT4_UA_ABORT,
 	EXT4_UA_FREEZE,
 	EXT4_UA_UNFREEZE,
 };
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 597768497c42..9119dc05850f 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -490,6 +490,9 @@ static void ext4_send_uevent_work(struct work_struct *w)
 	case EXT4_UA_ERROR:
 		ret = add_uevent_var(env, "FS_ACTION=%s", "ERROR");
 		break;
+	case EXT4_UA_ABORT:
+		ret = add_uevent_var(env, "FS_ACTION=%s", "ABORT");
+		break;
 	case EXT4_UA_FREEZE:
 		ret = add_uevent_var(env, "FS_ACTION=%s", "FREEZE");
 		break;
@@ -764,6 +767,9 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int 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, EXT4_UA_ABORT);
+
 		ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED);
 		if (journal)
 			jbd2_journal_abort(journal, -EIO);




More information about the Devel mailing list