Add indirection for large version vectors. (#6376)
This adds indirection of large version vectors in the same manner as we already to block lists. The effect is the same: less duplicated data in some situations. To mitigate the impact for when this indirection wouldn't be needed I've added an indirection cutoff for both blocks and the new version vector stuff: we don't do the indirection at all for small block lists or small version vectors, instead storing it directly like we used to do. This is faster for small files and small setups.
This commit is contained in:
+20
-1
@@ -65,6 +65,9 @@ const (
|
||||
|
||||
// KeyTypeBlockListMap <int32 folder ID> <block list hash> <file name> = <nothing>
|
||||
KeyTypeBlockListMap = 14
|
||||
|
||||
// KeyTypeVersion <version hash> = Vector
|
||||
KeyTypeVersion = 15
|
||||
)
|
||||
|
||||
type keyer interface {
|
||||
@@ -104,6 +107,9 @@ type keyer interface {
|
||||
|
||||
// Block lists
|
||||
GenerateBlockListKey(key []byte, hash []byte) blockListKey
|
||||
|
||||
// Version vectors
|
||||
GenerateVersionKey(key []byte, hash []byte) versionKey
|
||||
}
|
||||
|
||||
// defaultKeyer implements our key scheme. It needs folder and device
|
||||
@@ -328,7 +334,20 @@ func (k defaultKeyer) GenerateBlockListKey(key []byte, hash []byte) blockListKey
|
||||
return key
|
||||
}
|
||||
|
||||
func (k blockListKey) BlocksHash() []byte {
|
||||
func (k blockListKey) Hash() []byte {
|
||||
return k[keyPrefixLen:]
|
||||
}
|
||||
|
||||
type versionKey []byte
|
||||
|
||||
func (k defaultKeyer) GenerateVersionKey(key []byte, hash []byte) versionKey {
|
||||
key = resize(key, keyPrefixLen+len(hash))
|
||||
key[0] = KeyTypeVersion
|
||||
copy(key[keyPrefixLen:], hash)
|
||||
return key
|
||||
}
|
||||
|
||||
func (k versionKey) Hash() []byte {
|
||||
return k[keyPrefixLen:]
|
||||
}
|
||||
|
||||
|
||||
+56
-10
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/greatroar/blobloom"
|
||||
"github.com/syncthing/syncthing/lib/db/backend"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
"github.com/syncthing/syncthing/lib/sha256"
|
||||
"github.com/syncthing/syncthing/lib/sync"
|
||||
"github.com/syncthing/syncthing/lib/util"
|
||||
"github.com/thejerf/suture"
|
||||
@@ -34,6 +35,8 @@ const (
|
||||
|
||||
// Use indirection for the block list when it exceeds this many entries
|
||||
blocksIndirectionCutoff = 3
|
||||
// Use indirection for the version vector when it exceeds this many entries
|
||||
versionIndirectionCutoff = 10
|
||||
|
||||
recheckDefaultInterval = 30 * 24 * time.Hour
|
||||
)
|
||||
@@ -630,11 +633,8 @@ func (db *Lowlevel) gcIndirect(ctx context.Context) error {
|
||||
if db.gcKeyCount > capacity {
|
||||
capacity = db.gcKeyCount
|
||||
}
|
||||
blockFilter := blobloom.NewOptimized(blobloom.Config{
|
||||
Capacity: uint64(capacity),
|
||||
FPRate: indirectGCBloomFalsePositiveRate,
|
||||
MaxBits: 8 * indirectGCBloomMaxBytes,
|
||||
})
|
||||
blockFilter := newBloomFilter(capacity)
|
||||
versionFilter := newBloomFilter(capacity)
|
||||
|
||||
// Iterate the FileInfos, unmarshal the block and version hashes and
|
||||
// add them to the filter.
|
||||
@@ -651,12 +651,15 @@ func (db *Lowlevel) gcIndirect(ctx context.Context) error {
|
||||
default:
|
||||
}
|
||||
|
||||
var bl BlocksHashOnly
|
||||
if err := bl.Unmarshal(it.Value()); err != nil {
|
||||
var hashes IndirectionHashesOnly
|
||||
if err := hashes.Unmarshal(it.Value()); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(bl.BlocksHash) > 0 {
|
||||
blockFilter.Add(bloomHash(bl.BlocksHash))
|
||||
if len(hashes.BlocksHash) > 0 {
|
||||
blockFilter.Add(bloomHash(hashes.BlocksHash))
|
||||
}
|
||||
if len(hashes.VersionHash) > 0 {
|
||||
versionFilter.Add(bloomHash(hashes.VersionHash))
|
||||
}
|
||||
}
|
||||
it.Release()
|
||||
@@ -681,7 +684,7 @@ func (db *Lowlevel) gcIndirect(ctx context.Context) error {
|
||||
}
|
||||
|
||||
key := blockListKey(it.Key())
|
||||
if blockFilter.Has(bloomHash(key.BlocksHash())) {
|
||||
if blockFilter.Has(bloomHash(key.Hash())) {
|
||||
matchedBlocks++
|
||||
continue
|
||||
}
|
||||
@@ -694,8 +697,40 @@ func (db *Lowlevel) gcIndirect(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Iterate over version lists, removing keys with hashes that don't match
|
||||
// the filter.
|
||||
|
||||
it, err = db.NewPrefixIterator([]byte{KeyTypeVersion})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
matchedVersions := 0
|
||||
for it.Next() {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
key := versionKey(it.Key())
|
||||
if versionFilter.Has(bloomHash(key.Hash())) {
|
||||
matchedVersions++
|
||||
continue
|
||||
}
|
||||
if err := t.Delete(key); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
it.Release()
|
||||
if err := it.Error(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remember the number of unique keys we kept until the next pass.
|
||||
db.gcKeyCount = matchedBlocks
|
||||
if matchedVersions > matchedBlocks {
|
||||
db.gcKeyCount = matchedVersions
|
||||
}
|
||||
|
||||
if err := t.Commit(); err != nil {
|
||||
return err
|
||||
@@ -704,9 +739,20 @@ func (db *Lowlevel) gcIndirect(ctx context.Context) error {
|
||||
return db.Compact()
|
||||
}
|
||||
|
||||
func newBloomFilter(capacity int) *blobloom.Filter {
|
||||
return blobloom.NewOptimized(blobloom.Config{
|
||||
Capacity: uint64(capacity),
|
||||
FPRate: indirectGCBloomFalsePositiveRate,
|
||||
MaxBits: 8 * indirectGCBloomMaxBytes,
|
||||
})
|
||||
}
|
||||
|
||||
// Hash function for the bloomfilter: first eight bytes of the SHA-256.
|
||||
// Big or little-endian makes no difference, as long as we're consistent.
|
||||
func bloomHash(key []byte) uint64 {
|
||||
if len(key) != sha256.Size {
|
||||
panic("bug: bloomHash passed something not a SHA256 hash")
|
||||
}
|
||||
return binary.BigEndian.Uint64(key)
|
||||
}
|
||||
|
||||
|
||||
+31
-10
@@ -23,9 +23,10 @@ import (
|
||||
// 7: v0.14.53
|
||||
// 8-9: v1.4.0
|
||||
// 10-11: v1.6.0
|
||||
// 12: v1.7.0
|
||||
const (
|
||||
dbVersion = 11
|
||||
dbMinSyncthingVersion = "v1.6.0"
|
||||
dbVersion = 12
|
||||
dbMinSyncthingVersion = "v1.7.0"
|
||||
)
|
||||
|
||||
type databaseDowngradeError struct {
|
||||
@@ -88,6 +89,7 @@ func (db *schemaUpdater) updateSchema() error {
|
||||
{9, db.updateSchemaTo9},
|
||||
{10, db.updateSchemaTo10},
|
||||
{11, db.updateSchemaTo11},
|
||||
{12, db.updateSchemaTo12},
|
||||
}
|
||||
|
||||
for _, m := range migrations {
|
||||
@@ -453,7 +455,6 @@ func (db *schemaUpdater) updateSchema6to7(_ int) error {
|
||||
|
||||
func (db *schemaUpdater) updateSchemaTo9(prev int) error {
|
||||
// Loads and rewrites all files with blocks, to deduplicate block lists.
|
||||
// Checks for missing or incorrect sequence entries and rewrites those.
|
||||
|
||||
t, err := db.newReadWriteTransaction()
|
||||
if err != nil {
|
||||
@@ -461,6 +462,16 @@ func (db *schemaUpdater) updateSchemaTo9(prev int) error {
|
||||
}
|
||||
defer t.close()
|
||||
|
||||
if err := db.rewriteFiles(t); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
db.recordTime(indirectGCTimeKey)
|
||||
|
||||
return t.Commit()
|
||||
}
|
||||
|
||||
func (db *schemaUpdater) rewriteFiles(t readWriteTransaction) error {
|
||||
it, err := t.NewPrefixIterator([]byte{KeyTypeDevice})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -491,13 +502,7 @@ func (db *schemaUpdater) updateSchemaTo9(prev int) error {
|
||||
}
|
||||
}
|
||||
it.Release()
|
||||
if err := it.Error(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
db.recordTime(indirectGCTimeKey)
|
||||
|
||||
return t.Commit()
|
||||
return it.Error()
|
||||
}
|
||||
|
||||
func (db *schemaUpdater) updateSchemaTo10(_ int) error {
|
||||
@@ -610,3 +615,19 @@ func (db *schemaUpdater) updateSchemaTo11(_ int) error {
|
||||
}
|
||||
return t.Commit()
|
||||
}
|
||||
|
||||
func (db *schemaUpdater) updateSchemaTo12(_ int) error {
|
||||
// Loads and rewrites all files, to deduplicate version vectors.
|
||||
|
||||
t, err := db.newReadWriteTransaction()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer t.close()
|
||||
|
||||
if err := db.rewriteFiles(t); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return t.Commit()
|
||||
}
|
||||
|
||||
+171
-72
@@ -118,6 +118,7 @@ type FileInfoTruncated struct {
|
||||
RawBlockSize int32 `protobuf:"varint,13,opt,name=block_size,json=blockSize,proto3" json:"block_size,omitempty"`
|
||||
// see bep.proto
|
||||
LocalFlags uint32 `protobuf:"varint,1000,opt,name=local_flags,json=localFlags,proto3" json:"local_flags,omitempty"`
|
||||
VersionHash []byte `protobuf:"bytes,1001,opt,name=version_hash,json=versionHash,proto3" json:"version_hash,omitempty"`
|
||||
Deleted bool `protobuf:"varint,6,opt,name=deleted,proto3" json:"deleted,omitempty"`
|
||||
RawInvalid bool `protobuf:"varint,7,opt,name=invalid,proto3" json:"invalid,omitempty"`
|
||||
NoPermissions bool `protobuf:"varint,8,opt,name=no_permissions,json=noPermissions,proto3" json:"no_permissions,omitempty"`
|
||||
@@ -193,23 +194,25 @@ func (m *BlockList) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_BlockList proto.InternalMessageInfo
|
||||
|
||||
// BlocksHashOnly is used to only unmarshal the block list hash from a FileInfo
|
||||
type BlocksHashOnly struct {
|
||||
BlocksHash []byte `protobuf:"bytes,18,opt,name=blocks_hash,json=blocksHash,proto3" json:"blocks_hash,omitempty"`
|
||||
// IndirectionHashesOnly is used to only unmarshal the indirection hashes
|
||||
// from a FileInfo
|
||||
type IndirectionHashesOnly struct {
|
||||
BlocksHash []byte `protobuf:"bytes,18,opt,name=blocks_hash,json=blocksHash,proto3" json:"blocks_hash,omitempty"`
|
||||
VersionHash []byte `protobuf:"bytes,1001,opt,name=version_hash,json=versionHash,proto3" json:"version_hash,omitempty"`
|
||||
}
|
||||
|
||||
func (m *BlocksHashOnly) Reset() { *m = BlocksHashOnly{} }
|
||||
func (m *BlocksHashOnly) String() string { return proto.CompactTextString(m) }
|
||||
func (*BlocksHashOnly) ProtoMessage() {}
|
||||
func (*BlocksHashOnly) Descriptor() ([]byte, []int) {
|
||||
func (m *IndirectionHashesOnly) Reset() { *m = IndirectionHashesOnly{} }
|
||||
func (m *IndirectionHashesOnly) String() string { return proto.CompactTextString(m) }
|
||||
func (*IndirectionHashesOnly) ProtoMessage() {}
|
||||
func (*IndirectionHashesOnly) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e774e8f5f348d14d, []int{4}
|
||||
}
|
||||
func (m *BlocksHashOnly) XXX_Unmarshal(b []byte) error {
|
||||
func (m *IndirectionHashesOnly) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *BlocksHashOnly) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *IndirectionHashesOnly) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_BlocksHashOnly.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_IndirectionHashesOnly.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@@ -219,17 +222,17 @@ func (m *BlocksHashOnly) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *BlocksHashOnly) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BlocksHashOnly.Merge(m, src)
|
||||
func (m *IndirectionHashesOnly) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_IndirectionHashesOnly.Merge(m, src)
|
||||
}
|
||||
func (m *BlocksHashOnly) XXX_Size() int {
|
||||
func (m *IndirectionHashesOnly) XXX_Size() int {
|
||||
return m.ProtoSize()
|
||||
}
|
||||
func (m *BlocksHashOnly) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BlocksHashOnly.DiscardUnknown(m)
|
||||
func (m *IndirectionHashesOnly) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_IndirectionHashesOnly.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BlocksHashOnly proto.InternalMessageInfo
|
||||
var xxx_messageInfo_IndirectionHashesOnly proto.InternalMessageInfo
|
||||
|
||||
// For each folder and device we keep one of these to track the current
|
||||
// counts and sequence. We also keep one for the global state of the folder.
|
||||
@@ -320,7 +323,7 @@ func init() {
|
||||
proto.RegisterType((*VersionList)(nil), "db.VersionList")
|
||||
proto.RegisterType((*FileInfoTruncated)(nil), "db.FileInfoTruncated")
|
||||
proto.RegisterType((*BlockList)(nil), "db.BlockList")
|
||||
proto.RegisterType((*BlocksHashOnly)(nil), "db.BlocksHashOnly")
|
||||
proto.RegisterType((*IndirectionHashesOnly)(nil), "db.IndirectionHashesOnly")
|
||||
proto.RegisterType((*Counts)(nil), "db.Counts")
|
||||
proto.RegisterType((*CountsSet)(nil), "db.CountsSet")
|
||||
}
|
||||
@@ -328,54 +331,56 @@ func init() {
|
||||
func init() { proto.RegisterFile("structs.proto", fileDescriptor_e774e8f5f348d14d) }
|
||||
|
||||
var fileDescriptor_e774e8f5f348d14d = []byte{
|
||||
// 747 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xbf, 0x8f, 0xe2, 0x46,
|
||||
0x14, 0xc6, 0x07, 0x66, 0xe1, 0x19, 0xc8, 0xdd, 0xe4, 0xb4, 0xb2, 0x90, 0x62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 0x1a, 0x5e, 0x07, 0x97, 0x50,
|
||||
0x66, 0x62, 0x92, 0x10, 0x41, 0x62, 0xbb, 0xa5, 0x33, 0x05, 0x1c, 0x5f, 0x82, 0x55, 0x0c, 0xf2,
|
||||
0x3d, 0xe5, 0x02, 0xbd, 0x86, 0x4e, 0xd1, 0x85, 0xdb, 0x86, 0xdb, 0xf4, 0xac, 0x8b, 0x4f, 0x26,
|
||||
0x71, 0x38, 0xa9, 0xcd, 0x5b, 0x0c, 0x53, 0x95, 0x7d, 0xd5, 0xfa, 0xfd, 0x6e, 0xd4, 0x18, 0xff,
|
||||
0x62, 0xc2, 0x0b, 0x59, 0x35, 0x4b, 0x97, 0xec, 0x7d, 0xb6, 0x4b, 0xa3, 0x40, 0x90, 0x18, 0x21,
|
||||
0x68, 0xa5, 0xc1, 0x86, 0xa8, 0xc5, 0xba, 0x58, 0xc5, 0x92, 0xe3, 0xf4, 0x96, 0xa8, 0x11, 0x9b,
|
||||
0x58, 0xc5, 0xe8, 0x33, 0x80, 0x0d, 0x8b, 0xe9, 0x92, 0x92, 0x78, 0xc1, 0x6d, 0x53, 0x65, 0xba,
|
||||
0x25, 0x33, 0x47, 0x3f, 0x81, 0x55, 0xa5, 0xc3, 0xdc, 0xee, 0xb9, 0x86, 0xd7, 0xf2, 0xbf, 0x96,
|
||||
0x73, 0xfc, 0xb9, 0x1f, 0xbd, 0x59, 0x51, 0xb1, 0xde, 0x85, 0x93, 0x88, 0x6d, 0xa6, 0x3c, 0x4f,
|
||||
0x23, 0xb1, 0xa6, 0xe9, 0xaa, 0x16, 0xd5, 0x65, 0x98, 0xcc, 0xd7, 0x2c, 0x13, 0xb3, 0xb7, 0xb8,
|
||||
0x6a, 0xe7, 0xe7, 0x75, 0x01, 0xba, 0x1f, 0x27, 0xc0, 0x10, 0x3a, 0x9c, 0xfc, 0xbc, 0x23, 0x69,
|
||||
0x44, 0x6c, 0x50, 0xc3, 0x56, 0x18, 0xbd, 0x82, 0x01, 0xcf, 0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 0x9d, 0x46, 0xd8, 0x56, 0x72, 0xbd, 0xf9, 0x2f, 0x00,
|
||||
0x00, 0xff, 0xff, 0x8a, 0x67, 0x08, 0x85, 0x7f, 0x05, 0x00, 0x00,
|
||||
// 774 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x8f, 0xe3, 0x44,
|
||||
0x10, 0x8d, 0x37, 0x71, 0x3e, 0xca, 0x49, 0xd8, 0x6d, 0x96, 0x91, 0x15, 0x09, 0xc7, 0x0a, 0x5a,
|
||||
0xc9, 0xe2, 0x90, 0xc0, 0xec, 0x0d, 0x24, 0x0e, 0x61, 0x35, 0x22, 0x12, 0x62, 0x51, 0x67, 0xb5,
|
||||
0xa7, 0x95, 0x22, 0x7f, 0x74, 0x92, 0xd6, 0x38, 0xee, 0xe0, 0xee, 0xcc, 0xc8, 0xf3, 0x17, 0xb8,
|
||||
0x70, 0xe4, 0x38, 0x17, 0xfe, 0xcb, 0x1c, 0xe7, 0x88, 0x38, 0x44, 0x90, 0x70, 0x80, 0x7f, 0x81,
|
||||
0xba, 0xdb, 0x76, 0x3c, 0x73, 0x61, 0x6e, 0x55, 0xaf, 0x2a, 0xa9, 0xaa, 0xf7, 0x9e, 0x1b, 0x7a,
|
||||
0x5c, 0xa4, 0xbb, 0x50, 0xf0, 0xf1, 0x36, 0x65, 0x82, 0xa1, 0x67, 0x51, 0x30, 0xf8, 0x2c, 0x25,
|
||||
0x5b, 0xc6, 0x27, 0x0a, 0x08, 0x76, 0xcb, 0xc9, 0x8a, 0xad, 0x98, 0x4a, 0x54, 0xa4, 0x1b, 0x07,
|
||||
0x67, 0x31, 0x0d, 0x74, 0x4b, 0xc8, 0xe2, 0x49, 0x40, 0xb6, 0x1a, 0x1f, 0xfd, 0x6c, 0x80, 0x75,
|
||||
0x41, 0x63, 0xf2, 0x9e, 0xa4, 0x9c, 0xb2, 0x04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, 0xeb, 0x67, 0x67, 0xf6, 0x46, 0x39, 0xbc, 0x8b, 0xcb, 0x1c, 0x39, 0x50, 0xf1, 0x81, 0xa2,
|
||||
0xe2, 0x81, 0x33, 0x46, 0x6f, 0xa1, 0xa3, 0xaf, 0x9c, 0x13, 0x81, 0x3c, 0x68, 0x86, 0x2a, 0xc9,
|
||||
0x45, 0x00, 0xf9, 0xe0, 0xe8, 0x72, 0xc1, 0xbd, 0xae, 0xcb, 0xf5, 0xc3, 0x94, 0xc8, 0x87, 0x45,
|
||||
0x1d, 0x5e, 0xc7, 0x45, 0x3a, 0x75, 0xef, 0xfe, 0x72, 0x6a, 0x77, 0x07, 0xc7, 0xb8, 0x3f, 0x38,
|
||||
0xc6, 0x9f, 0x07, 0xa7, 0xf6, 0xcb, 0xd1, 0xa9, 0xdd, 0x1e, 0x1d, 0xe3, 0xfe, 0xe8, 0xd4, 0x7e,
|
||||
0x3f, 0x3a, 0xb5, 0xa0, 0xa9, 0x94, 0x7d, 0xfd, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x45,
|
||||
0x1c, 0xc5, 0xce, 0x05, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *FileVersion) Marshal() (dAtA []byte, err error) {
|
||||
@@ -495,6 +500,15 @@ func (m *FileInfoTruncated) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.VersionHash) > 0 {
|
||||
i -= len(m.VersionHash)
|
||||
copy(dAtA[i:], m.VersionHash)
|
||||
i = encodeVarintStructs(dAtA, i, uint64(len(m.VersionHash)))
|
||||
i--
|
||||
dAtA[i] = 0x3e
|
||||
i--
|
||||
dAtA[i] = 0xca
|
||||
}
|
||||
if m.LocalFlags != 0 {
|
||||
i = encodeVarintStructs(dAtA, i, uint64(m.LocalFlags))
|
||||
i--
|
||||
@@ -647,7 +661,7 @@ func (m *BlockList) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *BlocksHashOnly) Marshal() (dAtA []byte, err error) {
|
||||
func (m *IndirectionHashesOnly) Marshal() (dAtA []byte, err error) {
|
||||
size := m.ProtoSize()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@@ -657,16 +671,25 @@ func (m *BlocksHashOnly) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *BlocksHashOnly) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *IndirectionHashesOnly) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.ProtoSize()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *BlocksHashOnly) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *IndirectionHashesOnly) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.VersionHash) > 0 {
|
||||
i -= len(m.VersionHash)
|
||||
copy(dAtA[i:], m.VersionHash)
|
||||
i = encodeVarintStructs(dAtA, i, uint64(len(m.VersionHash)))
|
||||
i--
|
||||
dAtA[i] = 0x3e
|
||||
i--
|
||||
dAtA[i] = 0xca
|
||||
}
|
||||
if len(m.BlocksHash) > 0 {
|
||||
i -= len(m.BlocksHash)
|
||||
copy(dAtA[i:], m.BlocksHash)
|
||||
@@ -893,6 +916,10 @@ func (m *FileInfoTruncated) ProtoSize() (n int) {
|
||||
if m.LocalFlags != 0 {
|
||||
n += 2 + sovStructs(uint64(m.LocalFlags))
|
||||
}
|
||||
l = len(m.VersionHash)
|
||||
if l > 0 {
|
||||
n += 2 + l + sovStructs(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -911,7 +938,7 @@ func (m *BlockList) ProtoSize() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *BlocksHashOnly) ProtoSize() (n int) {
|
||||
func (m *IndirectionHashesOnly) ProtoSize() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@@ -921,6 +948,10 @@ func (m *BlocksHashOnly) ProtoSize() (n int) {
|
||||
if l > 0 {
|
||||
n += 2 + l + sovStructs(uint64(l))
|
||||
}
|
||||
l = len(m.VersionHash)
|
||||
if l > 0 {
|
||||
n += 2 + l + sovStructs(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -1620,6 +1651,40 @@ func (m *FileInfoTruncated) Unmarshal(dAtA []byte) error {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1001:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field VersionHash", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowStructs
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthStructs
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthStructs
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.VersionHash = append(m.VersionHash[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.VersionHash == nil {
|
||||
m.VersionHash = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipStructs(dAtA[iNdEx:])
|
||||
@@ -1731,7 +1796,7 @@ func (m *BlockList) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *BlocksHashOnly) Unmarshal(dAtA []byte) error {
|
||||
func (m *IndirectionHashesOnly) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@@ -1754,10 +1819,10 @@ func (m *BlocksHashOnly) Unmarshal(dAtA []byte) error {
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: BlocksHashOnly: wiretype end group for non-group")
|
||||
return fmt.Errorf("proto: IndirectionHashesOnly: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: BlocksHashOnly: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
return fmt.Errorf("proto: IndirectionHashesOnly: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 18:
|
||||
@@ -1794,6 +1859,40 @@ func (m *BlocksHashOnly) Unmarshal(dAtA []byte) error {
|
||||
m.BlocksHash = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 1001:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field VersionHash", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowStructs
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthStructs
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthStructs
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.VersionHash = append(m.VersionHash[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.VersionHash == nil {
|
||||
m.VersionHash = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipStructs(dAtA[iNdEx:])
|
||||
|
||||
@@ -42,7 +42,8 @@ message FileInfoTruncated {
|
||||
int32 block_size = 13 [(gogoproto.customname) = "RawBlockSize"];
|
||||
|
||||
// see bep.proto
|
||||
uint32 local_flags = 1000;
|
||||
uint32 local_flags = 1000;
|
||||
bytes version_hash = 1001;
|
||||
|
||||
bool deleted = 6;
|
||||
bool invalid = 7 [(gogoproto.customname) = "RawInvalid"];
|
||||
@@ -54,9 +55,11 @@ message BlockList {
|
||||
repeated protocol.BlockInfo Blocks = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// BlocksHashOnly is used to only unmarshal the block list hash from a FileInfo
|
||||
message BlocksHashOnly {
|
||||
bytes blocks_hash = 18;
|
||||
// IndirectionHashesOnly is used to only unmarshal the indirection hashes
|
||||
// from a FileInfo
|
||||
message IndirectionHashesOnly {
|
||||
bytes blocks_hash = 18;
|
||||
bytes version_hash = 1001;
|
||||
}
|
||||
|
||||
// For each folder and device we keep one of these to track the current
|
||||
|
||||
+58
-1
@@ -79,6 +79,9 @@ func (t readOnlyTransaction) unmarshalTrunc(bs []byte, trunc bool) (FileIntf, er
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := t.fillTruncated(&tf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tf, nil
|
||||
}
|
||||
|
||||
@@ -92,7 +95,8 @@ func (t readOnlyTransaction) unmarshalTrunc(bs []byte, trunc bool) (FileIntf, er
|
||||
return fi, nil
|
||||
}
|
||||
|
||||
// fillFileInfo follows the (possible) indirection of blocks and fills it out.
|
||||
// fillFileInfo follows the (possible) indirection of blocks and version
|
||||
// vector and fills it out.
|
||||
func (t readOnlyTransaction) fillFileInfo(fi *protocol.FileInfo) error {
|
||||
var key []byte
|
||||
|
||||
@@ -110,6 +114,41 @@ func (t readOnlyTransaction) fillFileInfo(fi *protocol.FileInfo) error {
|
||||
fi.Blocks = bl.Blocks
|
||||
}
|
||||
|
||||
if len(fi.VersionHash) != 0 {
|
||||
key = t.keyer.GenerateVersionKey(key, fi.VersionHash)
|
||||
bs, err := t.Get(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var v protocol.Vector
|
||||
if err := v.Unmarshal(bs); err != nil {
|
||||
return err
|
||||
}
|
||||
fi.Version = v
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// fillTruncated follows the (possible) indirection of version vector and
|
||||
// fills it.
|
||||
func (t readOnlyTransaction) fillTruncated(fi *FileInfoTruncated) error {
|
||||
var key []byte
|
||||
|
||||
if len(fi.VersionHash) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
key = t.keyer.GenerateVersionKey(key, fi.VersionHash)
|
||||
bs, err := t.Get(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var v protocol.Vector
|
||||
if err := v.Unmarshal(bs); err != nil {
|
||||
return err
|
||||
}
|
||||
fi.Version = v
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -511,6 +550,24 @@ func (t readWriteTransaction) putFile(fkey []byte, fi protocol.FileInfo, truncat
|
||||
fi.Blocks = nil
|
||||
}
|
||||
|
||||
// Indirect the version vector if it's large enough.
|
||||
if len(fi.Version.Counters) > versionIndirectionCutoff {
|
||||
fi.VersionHash = protocol.VectorHash(fi.Version)
|
||||
bkey = t.keyer.GenerateVersionKey(bkey, fi.VersionHash)
|
||||
if _, err := t.Get(bkey); backend.IsNotFound(err) {
|
||||
// Marshal the version vector and save it
|
||||
versionBs := mustMarshal(&fi.Version)
|
||||
if err := t.Put(bkey, versionBs); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
fi.Version = protocol.Vector{}
|
||||
} else {
|
||||
fi.VersionHash = nil
|
||||
}
|
||||
|
||||
fiBs := mustMarshal(&fi)
|
||||
return t.Put(fkey, fiBs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user