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.

Remove obsolete property Volume.dataFileSize

brstgt4fb5bb09b664
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index a42f67ecd1..9b9468c5b1 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -54,10 +54,6 @@ func (l *DiskLocation) loadExistingVolume(dir os.FileInfo, needleMapKind NeedleM
mutex.Unlock()
glog.V(0).Infof("data file %s, replicaPlacement=%s v=%d size=%d ttl=%s",
l.Directory+"/"+name, v.ReplicaPlacement, v.Version(), v.Size(), v.Ttl.String())
- if v.Size() != v.dataFileSize {
- glog.V(0).Infof("data file %s, size=%d expected=%d",
- l.Directory+"/"+name, v.Size(), v.dataFileSize)
- }
} else {
glog.V(0).Infof("new volume %s error %s", name, e)
}
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index df9f0b7a7f..f168ad1553 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -15,7 +15,6 @@ type Volume struct {
dir string
Collection string
dataFile *os.File
- dataFileSize int64
nm NeedleMapper
needleMapKind NeedleMapType
readOnly bool
diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.go
index c4f1aae9bc..5043c1754e 100644
--- a/weed/storage/volume_loading.go
+++ b/weed/storage/volume_loading.go
@@ -64,7 +64,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
return fmt.Errorf("cannot write Volume Index %s.idx: %v", fileName, e)
}
}
- if v.dataFileSize, e = CheckVolumeDataIntegrity(v, indexFile); e != nil {
+ if _, e = CheckVolumeDataIntegrity(v, indexFile); e != nil {
v.readOnly = true
glog.V(0).Infof("volumeDataIntegrityChecking failed %v", e)
}
diff --git a/weed/storage/volume_read_write.go b/weed/storage/volume_read_write.go
index d282c7c227..2314bc815f 100644
--- a/weed/storage/volume_read_write.go
+++ b/weed/storage/volume_read_write.go
@@ -60,8 +60,6 @@ func (v *Volume) AppendBlob(b []byte) (offset int64, err error) {
if offset, err = v.dataFile.Seek(0, 2); err != nil {
glog.V(0).Infof("failed to seek the end of file: %v", err)
return
- } else if offset != int64(v.dataFileSize) {
- glog.V(0).Infof("dataFileSize %d != actual data file size: %d, volumeId: %v", v.dataFileSize, offset, v.Id)
}
//ensure file writing starting from aligned positions
if offset%NeedlePaddingSize != 0 {
@@ -69,12 +67,9 @@ func (v *Volume) AppendBlob(b []byte) (offset int64, err error) {
if offset, err = v.dataFile.Seek(offset, 0); err != nil {
glog.V(0).Infof("failed to align in datafile %s: %v", v.dataFile.Name(), err)
return
- } else if offset != int64(v.dataFileSize) {
- glog.V(0).Infof("dataFileSize %d != actual data file size: %d, volumeId: %v", v.dataFileSize, offset, v.Id)
}
}
_, err = v.dataFile.Write(b)
- v.dataFileSize += int64(len(b))
return
}
@@ -91,12 +86,10 @@ func (v *Volume) writeNeedle(n *Needle) (size uint32, err error) {
glog.V(4).Infof("needle is unchanged!")
return
}
- var offset, actualSize int64
+ var offset int64
if offset, err = v.dataFile.Seek(0, 2); err != nil {
glog.V(0).Infof("failed to seek the end of file: %v", err)
return
- } else if offset != int64(v.dataFileSize) {
- glog.V(0).Infof("dataFileSize %d != actual data file size: %d, volumeId: %v", v.dataFileSize, offset, v.Id)
}
//ensure file writing starting from aligned positions
@@ -108,13 +101,12 @@ func (v *Volume) writeNeedle(n *Needle) (size uint32, err error) {
}
}
- if size, actualSize, err = n.Append(v.dataFile, v.Version()); err != nil {
+ if size, _, err = n.Append(v.dataFile, v.Version()); err != nil {
if e := v.dataFile.Truncate(offset); e != nil {
err = fmt.Errorf("%s\ncannot truncate %s: %v", err, v.dataFile.Name(), e)
}
return
}
- v.dataFileSize += actualSize
nv, ok := v.nm.Get(n.Id)
if !ok || int64(nv.Offset)*NeedlePaddingSize < offset {
@@ -139,18 +131,15 @@ func (v *Volume) deleteNeedle(n *Needle) (uint32, error) {
//fmt.Println("key", n.Id, "volume offset", nv.Offset, "data_size", n.Size, "cached size", nv.Size)
if ok && nv.Size != TombstoneFileSize {
size := nv.Size
- // println("adding tombstone", n.Id, "at offset", v.dataFileSize)
- if err := v.nm.Delete(n.Id, uint32(v.dataFileSize/NeedlePaddingSize)); err != nil {
+ offset, err := v.dataFile.Seek(0, 2)
+ if err != nil {
return size, err
}
- if offset, err := v.dataFile.Seek(0, 2); err != nil {
+ if err := v.nm.Delete(n.Id, uint32(offset/NeedlePaddingSize)); err != nil {
return size, err
- } else if offset != int64(v.dataFileSize) {
- glog.V(0).Infof("dataFileSize %d != actual data file size: %d, deleteMarker: %d, volumeId: %v", v.dataFileSize, offset, getActualSize(0), v.Id)
}
n.Data = nil
- _, actualSize, err := n.Append(v.dataFile, v.Version())
- v.dataFileSize += actualSize
+ _, _, err = n.Append(v.dataFile, v.Version())
return size, err
}
return 0, nil
diff --git a/weed/storage/volume_super_block.go b/weed/storage/volume_super_block.go
index ae6ee7c259..fc773273d7 100644
--- a/weed/storage/volume_super_block.go
+++ b/weed/storage/volume_super_block.go
@@ -56,7 +56,6 @@ func (v *Volume) maybeWriteSuperBlock() error {
}
}
}
- v.dataFileSize = SuperBlockSize
}
return e
}
diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go
index 13072d1fb1..07916fe6ba 100644
--- a/weed/storage/volume_vacuum.go
+++ b/weed/storage/volume_vacuum.go
@@ -24,7 +24,7 @@ func (v *Volume) Compact() error {
v.lastCompactIndexOffset = v.nm.IndexFileSize()
v.lastCompactRevision = v.SuperBlock.CompactRevision
glog.V(3).Infof("creating copies for volume %d ,last offset %d...", v.Id, v.lastCompactIndexOffset)
- return v.copyDataAndGenerateIndexFile(filePath+".cpd", filePath+".cpx", v.dataFileSize)
+ return v.copyDataAndGenerateIndexFile(filePath+".cpd", filePath+".cpx", 0)
}
func (v *Volume) Compact2() error {