Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clonefile on Windows over ReFS support. #3790

Merged
merged 1 commit into from Aug 27, 2019

Conversation

@kazuki-ma
Copy link
Contributor

@kazuki-ma kazuki-ma commented Aug 25, 2019

ReFS (wikipedia) is filesystem on Windows OS and it's support copy-on-write / file cloning since v3.2.
ReFS v3.2 is available since Windows Server 2016, Windows Server 2019 and Windows 10 also supports format & read-write.

I think many asset heavy product CI system and developer start using ReFS if git-lfs support dedup on it.

Reference:

This closes #3791

@kazuki-ma kazuki-ma force-pushed the kazuki-ma:clonefile_windows branch 14 times, most recently from 12cdd49 to 1b00158 Aug 25, 2019
@kazuki-ma kazuki-ma changed the title Add clonefile windows (ReFS) support. Add clonefile on Windows over ReFS support. Aug 26, 2019
@kazuki-ma kazuki-ma force-pushed the kazuki-ma:clonefile_windows branch from 1b00158 to b6884d3 Aug 26, 2019
@kazuki-ma kazuki-ma marked this pull request as ready for review Aug 26, 2019
Copy link
Member

@bk2204 bk2204 left a comment

Overall, this looks good. There are a few issues I noted which we may want to fix.

// Instructs the file system to copy a range of file bytes on behalf of an application.
//
// https://docs.microsoft.com/windows/win32/api/winioctl/ni-winioctl-fsctl_duplicate_extents_to_file
const _FSCTL_DUPLICATE_EXTENTS_TO_FILE = 623428

This comment has been minimized.

@bk2204

bk2204 Aug 26, 2019
Member

Even if Windows names this with a leading underscore, we probably don't want to.

// Contains parameters for the FSCTL_DUPLICATE_EXTENTS control code that performs the Block Cloning operation.
//
// https://docs.microsoft.com/windows/win32/api/winioctl/ns-winioctl-duplicate_extents_data
type _DUPLICATE_EXTENTS_DATA struct {

This comment has been minimized.

@bk2204

bk2204 Aug 26, 2019
Member

Same issue about the leading underscore. Since this is not supposed to be accessible outside of this package, we probably want to call it duplicateExtentsData.

Is there a way for us to get the definition of this struct and constant from a library so that we don't have to implement it ourselves?

"unsafe"

"github.com/rubyist/tracerx"
"golang.org/x/sys/windows"

This comment has been minimized.

@bk2204

bk2204 Aug 26, 2019
Member

Do we need to add this to go.mod, or is it already brought in by the golang.org/x/sys package?

This comment has been minimized.

@kazuki-ma

kazuki-ma Aug 26, 2019
Author Contributor

We don't add entry to go.mod. It's part of golang.org/x/sys.

}
defer os.Remove(src.Name())

_, err = src.WriteString("TESTING") // Non-empty file is required for correct result.

This comment has been minimized.

@bk2204

bk2204 Aug 26, 2019
Member

Is a non-empty file required just for this case or for the function itself to work correctly? If the latter, we probably want to check for a non-zero size below.

This comment has been minimized.

@kazuki-ma

kazuki-ma Aug 27, 2019
Author Contributor

Calling FSCTL_DUPLICATE_EXTENTS_TO_FILE to empty file is always success even filesystem don't support it.
To check filesystem support FSCTL_DUPLICATE_EXTENTS_TO_FILE or not, we have to use non-empty file.

I'll write those as comment.

tools/util_windows.go Outdated Show resolved Hide resolved
&bytesReturned,
&overlapped)

tracerx.Printf("DeviceIoControl:%+v result:%+v\n", request, err)

This comment has been minimized.

@bk2204

bk2204 Aug 26, 2019
Member

This also looks like perhaps it's debugging information.

package tools

import (
"crypto/sha1"

This comment has been minimized.

@bk2204

bk2204 Aug 26, 2019
Member

If we're going to use a hash for comparing two files, let's use SHA-256. SHA-1 is considered weak and we'd like to use less of it in our codebase, and we already use SHA-256 in a lot of places.

This comment has been minimized.

@kazuki-ma

kazuki-ma Aug 27, 2019
Author Contributor

Got it. Thank you.

@kazuki-ma kazuki-ma force-pushed the kazuki-ma:clonefile_windows branch from b6884d3 to 6c7aa06 Aug 27, 2019
@kazuki-ma kazuki-ma force-pushed the kazuki-ma:clonefile_windows branch from 6c7aa06 to e55bc4c Aug 27, 2019
@kazuki-ma
Copy link
Contributor Author

@kazuki-ma kazuki-ma commented Aug 27, 2019

Updated. Please review again.

@bk2204
bk2204 approved these changes Aug 27, 2019
Copy link
Member

@bk2204 bk2204 left a comment

This looks good. Thanks for the patch!

@bk2204 bk2204 merged commit a5ecadd into git-lfs:master Aug 27, 2019
6 checks passed
6 checks passed
ci/circleci: bootstrap Your tests passed on CircleCI!
Details
ci/circleci: build_with_earliest_supported_git Your tests passed on CircleCI!
Details
ci/circleci: build_with_latest_git Your tests passed on CircleCI!
Details
ci/circleci: build_with_system_git Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kazuki-ma kazuki-ma deleted the kazuki-ma:clonefile_windows branch Aug 27, 2019
@kazuki-ma
Copy link
Contributor Author

@kazuki-ma kazuki-ma commented Aug 27, 2019

Thank you very much for reviewing.

Artoria2e5 added a commit to Artoria2e5/libuv that referenced this pull request Dec 16, 2019
Windows Server has a reflink feature built onto the dedup-capable ReFS.
This is completely irrelevant for client users, but it would still be a
good thing to add given how Microsoft loves Nodejs now.

The FICLONE_FORCE mode is likely to fail since you have to pay for the
server thing to get it to work. Remove the check if the CI is capable.
(We still really need someone to test it.)

This PR is based on the git-lfs implementation.

Ref: git-lfs/git-lfs#3790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.