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_ 229e0af237SLiu Bo #include <linux/workqueue.h> 238b712842SChris Mason 24*cb001095SJeff Mahoney struct btrfs_fs_info; 25d458b054SQu Wenruo struct btrfs_workqueue; 261ca08976SQu Wenruo /* Internal use only */ 27d458b054SQu Wenruo struct __btrfs_workqueue; 286db8914fSQu Wenruo struct btrfs_work; 296db8914fSQu Wenruo typedef void (*btrfs_func_t)(struct btrfs_work *arg); 309e0af237SLiu Bo typedef void (*btrfs_work_func_t)(struct work_struct *arg); 3108a9ff32SQu Wenruo 32d458b054SQu Wenruo struct btrfs_work { 336db8914fSQu Wenruo btrfs_func_t func; 346db8914fSQu Wenruo btrfs_func_t ordered_func; 356db8914fSQu Wenruo btrfs_func_t ordered_free; 3608a9ff32SQu Wenruo 3708a9ff32SQu Wenruo /* Don't touch things below */ 3808a9ff32SQu Wenruo struct work_struct normal_work; 3908a9ff32SQu Wenruo struct list_head ordered_list; 40d458b054SQu Wenruo struct __btrfs_workqueue *wq; 4108a9ff32SQu Wenruo unsigned long flags; 4208a9ff32SQu Wenruo }; 4308a9ff32SQu Wenruo 449e0af237SLiu Bo #define BTRFS_WORK_HELPER_PROTO(name) \ 459e0af237SLiu Bo void btrfs_##name(struct work_struct *arg) 469e0af237SLiu Bo 479e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(worker_helper); 489e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delalloc_helper); 499e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper); 509e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(cache_helper); 519e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(submit_helper); 529e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(fixup_helper); 539e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_helper); 549e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_helper); 559e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper); 569e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_raid56_helper); 578b110e39SMiao Xie BTRFS_WORK_HELPER_PROTO(endio_repair_helper); 589e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(rmw_helper); 599e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(endio_write_helper); 609e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(freespace_write_helper); 619e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(delayed_meta_helper); 629e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(readahead_helper); 639e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper); 649e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(extent_refs_helper); 659e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrub_helper); 669e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubwrc_helper); 679e0af237SLiu Bo BTRFS_WORK_HELPER_PROTO(scrubnc_helper); 6820b2e302SZhao Lei BTRFS_WORK_HELPER_PROTO(scrubparity_helper); 6920b2e302SZhao Lei 709e0af237SLiu Bo 71*cb001095SJeff Mahoney struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, 72*cb001095SJeff Mahoney const char *name, 736f011058SDavid Sterba unsigned int flags, 74c6dd6ea5SQu Wenruo int limit_active, 750bd9289cSQu Wenruo int thresh); 769e0af237SLiu Bo void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper, 776db8914fSQu Wenruo btrfs_func_t func, 786db8914fSQu Wenruo btrfs_func_t ordered_func, 796db8914fSQu Wenruo btrfs_func_t ordered_free); 80d458b054SQu Wenruo void btrfs_queue_work(struct btrfs_workqueue *wq, 81d458b054SQu Wenruo struct btrfs_work *work); 82d458b054SQu Wenruo void btrfs_destroy_workqueue(struct btrfs_workqueue *wq); 83d458b054SQu Wenruo void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max); 84d458b054SQu Wenruo void btrfs_set_work_high_priority(struct btrfs_work *work); 85*cb001095SJeff Mahoney struct btrfs_fs_info *btrfs_work_owner(struct btrfs_work *work); 86*cb001095SJeff Mahoney struct btrfs_fs_info *btrfs_workqueue_owner(struct __btrfs_workqueue *wq); 878b712842SChris Mason #endif 88