[Devel] [PATCH RHEL9 COMMIT] fs: Introduce fs_events_wq to use instead ext4's rsv_conversion_wq

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

    fs: Introduce fs_events_wq to use instead ext4's rsv_conversion_wq
    
    The intention of this patch is to generalize wq for events
    in different filesystems.
    I considered to allocate per-super_block wq instead of this,
    but that looks worse since all filesystems will have to allocate
    it. Introduction a flag like FS_WANTS_EVENTS_WQ also looks
    not good for me.
    So, here is common wq for all root fs (ext4 and xfs).
    
    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/super.c    |  6 ++++--
 fs/super.c         | 11 +++++++++++
 include/linux/fs.h |  2 ++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7ede5fd72388..e40c511a9d26 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -519,17 +519,18 @@ void ext4_send_uevent(struct super_block *sb, enum fs_event_type action)
 	 * May happen if called from ext4_put_super() -> __ext4_abort()
 	 * -> ext4_send_uevent()
 	 */
-	if (!EXT4_SB(sb)->rsv_conversion_wq)
+	if (!fs_events_wq)
 		return;
 
 	e = kzalloc(sizeof(*e), GFP_NOIO);
 	if (!e)
 		return;
 
+	/* Do not forget to flush fs_events_wq before you kill sb */
 	e->sb = sb;
 	e->action = action;
 	INIT_WORK(&e->work, ext4_send_uevent_work);
-	queue_work(EXT4_SB(sb)->rsv_conversion_wq, &e->work);
+	queue_work(fs_events_wq, &e->work);
 }
 
 
@@ -1287,6 +1288,7 @@ static void ext4_put_super(struct super_block *sb)
 	int i, err;
 
 	ext4_send_uevent(sb, FS_UA_UMOUNT);
+	flush_workqueue(fs_events_wq);
 	ext4_unregister_li_request(sb);
 	ext4_quota_off_umount(sb);
 
diff --git a/fs/super.c b/fs/super.c
index e45ce5213d4b..c62e470c0b8b 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1826,3 +1826,14 @@ int thaw_super(struct super_block *sb)
 	return thaw_super_locked(sb);
 }
 EXPORT_SYMBOL(thaw_super);
+
+struct workqueue_struct *fs_events_wq;
+
+static int __init fs_events_init(void)
+{
+	fs_events_wq = alloc_workqueue("fs_events", 0, 0);
+	if (!fs_events_wq)
+		return -ENOMEM;
+	return 0;
+}
+fs_initcall(fs_events_init);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 075cca37d920..226093049c17 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3176,6 +3176,8 @@ struct fs_uevent {
 	struct work_struct work;
 };
 
+extern struct workqueue_struct *fs_events_wq;
+
 #include <linux/err.h>
 
 /* needed for stackable file system support */


More information about the Devel mailing list