1317ddf37SNishad Kamdar /* SPDX-License-Identifier: GPL-2.0 */ 2b0643e59SDennis Zhou 3b0643e59SDennis Zhou #ifndef BTRFS_DISCARD_H 4b0643e59SDennis Zhou #define BTRFS_DISCARD_H 5b0643e59SDennis Zhou 64aa9ad52SDennis Zhou #include <linux/sizes.h> 74aa9ad52SDennis Zhou 8b0643e59SDennis Zhou struct btrfs_fs_info; 9b0643e59SDennis Zhou struct btrfs_discard_ctl; 10b0643e59SDennis Zhou struct btrfs_block_group; 11b0643e59SDennis Zhou 124aa9ad52SDennis Zhou /* Discard size limits */ 1319b2a2c7SDennis Zhou #define BTRFS_ASYNC_DISCARD_DEFAULT_MAX_SIZE (SZ_64M) 147fe6d45eSDennis Zhou #define BTRFS_ASYNC_DISCARD_MAX_FILTER (SZ_1M) 157fe6d45eSDennis Zhou #define BTRFS_ASYNC_DISCARD_MIN_FILTER (SZ_32K) 167fe6d45eSDennis Zhou 177fe6d45eSDennis Zhou /* List operations */ 187fe6d45eSDennis Zhou void btrfs_discard_check_filter(struct btrfs_block_group *block_group, u64 bytes); 194aa9ad52SDennis Zhou 206e80d4f8SDennis Zhou /* Work operations */ 21b0643e59SDennis Zhou void btrfs_discard_cancel_work(struct btrfs_discard_ctl *discard_ctl, 22b0643e59SDennis Zhou struct btrfs_block_group *block_group); 23b0643e59SDennis Zhou void btrfs_discard_queue_work(struct btrfs_discard_ctl *discard_ctl, 24b0643e59SDennis Zhou struct btrfs_block_group *block_group); 25b0643e59SDennis Zhou void btrfs_discard_schedule_work(struct btrfs_discard_ctl *discard_ctl, 26b0643e59SDennis Zhou bool override); 27b0643e59SDennis Zhou 28dfb79ddbSDennis Zhou /* Update operations */ 29a2309300SDennis Zhou void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl); 30*66b53baeSJosef Bacik void btrfs_discard_update_discardable(struct btrfs_block_group *block_group); 31dfb79ddbSDennis Zhou 326e80d4f8SDennis Zhou /* Setup/cleanup operations */ 336e80d4f8SDennis Zhou void btrfs_discard_punt_unused_bgs_list(struct btrfs_fs_info *fs_info); 34b0643e59SDennis Zhou void btrfs_discard_resume(struct btrfs_fs_info *fs_info); 35b0643e59SDennis Zhou void btrfs_discard_stop(struct btrfs_fs_info *fs_info); 36b0643e59SDennis Zhou void btrfs_discard_init(struct btrfs_fs_info *fs_info); 37b0643e59SDennis Zhou void btrfs_discard_cleanup(struct btrfs_fs_info *fs_info); 38b0643e59SDennis Zhou 39b0643e59SDennis Zhou #endif 40