David Sterba | 9888c34 | 2018-04-03 19:16:55 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Chris Mason | 8b71284 | 2008-06-11 16:50:36 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2007 Oracle. All rights reserved. |
Qu Wenruo | 08a9ff3 | 2014-02-28 10:46:03 +0800 | [diff] [blame] | 4 | * Copyright (C) 2014 Fujitsu. All rights reserved. |
Chris Mason | 8b71284 | 2008-06-11 16:50:36 -0400 | [diff] [blame] | 5 | */ |
| 6 | |
David Sterba | 9888c34 | 2018-04-03 19:16:55 +0200 | [diff] [blame] | 7 | #ifndef BTRFS_ASYNC_THREAD_H |
| 8 | #define BTRFS_ASYNC_THREAD_H |
| 9 | |
Liu Bo | 9e0af23 | 2014-08-15 23:36:53 +0800 | [diff] [blame] | 10 | #include <linux/workqueue.h> |
Chris Mason | 8b71284 | 2008-06-11 16:50:36 -0400 | [diff] [blame] | 11 | |
Jeff Mahoney | cb00109 | 2016-06-09 16:22:11 -0400 | [diff] [blame] | 12 | struct btrfs_fs_info; |
Qu Wenruo | d458b05 | 2014-02-28 10:46:19 +0800 | [diff] [blame] | 13 | struct btrfs_workqueue; |
Qu Wenruo | 1ca0897 | 2014-02-28 10:46:04 +0800 | [diff] [blame] | 14 | /* Internal use only */ |
Qu Wenruo | d458b05 | 2014-02-28 10:46:19 +0800 | [diff] [blame] | 15 | struct __btrfs_workqueue; |
Qu Wenruo | 6db8914 | 2014-03-06 04:19:50 +0000 | [diff] [blame] | 16 | struct btrfs_work; |
| 17 | typedef void (*btrfs_func_t)(struct btrfs_work *arg); |
Liu Bo | 9e0af23 | 2014-08-15 23:36:53 +0800 | [diff] [blame] | 18 | typedef void (*btrfs_work_func_t)(struct work_struct *arg); |
Qu Wenruo | 08a9ff3 | 2014-02-28 10:46:03 +0800 | [diff] [blame] | 19 | |
Qu Wenruo | d458b05 | 2014-02-28 10:46:19 +0800 | [diff] [blame] | 20 | struct btrfs_work { |
Qu Wenruo | 6db8914 | 2014-03-06 04:19:50 +0000 | [diff] [blame] | 21 | btrfs_func_t func; |
| 22 | btrfs_func_t ordered_func; |
| 23 | btrfs_func_t ordered_free; |
Qu Wenruo | 08a9ff3 | 2014-02-28 10:46:03 +0800 | [diff] [blame] | 24 | |
| 25 | /* Don't touch things below */ |
| 26 | struct work_struct normal_work; |
| 27 | struct list_head ordered_list; |
Qu Wenruo | d458b05 | 2014-02-28 10:46:19 +0800 | [diff] [blame] | 28 | struct __btrfs_workqueue *wq; |
Qu Wenruo | 08a9ff3 | 2014-02-28 10:46:03 +0800 | [diff] [blame] | 29 | unsigned long flags; |
| 30 | }; |
| 31 | |
Liu Bo | 9e0af23 | 2014-08-15 23:36:53 +0800 | [diff] [blame] | 32 | #define BTRFS_WORK_HELPER_PROTO(name) \ |
| 33 | void btrfs_##name(struct work_struct *arg) |
| 34 | |
| 35 | BTRFS_WORK_HELPER_PROTO(worker_helper); |
| 36 | BTRFS_WORK_HELPER_PROTO(delalloc_helper); |
| 37 | BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper); |
| 38 | BTRFS_WORK_HELPER_PROTO(cache_helper); |
| 39 | BTRFS_WORK_HELPER_PROTO(submit_helper); |
| 40 | BTRFS_WORK_HELPER_PROTO(fixup_helper); |
| 41 | BTRFS_WORK_HELPER_PROTO(endio_helper); |
| 42 | BTRFS_WORK_HELPER_PROTO(endio_meta_helper); |
| 43 | BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper); |
| 44 | BTRFS_WORK_HELPER_PROTO(endio_raid56_helper); |
Miao Xie | 8b110e3 | 2014-09-12 18:44:03 +0800 | [diff] [blame] | 45 | BTRFS_WORK_HELPER_PROTO(endio_repair_helper); |
Liu Bo | 9e0af23 | 2014-08-15 23:36:53 +0800 | [diff] [blame] | 46 | BTRFS_WORK_HELPER_PROTO(rmw_helper); |
| 47 | BTRFS_WORK_HELPER_PROTO(endio_write_helper); |
| 48 | BTRFS_WORK_HELPER_PROTO(freespace_write_helper); |
| 49 | BTRFS_WORK_HELPER_PROTO(delayed_meta_helper); |
| 50 | BTRFS_WORK_HELPER_PROTO(readahead_helper); |
| 51 | BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper); |
| 52 | BTRFS_WORK_HELPER_PROTO(extent_refs_helper); |
| 53 | BTRFS_WORK_HELPER_PROTO(scrub_helper); |
| 54 | BTRFS_WORK_HELPER_PROTO(scrubwrc_helper); |
| 55 | BTRFS_WORK_HELPER_PROTO(scrubnc_helper); |
Zhao Lei | 20b2e30 | 2015-06-04 20:09:15 +0800 | [diff] [blame] | 56 | BTRFS_WORK_HELPER_PROTO(scrubparity_helper); |
| 57 | |
Liu Bo | 9e0af23 | 2014-08-15 23:36:53 +0800 | [diff] [blame] | 58 | |
Jeff Mahoney | cb00109 | 2016-06-09 16:22:11 -0400 | [diff] [blame] | 59 | struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, |
| 60 | const char *name, |
David Sterba | 6f01105 | 2015-02-16 18:34:01 +0100 | [diff] [blame] | 61 | unsigned int flags, |
Qu Wenruo | c6dd6ea | 2015-08-20 09:30:39 +0800 | [diff] [blame] | 62 | int limit_active, |
Qu Wenruo | 6db8914 | 2014-03-06 04:19:50 +0000 | [diff] [blame] | 63 | int thresh); |
Liu Bo | 9e0af23 | 2014-08-15 23:36:53 +0800 | [diff] [blame] | 64 | void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper, |
Qu Wenruo | 6db8914 | 2014-03-06 04:19:50 +0000 | [diff] [blame] | 65 | btrfs_func_t func, |
| 66 | btrfs_func_t ordered_func, |
| 67 | btrfs_func_t ordered_free); |
Qu Wenruo | d458b05 | 2014-02-28 10:46:19 +0800 | [diff] [blame] | 68 | void btrfs_queue_work(struct btrfs_workqueue *wq, |
| 69 | struct btrfs_work *work); |
| 70 | void btrfs_destroy_workqueue(struct btrfs_workqueue *wq); |
| 71 | void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max); |
| 72 | void btrfs_set_work_high_priority(struct btrfs_work *work); |
Jeff Mahoney | 9a35b63 | 2017-06-28 21:56:54 -0600 | [diff] [blame] | 73 | struct btrfs_fs_info *btrfs_work_owner(const struct btrfs_work *work); |
| 74 | struct btrfs_fs_info *btrfs_workqueue_owner(const struct __btrfs_workqueue *wq); |
| 75 | bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq); |
David Sterba | 9888c34 | 2018-04-03 19:16:55 +0200 | [diff] [blame] | 76 | |
Chris Mason | 8b71284 | 2008-06-11 16:50:36 -0400 | [diff] [blame] | 77 | #endif |