1 9888c340SDavid Sterba /* SPDX-License-Identifier: GPL-2.0 */ 2 8b712842SChris Mason /* 3 8b712842SChris Mason * Copyright (C) 2007 Oracle. All rights reserved. 4 08a9ff32SQu Wenruo * Copyright (C) 2014 Fujitsu. All rights reserved. 5 8b712842SChris Mason */ 6 8b712842SChris Mason 7 9888c340SDavid Sterba #ifndef BTRFS_ASYNC_THREAD_H 8 9888c340SDavid Sterba #define BTRFS_ASYNC_THREAD_H 9 9888c340SDavid Sterba 10 9e0af237SLiu Bo #include <linux/workqueue.h> 11 8b712842SChris Mason 12 cb001095SJeff Mahoney struct btrfs_fs_info; 13 d458b054SQu Wenruo struct btrfs_workqueue; 14 1ca08976SQu Wenruo /* Internal use only */ 15 d458b054SQu Wenruo struct __btrfs_workqueue; 16 6db8914fSQu Wenruo struct btrfs_work; 17 6db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg); 18 9e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg); 19 08a9ff32SQu Wenruo 20 d458b054SQu Wenruo struct btrfs_work { 21 6db8914fSQu Wenruo btrfs_func_t func; 22 6db8914fSQu Wenruo btrfs_func_t ordered_func; 23 6db8914fSQu Wenruo btrfs_func_t ordered_free; 24 08a9ff32SQu Wenruo 25 08a9ff32SQu Wenruo /* Don't touch things below */ 26 08a9ff32SQu Wenruo struct work_struct normal_work; 27 08a9ff32SQu Wenruo struct list_head ordered_list; 28 d458b054SQu Wenruo struct __btrfs_workqueue *wq; 29 08a9ff32SQu Wenruo unsigned long flags; 30 08a9ff32SQu Wenruo }; 31 08a9ff32SQu Wenruo 32 cb001095SJeff Mahoney struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, 33 cb001095SJeff Mahoney const char *name, 34 6f011058SDavid Sterba unsigned int flags, 35 c6dd6ea5SQu Wenruo int limit_active, 36 0bd9289cSQu Wenruo int thresh); 37 a0cac0ecSOmar Sandoval void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func, 38 a0cac0ecSOmar Sandoval btrfs_func_t ordered_func, btrfs_func_t ordered_free); 39 d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq, 40 d458b054SQu Wenruo struct btrfs_work *work); 41 d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq); 42 d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max); 43 d458b054SQu 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); 46 9a35b637SJeff Mahoney bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq); 47 *f0cc2cd7SFilipe Manana void btrfs_flush_workqueue(struct btrfs_workqueue *wq); 48 9888c340SDavid Sterba 49 8b712842SChris Mason #endif 50