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; 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 32cb001095SJeff Mahoney struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, 33cb001095SJeff Mahoney const char *name, 346f011058SDavid Sterba unsigned int flags, 35c6dd6ea5SQu Wenruo int limit_active, 360bd9289cSQu Wenruo int thresh); 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); 43d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work); 44*e1f60a65SDavid Sterba struct btrfs_fs_info * __pure btrfs_work_owner(const struct btrfs_work *work); 45*e1f60a65SDavid Sterba struct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct __btrfs_workqueue *wq); 469a35b637SJeff Mahoney bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq); 479888c340SDavid Sterba 488b712842SChris Mason #endif 49