blob: 57b9202f427f869a42b108f47dfeb08f26b79472 [file] [log] [blame]
Nishad Kamdar317ddf32020-04-19 20:06:44 +05301/* SPDX-License-Identifier: GPL-2.0 */
Dennis Zhoub0643e52019-12-13 16:22:14 -08002
3#ifndef BTRFS_DISCARD_H
4#define BTRFS_DISCARD_H
5
Dennis Zhou4aa9ad52020-01-02 16:26:37 -05006#include <linux/sizes.h>
7
Dennis Zhoub0643e52019-12-13 16:22:14 -08008struct btrfs_fs_info;
9struct btrfs_discard_ctl;
10struct btrfs_block_group;
11
Dennis Zhou4aa9ad52020-01-02 16:26:37 -050012/* Discard size limits */
Dennis Zhou19b2a2c2020-01-02 16:26:38 -050013#define BTRFS_ASYNC_DISCARD_DEFAULT_MAX_SIZE (SZ_64M)
Dennis Zhou7fe6d452020-01-02 16:26:39 -050014#define BTRFS_ASYNC_DISCARD_MAX_FILTER (SZ_1M)
15#define BTRFS_ASYNC_DISCARD_MIN_FILTER (SZ_32K)
16
17/* List operations */
18void btrfs_discard_check_filter(struct btrfs_block_group *block_group, u64 bytes);
Dennis Zhou4aa9ad52020-01-02 16:26:37 -050019
Dennis Zhou6e80d4f2019-12-13 16:22:15 -080020/* Work operations */
Dennis Zhoub0643e52019-12-13 16:22:14 -080021void btrfs_discard_cancel_work(struct btrfs_discard_ctl *discard_ctl,
22 struct btrfs_block_group *block_group);
23void btrfs_discard_queue_work(struct btrfs_discard_ctl *discard_ctl,
24 struct btrfs_block_group *block_group);
25void btrfs_discard_schedule_work(struct btrfs_discard_ctl *discard_ctl,
26 bool override);
27bool btrfs_run_discard_work(struct btrfs_discard_ctl *discard_ctl);
28
Dennis Zhoudfb79dd2019-12-13 16:22:20 -080029/* Update operations */
Dennis Zhoua2309302020-01-02 16:26:35 -050030void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl);
Josef Bacik66b53ba2020-10-23 09:58:07 -040031void btrfs_discard_update_discardable(struct btrfs_block_group *block_group);
Dennis Zhoudfb79dd2019-12-13 16:22:20 -080032
Dennis Zhou6e80d4f2019-12-13 16:22:15 -080033/* Setup/cleanup operations */
34void btrfs_discard_punt_unused_bgs_list(struct btrfs_fs_info *fs_info);
Dennis Zhoub0643e52019-12-13 16:22:14 -080035void btrfs_discard_resume(struct btrfs_fs_info *fs_info);
36void btrfs_discard_stop(struct btrfs_fs_info *fs_info);
37void btrfs_discard_init(struct btrfs_fs_info *fs_info);
38void btrfs_discard_cleanup(struct btrfs_fs_info *fs_info);
39
40#endif