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_ 22*9e0af237SLiu Bo #include <linux/workqueue.h> 238b712842SChris Mason 24d458b054SQu Wenruo struct btrfs_workqueue; 251ca08976SQu Wenruo /* Internal use only */ 26d458b054SQu Wenruo struct __btrfs_workqueue; 276db8914fSQu Wenruo struct btrfs_work; 286db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg); 29*9e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg); 3008a9ff32SQu Wenruo 31d458b054SQu Wenruo struct btrfs_work { 326db8914fSQu Wenruo btrfs_func_t func; 336db8914fSQu Wenruo btrfs_func_t ordered_func; 346db8914fSQu Wenruo btrfs_func_t ordered_free; 3508a9ff32SQu Wenruo 3608a9ff32SQu Wenruo /* Don't touch things below */ 3708a9ff32SQu Wenruo struct work_struct normal_work; 3808a9ff32SQu Wenruo struct list_head ordered_list; 39d458b054SQu Wenruo struct __btrfs_workqueue *wq; 4008a9ff32SQu Wenruo unsigned long flags; 4108a9ff32SQu Wenruo }; 4208a9ff32SQu Wenruo 43*9e0af237SLiu Bo #define BTRFS_WORK_HELPER_PROTO(name) \ 44*9e0af237SLiu Bo void btrfs_##name(struct work_struct *arg) 45*9e0af237SLiu Bo 46*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(worker_helper); 47*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delalloc_helper); 48*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper); 49*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(cache_helper); 50*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(submit_helper); 51*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(fixup_helper); 52*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_helper); 53*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_helper); 54*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper); 55*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_raid56_helper); 56*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(rmw_helper); 57*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_write_helper); 58*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(freespace_write_helper); 59*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delayed_meta_helper); 60*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(readahead_helper); 61*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper); 62*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(extent_refs_helper); 63*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrub_helper); 64*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubwrc_helper); 65*9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubnc_helper); 66*9e0af237SLiu Bo 67c3a46891SQu Wenruo struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, 6808a9ff32SQu Wenruo int flags, 690bd9289cSQu Wenruo int max_active, 700bd9289cSQu Wenruo int thresh); 71*9e0af237SLiu Bo void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper, 726db8914fSQu Wenruo btrfs_func_t func, 736db8914fSQu Wenruo btrfs_func_t ordered_func, 746db8914fSQu Wenruo btrfs_func_t ordered_free); 75d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq, 76d458b054SQu Wenruo struct btrfs_work *work); 77d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq); 78d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max); 79d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work); 808b712842SChris Mason #endif 81