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.

better output format

Chris Lu00d3f0187691
diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go
index e419a7fc27..791509f6c9 100644
--- a/weed/shell/command_volume_fsck.go
+++ b/weed/shell/command_volume_fsck.go
@@ -59,7 +59,7 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io.
if err != nil {
return fmt.Errorf("failed to create temp folder: %v", err)
}
- fmt.Fprintf(writer, "working directory: %s\n", tempFolder)
+ // fmt.Fprintf(writer, "working directory: %s\n", tempFolder)
// collect each volume file ids
for volumeId, vinfo := range volumeIdToServer {
@@ -77,7 +77,7 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io.
// volume file ids substract filer file ids
var totalOrphanChunkCount, totalOrphanDataSize uint64
for volumeId, server := range volumeIdToServer {
- orphanChunkCount, orphanDataSize, checkErr := c.oneVolumeFileIdsSubtractFilerFileIds(tempFolder, volumeId)
+ orphanChunkCount, orphanDataSize, checkErr := c.oneVolumeFileIdsSubtractFilerFileIds(tempFolder, volumeId, writer)
if checkErr != nil {
return fmt.Errorf("failed to collect file ids from volume %d on %s: %v", volumeId, server, checkErr)
}
@@ -86,7 +86,9 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io.
}
if totalOrphanChunkCount > 0 {
- fmt.Fprintf(writer, "total %d orphan chunks, %d bytes\n", totalOrphanChunkCount, totalOrphanDataSize)
+ fmt.Fprintf(writer, "\ntotal\t%d orphan entries\t%d bytes not used by filer http://%s:%d/\n",
+ totalOrphanChunkCount, totalOrphanDataSize, c.env.option.FilerHost, c.env.option.FilerPort)
+ fmt.Fprintf(writer, "This could be normal if multiple filers or no filers are used.\n")
} else {
fmt.Fprintf(writer, "no orphan data\n")
}
@@ -162,7 +164,7 @@ func (c *commandVolumeFsck) collectFilerFileIds(tempFolder string, volumeIdToSer
})
}
-func (c *commandVolumeFsck) oneVolumeFileIdsSubtractFilerFileIds(tempFolder string, volumeId uint32) (orphanChunkCount, orphanDataSize uint64, err error) {
+func (c *commandVolumeFsck) oneVolumeFileIdsSubtractFilerFileIds(tempFolder string, volumeId uint32, writer io.Writer) (orphanChunkCount, orphanDataSize uint64, err error) {
db := needle_map.NewMemDb()
defer db.Close()
@@ -187,12 +189,16 @@ func (c *commandVolumeFsck) oneVolumeFileIdsSubtractFilerFileIds(tempFolder stri
}
db.AscendingVisit(func(n needle_map.NeedleValue) error {
- fmt.Printf("%d,%x\n", volumeId, n.Key)
+ // fmt.Printf("%d,%x\n", volumeId, n.Key)
orphanChunkCount++
orphanDataSize += uint64(n.Size)
return nil
})
+ if orphanChunkCount > 0 {
+ fmt.Fprintf(writer, "volume %d\t%d orphan entries\t%d bytes\n", volumeId, orphanChunkCount, orphanDataSize)
+ }
+
return
}