btrfs: defrag: introduce control structure for later use
Currently btrfs_defrag_file() accepts not only
btrfs_ioctl_defrag_range_args but also other parameters like @newer_than
and @max_sectors_to_defrag for extra policies.
Those extra values are hidden from defrag ioctl and even caused bugs in
the past due to different behavior based on those extra values.
Here we introduce a new structure, btrfs_defrag_ctrl, to include:
- all members in btrfs_ioctl_defrag_range_args
- @max_sectors_to_defrag and @newer_than
- Extra values which callers of btrfs_defrag_file() may care
Like @sectors_defragged and @last_scanned.
With the new structure, also introduce a new helper,
btrfs_defrag_ioctl_args_to_ctrl() to:
- Do extra sanity check on @compress and @flags
- Do range alignment when possible
- Set default values.
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>