aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-08 09:45:26 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-08 09:45:26 -0800
commit288baf37fd214d7ef9b40fae547976dff8357d8b (patch)
tree0a8ed51ec17f8c1d45d619327d48f57caf68c16a
parentacf7ca7b93e0a33e9fc987dec600d1b9f1dc1e32 (diff)
downloadseaweedfs-288baf37fd214d7ef9b40fae547976dff8357d8b.tar.xz
seaweedfs-288baf37fd214d7ef9b40fae547976dff8357d8b.zip
saving .vif files correctly
-rw-r--r--weed/storage/volume_loading.go9
-rw-r--r--weed/storage/volume_tier.go5
2 files changed, 8 insertions, 6 deletions
diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.go
index fa1f7d617..6b42fc452 100644
--- a/weed/storage/volume_loading.go
+++ b/weed/storage/volume_loading.go
@@ -26,9 +26,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
fileName := v.FileName()
alreadyHasSuperBlock := false
- if !v.maybeLoadVolumeInfo() {
- v.SaveVolumeInfo()
- }
+ hasVolumeInfoFile := v.maybeLoadVolumeInfo() && v.volumeInfo.Version != 0
if v.HasRemoteFile() {
v.noWriteCanDelete = true
@@ -141,6 +139,11 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
}
}
+ if !hasVolumeInfoFile {
+ v.volumeInfo.Version = uint32(v.SuperBlock.Version)
+ v.SaveVolumeInfo()
+ }
+
stats.VolumeServerVolumeCounter.WithLabelValues(v.Collection, "volume").Inc()
return err
diff --git a/weed/storage/volume_tier.go b/weed/storage/volume_tier.go
index 99071285f..85eafa848 100644
--- a/weed/storage/volume_tier.go
+++ b/weed/storage/volume_tier.go
@@ -14,12 +14,11 @@ func (v *Volume) GetVolumeInfo() *volume_server_pb.VolumeInfo {
func (v *Volume) maybeLoadVolumeInfo() (found bool) {
- v.volumeInfo, found = pb.MaybeLoadVolumeInfo(v.FileName() + ".vif")
+ v.volumeInfo, v.hasRemoteFile = pb.MaybeLoadVolumeInfo(v.FileName() + ".vif")
- if found {
+ if v.hasRemoteFile {
glog.V(0).Infof("volume %d is tiered to %s as %s and read only", v.Id,
v.volumeInfo.Files[0].BackendName(), v.volumeInfo.Files[0].Key)
- v.hasRemoteFile = true
}
return