xref: /openbmc/linux/fs/btrfs/async-thread.h (revision 6db8914f9763d3f0a7610b497d44f93a4c17e62e)
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_
228b712842SChris Mason 
23d458b054SQu Wenruo struct btrfs_workqueue;
241ca08976SQu Wenruo /* Internal use only */
25d458b054SQu Wenruo struct __btrfs_workqueue;
26*6db8914fSQu Wenruo struct btrfs_work;
27*6db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg);
2808a9ff32SQu Wenruo 
29d458b054SQu Wenruo struct btrfs_work {
30*6db8914fSQu Wenruo 	btrfs_func_t func;
31*6db8914fSQu Wenruo 	btrfs_func_t ordered_func;
32*6db8914fSQu Wenruo 	btrfs_func_t ordered_free;
3308a9ff32SQu Wenruo 
3408a9ff32SQu Wenruo 	/* Don't touch things below */
3508a9ff32SQu Wenruo 	struct work_struct normal_work;
3608a9ff32SQu Wenruo 	struct list_head ordered_list;
37d458b054SQu Wenruo 	struct __btrfs_workqueue *wq;
3808a9ff32SQu Wenruo 	unsigned long flags;
3908a9ff32SQu Wenruo };
4008a9ff32SQu Wenruo 
41d458b054SQu Wenruo struct btrfs_workqueue *btrfs_alloc_workqueue(char *name,
4208a9ff32SQu Wenruo 					      int flags,
430bd9289cSQu Wenruo 					      int max_active,
440bd9289cSQu Wenruo 					      int thresh);
45d458b054SQu Wenruo void btrfs_init_work(struct btrfs_work *work,
46*6db8914fSQu Wenruo 		     btrfs_func_t func,
47*6db8914fSQu Wenruo 		     btrfs_func_t ordered_func,
48*6db8914fSQu Wenruo 		     btrfs_func_t ordered_free);
49d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq,
50d458b054SQu Wenruo 		      struct btrfs_work *work);
51d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
52d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
53d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work);
548b712842SChris Mason #endif
55