KarpelesLab / reflink

Reflink file copy in Go
MIT License
32 stars 4 forks source link

reflink.Partial didnt work #1

Open bve81 opened 1 year ago

bve81 commented 1 year ago

I have tried reflink.Partial and reflink.Reflink err = reflink.Reflink(dest, source, false) err = reflink.Partial(dest, source, 4096, 4096, 4096, false)

The partial is working only if callback = true, but reflink.Reflink works well

MagicalTux commented 1 year ago

Not all filesystems will support partial reflinks, and in that case fallback just performs a regular copy instead of a reflink.

Which filesystem are you testing this on?

bve81 commented 1 year ago

I had tested on xfs with reflink

30 июня 2023 г., в 17:08, Mark Karpelès @.***> написал(а):



Not all filesystems will support partial reflinks, and in that case fallback just performs a regular copy instead of a reflink.

Which filesystem are you testing this on?

— Reply to this email directly, view it on GitHubhttps://github.com/KarpelesLab/reflink/issues/1#issuecomment-1614707524, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AO4RT7BJM7WZNDDCUKESFB3XN3MVDANCNFSM6AAAAAAZJFCZ7Q. You are receiving this because you authored the thread.Message ID: @.***>

MagicalTux commented 1 year ago

After some research it seems xfs implements copy_file_range rather than the fairly recent ioctl(FICLONERANGE) (which was implemented initially for btrfs) for this kind of operations.

The problem is that there is no way to know if copy_file_range performed a copy on write operation or not as far as I can see, so this can't be set as standard behavior for this package, however I've implemented it into the fallback behavior if using fallback=true.

There's been some efforts to implement ioctl(FICLONERANGE) on xfs linux driver as I can see, but the patches seems to have been rejected, so I'm not sure if it'll be one day implemented. That should be the preferred way to perform cow data copy as it guarantees the underlying FS performed the right operation.

In the meantime you will want to have fallback=true for reflink to use copy_file_range.