162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2007 Oracle.  All rights reserved.
462306a36Sopenharmony_ci * Copyright (C) 2014 Fujitsu.  All rights reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef BTRFS_ASYNC_THREAD_H
862306a36Sopenharmony_ci#define BTRFS_ASYNC_THREAD_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/workqueue.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistruct btrfs_fs_info;
1362306a36Sopenharmony_cistruct btrfs_workqueue;
1462306a36Sopenharmony_cistruct btrfs_work;
1562306a36Sopenharmony_citypedef void (*btrfs_func_t)(struct btrfs_work *arg);
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_cistruct btrfs_work {
1862306a36Sopenharmony_ci	btrfs_func_t func;
1962306a36Sopenharmony_ci	btrfs_func_t ordered_func;
2062306a36Sopenharmony_ci	btrfs_func_t ordered_free;
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci	/* Don't touch things below */
2362306a36Sopenharmony_ci	struct work_struct normal_work;
2462306a36Sopenharmony_ci	struct list_head ordered_list;
2562306a36Sopenharmony_ci	struct btrfs_workqueue *wq;
2662306a36Sopenharmony_ci	unsigned long flags;
2762306a36Sopenharmony_ci};
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_cistruct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
3062306a36Sopenharmony_ci					      const char *name,
3162306a36Sopenharmony_ci					      unsigned int flags,
3262306a36Sopenharmony_ci					      int limit_active,
3362306a36Sopenharmony_ci					      int thresh);
3462306a36Sopenharmony_cistruct btrfs_workqueue *btrfs_alloc_ordered_workqueue(
3562306a36Sopenharmony_ci				struct btrfs_fs_info *fs_info, const char *name,
3662306a36Sopenharmony_ci				unsigned int flags);
3762306a36Sopenharmony_civoid btrfs_init_work(struct btrfs_work *work, btrfs_func_t func,
3862306a36Sopenharmony_ci		     btrfs_func_t ordered_func, btrfs_func_t ordered_free);
3962306a36Sopenharmony_civoid btrfs_queue_work(struct btrfs_workqueue *wq,
4062306a36Sopenharmony_ci		      struct btrfs_work *work);
4162306a36Sopenharmony_civoid btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
4262306a36Sopenharmony_civoid btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max);
4362306a36Sopenharmony_cistruct btrfs_fs_info * __pure btrfs_work_owner(const struct btrfs_work *work);
4462306a36Sopenharmony_cistruct btrfs_fs_info * __pure btrfs_workqueue_owner(const struct btrfs_workqueue *wq);
4562306a36Sopenharmony_cibool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq);
4662306a36Sopenharmony_civoid btrfs_flush_workqueue(struct btrfs_workqueue *wq);
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#endif
49