xref: /openbmc/linux/fs/btrfs/async-thread.h (revision 9888c3402c8567a977de37f61e9dd87792723064)
1*9888c340SDavid Sterba /* SPDX-License-Identifier: GPL-2.0 */
28b712842SChris Mason /*
38b712842SChris Mason  * Copyright (C) 2007 Oracle.  All rights reserved.
408a9ff32SQu Wenruo  * Copyright (C) 2014 Fujitsu.  All rights reserved.
58b712842SChris Mason  */
68b712842SChris Mason 
7*9888c340SDavid Sterba #ifndef BTRFS_ASYNC_THREAD_H
8*9888c340SDavid Sterba #define BTRFS_ASYNC_THREAD_H
9*9888c340SDavid Sterba 
109e0af237SLiu Bo #include <linux/workqueue.h>
118b712842SChris Mason 
12cb001095SJeff Mahoney struct btrfs_fs_info;
13d458b054SQu Wenruo struct btrfs_workqueue;
141ca08976SQu Wenruo /* Internal use only */
15d458b054SQu Wenruo struct __btrfs_workqueue;
166db8914fSQu Wenruo struct btrfs_work;
176db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg);
189e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg);
1908a9ff32SQu Wenruo 
20d458b054SQu Wenruo struct btrfs_work {
216db8914fSQu Wenruo 	btrfs_func_t func;
226db8914fSQu Wenruo 	btrfs_func_t ordered_func;
236db8914fSQu Wenruo 	btrfs_func_t ordered_free;
2408a9ff32SQu Wenruo 
2508a9ff32SQu Wenruo 	/* Don't touch things below */
2608a9ff32SQu Wenruo 	struct work_struct normal_work;
2708a9ff32SQu Wenruo 	struct list_head ordered_list;
28d458b054SQu Wenruo 	struct __btrfs_workqueue *wq;
2908a9ff32SQu Wenruo 	unsigned long flags;
3008a9ff32SQu Wenruo };
3108a9ff32SQu Wenruo 
329e0af237SLiu Bo #define BTRFS_WORK_HELPER_PROTO(name)					\
339e0af237SLiu Bo void btrfs_##name(struct work_struct *arg)
349e0af237SLiu Bo 
359e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(worker_helper);
369e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delalloc_helper);
379e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
389e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(cache_helper);
399e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(submit_helper);
409e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(fixup_helper);
419e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_helper);
429e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
439e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
449e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
458b110e39SMiao Xie BTRFS_WORK_HELPER_PROTO(endio_repair_helper);
469e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(rmw_helper);
479e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_write_helper);
489e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
499e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
509e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(readahead_helper);
519e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
529e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
539e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrub_helper);
549e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
559e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
5620b2e302SZhao Lei BTRFS_WORK_HELPER_PROTO(scrubparity_helper);
5720b2e302SZhao Lei 
589e0af237SLiu Bo 
59cb001095SJeff Mahoney struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
60cb001095SJeff Mahoney 					      const char *name,
616f011058SDavid Sterba 					      unsigned int flags,
62c6dd6ea5SQu Wenruo 					      int limit_active,
630bd9289cSQu Wenruo 					      int thresh);
649e0af237SLiu Bo void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
656db8914fSQu Wenruo 		     btrfs_func_t func,
666db8914fSQu Wenruo 		     btrfs_func_t ordered_func,
676db8914fSQu Wenruo 		     btrfs_func_t ordered_free);
68d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq,
69d458b054SQu Wenruo 		      struct btrfs_work *work);
70d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
71d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
72d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work);
739a35b637SJeff Mahoney struct btrfs_fs_info *btrfs_work_owner(const struct btrfs_work *work);
749a35b637SJeff Mahoney struct btrfs_fs_info *btrfs_workqueue_owner(const struct __btrfs_workqueue *wq);
759a35b637SJeff Mahoney bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq);
76*9888c340SDavid Sterba 
778b712842SChris Mason #endif
78