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); 169e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg); 1708a9ff32SQu Wenruo 18d458b054SQu Wenruo struct btrfs_work { 196db8914fSQu Wenruo btrfs_func_t func; 206db8914fSQu Wenruo btrfs_func_t ordered_func; 216db8914fSQu Wenruo btrfs_func_t ordered_free; 2208a9ff32SQu Wenruo 2308a9ff32SQu Wenruo /* Don't touch things below */ 2408a9ff32SQu Wenruo struct work_struct normal_work; 2508a9ff32SQu Wenruo struct list_head ordered_list; 26*a31b4a43SChristoph Hellwig struct btrfs_workqueue *wq; 2708a9ff32SQu Wenruo unsigned long flags; 2808a9ff32SQu Wenruo }; 2908a9ff32SQu Wenruo 30cb001095SJeff Mahoney struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, 31cb001095SJeff Mahoney const char *name, 326f011058SDavid Sterba unsigned int flags, 33c6dd6ea5SQu Wenruo int limit_active, 340bd9289cSQu Wenruo int thresh); 35a0cac0ecSOmar Sandoval void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func, 36a0cac0ecSOmar Sandoval btrfs_func_t ordered_func, btrfs_func_t ordered_free); 37d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq, 38d458b054SQu Wenruo struct btrfs_work *work); 39d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq); 40d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max); 41e1f60a65SDavid Sterba struct btrfs_fs_info * __pure btrfs_work_owner(const struct btrfs_work *work); 42*a31b4a43SChristoph Hellwig struct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct btrfs_workqueue *wq); 439a35b637SJeff Mahoney bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq); 44f0cc2cd7SFilipe Manana void btrfs_flush_workqueue(struct btrfs_workqueue *wq); 459888c340SDavid Sterba 468b712842SChris Mason #endif 47