btrfs: calculate hash key only once

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2017-02-06 17:09:11 -08:00
parent f861817a8e
commit 74949be676
No known key found for this signature in database
GPG Key ID: 67B3DED84EDC823F
1 changed files with 14 additions and 10 deletions

View File

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