Skip to content

Commit

Permalink
Fix gc tool never compacts keys with hash-prefix (#5277)
Browse files Browse the repository at this point in the history
Signed-off-by: Changxin Miao <[email protected]>
  • Loading branch information
polyrabbit authored Nov 5, 2024
1 parent ecf6c06 commit da1c8b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
13 changes: 2 additions & 11 deletions cmd/fsck.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import (
"fmt"
"sort"
"strings"
"time"

"github.com/juicedata/juicefs/pkg/chunk"
"github.com/juicedata/juicefs/pkg/meta"
"github.com/juicedata/juicefs/pkg/object"
osync "github.com/juicedata/juicefs/pkg/sync"
Expand Down Expand Up @@ -91,15 +89,8 @@ func fsck(ctx *cli.Context) error {
return m.Check(c, p, ctx.Bool("repair"), ctx.Bool("recursive"), ctx.Bool("sync-dir-stat"))
}

chunkConf := chunk.Config{
BlockSize: format.BlockSize * 1024,
Compress: format.Compression,
GetTimeout: time.Second * 60,
PutTimeout: time.Second * 60,
MaxUpload: 20,
BufferSize: 300 << 20,
CacheDir: "memory",
}
chunkConf := *getDefaultChunkConf(format)
chunkConf.CacheDir = "memory"

blob, err := createStorage(*format)
if err != nil {
Expand Down
11 changes: 2 additions & 9 deletions cmd/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,8 @@ func gc(ctx *cli.Context) error {
logger.Fatalf("load setting: %s", err)
}

chunkConf := chunk.Config{
BlockSize: format.BlockSize * 1024,
Compress: format.Compression,
GetTimeout: time.Second * 60,
PutTimeout: time.Second * 60,
MaxUpload: 20,
BufferSize: 300 << 20,
CacheDir: "memory",
}
chunkConf := *getDefaultChunkConf(format)
chunkConf.CacheDir = "memory"

blob, err := createStorage(*format)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func getFileCount(dir string) int {

func TestGc(t *testing.T) {
var bucket string
mountTemp(t, &bucket, []string{"--trash-days=0"}, nil)
mountTemp(t, &bucket, []string{"--trash-days=0", "--hash-prefix"}, nil)
defer umountTemp(t)

if err := writeSmallBlocks(testMountPoint); err != nil {
Expand Down

0 comments on commit da1c8b6

Please sign in to comment.