Browse Source

Revert "fix errors with frozen volume loading"

This reverts commit 92ffba2ab9.
pull/2/head
Chris Lu 12 years ago
parent
commit
ee08e38126
  1. 11
      weed-fs/src/pkg/storage/needle_map.go
  2. 4
      weed-fs/src/pkg/storage/store.go
  3. 9
      weed-fs/src/pkg/storage/volume.go

11
weed-fs/src/pkg/storage/needle_map.go

@ -178,11 +178,7 @@ func (nm *NeedleMap) Put(key uint64, offset uint32, size uint32) (int, error) {
return nm.indexFile.Write(nm.bytes)
}
func (nm *NeedleMap) Get(key uint64) (element *NeedleValue, ok bool) {
if nm.m != nil {
element, ok = nm.m.Get(Key(key))
} else {
element, ok = nm.fm.Get(Key(key))
}
element, ok = nm.m.Get(Key(key))
return
}
func (nm *NeedleMap) Delete(key uint64) error {
@ -206,8 +202,5 @@ func (nm *NeedleMap) ContentSize() uint64 {
// iterate through all needles using the iterator function
func (nm *NeedleMap) Walk(pedestrian func(*NeedleValue) error) (err error) {
if nm.m != nil {
return nm.m.Walk(pedestrian)
}
return nm.fm.Walk(pedestrian)
return nm.m.Walk(pedestrian)
}

4
weed-fs/src/pkg/storage/store.go

@ -118,9 +118,7 @@ func (s *Store) loadExistingVolumes() {
if s.volumes[vid] == nil {
if v, e := NewVolume(s.dir, vid, CopyNil); e == nil {
s.volumes[vid] = v
log.Println("In dir", s.dir, "read volume =", vid, "replicationType =", v.replicaType, "version =", v.version, "size =", v.Size(), "frozen?", !v.IsWritable())
} else {
log.Println("ERROR loading volume", vid, "in dir", s.dir, ":", e.Error())
log.Println("In dir", s.dir, "read volume =", vid, "replicationType =", v.replicaType, "version =", v.version, "size =", v.Size())
}
}
}

9
weed-fs/src/pkg/storage/volume.go

@ -36,14 +36,7 @@ func (v *Volume) load() error {
fileName := path.Join(v.dir, v.Id.String())
v.dataFile, e = os.OpenFile(fileName+".dat", os.O_RDWR|os.O_CREATE, 0644)
if e != nil {
if os.IsPermission(e) {
if util.FileExists(fileName + ".cdb") {
v.dataFile, e = os.Open(fileName + ".dat")
}
}
if e != nil {
return fmt.Errorf("cannot create Volume Data %s.dat: %s", fileName, e)
}
return fmt.Errorf("cannot create Volume Data %s.dat: %s", fileName, e)
}
if v.replicaType == CopyNil {
if e = v.readSuperBlock(); e != nil {

Loading…
Cancel
Save