Feature: ipfs add/get --reflink
Although filestores are nice, they carry the issue of someone carelessly changing the file content and the cost of checks related to this problem. With a bit of filesystem magic, we can actually do a basically no-cost copy of data from a file to the blockstore or vice versa. The specific API is FICLONERANGE (Linux) and FSCTL_DUPLICATE_EXTENTS_TO_FILE (Windows).
A new boolean / string option --reflink should be added to ipfs add and ipfs get. It accepts three values: false (disable reflink), auto (enable reflink with fallback), and true (enable reflink no fallback).
- For
ipfs add,--reflinkonly has an effect when the block store is aflatfs.--nocopywill disable--reflinksince the block store isn't even used. - For
ipfs get,--reflinkhas an effect in two cases: when the block store isflatfsand when a block is being retrived from afilestore. The proposed--nocopyoption (#6687) will work with this switch.
A big issue here is the datastore interface, as many bunches of file:offset:length information will need to be passed around for reflinking to happen in flatfs. (It could happen with other stores but no serious concurrent backend would expose these sort of internal data structure.) It might be easier for filestore since it already does that.
Source: ipfs/kubo