[Devel] [PATCH RH9 02/10] fs: Introduce fs_events_wq to use instead ext4's rsv_conversion_wq
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Jan 25 15:22:54 MSK 2022
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).
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
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