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
fs: synchronized meta file writing
Chris Lu09043c8e5a3b
diff --git a/weed/shell/command_fs_meta_save.go b/weed/shell/command_fs_meta_save.goindex 4ff00c64b9..ed070350fa 100644--- a/weed/shell/command_fs_meta_save.go+++ b/weed/shell/command_fs_meta_save.go@@ -74,6 +74,19 @@ func (c *commandFsMetaSave) Do(args []string, commandEnv *CommandEnv, writer io.}defer dst.Close()+ var wg sync.WaitGroup+ wg.Add(1)+ outputChan := make(chan []byte, 1024)+ go func() {+ sizeBuf := make([]byte, 4)+ for b := range outputChan {+ util.Uint32toBytes(sizeBuf, uint32(len(b)))+ dst.Write(sizeBuf)+ dst.Write(b)+ }+ wg.Done()+ }()+var dirCount, fileCount uint64err = doTraverseBFS(ctx, writer, commandEnv.getFilerClient(filerServer, filerPort), filer2.FullPath(path), func(parentPath filer2.FullPath, entry *filer_pb.Entry) {@@ -89,11 +102,7 @@ func (c *commandFsMetaSave) Do(args []string, commandEnv *CommandEnv, writer io.return}- sizeBuf := make([]byte, 4)- util.Uint32toBytes(sizeBuf, uint32(len(bytes)))-- dst.Write(sizeBuf)- dst.Write(bytes)+ outputChan <- bytesif entry.IsDirectory {atomic.AddUint64(&dirCount, 1)@@ -107,9 +116,13 @@ func (c *commandFsMetaSave) Do(args []string, commandEnv *CommandEnv, writer io.})+ close(outputChan)++ wg.Wait()+if err == nil {- fmt.Fprintf(writer, "\ntotal %d directories, %d files", dirCount, fileCount)- fmt.Fprintf(writer, "\nmeta data for http://%s:%d%s is saved to %s\n", filerServer, filerPort, path, fileName)+ fmt.Fprintf(writer, "total %d directories, %d files\n", dirCount, fileCount)+ fmt.Fprintf(writer, "meta data for http://%s:%d%s is saved to %s\n", filerServer, filerPort, path, fileName)}return err