Update btrfs driver to use snapshot storage

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2017-03-16 10:05:46 -07:00
parent 61b524aff2
commit 912746b016
No known key found for this signature in database
GPG key ID: F58C5D0A4405ACDB
7 changed files with 192 additions and 241 deletions

View file

@ -273,7 +273,7 @@ func (ms *boltMetastore) parents(bkt *bolt.Bucket, parent *Snapshot) (parents []
return
}
func (ms *boltMetastore) Remove(ctx context.Context, key string) (id string, err error) {
func (ms *boltMetastore) Remove(ctx context.Context, key string) (id string, k snapshot.Kind, err error) {
err = ms.withBucket(ctx, func(ctx context.Context, bkt *bolt.Bucket) error {
var ss Snapshot
b := bkt.Get([]byte(key))
@ -309,12 +309,10 @@ func (ms *boltMetastore) Remove(ctx context.Context, key string) (id string, err
}
id = fmt.Sprintf("%d", ss.ID)
k = fromProtoActive(ss.Active)
return nil
})
if err != nil {
return "", err
}
return
}

View file

@ -36,8 +36,8 @@ type MetaStore interface {
// Remove removes a snapshot from the metastore. The provided context
// must contain a writable transaction. The string identifier for the
// snapshot is returned.
Remove(ctx context.Context, key string) (string, error)
// snapshot is returned as well as the kind.
Remove(ctx context.Context, key string) (string, snapshot.Kind, error)
// Commit renames the active snapshot transaction referenced by `key`
// as a committed snapshot referenced by `Name`. The resulting snapshot

View file

@ -152,7 +152,7 @@ func createActiveBenchmark(ctx context.Context, b *testing.B, ms storage.MetaSto
b.Fatal(err)
}
b.StopTimer()
if _, err := ms.Remove(ctx, "active"); err != nil {
if _, _, err := ms.Remove(ctx, "active"); err != nil {
b.Fatal(err)
}
b.StartTimer()
@ -166,7 +166,7 @@ func removeBenchmark(ctx context.Context, b *testing.B, ms storage.MetaStore) {
b.Fatal(err)
}
b.StartTimer()
if _, err := ms.Remove(ctx, "active"); err != nil {
if _, _, err := ms.Remove(ctx, "active"); err != nil {
b.Fatal(err)
}
}
@ -183,7 +183,7 @@ func commitBenchmark(ctx context.Context, b *testing.B, ms storage.MetaStore) {
b.Fatal(err)
}
b.StopTimer()
if _, err := ms.Remove(ctx, "committed"); err != nil {
if _, _, err := ms.Remove(ctx, "committed"); err != nil {
b.Fatal(err)
}
}