Merge pull request #495 from stevvooe/btrfs-hash-once

btrfs: calculate hash key only once
This commit is contained in:
Phil Estes 2017-02-07 09:45:34 -08:00 committed by GitHub
commit 51f1ebfca0

View file

@ -36,10 +36,12 @@ func (b *Driver) makeActive(key, parent string, readonly bool) ([]containerd.Mou
parents = filepath.Join(b.root, "parents") parents = filepath.Join(b.root, "parents")
snapshots = filepath.Join(b.root, "snapshots") snapshots = filepath.Join(b.root, "snapshots")
names = filepath.Join(b.root, "names") names = filepath.Join(b.root, "names")
dir = filepath.Join(active, hash(key)) keyh = hash(key)
namep = filepath.Join(names, hash(key)) parenth = hash(parent)
parentlink = filepath.Join(parents, hash(key)) dir = filepath.Join(active, keyh)
parentp = filepath.Join(snapshots, hash(parent)) namep = filepath.Join(names, keyh)
parentlink = filepath.Join(parents, keyh)
parentp = filepath.Join(snapshots, parenth)
) )
for _, path := range []string{ for _, path := range []string{
@ -108,12 +110,14 @@ func (b *Driver) Commit(name, key string) error {
snapshots = filepath.Join(b.root, "snapshots") snapshots = filepath.Join(b.root, "snapshots")
names = filepath.Join(b.root, "names") names = filepath.Join(b.root, "names")
parents = filepath.Join(b.root, "parents") parents = filepath.Join(b.root, "parents")
dir = filepath.Join(active, hash(key)) keyh = hash(key)
target = filepath.Join(snapshots, hash(name)) nameh = hash(name)
keynamep = filepath.Join(names, hash(key)) dir = filepath.Join(active, keyh)
namep = filepath.Join(names, hash(name)) target = filepath.Join(snapshots, nameh)
keyparentlink = filepath.Join(parents, hash(key)) keynamep = filepath.Join(names, keyh)
parentlink = filepath.Join(parents, hash(name)) namep = filepath.Join(names, nameh)
keyparentlink = filepath.Join(parents, keyh)
parentlink = filepath.Join(parents, nameh)
) )
info, err := btrfs.SubvolInfo(dir) info, err := btrfs.SubvolInfo(dir)