aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed/pb/master_pb/seaweed.pb.go81
-rw-r--r--weed/pb/seaweed.proto3
-rw-r--r--weed/storage/volume_super_block.go56
-rw-r--r--weed/storage/volume_vacuum_test.go4
4 files changed, 96 insertions, 48 deletions
diff --git a/weed/pb/master_pb/seaweed.pb.go b/weed/pb/master_pb/seaweed.pb.go
index a0f23225a..d667bd7f5 100644
--- a/weed/pb/master_pb/seaweed.pb.go
+++ b/weed/pb/master_pb/seaweed.pb.go
@@ -13,6 +13,7 @@ It has these top-level messages:
HeartbeatResponse
VolumeInformationMessage
Empty
+ SuperBlockExtra
*/
package master_pb
@@ -244,11 +245,20 @@ func (m *Empty) String() string { return proto.CompactTextString(m) }
func (*Empty) ProtoMessage() {}
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
+type SuperBlockExtra struct {
+}
+
+func (m *SuperBlockExtra) Reset() { *m = SuperBlockExtra{} }
+func (m *SuperBlockExtra) String() string { return proto.CompactTextString(m) }
+func (*SuperBlockExtra) ProtoMessage() {}
+func (*SuperBlockExtra) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
+
func init() {
proto.RegisterType((*Heartbeat)(nil), "master_pb.Heartbeat")
proto.RegisterType((*HeartbeatResponse)(nil), "master_pb.HeartbeatResponse")
proto.RegisterType((*VolumeInformationMessage)(nil), "master_pb.VolumeInformationMessage")
proto.RegisterType((*Empty)(nil), "master_pb.Empty")
+ proto.RegisterType((*SuperBlockExtra)(nil), "master_pb.SuperBlockExtra")
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -423,39 +433,40 @@ var _Seaweed_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("seaweed.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
- // 540 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x93, 0xcf, 0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x70, 0x5c, 0xa2, 0x44, 0xdb, 0x09, 0xbc, 0x53, 0x03, 0xcf, 0xbc,
- 0xe4, 0x39, 0x30, 0x7f, 0x2c, 0xf3, 0x65, 0xbb, 0x15, 0xf6, 0x48, 0x38, 0xda, 0x64, 0xde, 0xb4,
- 0x9d, 0xfa, 0x01, 0xc4, 0x1a, 0x79, 0x99, 0xd7, 0x4a, 0xb6, 0x64, 0xde, 0x51, 0x76, 0xe4, 0xc0,
- 0x27, 0x25, 0x5b, 0xf6, 0x0c, 0x4e, 0x35, 0x36, 0x52, 0x14, 0x3c, 0x6f, 0x24, 0x2f, 0xb0, 0x42,
- 0xd5, 0xf9, 0x38, 0xda, 0x24, 0xae, 0x3a, 0xce, 0x12, 0xe8, 0xdf, 0xa2, 0x36, 0xee, 0xb7, 0x62,
- 0x92, 0x74, 0x47, 0x36, 0x82, 0x03, 0x6b, 0x65, 0x02, 0x44, 0x5d, 0x38, 0xe9, 0xc3, 0xe1, 0xdb,
- 0xaa, 0xb1, 0xed, 0xc5, 0xf7, 0x00, 0xfa, 0x0b, 0xff, 0x22, 0xd8, 0x25, 0x0c, 0x17, 0xa8, 0xca,
- 0xdd, 0x1b, 0xb8, 0xb7, 0x77, 0x1f, 0xb6, 0xf4, 0xec, 0xfc, 0x6f, 0xb4, 0xbb, 0x00, 0x93, 0xff,
- 0xd2, 0xe0, 0x45, 0xc0, 0x5e, 0xc1, 0x70, 0x8e, 0xd8, 0xcc, 0x6a, 0xa5, 0xb0, 0xb0, 0x58, 0xb2,
- 0xd1, 0x5e, 0x11, 0x75, 0x3e, 0xfb, 0x83, 0xf8, 0xd2, 0x65, 0x8f, 0x1e, 0xe6, 0xcb, 0x5f, 0x01,
- 0x00, 0x00, 0xff, 0xff, 0x41, 0x64, 0x8a, 0xd9, 0xa9, 0x03, 0x00, 0x00,
+ // 553 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff,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 0x59, 0xcb, 0xbc, 0x03, 0x00, 0x00,
}
diff --git a/weed/pb/seaweed.proto b/weed/pb/seaweed.proto
index 4d31f8e6a..79c161f2d 100644
--- a/weed/pb/seaweed.proto
+++ b/weed/pb/seaweed.proto
@@ -46,3 +46,6 @@ message VolumeInformationMessage {
message Empty {
}
+
+message SuperBlockExtra {
+}
diff --git a/weed/storage/volume_super_block.go b/weed/storage/volume_super_block.go
index b15b848bd..5d62aff5f 100644
--- a/weed/storage/volume_super_block.go
+++ b/weed/storage/volume_super_block.go
@@ -5,7 +5,9 @@ import (
"os"
"github.com/chrislusf/seaweedfs/weed/glog"
+ "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/golang/protobuf/proto"
)
const (
@@ -25,9 +27,15 @@ type SuperBlock struct {
ReplicaPlacement *ReplicaPlacement
Ttl *TTL
CompactRevision uint16
+ Extra *master_pb.SuperBlockExtra
+ extraSize uint16
}
func (s *SuperBlock) BlockSize() int {
+ switch version {
+ case Version2:
+ return _SuperBlockSize + int(s.extraSize)
+ }
return _SuperBlockSize
}
@@ -40,6 +48,22 @@ func (s *SuperBlock) Bytes() []byte {
header[1] = s.ReplicaPlacement.Byte()
s.Ttl.ToBytes(header[2:4])
util.Uint16toBytes(header[4:6], s.CompactRevision)
+
+ if s.Extra != nil {
+ extraData, err := proto.Marshal(s.Extra)
+ if err != nil {
+ glog.Fatalf("cannot marshal super block extra %+v: %v", s.Extra, err)
+ }
+ extraSize := len(extraData)
+ if extraSize > 256*256 {
+ glog.Fatalf("super block extra size is %d bigger than %d: %v", extraSize, 256*256)
+ }
+ s.extraSize = uint16(extraSize)
+ util.Uint16toBytes(header[6:8], s.extraSize)
+
+ header = append(header, extraData...)
+ }
+
return header
}
@@ -69,16 +93,6 @@ func (v *Volume) readSuperBlock() (err error) {
return err
}
-func parseSuperBlock(header []byte) (superBlock SuperBlock, err error) {
- superBlock.version = Version(header[0])
- if superBlock.ReplicaPlacement, err = NewReplicaPlacementFromByte(header[1]); err != nil {
- err = fmt.Errorf("cannot read replica type: %s", err.Error())
- }
- superBlock.Ttl = LoadTTLFromBytes(header[2:4])
- superBlock.CompactRevision = util.BytesToUint16(header[4:6])
- return
-}
-
// ReadSuperBlock reads from data file and load it into volume's super block
func ReadSuperBlock(dataFile *os.File) (superBlock SuperBlock, err error) {
if _, err = dataFile.Seek(0, 0); err != nil {
@@ -90,5 +104,25 @@ func ReadSuperBlock(dataFile *os.File) (superBlock SuperBlock, err error) {
err = fmt.Errorf("cannot read volume %s super block: %v", dataFile.Name(), e)
return
}
- return parseSuperBlock(header)
+ superBlock.version = Version(header[0])
+ if superBlock.ReplicaPlacement, err = NewReplicaPlacementFromByte(header[1]); err != nil {
+ err = fmt.Errorf("cannot read replica type: %s", err.Error())
+ return
+ }
+ superBlock.Ttl = LoadTTLFromBytes(header[2:4])
+ superBlock.CompactRevision = util.BytesToUint16(header[4:6])
+ superBlock.extraSize = util.BytesToUint16(header[6:8])
+
+ if superBlock.extraSize > 0 {
+ // read more
+ extraData := make([]byte, int(superBlock.extraSize))
+ superBlock.Extra = &master_pb.SuperBlockExtra{}
+ err = proto.Unmarshal(extraData, superBlock.Extra)
+ if err != nil {
+ err = fmt.Errorf("cannot read volume %s super block extra: %v", dataFile.Name(), e)
+ return
+ }
+ }
+
+ return
}
diff --git a/weed/storage/volume_vacuum_test.go b/weed/storage/volume_vacuum_test.go
index 5f28330f8..53c50b743 100644
--- a/weed/storage/volume_vacuum_test.go
+++ b/weed/storage/volume_vacuum_test.go
@@ -1,10 +1,10 @@
package storage
import (
- "testing"
- "os"
"io/ioutil"
"math/rand"
+ "os"
+ "testing"
)
/*