blob: f9445ee5dcc329966d2c66094d4e768a91bae2cc [file] [log] [blame]
Dennis Zhoub0643e52019-12-13 16:22:14 -08001// SPDX-License-Identifier: GPL-2.0
2
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 Zhou4aa9ad52020-01-02 16:26:37 -050014
Dennis Zhou6e80d4f2019-12-13 16:22:15 -080015/* Work operations */
Dennis Zhoub0643e52019-12-13 16:22:14 -080016void btrfs_discard_cancel_work(struct btrfs_discard_ctl *discard_ctl,
17 struct btrfs_block_group *block_group);
18void btrfs_discard_queue_work(struct btrfs_discard_ctl *discard_ctl,
19 struct btrfs_block_group *block_group);
20void btrfs_discard_schedule_work(struct btrfs_discard_ctl *discard_ctl,
21 bool override);
22bool btrfs_run_discard_work(struct btrfs_discard_ctl *discard_ctl);
23
Dennis Zhoudfb79dd2019-12-13 16:22:20 -080024/* Update operations */
Dennis Zhoua2309302020-01-02 16:26:35 -050025void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl);
Dennis Zhoudfb79dd2019-12-13 16:22:20 -080026void btrfs_discard_update_discardable(struct btrfs_block_group *block_group,
27 struct btrfs_free_space_ctl *ctl);
28
Dennis Zhou6e80d4f2019-12-13 16:22:15 -080029/* Setup/cleanup operations */
30void btrfs_discard_punt_unused_bgs_list(struct btrfs_fs_info *fs_info);
Dennis Zhoub0643e52019-12-13 16:22:14 -080031void btrfs_discard_resume(struct btrfs_fs_info *fs_info);
32void btrfs_discard_stop(struct btrfs_fs_info *fs_info);
33void btrfs_discard_init(struct btrfs_fs_info *fs_info);
34void btrfs_discard_cleanup(struct btrfs_fs_info *fs_info);
35
36#endif