koverstreet / bcachefs

Other
643 stars 71 forks source link

Support REMAP_FILE_DEDUP flag for remap_file_range #622

Closed boomshroom closed 1 month ago

boomshroom commented 7 months ago

This flag is set by the FIDEDUPERANGE ioctl call and denotes that the provided ranges are to be checked for equality before reflinking them. This ioctl call is used by several out-of-band deduplication utilities like duperemove and rmlint, though this functionality would become unnecessary if bcachefs added its own out-of-band or in-band deduplication.

While it could potentially be faster to handle the checking within bcachefs itself, generic_remap_file_range_prep, which bcachefs already calls, has its own implementation of said equality checking, so it doesn't seem like additional work would be required. With this in mind, it's unclear to me why bcachefs seems to check for this flag to return EOPNOTSUPP.

If in-band deduplication were ever added, then this flag could potentially trigger an early return since nothing would need to happen, though that would naturally be a longer term goal.

boomshroom commented 1 month ago

Fixed in https://github.com/koverstreet/bcachefs/commit/8d67f575f51a8544942db258716d303f9731a4d4. While not adding native equality checking, it does remove the early return allowing for deduplication utilities to function.