diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-12-19 00:42:46 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-12-19 00:42:46 -0800 |
| commit | f61de28c697e80fd9f74d9519609c3d5282a9a6a (patch) | |
| tree | b85499291aa420ec13e026a53909fedb58b0be42 /weed/storage/volume_loading.go | |
| parent | deb03ecfa360e8b0909c01edd2fc8cddd53813f0 (diff) | |
| download | seaweedfs-f61de28c697e80fd9f74d9519609c3d5282a9a6a.tar.xz seaweedfs-f61de28c697e80fd9f74d9519609c3d5282a9a6a.zip | |
volume: add deletion capability for previously readonly volumes
Diffstat (limited to 'weed/storage/volume_loading.go')
| -rw-r--r-- | weed/storage/volume_loading.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.go index 4b5f539dc..42780341b 100644 --- a/weed/storage/volume_loading.go +++ b/weed/storage/volume_loading.go @@ -27,7 +27,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind alreadyHasSuperBlock := false if v.maybeLoadVolumeTierInfo() { - v.readOnly = true + v.noWriteCanDelete = true // open remote file alreadyHasSuperBlock = true } else if exists, canRead, canWrite, modifiedTime, fileSize := checkFile(fileName + ".dat"); exists { @@ -41,7 +41,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind } else { glog.V(0).Infoln("opening " + fileName + ".dat in READONLY mode") dataFile, e = os.Open(fileName + ".dat") - v.readOnly = true + v.noWriteOrDelete = true } v.lastModifiedTsSeconds = uint64(modifiedTime.Unix()) if fileSize >= _SuperBlockSize { @@ -74,7 +74,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind } if e == nil && alsoLoadIndex { var indexFile *os.File - if v.readOnly { + if v.noWriteOrDelete { glog.V(1).Infoln("open to read file", fileName+".idx") if indexFile, e = os.OpenFile(fileName+".idx", os.O_RDONLY, 0644); e != nil { return fmt.Errorf("cannot read Volume Index %s.idx: %v", fileName, e) @@ -86,11 +86,11 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind } } if v.lastAppendAtNs, e = CheckVolumeDataIntegrity(v, indexFile); e != nil { - v.readOnly = true + v.noWriteOrDelete = true glog.V(0).Infof("volumeDataIntegrityChecking failed %v", e) } - if v.readOnly { + if v.noWriteOrDelete || v.noWriteCanDelete { if v.nm, e = NewSortedFileNeedleMap(fileName, indexFile); e != nil { glog.V(0).Infof("loading sorted db %s error: %v", fileName+".sdb", e) } |
