Re: [PATCH v5 08/11] btrfs: defrag: introduce a new helper to defrag one cluster
From: David Sterba <hidden>
Date: 2021-08-23 19:30:07
From: David Sterba <hidden>
Date: 2021-08-23 19:30:07
On Fri, Aug 06, 2021 at 04:12:39PM +0800, Qu Wenruo wrote:
This new helper, defrag_one_cluster(), will defrag one cluster (at most 256K) by: - Collect all initial targets - Kick in readahead when possible - Call defrag_one_range() on each initial target With some extra range clamping. - Update @sectors_defragged parameter This involves one behavior change, the defragged sectors accounting is no longer as accurate as old behavior, as the initial targets are not consistent. We can have new holes punched inside the initial target, and we will skip such holes later. But the defragged sectors accounting doesn't need to be that accurate anyway, thus I don't want to pass those extra accounting burden into defrag_one_range().
I think it's ok, any parallel operation can change the file during defragmentation at any point.