Skip to content

Commit

Permalink
graphdriver/copy: faster copy of hard links
Browse files Browse the repository at this point in the history
The DirCopy() function in "graphdriver/copy/copy.go" has a special case for
skip file-attribute copying when making a hard link to an already-copied
file, if "copyMode == Hardlink". Do the same for copies of hard-links in
the source filesystem.

Significantly speeds up vfs's copy of a BusyBox filesystem (which
consists mainly of hard links to a single binary), making moby's
integration tests run more quickly and more reliably in a dev container.

Fixes moby#46810

Signed-off-by: Rob Murray <rob.murray@docker.com>
  • Loading branch information
robmry committed Nov 13, 2023
1 parent 6af7d6e commit a3fdad8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions daemon/graphdriver/copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyOpaqueXattrs bool) error
return err2
}
} else if hardLinkDstPath, ok := copiedFiles[id]; ok {
isHardlink = true
if err2 := os.Link(hardLinkDstPath, dstPath); err2 != nil {
return err2
}
Expand Down

0 comments on commit a3fdad8

Please sign in to comment.