Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

refactoring: separating .vif from tier file loading

Chris Luf4a74e03d18d
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index 9af70c86f9..49af6f850c 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -27,6 +27,7 @@ type Volume struct {
needleMapKind NeedleMapType
noWriteOrDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
noWriteCanDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete
+ hasRemoteFile bool // if the volume has a remote file
MemoryMapMaxSizeMb uint32
super_block.SuperBlock
diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.go
index 42562d2337..9a99c5366c 100644
--- a/weed/storage/volume_loading.go
+++ b/weed/storage/volume_loading.go
@@ -26,9 +26,13 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
fileName := v.FileName()
alreadyHasSuperBlock := false
- if v.maybeLoadVolumeInfo() {
+ v.maybeLoadVolumeInfo()
+
+ if v.HasRemoteFile() {
v.noWriteCanDelete = true
- // open remote file
+ v.noWriteOrDelete = false
+ glog.V(0).Infof("loading volume %d from remote %v", v.Id, v.volumeInfo.Files)
+ v.LoadRemoteFile()
alreadyHasSuperBlock = true
} else if exists, canRead, canWrite, modifiedTime, fileSize := checkFile(fileName + ".dat"); exists {
// open dat file
diff --git a/weed/storage/volume_tier.go b/weed/storage/volume_tier.go
index 82b8223936..6e3ca8e2ef 100644
--- a/weed/storage/volume_tier.go
+++ b/weed/storage/volume_tier.go
@@ -7,10 +7,11 @@ import (
_ "github.com/chrislusf/seaweedfs/weed/storage/backend/s3_backend"
+ "github.com/golang/protobuf/jsonpb"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/storage/backend"
- "github.com/golang/protobuf/jsonpb"
)
func (v *Volume) GetVolumeInfo() *volume_server_pb.VolumeInfo {
@@ -57,21 +58,13 @@ func (v *Volume) maybeLoadVolumeInfo() bool {
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.noWriteCanDelete = true
- v.noWriteOrDelete = false
-
- glog.V(0).Infof("loading volume %d from remote %v", v.Id, v.volumeInfo.Files)
- v.LoadRemoteFile()
+ v.hasRemoteFile = true
return true
}
func (v *Volume) HasRemoteFile() bool {
- if v.DataBackend == nil {
- return false
- }
- _, ok := v.DataBackend.(*backend.DiskFile)
- return !ok
+ return v.hasRemoteFile
}
func (v *Volume) LoadRemoteFile() error {