mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
btrfs: Added btrfs_workqueue_struct implemented ordered execution based on kernel workqueue
Use kernel workqueue to implement a new btrfs_workqueue_struct, which has the ordering execution feature like the btrfs_worker. The func is executed in a concurrency way, and the ordred_func/ordered_free is executed in the sequence them are queued after the corresponding func is done. The new btrfs_workqueue works much like the original one, one workqueue for normal work and a list for ordered work. When a work is queued, ordered work will be added to the list and helper function will be queued into the workqueue. The helper function will execute a normal work and then check and execute as many ordered work as possible in the sequence they were queued. At this patch, high priority work queue or thresholding is not added yet. The high priority feature and thresholding will be added in the following patches. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Tested-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fb.com>
This commit is contained in:
parent
f5961d41d7
commit
08a9ff3264
2 changed files with 164 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Oracle. All rights reserved.
|
||||
* Copyright (C) 2014 Fujitsu. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
|
@ -118,4 +119,30 @@ void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max,
|
|||
struct btrfs_workers *async_starter);
|
||||
void btrfs_requeue_work(struct btrfs_work *work);
|
||||
void btrfs_set_work_high_prio(struct btrfs_work *work);
|
||||
|
||||
struct btrfs_workqueue_struct;
|
||||
|
||||
struct btrfs_work_struct {
|
||||
void (*func)(struct btrfs_work_struct *arg);
|
||||
void (*ordered_func)(struct btrfs_work_struct *arg);
|
||||
void (*ordered_free)(struct btrfs_work_struct *arg);
|
||||
|
||||
/* Don't touch things below */
|
||||
struct work_struct normal_work;
|
||||
struct list_head ordered_list;
|
||||
struct btrfs_workqueue_struct *wq;
|
||||
unsigned long flags;
|
||||
};
|
||||
|
||||
struct btrfs_workqueue_struct *btrfs_alloc_workqueue(char *name,
|
||||
int flags,
|
||||
int max_active);
|
||||
void btrfs_init_work(struct btrfs_work_struct *work,
|
||||
void (*func)(struct btrfs_work_struct *),
|
||||
void (*ordered_func)(struct btrfs_work_struct *),
|
||||
void (*ordered_free)(struct btrfs_work_struct *));
|
||||
void btrfs_queue_work(struct btrfs_workqueue_struct *wq,
|
||||
struct btrfs_work_struct *work);
|
||||
void btrfs_destroy_workqueue(struct btrfs_workqueue_struct *wq);
|
||||
void btrfs_workqueue_set_max(struct btrfs_workqueue_struct *wq, int max);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue