btrfs: calculate hash key only once
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
		| @@ -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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stephen J Day
					Stephen J Day