xref: /openbmc/linux/fs/btrfs/async-thread.h (revision c6dd6ea55758cf403bdc07a51a06c2a1d474f906)
1 8b712842SChris Mason /*
2 8b712842SChris Mason  * Copyright (C) 2007 Oracle.  All rights reserved.
3 08a9ff32SQu Wenruo  * Copyright (C) 2014 Fujitsu.  All rights reserved.
4 8b712842SChris Mason  *
5 8b712842SChris Mason  * This program is free software; you can redistribute it and/or
6 8b712842SChris Mason  * modify it under the terms of the GNU General Public
7 8b712842SChris Mason  * License v2 as published by the Free Software Foundation.
8 8b712842SChris Mason  *
9 8b712842SChris Mason  * This program is distributed in the hope that it will be useful,
10 8b712842SChris Mason  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 8b712842SChris Mason  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 8b712842SChris Mason  * General Public License for more details.
13 8b712842SChris Mason  *
14 8b712842SChris Mason  * You should have received a copy of the GNU General Public
15 8b712842SChris Mason  * License along with this program; if not, write to the
16 8b712842SChris Mason  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 8b712842SChris Mason  * Boston, MA 021110-1307, USA.
18 8b712842SChris Mason  */
19 8b712842SChris Mason 
20 8b712842SChris Mason #ifndef __BTRFS_ASYNC_THREAD_
21 8b712842SChris Mason #define __BTRFS_ASYNC_THREAD_
22 9e0af237SLiu Bo #include <linux/workqueue.h>
23 8b712842SChris Mason 
24 d458b054SQu Wenruo struct btrfs_workqueue;
25 1ca08976SQu Wenruo /* Internal use only */
26 d458b054SQu Wenruo struct __btrfs_workqueue;
27 6db8914fSQu Wenruo struct btrfs_work;
28 6db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg);
29 9e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg);
30 08a9ff32SQu Wenruo 
31 d458b054SQu Wenruo struct btrfs_work {
32 6db8914fSQu Wenruo 	btrfs_func_t func;
33 6db8914fSQu Wenruo 	btrfs_func_t ordered_func;
34 6db8914fSQu Wenruo 	btrfs_func_t ordered_free;
35 08a9ff32SQu Wenruo 
36 08a9ff32SQu Wenruo 	/* Don't touch things below */
37 08a9ff32SQu Wenruo 	struct work_struct normal_work;
38 08a9ff32SQu Wenruo 	struct list_head ordered_list;
39 d458b054SQu Wenruo 	struct __btrfs_workqueue *wq;
40 08a9ff32SQu Wenruo 	unsigned long flags;
41 08a9ff32SQu Wenruo };
42 08a9ff32SQu Wenruo 
43 9e0af237SLiu Bo #define BTRFS_WORK_HELPER_PROTO(name)					\
44 9e0af237SLiu Bo void btrfs_##name(struct work_struct *arg)
45 9e0af237SLiu Bo 
46 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(worker_helper);
47 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delalloc_helper);
48 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
49 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(cache_helper);
50 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(submit_helper);
51 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(fixup_helper);
52 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_helper);
53 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
54 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
55 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
56 8b110e39SMiao Xie BTRFS_WORK_HELPER_PROTO(endio_repair_helper);
57 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(rmw_helper);
58 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_write_helper);
59 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
60 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
61 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(readahead_helper);
62 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
63 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
64 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrub_helper);
65 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
66 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
67 20b2e302SZhao Lei BTRFS_WORK_HELPER_PROTO(scrubparity_helper);
68 20b2e302SZhao Lei 
69 9e0af237SLiu Bo 
70 c3a46891SQu Wenruo struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
71 6f011058SDavid Sterba 					      unsigned int flags,
72 *c6dd6ea5SQu Wenruo 					      int limit_active,
73 0bd9289cSQu Wenruo 					      int thresh);
74 9e0af237SLiu Bo void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
75 6db8914fSQu Wenruo 		     btrfs_func_t func,
76 6db8914fSQu Wenruo 		     btrfs_func_t ordered_func,
77 6db8914fSQu Wenruo 		     btrfs_func_t ordered_free);
78 d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq,
79 d458b054SQu Wenruo 		      struct btrfs_work *work);
80 d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
81 d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
82 d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work);
83 8b712842SChris Mason #endif
84