blob: 7861c9feba5f4f0ceac82946de06ada2f24f19eb [file] [log] [blame]
David Sterba9888c342018-04-03 19:16:55 +02001/* SPDX-License-Identifier: GPL-2.0 */
Chris Mason8b712842008-06-11 16:50:36 -04002/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
Qu Wenruo08a9ff32014-02-28 10:46:03 +08004 * Copyright (C) 2014 Fujitsu. All rights reserved.
Chris Mason8b712842008-06-11 16:50:36 -04005 */
6
David Sterba9888c342018-04-03 19:16:55 +02007#ifndef BTRFS_ASYNC_THREAD_H
8#define BTRFS_ASYNC_THREAD_H
9
Liu Bo9e0af232014-08-15 23:36:53 +080010#include <linux/workqueue.h>
Chris Mason8b712842008-06-11 16:50:36 -040011
Jeff Mahoneycb001092016-06-09 16:22:11 -040012struct btrfs_fs_info;
Qu Wenruod458b052014-02-28 10:46:19 +080013struct btrfs_workqueue;
Qu Wenruo1ca08972014-02-28 10:46:04 +080014/* Internal use only */
Qu Wenruod458b052014-02-28 10:46:19 +080015struct __btrfs_workqueue;
Qu Wenruo6db89142014-03-06 04:19:50 +000016struct btrfs_work;
17typedef void (*btrfs_func_t)(struct btrfs_work *arg);
Liu Bo9e0af232014-08-15 23:36:53 +080018typedef void (*btrfs_work_func_t)(struct work_struct *arg);
Qu Wenruo08a9ff32014-02-28 10:46:03 +080019
Qu Wenruod458b052014-02-28 10:46:19 +080020struct btrfs_work {
Qu Wenruo6db89142014-03-06 04:19:50 +000021 btrfs_func_t func;
22 btrfs_func_t ordered_func;
23 btrfs_func_t ordered_free;
Qu Wenruo08a9ff32014-02-28 10:46:03 +080024
25 /* Don't touch things below */
26 struct work_struct normal_work;
27 struct list_head ordered_list;
Qu Wenruod458b052014-02-28 10:46:19 +080028 struct __btrfs_workqueue *wq;
Qu Wenruo08a9ff32014-02-28 10:46:03 +080029 unsigned long flags;
30};
31
Liu Bo9e0af232014-08-15 23:36:53 +080032#define BTRFS_WORK_HELPER_PROTO(name) \
33void btrfs_##name(struct work_struct *arg)
34
35BTRFS_WORK_HELPER_PROTO(worker_helper);
36BTRFS_WORK_HELPER_PROTO(delalloc_helper);
37BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
38BTRFS_WORK_HELPER_PROTO(cache_helper);
39BTRFS_WORK_HELPER_PROTO(submit_helper);
40BTRFS_WORK_HELPER_PROTO(fixup_helper);
41BTRFS_WORK_HELPER_PROTO(endio_helper);
42BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
43BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
44BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
Miao Xie8b110e32014-09-12 18:44:03 +080045BTRFS_WORK_HELPER_PROTO(endio_repair_helper);
Liu Bo9e0af232014-08-15 23:36:53 +080046BTRFS_WORK_HELPER_PROTO(rmw_helper);
47BTRFS_WORK_HELPER_PROTO(endio_write_helper);
48BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
49BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
50BTRFS_WORK_HELPER_PROTO(readahead_helper);
51BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
52BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
53BTRFS_WORK_HELPER_PROTO(scrub_helper);
54BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
55BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
Zhao Lei20b2e302015-06-04 20:09:15 +080056BTRFS_WORK_HELPER_PROTO(scrubparity_helper);
57
Liu Bo9e0af232014-08-15 23:36:53 +080058
Jeff Mahoneycb001092016-06-09 16:22:11 -040059struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
60 const char *name,
David Sterba6f011052015-02-16 18:34:01 +010061 unsigned int flags,
Qu Wenruoc6dd6ea2015-08-20 09:30:39 +080062 int limit_active,
Qu Wenruo6db89142014-03-06 04:19:50 +000063 int thresh);
Liu Bo9e0af232014-08-15 23:36:53 +080064void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
Qu Wenruo6db89142014-03-06 04:19:50 +000065 btrfs_func_t func,
66 btrfs_func_t ordered_func,
67 btrfs_func_t ordered_free);
Qu Wenruod458b052014-02-28 10:46:19 +080068void btrfs_queue_work(struct btrfs_workqueue *wq,
69 struct btrfs_work *work);
70void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
71void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
72void btrfs_set_work_high_priority(struct btrfs_work *work);
Jeff Mahoney9a35b632017-06-28 21:56:54 -060073struct btrfs_fs_info *btrfs_work_owner(const struct btrfs_work *work);
74struct btrfs_fs_info *btrfs_workqueue_owner(const struct __btrfs_workqueue *wq);
75bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq);
David Sterba9888c342018-04-03 19:16:55 +020076
Chris Mason8b712842008-06-11 16:50:36 -040077#endif