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 | |
Jeff Mahoney | cb00109 | 2016-06-09 16:22:11 -0400 | [diff] [blame] | 32 | struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, |
| 33 | const char *name, |
David Sterba | 6f01105 | 2015-02-16 18:34:01 +0100 | [diff] [blame] | 34 | unsigned int flags, |
Qu Wenruo | c6dd6ea | 2015-08-20 09:30:39 +0800 | [diff] [blame] | 35 | int limit_active, |
Qu Wenruo | 6db8914 | 2014-03-06 04:19:50 +0000 | [diff] [blame] | 36 | int thresh); |
Omar Sandoval | a0cac0e | 2019-09-16 11:30:57 -0700 | [diff] [blame] | 37 | void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func, |
| 38 | btrfs_func_t ordered_func, btrfs_func_t ordered_free); |
Qu Wenruo | d458b05 | 2014-02-28 10:46:19 +0800 | [diff] [blame] | 39 | void btrfs_queue_work(struct btrfs_workqueue *wq, |
| 40 | struct btrfs_work *work); |
| 41 | void btrfs_destroy_workqueue(struct btrfs_workqueue *wq); |
| 42 | void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max); |
| 43 | void btrfs_set_work_high_priority(struct btrfs_work *work); |
David Sterba | e1f60a6 | 2019-10-01 19:57:39 +0200 | [diff] [blame] | 44 | struct btrfs_fs_info * __pure btrfs_work_owner(const struct btrfs_work *work); |
| 45 | struct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct __btrfs_workqueue *wq); |
Jeff Mahoney | 9a35b63 | 2017-06-28 21:56:54 -0600 | [diff] [blame] | 46 | bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq); |
Filipe Manana | f0cc2cd | 2020-02-28 13:04:36 +0000 | [diff] [blame] | 47 | void btrfs_flush_workqueue(struct btrfs_workqueue *wq); |
David Sterba | 9888c34 | 2018-04-03 19:16:55 +0200 | [diff] [blame] | 48 | |
Chris Mason | 8b71284 | 2008-06-11 16:50:36 -0400 | [diff] [blame] | 49 | #endif |