瀏覽代碼

graphdriver/copy: faster copy of hard links

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 #46810

Signed-off-by: Rob Murray <rob.murray@docker.com>
Rob Murray 1 年之前
父節點
當前提交
a3fdad84ad
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      daemon/graphdriver/copy/copy.go

+ 1 - 0
daemon/graphdriver/copy/copy.go

@@ -159,6 +159,7 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyOpaqueXattrs bool) error
 					return err2
 					return err2
 				}
 				}
 			} else if hardLinkDstPath, ok := copiedFiles[id]; ok {
 			} else if hardLinkDstPath, ok := copiedFiles[id]; ok {
+				isHardlink = true
 				if err2 := os.Link(hardLinkDstPath, dstPath); err2 != nil {
 				if err2 := os.Link(hardLinkDstPath, dstPath); err2 != nil {
 					return err2
 					return err2
 				}
 				}