1 8b712842SChris Mason /* 2 8b712842SChris Mason * Copyright (C) 2007 Oracle. All rights reserved. 3 08a9ff32SQu Wenruo * Copyright (C) 2014 Fujitsu. All rights reserved. 4 8b712842SChris Mason * 5 8b712842SChris Mason * This program is free software; you can redistribute it and/or 6 8b712842SChris Mason * modify it under the terms of the GNU General Public 7 8b712842SChris Mason * License v2 as published by the Free Software Foundation. 8 8b712842SChris Mason * 9 8b712842SChris Mason * This program is distributed in the hope that it will be useful, 10 8b712842SChris Mason * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 8b712842SChris Mason * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 8b712842SChris Mason * General Public License for more details. 13 8b712842SChris Mason * 14 8b712842SChris Mason * You should have received a copy of the GNU General Public 15 8b712842SChris Mason * License along with this program; if not, write to the 16 8b712842SChris Mason * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 8b712842SChris Mason * Boston, MA 021110-1307, USA. 18 8b712842SChris Mason */ 19 8b712842SChris Mason 20 8b712842SChris Mason #ifndef __BTRFS_ASYNC_THREAD_ 21 8b712842SChris Mason #define __BTRFS_ASYNC_THREAD_ 22 9e0af237SLiu Bo #include <linux/workqueue.h> 23 8b712842SChris Mason 24 cb001095SJeff Mahoney struct btrfs_fs_info; 25 d458b054SQu Wenruo struct btrfs_workqueue; 26 1ca08976SQu Wenruo /* Internal use only */ 27 d458b054SQu Wenruo struct __btrfs_workqueue; 28 6db8914fSQu Wenruo struct btrfs_work; 29 6db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg); 30 9e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg); 31 08a9ff32SQu Wenruo 32 d458b054SQu Wenruo struct btrfs_work { 33 6db8914fSQu Wenruo btrfs_func_t func; 34 6db8914fSQu Wenruo btrfs_func_t ordered_func; 35 6db8914fSQu Wenruo btrfs_func_t ordered_free; 36 08a9ff32SQu Wenruo 37 08a9ff32SQu Wenruo /* Don't touch things below */ 38 08a9ff32SQu Wenruo struct work_struct normal_work; 39 08a9ff32SQu Wenruo struct list_head ordered_list; 40 d458b054SQu Wenruo struct __btrfs_workqueue *wq; 41 08a9ff32SQu Wenruo unsigned long flags; 42 08a9ff32SQu Wenruo }; 43 08a9ff32SQu Wenruo 44 9e0af237SLiu Bo #define BTRFS_WORK_HELPER_PROTO(name) \ 45 9e0af237SLiu Bo void btrfs_##name(struct work_struct *arg) 46 9e0af237SLiu Bo 47 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(worker_helper); 48 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delalloc_helper); 49 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper); 50 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(cache_helper); 51 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(submit_helper); 52 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(fixup_helper); 53 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_helper); 54 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_helper); 55 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper); 56 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_raid56_helper); 57 8b110e39SMiao Xie BTRFS_WORK_HELPER_PROTO(endio_repair_helper); 58 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(rmw_helper); 59 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_write_helper); 60 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(freespace_write_helper); 61 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delayed_meta_helper); 62 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(readahead_helper); 63 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper); 64 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(extent_refs_helper); 65 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrub_helper); 66 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubwrc_helper); 67 9e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubnc_helper); 68 20b2e302SZhao Lei BTRFS_WORK_HELPER_PROTO(scrubparity_helper); 69 20b2e302SZhao Lei 70 9e0af237SLiu Bo 71 cb001095SJeff Mahoney struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, 72 cb001095SJeff Mahoney const char *name, 73 6f011058SDavid Sterba unsigned int flags, 74 c6dd6ea5SQu Wenruo int limit_active, 75 0bd9289cSQu Wenruo int thresh); 76 9e0af237SLiu Bo void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper, 77 6db8914fSQu Wenruo btrfs_func_t func, 78 6db8914fSQu Wenruo btrfs_func_t ordered_func, 79 6db8914fSQu Wenruo btrfs_func_t ordered_free); 80 d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq, 81 d458b054SQu Wenruo struct btrfs_work *work); 82 d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq); 83 d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max); 84 d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work); 85 *9a35b637SJeff Mahoney struct btrfs_fs_info *btrfs_work_owner(const struct btrfs_work *work); 86 *9a35b637SJeff Mahoney struct btrfs_fs_info *btrfs_workqueue_owner(const struct __btrfs_workqueue *wq); 87 *9a35b637SJeff Mahoney bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq); 88 8b712842SChris Mason #endif 89