xref: /openbmc/linux/fs/btrfs/async-thread.h (revision 6f0110581911623df08bf4b65fdef4548ebcda0a)
18b712842SChris Mason /*
28b712842SChris Mason  * Copyright (C) 2007 Oracle.  All rights reserved.
308a9ff32SQu Wenruo  * Copyright (C) 2014 Fujitsu.  All rights reserved.
48b712842SChris Mason  *
58b712842SChris Mason  * This program is free software; you can redistribute it and/or
68b712842SChris Mason  * modify it under the terms of the GNU General Public
78b712842SChris Mason  * License v2 as published by the Free Software Foundation.
88b712842SChris Mason  *
98b712842SChris Mason  * This program is distributed in the hope that it will be useful,
108b712842SChris Mason  * but WITHOUT ANY WARRANTY; without even the implied warranty of
118b712842SChris Mason  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
128b712842SChris Mason  * General Public License for more details.
138b712842SChris Mason  *
148b712842SChris Mason  * You should have received a copy of the GNU General Public
158b712842SChris Mason  * License along with this program; if not, write to the
168b712842SChris Mason  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
178b712842SChris Mason  * Boston, MA 021110-1307, USA.
188b712842SChris Mason  */
198b712842SChris Mason 
208b712842SChris Mason #ifndef __BTRFS_ASYNC_THREAD_
218b712842SChris Mason #define __BTRFS_ASYNC_THREAD_
229e0af237SLiu Bo #include <linux/workqueue.h>
238b712842SChris Mason 
24d458b054SQu Wenruo struct btrfs_workqueue;
251ca08976SQu Wenruo /* Internal use only */
26d458b054SQu Wenruo struct __btrfs_workqueue;
276db8914fSQu Wenruo struct btrfs_work;
286db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg);
299e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg);
3008a9ff32SQu Wenruo 
31d458b054SQu Wenruo struct btrfs_work {
326db8914fSQu Wenruo 	btrfs_func_t func;
336db8914fSQu Wenruo 	btrfs_func_t ordered_func;
346db8914fSQu Wenruo 	btrfs_func_t ordered_free;
3508a9ff32SQu Wenruo 
3608a9ff32SQu Wenruo 	/* Don't touch things below */
3708a9ff32SQu Wenruo 	struct work_struct normal_work;
3808a9ff32SQu Wenruo 	struct list_head ordered_list;
39d458b054SQu Wenruo 	struct __btrfs_workqueue *wq;
4008a9ff32SQu Wenruo 	unsigned long flags;
4108a9ff32SQu Wenruo };
4208a9ff32SQu Wenruo 
439e0af237SLiu Bo #define BTRFS_WORK_HELPER_PROTO(name)					\
449e0af237SLiu Bo void btrfs_##name(struct work_struct *arg)
459e0af237SLiu Bo 
469e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(worker_helper);
479e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delalloc_helper);
489e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
499e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(cache_helper);
509e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(submit_helper);
519e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(fixup_helper);
529e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_helper);
539e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
549e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
559e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
568b110e39SMiao Xie BTRFS_WORK_HELPER_PROTO(endio_repair_helper);
579e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(rmw_helper);
589e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_write_helper);
599e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
609e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
619e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(readahead_helper);
629e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
639e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
649e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrub_helper);
659e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
669e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
679e0af237SLiu Bo 
68c3a46891SQu Wenruo struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
69*6f011058SDavid Sterba 					      unsigned int flags,
700bd9289cSQu Wenruo 					      int max_active,
710bd9289cSQu Wenruo 					      int thresh);
729e0af237SLiu Bo void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
736db8914fSQu Wenruo 		     btrfs_func_t func,
746db8914fSQu Wenruo 		     btrfs_func_t ordered_func,
756db8914fSQu Wenruo 		     btrfs_func_t ordered_free);
76d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq,
77d458b054SQu Wenruo 		      struct btrfs_work *work);
78d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
79d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
80d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work);
818b712842SChris Mason #endif
82