btrfs: defrag: use control structure in btrfs_defrag_file()
authorQu Wenruo <wqu@suse.com>
Fri, 11 Feb 2022 06:41:42 +0000 (14:41 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 15 Feb 2022 15:41:51 +0000 (16:41 +0100)
commite6c69fcbee7ef1d7bde4ff78eb1377dbe09d71cf
tree2c073a58bed19254721ca66615131e1e38934203
parenta65b76f42a5ea3e386784fc396a1e92d164c71bc
btrfs: defrag: use control structure in btrfs_defrag_file()

Use defrag control structure and replace function arguments. This brings
the following benefits:

- No more strange range->start update to indicate last scanned bytenr
  We have btrfs_defrag_ctrl::last_scanned (exclusive) for it directly.

- No more return value to indicate defragged sectors
  Now btrfs_defrag_file() will just return 0 if no error happened.
  And btrfs_defrag_ctrl::sectors_defragged will show that value.

- Fewer parameters to carry around
  Now most defrag_* functions only need to fetch their policy parameters
  from btrfs_defrag_ctrl directly.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/ioctl.c