Merge pull request #13067 from burke/faster-commit-for-overlay

overlay: skip superfluous metadata sets on commit
This commit is contained in:
Alexander Morozov 2015-05-07 13:58:46 -07:00
commit 93536cfa76

View file

@ -71,9 +71,12 @@ func copyDir(srcDir, dstDir string, flags CopyFlags) error {
return fmt.Errorf("Unable to get raw syscall.Stat_t data for %s", srcPath)
}
isHardlink := false
switch f.Mode() & os.ModeType {
case 0: // Regular file
if flags&CopyHardlink != 0 {
isHardlink = true
if err := os.Link(srcPath, dstPath); err != nil {
return err
}
@ -114,6 +117,12 @@ func copyDir(srcDir, dstDir string, flags CopyFlags) error {
return fmt.Errorf("Unknown file type for %s\n", srcPath)
}
// Everything below is copying metadata from src to dst. All this metadata
// already shares an inode for hardlinks.
if isHardlink {
return nil
}
if err := os.Lchown(dstPath, int(stat.Uid), int(stat.Gid)); err != nil {
return err
}