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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
refactor: prepare for snapshotting
Chris Lu338e6d60a53f
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.goindex faf9b9bcaf..6b784e0b20 100644--- a/weed/filer2/filer.go+++ b/weed/filer2/filer.go@@ -246,7 +246,7 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p FullPath, isRecurs}if shouldDeleteChunks {- f.DeleteChunks(entry.Chunks)+ f.DeleteChunks(p, entry.Chunks)}if p == "/" {diff --git a/weed/filer2/filer_deletion.go b/weed/filer2/filer_deletion.goindex c7d02657d7..590df6a8db 100644--- a/weed/filer2/filer_deletion.go+++ b/weed/filer2/filer_deletion.go@@ -51,7 +51,7 @@ func (f *Filer) loopProcessingDeletion() {}}-func (f *Filer) DeleteChunks(chunks []*filer_pb.FileChunk) {+func (f *Filer) DeleteChunks(fullpath FullPath, chunks []*filer_pb.FileChunk) {for _, chunk := range chunks {f.fileIdDeletionChan <- chunk.FileId}@@ -67,7 +67,7 @@ func (f *Filer) deleteChunksIfNotNew(oldEntry, newEntry *Entry) {return}if newEntry == nil {- f.DeleteChunks(oldEntry.Chunks)+ f.DeleteChunks(oldEntry.FullPath, oldEntry.Chunks)}var toDelete []*filer_pb.FileChunk@@ -84,5 +84,5 @@ func (f *Filer) deleteChunksIfNotNew(oldEntry, newEntry *Entry) {toDelete = append(toDelete, oldChunk)}}- f.DeleteChunks(toDelete)+ f.DeleteChunks(oldEntry.FullPath, toDelete)}diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.goindex c9cb6dbe71..1c2d95e1ff 100644--- a/weed/server/filer_grpc_server.go+++ b/weed/server/filer_grpc_server.go@@ -114,7 +114,7 @@ func (fs *FilerServer) CreateEntry(ctx context.Context, req *filer_pb.CreateEntrfullpath := filer2.FullPath(filepath.ToSlash(filepath.Join(req.Directory, req.Entry.Name)))chunks, garbages := filer2.CompactFileChunks(req.Entry.Chunks)- fs.filer.DeleteChunks(garbages)+ fs.filer.DeleteChunks(fullpath, garbages)if req.Entry.Attributes == nil {return nil, fmt.Errorf("can not create entry with empty attributes")@@ -175,8 +175,8 @@ func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntr}if err = fs.filer.UpdateEntry(ctx, entry, newEntry); err == nil {- fs.filer.DeleteChunks(unusedChunks)- fs.filer.DeleteChunks(garbages)+ fs.filer.DeleteChunks(entry.FullPath, unusedChunks)+ fs.filer.DeleteChunks(entry.FullPath, garbages)}fs.filer.NotifyUpdateEvent(entry, newEntry, true)diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.goindex 92f5f19b69..e6fe9af763 100644--- a/weed/server/filer_server_handlers_write.go+++ b/weed/server/filer_server_handlers_write.go@@ -206,7 +206,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {}// glog.V(4).Infof("saving %s => %+v", path, entry)if db_err := fs.filer.CreateEntry(ctx, entry); db_err != nil {- fs.filer.DeleteFileByFileId(fileId)+ fs.filer.DeleteChunks(entry.FullPath, entry.Chunks)glog.V(0).Infof("failing to write %s to filer server : %v", path, db_err)writeJsonError(w, r, http.StatusInternalServerError, db_err)returndiff --git a/weed/server/filer_server_handlers_write_autochunk.go b/weed/server/filer_server_handlers_write_autochunk.goindex 112f46c0cf..7da6aab04f 100644--- a/weed/server/filer_server_handlers_write_autochunk.go+++ b/weed/server/filer_server_handlers_write_autochunk.go@@ -170,6 +170,7 @@ func (fs *FilerServer) doAutoChunk(ctx context.Context, w http.ResponseWriter, rChunks: fileChunks,}if db_err := fs.filer.CreateEntry(ctx, entry); db_err != nil {+ fs.filer.DeleteChunks(entry.FullPath, entry.Chunks)replyerr = db_errfilerResult.Error = db_err.Error()glog.V(0).Infof("failing to write %s to filer server : %v", path, db_err)