xref: /openbmc/linux/fs/btrfs/async-thread.h (revision 58e814fc)
19888c340SDavid 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 
79888c340SDavid Sterba #ifndef BTRFS_ASYNC_THREAD_H
89888c340SDavid Sterba #define BTRFS_ASYNC_THREAD_H
99888c340SDavid Sterba 
109e0af237SLiu Bo #include <linux/workqueue.h>
118b712842SChris Mason 
12cb001095SJeff Mahoney struct btrfs_fs_info;
13d458b054SQu Wenruo struct btrfs_workqueue;
146db8914fSQu Wenruo struct btrfs_work;
156db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg);
1608a9ff32SQu Wenruo 
17d458b054SQu Wenruo struct btrfs_work {
186db8914fSQu Wenruo 	btrfs_func_t func;
196db8914fSQu Wenruo 	btrfs_func_t ordered_func;
206db8914fSQu Wenruo 	btrfs_func_t ordered_free;
2108a9ff32SQu Wenruo 
2208a9ff32SQu Wenruo 	/* Don't touch things below */
2308a9ff32SQu Wenruo 	struct work_struct normal_work;
2408a9ff32SQu Wenruo 	struct list_head ordered_list;
25a31b4a43SChristoph Hellwig 	struct btrfs_workqueue *wq;
2608a9ff32SQu Wenruo 	unsigned long flags;
2708a9ff32SQu Wenruo };
2808a9ff32SQu Wenruo 
29cb001095SJeff Mahoney struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
30cb001095SJeff Mahoney 					      const char *name,
316f011058SDavid Sterba 					      unsigned int flags,
32c6dd6ea5SQu Wenruo 					      int limit_active,
330bd9289cSQu Wenruo 					      int thresh);
34*58e814fcSTejun Heo struct btrfs_workqueue *btrfs_alloc_ordered_workqueue(
35*58e814fcSTejun Heo 				struct btrfs_fs_info *fs_info, const char *name,
36*58e814fcSTejun Heo 				unsigned int flags);
37a0cac0ecSOmar Sandoval void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func,
38a0cac0ecSOmar Sandoval 		     btrfs_func_t ordered_func, btrfs_func_t ordered_free);
39d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq,
40d458b054SQu Wenruo 		      struct btrfs_work *work);
41d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
42d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
43e1f60a65SDavid Sterba struct btrfs_fs_info * __pure btrfs_work_owner(const struct btrfs_work *work);
44a31b4a43SChristoph Hellwig struct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct btrfs_workqueue *wq);
459a35b637SJeff Mahoney bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq);
46f0cc2cd7SFilipe Manana void btrfs_flush_workqueue(struct btrfs_workqueue *wq);
479888c340SDavid Sterba 
488b712842SChris Mason #endif
49