From 74949be67680a9c73c00dfa0f0b16ffc2e5456a7 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Mon, 6 Feb 2017 17:09:11 -0800 Subject: [PATCH] btrfs: calculate hash key only once Signed-off-by: Stephen J Day --- snapshot/btrfs/btrfs.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/snapshot/btrfs/btrfs.go b/snapshot/btrfs/btrfs.go index c95128b..f3af142 100644 --- a/snapshot/btrfs/btrfs.go +++ b/snapshot/btrfs/btrfs.go @@ -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)