xref: /openbmc/linux/fs/btrfs/async-thread.h (revision d458b0540ebd728b4d6ef47cc5ef0dbfd4dd361a)
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 
23*d458b054SQu Wenruo struct btrfs_workqueue;
241ca08976SQu Wenruo /* Internal use only */
25*d458b054SQu Wenruo struct __btrfs_workqueue;
2608a9ff32SQu Wenruo 
27*d458b054SQu Wenruo struct btrfs_work {
28*d458b054SQu Wenruo 	void (*func)(struct btrfs_work *arg);
29*d458b054SQu Wenruo 	void (*ordered_func)(struct btrfs_work *arg);
30*d458b054SQu Wenruo 	void (*ordered_free)(struct btrfs_work *arg);
3108a9ff32SQu Wenruo 
3208a9ff32SQu Wenruo 	/* Don't touch things below */
3308a9ff32SQu Wenruo 	struct work_struct normal_work;
3408a9ff32SQu Wenruo 	struct list_head ordered_list;
35*d458b054SQu Wenruo 	struct __btrfs_workqueue *wq;
3608a9ff32SQu Wenruo 	unsigned long flags;
3708a9ff32SQu Wenruo };
3808a9ff32SQu Wenruo 
39*d458b054SQu Wenruo struct btrfs_workqueue *btrfs_alloc_workqueue(char *name,
4008a9ff32SQu Wenruo 						     int flags,
410bd9289cSQu Wenruo 						     int max_active,
420bd9289cSQu Wenruo 						     int thresh);
43*d458b054SQu Wenruo void btrfs_init_work(struct btrfs_work *work,
44*d458b054SQu Wenruo 		     void (*func)(struct btrfs_work *),
45*d458b054SQu Wenruo 		     void (*ordered_func)(struct btrfs_work *),
46*d458b054SQu Wenruo 		     void (*ordered_free)(struct btrfs_work *));
47*d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq,
48*d458b054SQu Wenruo 		      struct btrfs_work *work);
49*d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
50*d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
51*d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work);
528b712842SChris Mason #endif
53